using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Collections.Specialized; using System.Data; using DeiNiu.Wms.CE.Util; namespace DeiNiu.Wms.CE { public partial class StorageLocationCheck : basicForm { #region 界面初始化 string gooodsid = string.Empty; string batch = string.Empty; int skuId = 0; int ye = 0; int index = 0; DataTable dt; decimal oldcount=0m; DataTable dtaa = null; // StockLocationServiceClient client { get; set; } public StorageLocationCheck() { setTitle(); InitializeComponent(); initialComBoxes(); lacationid_txt.Focus(); button1.Enabled = false; button2.Enabled = false; // client = new StockLocationServiceClient(WcfHelp.getBasicBinding(), WcfHelp.getEndpoint("StockLocationService")); //client.setOperId(LoginInfo.UserId, LoginInfo.Token); } private void BarCodeStorage_Load(object sender, EventArgs e) { //if (page == 0) //{ // goodscode_txt.Enabled = true; // cb1.Checked = false; // cb1.Enabled = true; //} //else //{ // lacationid_txt.Focus(); // goodscode_txt.Enabled = false; // cb1.Checked = true; // cb1.Enabled = false; //} } #endregion /// /// 扫描商品条码,获取数据 /// /// /// /// /// 绑定数据到界面 /// /// /// private void SetValue(int index0, DataTable dta) { ye = dt.Rows.Count; row_lab.Text = String.Format("{0}/{1}页", ye > 0 ? index0 + 1 : index0, ye); down_bt.Enabled = up_bt.Enabled = true; if (ye < 2) { up_bt.Enabled = down_bt.Enabled = false; } else { if (index0 == 0) //首页 { up_bt.Enabled = false; } else if ((index0 + 1) == ye) //最后一页 { down_bt.Enabled = false; } } int y = index0; skuId = Convert.ToInt16(dta.Rows[y]["skuId"].ToString()); gooodsid = dta.Rows[y]["goodsId"].ToString();//商品id name_lab.Text = dta.Rows[y]["goodsName"].ToString();//品名 spec_lab.Text = dta.Rows[y]["spec"].ToString();//规格 PCompany_lab.Text = dta.Rows[y]["manufacturer"].ToString();//生产厂商 batch = dta.Rows[y]["batch"].ToString(); batch_lab.Text = batch;//批号 product_date_lab.Text = dta.Rows[y]["productDate"].ToString();//生产日期 save_date_lab.Text = dta.Rows[y]["validDate"].ToString();//有效期 //oldcount_lab.Text = GetData[y].Val;//库存数量 string count = dta.Rows[y]["avCount"].ToString(); count_txt.Text = count; oldcount = Convert.ToDecimal(count); Stocknum_lab.Text = count; lbbigcount.Text = dta.Rows[y]["bigcount"].ToString(); unit_lab.Text = dta.Rows[y]["unit"].ToString();//单位 lacationid_txt.Visible = true; } /// /// 扫描货位码 /// /// /// private void lacationid_txt_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { dtaa = null; string locId = lacationid_txt.Text; lacationid_txt.Text = ""; lacationid_lab.Text = locId; if (locId.Length < 7) { MessageBox.Show("请扫货位条码"); lacationid_txt.Focus(); return; } #region 根据货位显示信息 Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; try { dt = client.getStockLocation(locId); } catch (Exception er) { Cursor.Current = System.Windows.Forms.Cursors.Default; //MessageBox.Show("发生错误:" + er.Message); showErrorMsg(er); return; } Cursor.Current = System.Windows.Forms.Cursors.Default; if (dt.Rows.Count > 0) { SetValue(0,dt); dtaa = dt; button1.Enabled = true; button2.Enabled = true; } else { //MessageBox.Show("无数据"); lacationid_lab.Text = string.Format("'{0}' 无相关库存信息", locId); button1.Enabled=false; button2.Enabled = false; row_lab.Text= name_lab.Text = spec_lab.Text = PCompany_lab.Text = unit_lab.Text = ""; Stocknum_lab.Text = batch_lab.Text = row_lab.Text = product_date_lab.Text = save_date_lab.Text = ""; count_txt.Text = "0"; lacationid_txt.Focus(); ye = 0; index = 0; } #endregion Cursor.Current = System.Windows.Forms.Cursors.Default; } } private void cb1_CheckStateChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e)//修改数量 { try { string locID = lacationid_lab.Text.ToString(); decimal count = 0m; try { count = Convert.ToDecimal(count_txt.Text.ToString()); } catch { MessageBox.Show("请输入数量!"); count_txt.Focus(); return; } if (oldcount == count) { MessageBox.Show("请确认输入的数量"); count_txt.Focus(); return; } if (this.comboBox1.SelectedIndex ==0) { MessageBox.Show("请选择原因!"); comboBox1.Focus(); return; } bool i; Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; try { i = client.updateStockLocation(locID, gooodsid, skuId, batch, count, comboBox1.Text.ToString(), (int)enumStockRecordType.手持盘点, LoginInfo.UserId, LoginInfo.Token); } catch (Exception er) { Cursor.Current = System.Windows.Forms.Cursors.Default; MessageBox.Show("发生错误:" + er.Message); return; } Cursor.Current = System.Windows.Forms.Cursors.Default; if (i == false) { MessageBox.Show("修改失败!!!"); lacationid_txt.Focus(); } else { MessageBox.Show("修改成功!"); //Stocknum_lab.Text ="库存:" +sl; dtaa = null; name_lab.Text = spec_lab.Text = PCompany_lab.Text = lacationid_lab.Text = unit_lab.Text = lbbigcount.Text = ""; Stocknum_lab.Text = batch_lab.Text = row_lab.Text = product_date_lab.Text = save_date_lab.Text = ""; count_txt.Text = "0"; lacationid_txt.Focus(); } } catch(Exception er) { showErrorMsg(er); //MessageBox.Show("出错了:" + er.Message); lacationid_txt.Focus(); } } private void button2_Click(object sender, EventArgs e)//货位清零 { if (this.comboBox1.SelectedIndex == 0) { MessageBox.Show("请选择原因!"); comboBox1.Focus(); return; } Message me = new Message(); me.title = "您确认要清空货位吗?"; if(me.ShowDialog()==DialogResult.Cancel) { lacationid_txt.Focus(); return; } me.title = "真的要清空吗?"; if (me.ShowDialog() == DialogResult.Cancel) { lacationid_txt.Focus(); return; } me.title = "请再次确认是否要清空货位?"; if (me.ShowDialog() == DialogResult.Cancel) { lacationid_txt.Focus(); return; } string locId = lacationid_lab.Text.ToString(); bool tr ; Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; try { tr = client.clearLocation(locId, comboBox1.Text, LoginInfo.UserId, LoginInfo.Token); } catch (Exception er) { Cursor.Current = System.Windows.Forms.Cursors.Default; // MessageBox.Show("发生错误:" + er.Message); showErrorMsg(er); return; } Cursor.Current = System.Windows.Forms.Cursors.Default; if(tr==true) { MessageBox.Show("货位清空成功!"); dtaa = null; name_lab.Text = spec_lab.Text = PCompany_lab.Text = lacationid_lab.Text = unit_lab.Text = ""; Stocknum_lab.Text = batch_lab.Text = row_lab.Text = product_date_lab.Text = save_date_lab.Text = ""; count_txt.Text = "0"; lacationid_txt.Focus(); } else { MessageBox.Show("货位清空失败!!!!"); lacationid_txt.Focus(); } } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { } private void lacationid_txt_TextChanged(object sender, EventArgs e) { } private void initialComBoxes() { Utils.buildCombox(2008, this.comboBox1); } /// /// 上一页 /// /// /// private void up_bt_Click(object sender, EventArgs e) { if (index < ye) { index--; SetValue(index, dt); } } /// /// 下一页 /// /// /// private void down_bt_Click(object sender, EventArgs e) { if (index < ye) { index++; SetValue(index, dt); } } } }