private void textBox8_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyValue == 13) { string strBarcode = txtBarcode.Text; if (strBarcode.IndexOf('*') > 0) { string[] strTemp = strBarcode.Split('*'); string strGoodsCode = strTemp[0].ToString(); if (cmbGoodsCode.Items.Contains(strGoodsCode)) { cmbGoodsCode.Text = strTemp[0].ToString(); cmbPc.Text = strTemp[1].ToString(); txtQty.Text = strTemp[2].ToString(); MesGoodsBLL GoodsBLL = new MesGoodsBLL(); var Goods_rows = GoodsBLL.GetList(strTemp[0].ToString(), ""); 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(','); string strGoodsCode = Resolve(strTemp[0].ToString()); if (cmbGoodsCode.Items.Contains(strGoodsCode)) { cmbGoodsCode.Text = Resolve(strTemp[0].ToString()); cmbPc.Text = Resolve(strTemp[1].ToString()); txtQty.Text = Resolve(strTemp[2].ToString()); MesGoodsBLL GoodsBLL = new MesGoodsBLL(); var Goods_rows = GoodsBLL.GetList(cmbGoodsCode.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(); } } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void comGoods_SelectedIndexChanged(object sender, EventArgs e) { try { string[] strGoods = comGoods.Text.ToString().Split('$'); MesGoodsBLL GoodsBLL = new MesGoodsBLL(); //MesMaterInDetailEntity MaterInDetail = new MesMaterInDetailEntity(); var Goods_rows = GoodsBLL.GetList(strGoods[0], strGoods[1]); if (Goods_rows == null || Goods_rows.Count < 1 || Goods_rows[0].G_Kind == 2) { untCommon.InfoMsg("输入的物料编码错误,请重新输入!"); return; } if (Goods_rows[0].G_Kind == 1) { //txtGoodsCode.Text = Goods_rows[0].G_Code; //txtGoodsName.Text = Goods_rows[0].G_Name; txtUnit.Text = Goods_rows[0].G_Unit.ToString(); Itox = Goods_rows[0].G_Itax; //txtPrice.Text = Goods_rows[0].G_Price.ToString(); if (Goods_rows[0].G_Kind == 1) { txtKind.Text = "原物料"; } txtBatch.Text = DateTime.Now.ToString("yyyyMMdd"); Mes_InPriceBLL InPriceBLL = new Mes_InPriceBLL(); var InPrice_row = InPriceBLL.GetList_Mes_Price(" where P_GoodsCode = '" + strGoods[0] + "' and P_SupplyCode = '" + Globels.strSupplyCode + "'"); if (InPrice_row.Count > 0) { txtPrice.Text = InPrice_row[0].P_InPrice.ToString(); } else { untCommon.InfoMsg("请先维护商品的入库价格"); return; } txtQty.Focus(); } else { untCommon.InfoMsg("输入的物料编码不是原物料,请重新输入!"); //txtGoodsCode.Text = ""; //txtGoodsCode.Focus(); } } catch (Exception Exception) { MessageBox.Show(Exception.ToString()); } }
private void comGoods_SelectedIndexChanged(object sender, EventArgs e) { string[] strGoods = comGoods.Text.ToString().Split('$'); MesGoodsBLL GoodsBLL = new MesGoodsBLL(); //MesMaterInDetailEntity MaterInDetail = new MesMaterInDetailEntity(); var Goods_rows = GoodsBLL.GetList(strGoods[0], strGoods[1]); if (Goods_rows == null || Goods_rows.Count < 1 || Goods_rows[0].G_Kind == 2) { untCommon.InfoMsg("输入的物料编码错误,请重新输入!"); return; } if (Goods_rows[0].G_Kind == 1) { //txtGoodsCode.Text = Goods_rows[0].G_Code; //txtGoodsName.Text = Goods_rows[0].G_Name; txtUnit.Text = Goods_rows[0].G_Unit; txtPrice.Text = Goods_rows[0].G_Price.ToString(); if (Goods_rows[0].G_Kind == 1) { txtKind.Text = "原物料"; } txtBatch.Text = DateTime.Now.ToString("yyyyMMdd"); cmbSupply.Items.Clear(); Mes_InPriceBLL InPriceBLL = new Mes_InPriceBLL(); var InPrice_row = InPriceBLL.GetList_Mes_Price("where P_GoodsCode = '" + strGoods[0] + "'"); if (InPrice_row.Count > 0) { for (int i = 0; i < InPrice_row.Count; i++) { cmbSupply.Items.Add(InPrice_row[i].P_SupplyCode); } if (InPrice_row.Count == 1) { cmbSupply.Text = InPrice_row[0].P_SupplyCode; } } else { untCommon.InfoMsg("请先维护商品的入库价格"); return; } txtQty.Focus(); } else { untCommon.InfoMsg("输入的物料编码不是原物料,请重新输入!"); //txtGoodsCode.Text = ""; //txtGoodsCode.Focus(); } }
private void cmbGoodsCode_SelectedIndexChanged(object sender, EventArgs e) { try { cmbBatch.Items.Clear(); MesInventoryBLL InventoryBLL = new MesInventoryBLL(); var row = InventoryBLL.GetData("where I_StockCode = '" + cmbStock.Text + "' and I_GoodsCode = '" + cmbGoodsCode.Text + "' and I_Qty > 0"); for (int i = 0; i < row.Count; i++) { cmbBatch.Items.Add(row[i].I_Batch); } if (row.Count == 1) { cmbBatch.Text = row[0].I_Batch; txtQty.Text = row[0].I_Qty.ToString(); } MesGoodsBLL GoodsBLL = new MesGoodsBLL(); var Goods_rows = GoodsBLL.GetList(cmbGoodsCode.Text, ""); int nLen = Goods_rows.Count; if (nLen > 0) { cmbGoodsName.Text = Goods_rows[0].G_Name; txtUnit.Text = Goods_rows[0].G_Unit.ToString(); dPrice = Goods_rows[0].G_Price; //int nKind = Goods_rows[0].G_Kind; //if (nKind == 1) //{ // label17.Visible = true; // cmbSupplyName.Visible = true; //} //else //{ // ; //} } } catch (Exception ex) { //lblTS.Text = "ex.ToString()"; } }
private void txtGoodsName_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter)//如果输入的是回车键 { MesGoodsBLL GoodsBLL = new MesGoodsBLL(); //MesMaterInDetailEntity MaterInDetail = new MesMaterInDetailEntity(); var Goods_rows = GoodsBLL.GetList("", txtGoodsName.Text.Trim()); if (Goods_rows == null || Goods_rows.Count < 1) { untCommon.InfoMsg("输入的物料名称错误,请重新输入!"); } else { txtGoodsCode.Text = Goods_rows[0].G_Code; txtGoodsName.Text = Goods_rows[0].G_Name; txtUnit.Text = Goods_rows[0].G_Unit; } } }
private void BracodePrintf_Load(object sender, EventArgs e) { MesBasketBLL BasketBLL = new MesBasketBLL(); var Basket_rows = BasketBLL.GetList(); for (int i = 0; i < Basket_rows.Count; i++) { comBasketType.Items.Add(Basket_rows[i].B_BasketName); } checkBox1.Checked = true; comGoods.Items.Clear(); MesGoodsBLL GoodsBLL = new MesGoodsBLL(); var row = GoodsBLL.GetList("", ""); for (int i = 0; i < row.Count; i++) { comGoods.Items.Add(row[i].G_Code + "$" + row[i].G_Name); } txtBatch.Text = DateTime.Now.ToString("yyyyMMdd"); }
/// <summary> /// 称重记录保存 /// </summary> //private void addWeighStorage() //{ // try // { // MesWeightRecordBLL MesWeightRecordBLL = new MesWeightRecordBLL(); // MesMaterInDetailBLL MaterInDetailBLL = new MesMaterInDetailBLL(); // var rows = MaterInDetailBLL.GetList_GoodsCode("",""); // if (checkInput()) // { // rows = MaterInDetailBLL.GetList_GoodsCode(txtGoodsCode.Text,M_MaterInNo); // if (rows[0].M_GoodsCode == txtGoodsCode.Text && rows[0].M_GoodsName == txtGoodsName.Text && rows[0].M_Qty.ToString() == txtQty.Text) // { // untCommon.InfoMsg("称重记录数据错误!"); // return; // } // MesWeightRecordEntity MesWeightRecord = new MesWeightRecordEntity(); // MesWeightRecord.P_OrderNo = P_OrderNo; // MesWeightRecord.W_Kind = W_Kind; // MesWeightRecord.W_Date = DateTime.Now; // MesWeightRecord.W_GoodsCode = txtGoodsCode.Text; // MesWeightRecord.W_GoodsName = txtGoodsName.Text; // MesWeightRecord.W_Batch = txtBatch.Text; // MesWeightRecord.W_Qty = decimal.Parse(txtQty.Text); // MesWeightRecord.W_Unit = txtUnit.Text; // if (MesWeightRecordBLL.SaveEntity("", MesWeightRecord) > 0) // { // untCommon.InfoMsg("称重记录添加成功!"); // whether = 2; // //frmParent.loadData(); // frmStorage.Refresh(); // } // else // { // untCommon.InfoMsg("称重记录添加失败!"); // } // } // rows = MaterInDetailBLL.GetList(M_MaterInNo); // dataGridView.DataSource = rows; // } // catch (Exception ex) // { // untCommon.ErrorMsg("称重数据异常:" + ex.Message); // } //} /// <summary> /// 保存 /// </summary> private void addStorage() { try { string[] strGoods = comGoods.Text.ToString().Split('$'); MesWeightRecordBLL MesWeightRecordBLL = new MesWeightRecordBLL(); MesMaterInDetailBLL MaterInDetailBLL = new MesMaterInDetailBLL(); MesWeightRecordEntity MesWeightRecord = new MesWeightRecordEntity(); var rows = MaterInDetailBLL.GetList_GoodsCode("", ""); if (checkInput()) { //rows = MaterInDetailBLL.GetList_GoodsCode(txtGoodsCode.Text,M_MaterInNo); //if (rows[0].M_GoodsCode == txtGoodsCode.Text && rows[0].M_GoodsName == txtGoodsName.Text && rows[0].M_Qty.ToString() == txtQty.Text) //{ // untCommon.InfoMsg("称重记录数据错误!"); // return; //} MesWeightRecord.P_OrderNo = P_OrderNo; MesWeightRecord.W_Kind = W_Kind; MesWeightRecord.W_Date = DateTime.Now; MesWeightRecord.W_GoodsCode = strGoods[0]; MesWeightRecord.W_GoodsName = strGoods[1]; MesWeightRecord.W_Batch = txtBatch.Text; MesWeightRecord.W_Qty = decimal.Parse(txtQty.Text); MesWeightRecord.W_Unit = txtUnit.Text; MesMaterInDetailEntity MaterInDetail = new MesMaterInDetailEntity(); MesGoodsBLL GoodsBLL = new MesGoodsBLL(); //MesMaterInDetailEntity MaterInDetail = new MesMaterInDetailEntity(); var Goods_rows = GoodsBLL.GetList(strGoods[0], ""); string cz = "";//是否存在相同物料 MaterInDetail.M_MaterInNo = txtMaterInNo.Text; MaterInDetail.M_GoodsCode = strGoods[0]; MaterInDetail.M_GoodsName = strGoods[1]; MaterInDetail.M_Batch = txtBatch.Text; MaterInDetail.M_Price = Convert.ToDecimal(txtPrice.Text); MaterInDetail.M_GoodsItax = Itox; if (checkBox1.Checked == true) { drqQty = decimal.Parse(txtBasketQty.Text); MaterInDetail.M_Qty = decimal.Parse(txtQty.Text) - drqQty; } else { MaterInDetail.M_Qty = decimal.Parse(txtQty.Text); } MaterInDetail.M_Unit = txtUnit.Text; MaterInDetail.M_Kind = Convert.ToString(Goods_rows[0].G_Kind); // MesGoodsBLL GoodsBLL = new MesGoodsBLL(); //var Goods_rows = GoodsBLL.GetList(MaterInDetail.M_GoodsCode, MaterInDetail.M_GoodsName); if (Goods_rows == null || Goods_rows.Count < 1) { untCommon.InfoMsg("输入的物料名称错误,请重新输入!"); return; } else if (Goods_rows[0].G_Kind == 1) { //txtGoodsCode.Text = Goods_rows[0].G_Code; //txtGoodsName.Text = Goods_rows[0].G_Name; txtUnit.Text = Goods_rows[0].G_Unit; } else { untCommon.InfoMsg("输入的物料名称错误,请重新输入!"); return; } int i = dataGridView.Rows.Count; if (dataGridView.RowCount > 0 && dataGridView.DataSource != null) { for (int j = 0; j < i; j++) { if (dataGridView.Rows[j].Cells["物料编码"].Value.ToString() == strGoods[0]) { if (dataGridView.Rows[j].Cells["批次"].Value.ToString() == txtBatch.Text.Trim()) { cz = "存在"; } } } } if (cz == "存在") { var MaterInDetai_rows = MaterInDetailBLL.GetList_GoodsCode(MaterInDetail.M_GoodsCode, M_MaterInNo); var rowData = MaterInDetailBLL.GetEntity(MaterInDetai_rows[0].ID); // decimal dPrice = (rowData.M_Price * rowData.M_Qty + MaterInDetail.M_Price * MaterInDetail.M_Qty) / (rowData.M_Qty + MaterInDetail.M_Qty); rowData.M_Price = dPrice; rowData.M_Qty += MaterInDetail.M_Qty; if (MaterInDetailBLL.SaveEntityTrans(rowData.ID, rowData, "", MesWeightRecord) > 0)//事务 { untCommon.InfoMsg("修改成功!"); whether = 2; //frmParent.loadData(); frmStorage.Refresh(); } else { untCommon.InfoMsg("修改失败!"); } //if (MaterInDetailBLL.SaveEntity(rowData.ID, rowData) > 0) //{ // untCommon.InfoMsg("修改失败!"); // whether = 2; // //frmParent.loadData(); // frmStorage.Refresh(); // clear(); //} //else //{ // untCommon.InfoMsg("修改失败!"); //} } else { if (MaterInDetailBLL.SaveEntityTrans("", MaterInDetail, "", MesWeightRecord) > 0) { untCommon.InfoMsg("添加成功!"); //frmParent.loadData(); whether = 2; frmStorage.Refresh(); } else { untCommon.InfoMsg("添加失败!"); } } } rows = MaterInDetailBLL.GetList(M_MaterInNo); dataGridView.DataSource = rows; } catch (Exception ex) { untCommon.ErrorMsg("称重保存数据异常:" + ex.Message); } }