private void Search() { string strSql = "select * from Mes_Barcode where B_WorkShopCode = '" + txtCode.Text + "' and B_Status = '1' order by B_Code"; Mes_BarcodeBLL BarcodeBLL = new Mes_BarcodeBLL(); var row = BarcodeBLL.GetList_Mes_Barcode(strSql); int nLen = row.Count; this.listView1.Items.Clear(); this.listView1.BeginUpdate(); for (int i = 0; i < nLen; i++) { ListViewItem lvi = new ListViewItem(row[i].B_Code); lvi.SubItems.Add(row[i].B_Name); lvi.SubItems.Add(row[i].B_Qty.ToString()); this.listView1.Items.Add(lvi); } this.listView1.EndUpdate(); }
private void txtBarcode_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyValue == 13) { string strBarcode = txtBarcode.Text; if (strBarcode.IndexOf('*') > 0) { string[] strTemp = strBarcode.Split('*'); txtCode.Text = strTemp[0].ToString(); txtPc.Text = strTemp[1].ToString(); txtQty.Text = strTemp[2].ToString(); MesGoodsBLL GoodsBLL = new MesGoodsBLL(); var Goods_rows = GoodsBLL.GetListCondit("where G_Code = '" + txtCode.Text + "'"); int nLen = Goods_rows.Count; if (nLen > 0) { txtName.Text = Goods_rows[0].G_Name; txtPrice.Text = Goods_rows[0].G_Price.ToString(); strUnit = Goods_rows[0].G_Unit.ToString(); } } else { string[] strTemp = strBarcode.Split(','); //MessageBox.Show(strTemp.Length.ToString()); txtCode.Text = Resolve(strTemp[0].ToString()); txtPc.Text = Resolve(strTemp[1].ToString()); txtQty.Text = Resolve(strTemp[2].ToString()); m_strBarcode = strTemp[4].ToString(); Mes_BarcodeBLL BarcodeBLL = new Mes_BarcodeBLL(); var Barcode_rows = BarcodeBLL.GetList_Mes_Barcode("select * from Mes_Barcode where B_Status = 1 and B_Barcode = '" + m_strBarcode + "'"); if (Barcode_rows.Count > 0) { } else { MessageBox.Show("此标签已经入库, 或者状态不对"); txtBarcode.Text = ""; txtBarcode.Focus(); txtBarcode.SelectAll(); return; } MesGoodsBLL GoodsBLL = new MesGoodsBLL(); var Goods_rows = GoodsBLL.GetListCondit("where G_Code = '" + txtCode.Text + "'"); int nLen = Goods_rows.Count; if (nLen > 0) { txtName.Text = Goods_rows[0].G_Name; strUnit = Goods_rows[0].G_Unit; txtPrice.Text = Goods_rows[0].G_Price.ToString(); } } Save(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }