private void RefreshInput() { tbBarcode.Text = ""; tbProductNo.Text = ""; tbLotSn.Text = ""; tbQty.Text = ""; cbInputSnLot.Checked = false; lbItemDesc.ForeColor = Color.Green; ScanItem = null; }
/// <summary> /// 获取Item对象 /// </summary> /// <param name="sBarcode"></param> /// <param name="iCustomerId"></param> /// <returns></returns> internal static Entities.EntityItem GetItem(string sBarcode, int iCustomerId) { Entities.EntityItem entityItem = new Entities.EntityItem(); //and i.customer_id = b.customer_id string sSql = @"SELECT i.product_no,i.item_no,b.item_barcode,i.item_desc,i.customer_id,c.customer_desc FROM im_item i join im_item_barcode b on i.product_no = b.product_no join bc_customer c on c.customer_id = i.customer_id where i.void=0 "; sSql += " and b.item_barcode = '" + sBarcode + "' and b.customer_id = " + iCustomerId.ToString(); sSql += " order by i.product_no,b.item_barcode "; DataSet dsItems = Common.CommonDa.ExecuteQuery(sSql); if (dsItems != null) { if (dsItems.Tables[0].Rows.Count == 0) { return(null); } try { entityItem.CustomerId = iCustomerId; entityItem.ItemDesc = dsItems.Tables[0].Rows[0]["item_desc"].ToString().Trim(); entityItem.ItemNo = dsItems.Tables[0].Rows[0]["item_no"].ToString().Trim(); entityItem.ProductNo = int.Parse(dsItems.Tables[0].Rows[0]["product_no"].ToString().Trim()); List <Entities.EntityItemBarcode> lstItemBarcodes = new List <Entities.EntityItemBarcode>(); foreach (DataRow dr in dsItems.Tables[0].Rows) { Entities.EntityItemBarcode ib = new Entities.EntityItemBarcode(); ib.CustomerId = iCustomerId; ib.ProductNo = entityItem.ProductNo; ib.ItemBarcode = dr["item_barcode"].ToString(); lstItemBarcodes.Add(ib); } entityItem.ItemBarcodes = lstItemBarcodes; } catch (Exception ex) { throw (ex); } } return(entityItem); }
private void GetItem() { string sBarcode = tbBarcode.Text.Trim(); if (sBarcode == "") { return; } Entities.EntityItem entityItem = Common.CommonUtil.GetItem(sBarcode, int.Parse(cbCustomeId.SelectedValue.ToString())); if ((entityItem != null) && (entityItem.ProductNo != -1)) { tbProductNo.Text = entityItem.ProductNo.ToString(); lbItemDesc.Text = entityItem.ItemDesc; ScanItem = entityItem; if (tbQty.Text.Trim() == "") { tbQty.Text = "1"; tbContainerNo.Focus(); } else { Regex r = new Regex(@"^\d+$"); if (!(r.Match(tbQty.Text.Trim()).Success)) { tbQty.Text = "1"; tbContainerNo.Focus(); return; } int iQty = int.Parse(tbQty.Text.Trim()); //今后再添加扫描同条码累计功能 } } else { lbItemDesc.Text = "商品不存在(未维护基本信息)."; lbItemDesc.ForeColor = Color.Red; } //MessageBox.Show("商品不存在(未维护基本信息)."); }
private void FormAddModifyItem_Load(object sender, EventArgs e) { CurrentItem = new EntityItem(); cbCustomeId.DisplayMember = "customer_desc"; cbCustomeId.ValueMember = "customer_id"; if (FormMain.DS_BC_CUSTOMER != null) { if (FormMain.DS_BC_CUSTOMER.Tables[0].Rows.Count > 1) { DataTable dtCust = FormMain.DS_BC_CUSTOMER.Tables[0]; System.Data.DataRow dr = dtCust.NewRow(); dr["customer_id"] = -1; // CommonDefine.MSG_SELECT; dr["customer_desc"] = "全部"; // CommonDefine.MSG_SELECT; dtCust.Rows.Add(dr); cbCustomeId.DataSource = dtCust; cbCustomeId.SelectedValue = -1; } else { cbCustomeId.DataSource = FormMain.DS_BC_CUSTOMER.Tables[0]; } if (cbCustomeId.Items.Count > 0) { cbCustomeId.SelectedIndex = 0; } try { if (iLoadCustomerId != -1) { cbCustomeId.SelectedValue = iLoadCustomerId; } } catch { } } if (!bIsModifyItem) //新增时获取新id { int iProductNo = Common.CommonUtil.GenProductNo("im_item.product_no"); if (iProductNo != -1) { tbProductNo.Text = iProductNo.ToString(); } } if (sLoadItemBarcode.Trim() != "") { tbItemBarcode.Text = sLoadItemBarcode; Entities.EntityItem entityItem = Common.CommonUtil.GetItem(sLoadItemBarcode.Trim(), int.Parse(cbCustomeId.SelectedValue.ToString())); if ((entityItem != null) && (entityItem.ProductNo != -1)) { MessageBox.Show("商品已经存在."); } } //20140924 获取打印机列表 LoadAvilablePrinter(); tbItemBarcode.Focus(); }