142 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			142 lines
		
	
	
		
			5.1 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 System.Collections.Specialized;
 | |
| 
 | |
| 
 | |
| namespace  DeiNiu.Wms.CE
 | |
| {
 | |
|     public partial class LocationStockCompare :basicForm
 | |
|     {
 | |
|         #region 界面初始化
 | |
|    
 | |
|         DataTable dt = new DataTable();
 | |
|         public LocationStockCompare()
 | |
|         {
 | |
|             InitializeComponent();
 | |
|         }
 | |
|         #endregion
 | |
|         /// <summary>
 | |
|         /// 定义清除界面数据方法
 | |
|         /// </summary>
 | |
|         private void clear()
 | |
|         {
 | |
|             setTitle();
 | |
|             locationid_lab.Text = name_lab.Text = spea_lab.Text = company_lab.Text = erpcount_lab.Text =
 | |
|                 wmscount_lab.Text =  "";
 | |
|             dg1.DataSource = new DataTable();
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 扫描货位触发事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         private void locationid_txt_KeyUp(object sender, KeyEventArgs e)
 | |
|         {
 | |
|             if (e.KeyCode == Keys.Enter)
 | |
|             {
 | |
|                 locationid_lab.Text = locationid_txt.Text;
 | |
|                 locationid_txt.Text = "";
 | |
|                 string goodsCode = useLoc ? "" : locationid_lab.Text;
 | |
|                 string goodsId = "";
 | |
|                 try
 | |
|                 {
 | |
|                     DataTable dta = null;
 | |
|                     if (useLoc)
 | |
|                     {
 | |
|                         dta = client.getStockLocation(locationid_lab.Text);
 | |
|                         if (dta.Rows.Count > 0)
 | |
|                         {
 | |
|                             goodsCode = dta.Rows[0]["barcode"].ToString();
 | |
|                             goodsId = dta.Rows[0]["goodsId"].ToString();
 | |
|                         }
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         dta = client.getStockLocationsByBarcode(locationid_lab.Text);
 | |
|                     }
 | |
| 
 | |
|                     if (dta.Rows.Count>0 && !string.IsNullOrEmpty(goodsCode+goodsId))
 | |
|                     {
 | |
|                         name_lab.Text = dta.Rows[0]["spec"].ToString();
 | |
|                         spea_lab.Text = dta.Rows[0]["type"].ToString();
 | |
|                         company_lab.Text = dta.Rows[0]["manufacturer"].ToString();
 | |
|                         Cursor.Current = Cursors.WaitCursor;
 | |
|                         dt = client.getStockCompareErp(goodsId, goodsCode);
 | |
|                         Cursor.Current = Cursors.Default;
 | |
|                         dg1.DataSource = dt;
 | |
| 
 | |
|                         DataRow[] row = dt.Select("来源='wms'");
 | |
|                         double sum = 0;
 | |
|                         foreach (DataRow dr in row)
 | |
|                         {
 | |
|                             sum = sum + Convert.ToDouble(dr["数量"].ToString());
 | |
|                         }
 | |
| 
 | |
|                         wmscount_lab.Text = sum.ToString() + dta.Rows[0]["unit"].ToString();
 | |
|                          sum = 0;
 | |
|                         DataRow[] rower = dt.Select("来源='erp'");
 | |
| 
 | |
|                         foreach (DataRow d in rower)
 | |
|                         {
 | |
|                             sum = sum + Convert.ToDouble(d["数量"].ToString());
 | |
|                         }
 | |
| 
 | |
|                         erpcount_lab.Text = sum.ToString() + dta.Rows[0]["unit"].ToString();
 | |
|                         if (wmscount_lab.Text != erpcount_lab.Text)
 | |
|                         {
 | |
|                             wmscount_lab.ForeColor = Color.Red;
 | |
|                             erpcount_lab.ForeColor = Color.Red;
 | |
|                         }
 | |
|                         else
 | |
|                         {
 | |
|                             wmscount_lab.ForeColor = Color.Black;
 | |
|                             erpcount_lab.ForeColor = Color.Black;
 | |
|                         }
 | |
| 
 | |
|                         DataGridTableStyle dts = new DataGridTableStyle();
 | |
|                         dts.MappingName = dt.TableName;
 | |
|                         dg1.TableStyles.Add(dts);
 | |
|                         dg1.TableStyles[0].GridColumnStyles["来源"].Width = 38;
 | |
|                         dg1.TableStyles[0].GridColumnStyles["货位"].Width = 70;
 | |
|                         dg1.TableStyles[0].GridColumnStyles["批号"].Width = 60;
 | |
|                         dg1.TableStyles[0].GridColumnStyles["生产日期"].Width = 75;
 | |
|                         dg1.TableStyles[0].GridColumnStyles["有效期至"].Width = 75;
 | |
| 
 | |
| 
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         clear();
 | |
|                     }
 | |
|                  
 | |
| 
 | |
|                 }
 | |
|                 catch(Exception er)
 | |
|                 {
 | |
|                     MessageBox.Show(er.Message.ToString());
 | |
|                     Cursor.Current = Cursors.Default;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         bool useLoc = true;
 | |
|         private void rdLoc_CheckedChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             useLoc = rdLoc.Checked;
 | |
|             locationid_txt.Text ="";
 | |
|             locationid_txt.Focus();
 | |
|         }
 | |
| 
 | |
|         private void radioButton2_CheckedChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             useLoc = rdLoc.Checked;
 | |
|             locationid_txt.Text = "";
 | |
|             locationid_txt.Focus();
 | |
|         }
 | |
|     }
 | |
| } |