diff --git a/ButcherFactory.BO/LocalBL/CarcassSaleOutBL.cs b/ButcherFactory.BO/LocalBL/CarcassSaleOutBL.cs index 1a737ff..5b2e45f 100644 --- a/ButcherFactory.BO/LocalBL/CarcassSaleOutBL.cs +++ b/ButcherFactory.BO/LocalBL/CarcassSaleOutBL.cs @@ -116,23 +116,19 @@ namespace ButcherFactory.BO.LocalBL list.Add(new Tuple("ProductBatch_ID", first.ProductBatch_ID)); } else - { - try + { + var json = RpcFacade.Call("/MainSystem/B3ButcherManage/Rpcs/CarcassStoreDetailRpc/GetCarcassInstoreInfo", barCode); + var mesInfo = JsonConvert.DeserializeObject(json); + if (!string.IsNullOrEmpty(mesInfo.Goods_Code)) { - var json = ButcherFactoryUtil.SecondUrlCall(MESPath + "CarcassSaleOutStoreRpc/GetCarcassInstoreInfo", barCode); - var mesInfo = JsonConvert.DeserializeObject(json); - if (!string.IsNullOrEmpty(mesInfo.Goods_Code)) - { - if (mesInfo.Goods_Code == "X002")//特殊处理,有个存货编码不存在。 - mesInfo.Goods_Code = "0001"; - var gInfo = GetGoodsInfo(mesInfo.Goods_Code); - first.Goods_Code = mesInfo.Goods_Code; - first.InStoreWeight = mesInfo.InStoreWeight; - first.Goods_ID = gInfo.Item1; - first.Goods_Name = gInfo.Item2; - } + if (mesInfo.Goods_Code == "X002")//特殊处理,有个存货编码不存在。 + mesInfo.Goods_Code = "0001"; + var gInfo = GetGoodsInfo(mesInfo.Goods_Code); + first.Goods_Code = mesInfo.Goods_Code; + first.InStoreWeight = mesInfo.InStoreWeight; + first.Goods_ID = gInfo.Item1; + first.Goods_Name = gInfo.Item2; } - catch { }; first.BarCode = barCode; list.Add(new Tuple("BarCode", first.BarCode)); list.Add(new Tuple("InStoreWeight", first.InStoreWeight)); @@ -199,9 +195,9 @@ namespace ButcherFactory.BO.LocalBL return JsonConvert.DeserializeObject>(json); } - public static void SubmitDetails(IEnumerable details, SaleOutStore_Detail detail) - { - var arr = details.Select(x => new WeightRecord { Flag = (!string.IsNullOrEmpty(x.BarCode) && x.BarCode.StartsWith("P")) ? -1 : 0, ID = x.ID, WeightTime = x.Time, MainUnitNum = x.Weight, SecondNumber = x.Number, ProductBatch_ID = x.ProductBatch_ID, BarCode = x.BarCode }); + public static void SubmitDetails(IEnumerable details, SaleOutStore_Detail detail,DateTime? mProductTime) + { + var arr = details.Select(x => new WeightRecord { Flag = (!string.IsNullOrEmpty(x.BarCode) && x.BarCode.StartsWith("P")) ? -1 : 0, ID = x.ID, WeightTime = x.Time, MainUnitNum = x.Weight, SecondNumber = x.Number, ProductBatch_ID = x.ProductBatch_ID, BarCode = x.BarCode, ProductTime = mProductTime }); var json = RpcFacade.Call(RpcPath + "SaleOutStoreRpc/SaveWeightRecord", JsonConvert.SerializeObject(arr), detail.ID); var back = JsonConvert.DeserializeObject>>(json); using (var session = DmoSession.New()) @@ -239,12 +235,12 @@ namespace ButcherFactory.BO.LocalBL delete.EExecute(); } - public static void AddAndUpdate(CarcassSaleOut_Detail detail, int flag) + public static void AddAndUpdate(CarcassSaleOut_Detail detail, int flag,DateTime? productTime) { using (var session = DmoSession.New()) { - session.Insert(detail); - var arr = new List { new WeightRecord { Flag = flag, ID = detail.ID, WeightTime = detail.Time, MainUnitNum = detail.Weight, SecondNumber = detail.Number } }; + session.Insert(detail); + var arr = new List { new WeightRecord { Flag = flag, ID = detail.ID, WeightTime = detail.Time, MainUnitNum = detail.Weight, SecondNumber = detail.Number, ProductTime = productTime } }; var json = RpcFacade.Call(RpcPath + "SaleOutStoreRpc/SaveWeightRecord", JsonConvert.SerializeObject(arr), detail.DetailID); var back = JsonConvert.DeserializeObject>>(json); @@ -428,6 +424,7 @@ namespace ButcherFactory.BO.LocalBL public long? ProductBatch_ID { get; set; } public DateTime WeightTime { get; set; } public decimal? MainUnitNum { get; set; } - public decimal? SecondNumber { get; set; } + public decimal? SecondNumber { get; set; } + public DateTime? ProductTime { get; set; } } } diff --git a/ButcherFactory.Form/CarcassSaleOut2_/CarcassSaleOutForm.cs b/ButcherFactory.Form/CarcassSaleOut2_/CarcassSaleOutForm.cs index 42e2f9a..5b781e6 100644 --- a/ButcherFactory.Form/CarcassSaleOut2_/CarcassSaleOutForm.cs +++ b/ButcherFactory.Form/CarcassSaleOut2_/CarcassSaleOutForm.cs @@ -44,7 +44,8 @@ namespace ButcherFactory.CarcassSaleOut2_ internal long? storeID; long? batchID; bool already = false; - bool scanCode = true; + bool scanCode = true; + DateTime? mProductTime = null; public CarcassSaleOutForm() { @@ -58,11 +59,17 @@ namespace ButcherFactory.CarcassSaleOut2_ uScanPanel1.AfterScan += uScanPanel1_AfterScan; productBatchSelect.SelectedIndexChanged += delegate - { - if (productBatchSelect.SelectedValue == null) - batchID = null; - else - batchID = (long)productBatchSelect.SelectedValue; + { + if (productBatchSelect.SelectedValue == null) + { + batchID = null; + mProductTime = null; + } + else + { + batchID = (long)productBatchSelect.SelectedValue; + mProductTime = (productBatchSelect.SelectedItem as ProductBatch).Date; + } }; sendGridView.CellFormatting += sendGridView_CellFormatting; @@ -216,8 +223,8 @@ namespace ButcherFactory.CarcassSaleOut2_ { if (orderGridView.CurrentRow == null) throw new Exception("请选择配货明细"); - var detail = orderGridView.CurrentRow.DataBoundItem as SaleOutStore_Detail; - var dg = new WeightRecordDialog(details.First(x => x.ID == detail.ID), already, batchID); + var detail = orderGridView.CurrentRow.DataBoundItem as SaleOutStore_Detail; + var dg = new WeightRecordDialog(details.First(x => x.ID == detail.ID), already, batchID, mProductTime); dg.ShowDialog(); if (dg.Changed) BindOrderGrid(detail.SaleOutStore_ID); @@ -276,8 +283,8 @@ namespace ButcherFactory.CarcassSaleOut2_ if (subList.Any(x => !x.Filled)) throw new Exception("有未扫码的明细"); var detailID = (long)orderGridView.CurrentRow.Cells[0].Value; - var detail = details.First(x => x.ID == detailID); - CarcassSaleOutBL.SubmitDetails(subList, detail); + var detail = details.First(x => x.ID == detailID); + CarcassSaleOutBL.SubmitDetails(subList, detail, mProductTime); foreach (var item in subList) weightRecord.Remove(item); var idx = weightRecord.Count; diff --git a/ButcherFactory.Form/CarcassSaleOut2_/CarcassSaleOutReadForm.cs b/ButcherFactory.Form/CarcassSaleOut2_/CarcassSaleOutReadForm.cs index 9eee224..a27ca94 100644 --- a/ButcherFactory.Form/CarcassSaleOut2_/CarcassSaleOutReadForm.cs +++ b/ButcherFactory.Form/CarcassSaleOut2_/CarcassSaleOutReadForm.cs @@ -231,8 +231,8 @@ namespace ButcherFactory.CarcassSaleOut2_ { if (orderGridView.CurrentRow == null) throw new Exception("请选择配货明细"); - var detail = orderGridView.CurrentRow.DataBoundItem as SaleOutStore_Detail; - var dg = new WeightRecordDialog(details.First(x => x.ID == detail.ID), already, batchID); + var detail = orderGridView.CurrentRow.DataBoundItem as SaleOutStore_Detail; + var dg = new WeightRecordDialog(details.First(x => x.ID == detail.ID), already, batchID, null); dg.ShowDialog(); if (dg.Changed) BindOrderGrid(detail.SaleOutStore_ID); @@ -291,8 +291,8 @@ namespace ButcherFactory.CarcassSaleOut2_ if (subList.Any(x => !x.Filled)) throw new Exception("有未扫码的明细"); var detailID = (long)orderGridView.CurrentRow.Cells[0].Value; - var detail = details.First(x => x.ID == detailID); - CarcassSaleOutBL.SubmitDetails(subList, detail); + var detail = details.First(x => x.ID == detailID); + CarcassSaleOutBL.SubmitDetails(subList, detail, null); foreach (var item in subList) weightRecord.Remove(item); var idx = weightRecord.Count; diff --git a/ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutForm.cs b/ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutForm.cs index f2993d6..64a4822 100644 --- a/ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutForm.cs +++ b/ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutForm.cs @@ -193,8 +193,8 @@ namespace ButcherFactory.CarcassSaleOut_ { if (orderGridView.CurrentRow == null) throw new Exception("请选择配货明细"); - var detail = orderGridView.CurrentRow.DataBoundItem as SaleOutStore_Detail; - var dg = new WeightRecordDialog(details.First(x => x.ID == detail.ID), already, batchID); + var detail = orderGridView.CurrentRow.DataBoundItem as SaleOutStore_Detail; + var dg = new WeightRecordDialog(details.First(x => x.ID == detail.ID), already, batchID, null); dg.ShowDialog(); if (dg.Changed) BindOrderGrid(detail.SaleOutStore_ID); @@ -253,8 +253,8 @@ namespace ButcherFactory.CarcassSaleOut_ if (subList.Any(x => !x.Filled)) throw new Exception("有未扫码的明细"); var detailID = (long)orderGridView.CurrentRow.Cells[0].Value; - var detail = details.First(x => x.ID == detailID); - CarcassSaleOutBL.SubmitDetails(subList, detail); + var detail = details.First(x => x.ID == detailID); + CarcassSaleOutBL.SubmitDetails(subList, detail, null); foreach (var item in subList) weightRecord.Remove(item); var idx = weightRecord.Count; diff --git a/ButcherFactory.Form/Dialogs/AddWeightRecord.cs b/ButcherFactory.Form/Dialogs/AddWeightRecord.cs index 66ea807..278b440 100644 --- a/ButcherFactory.Form/Dialogs/AddWeightRecord.cs +++ b/ButcherFactory.Form/Dialogs/AddWeightRecord.cs @@ -17,40 +17,42 @@ namespace ButcherFactory.Dialogs public partial class AddWeightRecord : Form { SaleOutStore_Detail mDetail; - long? mBatchID = null; - public AddWeightRecord(SaleOutStore_Detail detail,long? batchID) + long? mBatchID = null; + DateTime? mProductTime; + public AddWeightRecord(SaleOutStore_Detail detail,long? batchID,DateTime? productTime) { InitializeComponent(); mDetail = detail; mBatchID = batchID; numberInput.Text = "1"; - goodsLabel.Text = mDetail.Goods_Name; - } - - private void okBtn_Click(object sender, EventArgs e) - { - decimal weight = 0; - if (!decimal.TryParse(weightInput.Text, out weight)) - throw new Exception("请输入重量"); - decimal number = 0; - if (!decimal.TryParse(numberInput.Text, out number)) - throw new Exception("请输入数量"); - if (number < 0) - throw new Exception("数量不能为负"); - var record = new CarcassSaleOut_Detail(); - record.BillID = mDetail.SaleOutStore_ID; - record.DetailID = mDetail.ID; - record.Filled = true; - record.ProductBatch_ID = mBatchID; - record.Goods_Code = mDetail.Goods_Code; - record.Goods_ID = mDetail.Goods_ID; - record.Goods_Name = mDetail.Goods_Name; - record.Number = number; - record.Weight = weight; - record.Operator = AppContext.Worker.Name; - var flag = mDetail.Goods_ID == 7318 ? -1 : 0; //套猪袋 - CarcassSaleOutBL.AddAndUpdate(record, flag); - DialogResult = DialogResult.OK; + goodsLabel.Text = mDetail.Goods_Name; + mProductTime = productTime; + } + + private void okBtn_Click(object sender, EventArgs e) + { + decimal weight = 0; + if (!decimal.TryParse(weightInput.Text, out weight)) + throw new Exception("请输入重量"); + decimal number = 0; + if (!decimal.TryParse(numberInput.Text, out number)) + throw new Exception("请输入数量"); + if (number < 0) + throw new Exception("数量不能为负"); + var record = new CarcassSaleOut_Detail(); + record.BillID = mDetail.SaleOutStore_ID; + record.DetailID = mDetail.ID; + record.Filled = true; + record.ProductBatch_ID = mBatchID; + record.Goods_Code = mDetail.Goods_Code; + record.Goods_ID = mDetail.Goods_ID; + record.Goods_Name = mDetail.Goods_Name; + record.Number = number; + record.Weight = weight; + record.Operator = AppContext.Worker.Name; + var flag = mDetail.Goods_ID == 7318 ? -1 : 0; //套猪袋 + CarcassSaleOutBL.AddAndUpdate(record, flag, mProductTime); + DialogResult = DialogResult.OK; } private void cancelBtn_Click(object sender, EventArgs e) diff --git a/ButcherFactory.Form/Dialogs/WeightRecordDialog.cs b/ButcherFactory.Form/Dialogs/WeightRecordDialog.cs index da5dc13..215d229 100644 --- a/ButcherFactory.Form/Dialogs/WeightRecordDialog.cs +++ b/ButcherFactory.Form/Dialogs/WeightRecordDialog.cs @@ -20,12 +20,14 @@ namespace ButcherFactory.Dialogs SaleOutStore_Detail mDetail; long? mBatchID = null; public bool Changed = false; - public bool rolBack = false; - public WeightRecordDialog(SaleOutStore_Detail detail, bool readOnly, long? batchID) + public bool rolBack = false; + DateTime? mProductTime; + public WeightRecordDialog(SaleOutStore_Detail detail, bool readOnly, long? batchID,DateTime? productTime) { InitializeComponent(); mDetail = detail; - mBatchID = batchID; + mBatchID = batchID; + mProductTime = productTime; if (readOnly) { addBtn.Enabled = false; @@ -111,11 +113,11 @@ namespace ButcherFactory.Dialogs } private void addBtn_Click(object sender, EventArgs e) - { - if (new AddWeightRecord(mDetail, mBatchID).ShowDialog() == DialogResult.OK) - { - BindGrid(); - Changed = true; + { + if (new AddWeightRecord(mDetail, mBatchID, mProductTime).ShowDialog() == DialogResult.OK) + { + BindGrid(); + Changed = true; } }