/// <summary> /// 称重记录保存 /// </summary> private void addWeighStorage() { try { MesWeightRecordBLL MesWeightRecordBLL = new MesWeightRecordBLL(); if (checkInput()) { MesMaterInDetailBLL MaterInDetailBLL = new MesMaterInDetailBLL(); var rows = MaterInDetailBLL.GetList_GoodsCode(txtGoodsCode.Text, ""); 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 = txtOrderNo.Text; MesWeightRecord.W_Kind = comKind.Text; 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("称重记录添加成功!"); } else { untCommon.InfoMsg("称重记录添加失败!"); } } } catch (Exception ex) { untCommon.ErrorMsg("设备管理添加数据异常:" + ex.Message); } }
/// <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); } }