775 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			775 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| 
 | |
| using System.Collections.Generic;
 | |
| using System.ComponentModel;
 | |
| using System.Data;
 | |
| using System.Drawing;
 | |
| using System.Text;
 | |
| using System.Windows.Forms;
 | |
| using Microsoft.Tools.ServiceModel;
 | |
|  
 | |
| 
 | |
| namespace DeiNiu.Wms.CE
 | |
| {
 | |
|     public partial class StockReceive   : basicForm 
 | |
|     {
 | |
| 
 | |
|         string preInOrder,goodsId = "";
 | |
|         DataTable dtPreIn,dtBulks;
 | |
|         decimal bigCount, maxReceiveCnt ,maxValidCnt= 0;
 | |
|         int  expiringDays =0;
 | |
|         public StockReceive()
 | |
|         {
 | |
|             InitializeComponent();
 | |
|             //client = new WmsOutPickRequestClient(WcfHelp.getBasicBinding(), WcfHelp.getEndpoint("WmsOutPickRequestService"));
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
|         private void StockReceive_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             initialData();
 | |
|         }
 | |
| 
 | |
|          void initialData()
 | |
|         {
 | |
|             dtPreIn = null;
 | |
|             initialFirstTabData();
 | |
|             initialSecondTabData();
 | |
|             initialThirdTabData();
 | |
|             initialFourthTabData();
 | |
|             textPreInNo.Focus();
 | |
|             //tb1.SelectedIndex = 1;
 | |
|         }
 | |
| 
 | |
| 
 | |
|          void initialFirstTabData()
 | |
|          {
 | |
| 
 | |
|              textPreInNo.Focus();
 | |
| 
 | |
|              lbvender.Text = lbVeNo.Text = lbPhone.Text = "";
 | |
|  
 | |
|          }
 | |
| 
 | |
|          void initialSecondTabData()
 | |
|          {
 | |
|              
 | |
|              txtReceiveGdBarcod.Focus();
 | |
|              goodsId = "";
 | |
|              lbGoodsName1.Text = lbPackcnt.Text = lbUnit.Text = lbArriveNum.Text = lbNotReceived.Text = txtWendu.Text =
 | |
|                  txtReceivePkgNum.Text = txtBulkCnt.Text  = "";
 | |
|              chkZhitong.Checked = false;
 | |
|              chkNoQc.Checked = false;
 | |
|              btnReceive.Enabled = false;
 | |
|              rdReceive.Checked = true;
 | |
|              rdRefuse.Checked = false;
 | |
| 
 | |
|          }
 | |
|          void initialThirdTabData()
 | |
|          {
 | |
|             
 | |
|              btnValid.Enabled = false;
 | |
|              goodsId = "";
 | |
|              
 | |
|              txtShelfNo.Text=lbExpiryDays.Text = lbGoodsName2.Text = txtBatchBoxCnt.Text =
 | |
|                  lbToValidCnt.Text = txtBatch.Text = txtSeedsNum.Text = lbSeedsCnt.Text = "";
 | |
|              rdValidPass.Checked = true;
 | |
|              rdValidFaild.Checked = false;
 | |
|              txtShelfNo.Focus();
 | |
|               
 | |
| 
 | |
|          }
 | |
|          void initialFourthTabData()
 | |
|          {
 | |
|             // btnInPlate.Enabled = false; 
 | |
|             // txtPlateId.Focus();
 | |
|            //  txtSkuId.Text = txtPlateId.Text =   "";
 | |
|              dgResult.DataSource = null;
 | |
| 
 | |
|          }
 | |
| 
 | |
|         private void dg1_DoubleClick(object sender, EventArgs e)
 | |
|         {
 | |
|             if (dg1.DataSource == null || dg1.CurrentRowIndex < 0)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|           //  preInOrder = dg1[dg1.CurrentRowIndex, 0].ToString();
 | |
|           //  showTranPickRequests();
 | |
|         }
 | |
| 
 | |
| 
 | |
|         /*
 | |
|         void showTranPickRequests()
 | |
|         {
 | |
| 
 | |
| 
 | |
| 
 | |
|             if (dg1.DataSource == null)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             if (dg1.CurrentRowIndex < 0)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             if (string.IsNullOrEmpty(preInOrder))
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             lbGoodsName1.Text = preInOrder;
 | |
|             Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
 | |
|           
 | |
|             try
 | |
|             {
 | |
|                 dtBulks = client.getTransRequestsDetail(preInOrder,0);
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|                 MessageBox.Show("发生错误:" + er.Message);
 | |
| 
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
| 
 | |
|             bindBg2(dtBulks);
 | |
| 
 | |
|             tb1.SelectedIndex = 1;
 | |
| 
 | |
|             txtReceiveGdBarcod.Focus();
 | |
| 
 | |
|             lbGoodsName1.Text = dtBulks.Rows.Count> 0 ? preInOrder :"";
 | |
|         }
 | |
|         */
 | |
| 
 | |
| 
 | |
| 
 | |
|         private void tb1_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|             if (tb1.SelectedIndex == 0)
 | |
|             {
 | |
|                // bindBg1();
 | |
|                 textPreInNo.Focus();
 | |
|             }
 | |
|             else if(tb1.SelectedIndex == 1)
 | |
|             {
 | |
|                 txtReceiveGdBarcod.Focus();
 | |
|             }
 | |
|             else if (tb1.SelectedIndex == 2)
 | |
|             {
 | |
|                 
 | |
|             }
 | |
|             else if (tb1.SelectedIndex == 3)
 | |
|             {
 | |
|                 queryValidResult();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         void queryValidResult()
 | |
|         {
 | |
|             if (dtPreIn != null && !String.IsNullOrEmpty(preInOrder))
 | |
|             {
 | |
|                 DataTable dt;
 | |
|                 try
 | |
|                 {
 | |
|                    dt = client.getPreValidResult(preInOrder,-1);
 | |
|                    dgResult.DataSource = dt; 
 | |
| 
 | |
|                 }
 | |
|                 catch (Exception er)
 | |
|                 {
 | |
|                     Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|                    
 | |
|                     showErrorMsg(er, "发生错误");
 | |
|                     return;
 | |
|                 }
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
| 
 | |
|                 dgResult.TableStyles.Clear();
 | |
|                 DataGridTableStyle ts = new DataGridTableStyle();
 | |
|                 ts.MappingName = dt.TableName;
 | |
|                 dgResult.TableStyles.Add(ts);
 | |
|                 //  [商品名称]  [上架数量] ,[预到数量] ,[验收数量]  ,[温度],[车牌] ,[运单] ,[电话]
 | |
|                 ts.GridColumnStyles[0].Width = 65;
 | |
|                 ts.GridColumnStyles[1].Width = 0;
 | |
|                 ts.GridColumnStyles[2].Width = 0;
 | |
|                 ts.GridColumnStyles[3].Width = 80;
 | |
|                 ts.GridColumnStyles[4].Width = 40;
 | |
|                 ts.GridColumnStyles[5].Width = 40;
 | |
|                 ts.GridColumnStyles[6].Width = 0;
 | |
|             }
 | |
|         }
 | |
|         private void dg1_CurrentCellChanged(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void bindPreIn(string preInNo)
 | |
|         {
 | |
|      
 | |
|             Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
 | |
|             initialData();
 | |
|             try
 | |
|             {
 | |
|                 dtPreIn = client.getPreInDetail(preInNo,LoginInfo.UserId,LoginInfo.Token);
 | |
|                 dg1.DataSource = dtPreIn;
 | |
|                 if (dtPreIn.Rows.Count > 0)
 | |
|                 {
 | |
|                     lbvender.Text = dtPreIn.Rows[0]["供应商名称"].ToString();
 | |
|                     lbVeNo.Text = dtPreIn.Rows[0]["车牌"].ToString();
 | |
|                     lbPhone.Text = dtPreIn.Rows[0]["电话"].ToString();
 | |
|                 }
 | |
|                 
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.Default; 
 | |
|                // MessageBox.Show("发生错误:" +getExceptionMsg( er));
 | |
|                 showErrorMsg(er, "发生错误");
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|            
 | |
|             Cursor.Current = System.Windows.Forms.Cursors.Default; 
 | |
|           
 | |
|             dg1.TableStyles.Clear();
 | |
|             DataGridTableStyle ts = new DataGridTableStyle();
 | |
|             ts.MappingName = dtPreIn.TableName;
 | |
|             dg1.TableStyles.Add(ts);
 | |
|             //  [商品名称]  [上架数量] ,[预到数量] ,[验收数量]  ,[温度],[车牌] ,[运单] ,[电话]
 | |
|             ts.GridColumnStyles[0].Width = 55;
 | |
|             ts.GridColumnStyles[1].Width = 35;
 | |
|             ts.GridColumnStyles[2].Width = 35;
 | |
|             ts.GridColumnStyles[3].Width = 35;
 | |
|             ts.GridColumnStyles[4].Width = 35;
 | |
|             /*ts.GridColumnStyles[5].Width = 0;
 | |
|             ts.GridColumnStyles[6].Width = 0;
 | |
|             ts.GridColumnStyles[9].Width = 80;  
 | |
|             ts.GridColumnStyles[11].Width =70;
 | |
|              * */
 | |
|         }
 | |
| 
 | |
|         
 | |
| 
 | |
|        
 | |
| 
 | |
|         private void textPreInNo_KeyUp(object sender, KeyEventArgs e)
 | |
|         {
 | |
|             preInOrder = textPreInNo.Text;
 | |
| 
 | |
| 
 | |
|             if (string.IsNullOrEmpty(preInOrder))
 | |
|             {
 | |
|                 textPreInNo.Focus();
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             if (e.KeyCode == Keys.Enter || e.KeyCode ==Keys.Space)
 | |
|             {
 | |
| 
 | |
|                 bindPreIn(preInOrder);  
 | |
|                 
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|         bool isPreInOrderOkay()
 | |
|         {
 | |
|             if (dtPreIn != null)
 | |
|             {
 | |
|                 return true;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 MessageBox.Show("请输入预到单");
 | |
|                 tb1.SelectedIndex = 0;
 | |
|                 initialFirstTabData();
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void textGdbarcode_KeyUp(object sender, KeyEventArgs e)
 | |
|         {
 | |
|            string goodBarcod = txtReceiveGdBarcod.Text;
 | |
|              
 | |
|            if (e.KeyCode == Keys.Enter)
 | |
|            {
 | |
|                if (!isPreInOrderOkay())
 | |
|                {
 | |
|                    return;
 | |
|                }
 | |
| 
 | |
|                if (string.IsNullOrEmpty(goodBarcod))
 | |
|                {
 | |
|                    // MessageBox.Show("请选择运单");
 | |
|                    txtReceiveGdBarcod.Focus();
 | |
|                    return;
 | |
|                }
 | |
|                getDataByGoodsBarcode(goodBarcod);
 | |
| 
 | |
|                
 | |
| 
 | |
|            }
 | |
|         }
 | |
| 
 | |
|         void getDataByGoodsBarcode(string goodsBarcod)
 | |
|         {
 | |
|             if (String.IsNullOrEmpty(preInOrder))
 | |
|             {
 | |
|                 MessageBox.Show("请输入预到号码");
 | |
|                 tb1.SelectedIndex = 0;
 | |
|                 return;
 | |
|             }
 | |
|             Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
 | |
|             DataTable dtPreDetail = client.getReceiveDetailByBarcode(preInOrder,goodsBarcod);
 | |
|             Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|             if (dtPreDetail.Rows.Count == 0)
 | |
|             {
 | |
|                 MessageBox.Show("没找到数据");
 | |
|                 initialSecondTabData();
 | |
|                 txtReceiveGdBarcod.SelectAll();
 | |
|                 txtReceiveGdBarcod.Focus();
 | |
| 
 | |
|                 return;
 | |
|             }
 | |
|             string packQty = dtPreDetail.Rows[0]["packingQty"].ToString();
 | |
|             lbGoodsName1.Text = lbGoodsName2.Text =  dtPreDetail.Rows[0]["goodsName"].ToString();
 | |
|            
 | |
|             goodsId = dtPreDetail.Rows[0]["goodsId"].ToString();
 | |
|             string isQc = dtPreDetail.Rows[0]["isQc"].ToString();
 | |
|             string isZhitong = dtPreDetail.Rows[0]["isZhitong"].ToString();
 | |
|             lbUnit.Text = dtPreDetail.Rows[0]["unit"].ToString();
 | |
|             lbArriveNum.Text = dtPreDetail.Rows[0]["newArriveCount"].ToString();
 | |
|             lbNotReceived.Text = dtPreDetail.Rows[0]["newCount4Receive"].ToString();
 | |
|             lbToValidCnt.Text = dtPreDetail.Rows[0]["newCount4Valid"].ToString();
 | |
|             lbExpiryDays.Text = dtPreDetail.Rows[0]["expiryDays"].ToString();
 | |
|             try
 | |
|             {
 | |
|                 chkNoQc.Checked = Convert.ToInt16(isQc) == 0;
 | |
|                 chkZhitong.Checked = Convert.ToInt16(isZhitong) != 0;
 | |
|                 expiringDays = Convert.ToInt16(lbExpiryDays.Text);
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
| 
 | |
|             }
 | |
|             try
 | |
|             {
 | |
| 
 | |
|                 bigCount = Convert.ToDecimal(packQty);
 | |
|                 maxReceiveCnt = Convert.ToDecimal(lbNotReceived.Text);
 | |
|                 maxValidCnt = Convert.ToDecimal(lbToValidCnt.Text);
 | |
| 
 | |
|                 
 | |
|                 if (this.tb1.SelectedIndex == 1)
 | |
|                 {
 | |
|                     btnReceive.Enabled = maxReceiveCnt > 0;                   
 | |
|                     decimal bulkCnt = maxReceiveCnt % bigCount;
 | |
|                     decimal boxCnt =( maxReceiveCnt - bulkCnt) / bigCount;
 | |
| 
 | |
|                     txtReceivePkgNum.Text = boxCnt + "";
 | |
|                     txtBulkCnt.Text = bulkCnt + "";
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     btnValid.Enabled = maxValidCnt > 0;
 | |
|                     decimal bulkCnt = maxValidCnt % bigCount;
 | |
|                     decimal boxCnt = (maxValidCnt - bulkCnt) / bigCount;
 | |
| 
 | |
|                     txtBatchBoxCnt.Text = boxCnt + "";
 | |
|                     txtBachCnt.Text = bulkCnt + "";
 | |
|                    
 | |
|                 }
 | |
|                 
 | |
|                 
 | |
|                 lbPackcnt.Text = bigCount + "";
 | |
| 
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 bigCount = 1;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         decimal getReceiveCount()
 | |
|         {
 | |
|             string pkcnt = txtReceivePkgNum.Text.Trim(); 
 | |
|             string bulkcnt = txtBulkCnt.Text.Trim();
 | |
|             decimal packCount = 0, bulkCount = 0 ;
 | |
| 
 | |
|             if (String.IsNullOrEmpty(pkcnt) && String.IsNullOrEmpty(bulkcnt))
 | |
|             {
 | |
|                 MessageBox.Show("请输入收货数量");
 | |
|                 txtReceivePkgNum.Focus();
 | |
|                 return 0;
 | |
|             }
 | |
| 
 | |
|             try
 | |
|             {
 | |
| 
 | |
|                 if (!String.IsNullOrEmpty(pkcnt))
 | |
|                 {
 | |
|                     packCount = Convert.ToDecimal(pkcnt);
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 MessageBox.Show("请输入收货数量");
 | |
|                 txtReceivePkgNum.SelectAll();
 | |
|                 txtReceivePkgNum.Focus();
 | |
|                 return 0;
 | |
|             }
 | |
|             try
 | |
|             {
 | |
| 
 | |
|                 if (!String.IsNullOrEmpty(bulkcnt))
 | |
|                 {
 | |
|                     bulkCount = Convert.ToDecimal(bulkcnt);
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 MessageBox.Show("请输入收货数量");
 | |
|                 txtBulkCnt.SelectAll();
 | |
|                 txtBulkCnt.Focus();
 | |
|                 return 0;
 | |
|             }
 | |
| 
 | |
|             
 | |
|             decimal count = packCount * bigCount + bulkCount;
 | |
| 
 | |
|             if (count == 0)
 | |
|             {
 | |
|                 MessageBox.Show("请输入收货数量");
 | |
|                 txtReceivePkgNum.Focus();
 | |
|                 return 0;
 | |
|             }
 | |
| 
 | |
| 
 | |
|            
 | |
|             return count;
 | |
|         }
 | |
|         private void btnReceive_Click(object sender, EventArgs e)
 | |
|         {
 | |
|              
 | |
|             string tmp = txtWendu.Text.Trim();
 | |
|              
 | |
|             decimal  temperature = -100;
 | |
|              
 | |
|             try
 | |
|             {
 | |
| 
 | |
|                 if (!String.IsNullOrEmpty(tmp))
 | |
|                 {
 | |
|                     temperature = Convert.ToDecimal(tmp);
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 MessageBox.Show("请输入温度");
 | |
|                 txtWendu.SelectAll();
 | |
|                 txtWendu.Focus();
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             decimal count = getReceiveCount();
 | |
| 
 | |
|             if (count > maxReceiveCnt)
 | |
|             {
 | |
|                 MessageBox.Show("超过最大应收数量:" + maxReceiveCnt);
 | |
|                 txtReceivePkgNum.SelectAll();
 | |
|                 txtReceivePkgNum.Focus();
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             if (count <= 0) { return; }
 | |
|             try
 | |
|             {
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
 | |
|                
 | |
|                 
 | |
|                 decimal arriveCnt = Convert.ToDecimal(lbArriveNum.Text);
 | |
|                 int intype = rdReceive.Checked?0:1;//pass
 | |
|                 bool rt = client.receiveDetail(preInOrder, goodsId, arriveCnt, count, intype, "", temperature, chkZhitong.Checked, 0, LoginInfo.UserId, LoginInfo.Token);
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|               if (rt)
 | |
|               {
 | |
|                   MessageBox.Show("收货成功!");
 | |
|                   initialSecondTabData();
 | |
| 
 | |
|                   if (chkValid.Checked)
 | |
|                   {
 | |
|                       tb1.SelectedIndex = 2;//验收
 | |
| 
 | |
|                       txtValidGdBarcod.Text = txtReceiveGdBarcod.Text;
 | |
|                       lbGoodsName2.Text = lbGoodsName1.Text;
 | |
| 
 | |
| 
 | |
|                   }
 | |
|               }
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 //MessageBox.Show("收货失败!");
 | |
|                 showErrorMsg(er, "收货失败");
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void txtValidGdBarcod_KeyUp(object sender, KeyEventArgs e)
 | |
|         {
 | |
|             string goodBarcod = txtValidGdBarcod.Text;
 | |
| 
 | |
|             if (e.KeyCode == Keys.Enter)
 | |
|             {
 | |
|                 if (!isPreInOrderOkay())
 | |
|                 {
 | |
|                     return;
 | |
|                 }
 | |
| 
 | |
| 
 | |
|                 if (string.IsNullOrEmpty(goodBarcod))
 | |
|                 {
 | |
|                     // MessageBox.Show("请选择运单");
 | |
|                     txtValidGdBarcod.Focus();
 | |
|                     return;
 | |
|                 }
 | |
|                 getDataByGoodsBarcode(goodBarcod);
 | |
| 
 | |
|                // txtBatchBoxCnt.Text = maxValidCnt+"";
 | |
| 
 | |
|                // txtBatchBoxCnt.Focus();
 | |
| 
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void btnSeeds_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             decimal batchCnt =   getValidCount();;
 | |
|             if(batchCnt<=0){
 | |
|                 return;
 | |
|             }
 | |
|             Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
 | |
|             decimal seedsNum = client.getValidSeedsCnt(goodsId,batchCnt );
 | |
|             Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|             lbSeedsCnt.Text = seedsNum + "";
 | |
|             txtSeedsNum.Text = seedsNum+"";
 | |
| 
 | |
|         }
 | |
| 
 | |
|         decimal getValidCount()
 | |
|         {
 | |
|             string batchBoxCnt = txtBatchBoxCnt.Text.Trim();
 | |
|            
 | |
|             string batchCnt = txtBachCnt.Text.Trim();
 | |
|           
 | |
|             
 | |
|             decimal packCount=0, bulkCount=0 ;
 | |
| 
 | |
|             if (String.IsNullOrEmpty(batchBoxCnt) && String.IsNullOrEmpty(batchCnt))
 | |
|             {
 | |
|                 MessageBox.Show("请输入验收数量");
 | |
|                 txtBatchBoxCnt.Focus();
 | |
|                 return 0;
 | |
|             }
 | |
| 
 | |
|             try
 | |
|             {
 | |
| 
 | |
|                 if (!String.IsNullOrEmpty(batchBoxCnt))
 | |
|                 {
 | |
|                     packCount = Convert.ToDecimal(batchBoxCnt);
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
| 
 | |
|                  MessageBox.Show("请输入验收数量");
 | |
|                 txtBatchBoxCnt.Focus();
 | |
|                 return 0;
 | |
|             }
 | |
| 
 | |
|             try
 | |
|             {
 | |
| 
 | |
|                 if (!String.IsNullOrEmpty(batchCnt))
 | |
|                 {
 | |
|                     bulkCount = Convert.ToDecimal(batchCnt);
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 MessageBox.Show("请输入验收数量");
 | |
|                 txtBachCnt.Focus();
 | |
|                 return 0;
 | |
|             }
 | |
| 
 | |
|             
 | |
| 
 | |
|             decimal count = packCount * bigCount + bulkCount;
 | |
| 
 | |
|             if (count == 0)
 | |
|             {
 | |
|                 MessageBox.Show("请输入验收数量");
 | |
|                 txtReceivePkgNum.Focus();
 | |
|                 return 0;
 | |
|             }
 | |
| 
 | |
| 
 | |
|            
 | |
|             return count;
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void btnValid_Click(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|             string batch = txtBatch.Text.Trim();
 | |
|             
 | |
|             int onShelfId = 0;
 | |
|             string seedsCnt = txtSeedsNum.Text.Trim();
 | |
|             DateTime dtProd = dtpProduct.Value;
 | |
|             DateTime dtValidTo = dtpValidTo.Value;
 | |
|             decimal seedsCount = -100;
 | |
|             decimal count = getValidCount();
 | |
|             if (count <= 0   )
 | |
|             { 
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             if (count > maxValidCnt)
 | |
|             {
 | |
|                 getDataByGoodsBarcode(this.txtValidGdBarcod.Text.Trim());//refresh data from svr.
 | |
|                 if (count > maxValidCnt)
 | |
|                 {
 | |
|                     return;
 | |
|                 }
 | |
| 
 | |
|             }
 | |
| 
 | |
|             try
 | |
|             {
 | |
|                  
 | |
| 
 | |
|                 if (!String.IsNullOrEmpty(seedsCnt))
 | |
|                 {
 | |
|                     seedsCount = Convert.ToDecimal(seedsCnt);
 | |
|                 }
 | |
|                 if (seedsCount <= 0 || seedsCount > count)
 | |
|                 {
 | |
|                     throw new Exception();
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 MessageBox.Show("请输入正确抽样数量");
 | |
|                 txtSeedsNum.Focus();
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             try
 | |
|             {
 | |
|                 onShelfId = Convert.ToInt32(txtShelfNo.Text);
 | |
|                  
 | |
|                 if (onShelfId <= 0  )
 | |
|                 {
 | |
|                     throw new Exception();
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 MessageBox.Show("请输入正确上架流水号");
 | |
|                 txtShelfNo.SelectAll();
 | |
|                 txtShelfNo.Focus();
 | |
|                 return;
 | |
|             }
 | |
|           
 | |
|             string[] skuKeys = { "生产日期", "到期日期", "厂家批次" };
 | |
|             string[] skuValues = { dtProd.ToShortDateString(), dtValidTo.ToShortDateString(), batch };
 | |
|             try
 | |
|             {
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
 | |
| 
 | |
|                 bool issueLocations = true; //按流水号入库,并分配货位
 | |
|                 enumValidInResult  result =(enumValidInResult) client.validIn(preInOrder, onShelfId, goodsId, count, seedsCount, skuKeys, skuValues,
 | |
|                     rdValidPass.Checked, issueLocations, LoginInfo.UserId, LoginInfo.Token);
 | |
| 
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
| 
 | |
|                 if (result == enumValidInResult.成功)
 | |
|                 {
 | |
|                     MessageBox.Show("验收成功");
 | |
| 
 | |
|                     initialThirdTabData();
 | |
|                     //TODO: print sku info for into plate operation
 | |
| 
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     MessageBox.Show("验收失败: " + result.ToString());
 | |
|                 }
 | |
| 
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             { 
 | |
|                 Cursor.Current = System.Windows.Forms.Cursors.Default;
 | |
|                 showErrorMsg(er, "验收失败");
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void txtSkuId_KeyUp(object sender, KeyEventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void rdValidFaild_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             rdValidPass.Checked = !rdValidFaild.Checked;
 | |
|         }
 | |
| 
 | |
|         private void rdValidPass_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             rdValidFaild.Checked = !rdValidPass.Checked;
 | |
|         }
 | |
| 
 | |
|         private void dtpProduct_ValueChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             dtpValidTo.Value = dtpProduct.Value.AddDays(expiringDays);
 | |
|         }
 | |
| 
 | |
|         private void rdReceive_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             rdRefuse.Checked = !rdReceive.Checked;
 | |
|         }
 | |
| 
 | |
|         private void rdRefuse_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             rdReceive.Checked = !rdRefuse.Checked;
 | |
|         }
 | |
| 
 | |
|         private void txtShelfNo_KeyUp(object sender, KeyEventArgs e)
 | |
|         {
 | |
|             if (e.KeyCode == Keys.Enter)
 | |
|             {
 | |
|                 if (!isPreInOrderOkay())
 | |
|                 {
 | |
|                     return;
 | |
|                 }
 | |
|                 txtValidGdBarcod.SelectAll();
 | |
|                 txtValidGdBarcod.Focus();
 | |
|             }
 | |
|         }
 | |
|  
 | |
|        
 | |
| 
 | |
|     }
 | |
| } |