Browse Source

扫码发货需要记录生产批次上的日期

master
yibo 5 years ago
parent
commit
ab99501dbf
6 changed files with 85 additions and 77 deletions
  1. +19
    -22
      ButcherFactory.BO/LocalBL/CarcassSaleOutBL.cs
  2. +17
    -10
      ButcherFactory.Form/CarcassSaleOut2_/CarcassSaleOutForm.cs
  3. +4
    -4
      ButcherFactory.Form/CarcassSaleOut2_/CarcassSaleOutReadForm.cs
  4. +4
    -4
      ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutForm.cs
  5. +31
    -29
      ButcherFactory.Form/Dialogs/AddWeightRecord.cs
  6. +10
    -8
      ButcherFactory.Form/Dialogs/WeightRecordDialog.cs

+ 19
- 22
ButcherFactory.BO/LocalBL/CarcassSaleOutBL.cs View File

@ -116,23 +116,19 @@ namespace ButcherFactory.BO.LocalBL
list.Add(new Tuple<string, object>("ProductBatch_ID", first.ProductBatch_ID)); list.Add(new Tuple<string, object>("ProductBatch_ID", first.ProductBatch_ID));
} }
else else
{
try
{
var json = RpcFacade.Call<string>("/MainSystem/B3ButcherManage/Rpcs/CarcassStoreDetailRpc/GetCarcassInstoreInfo", barCode);
var mesInfo = JsonConvert.DeserializeObject<SaleOutCarcassObj>(json);
if (!string.IsNullOrEmpty(mesInfo.Goods_Code))
{ {
var json = ButcherFactoryUtil.SecondUrlCall<string>(MESPath + "CarcassSaleOutStoreRpc/GetCarcassInstoreInfo", barCode);
var mesInfo = JsonConvert.DeserializeObject<SaleOutCarcassObj>(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; first.BarCode = barCode;
list.Add(new Tuple<string, object>("BarCode", first.BarCode)); list.Add(new Tuple<string, object>("BarCode", first.BarCode));
list.Add(new Tuple<string, object>("InStoreWeight", first.InStoreWeight)); list.Add(new Tuple<string, object>("InStoreWeight", first.InStoreWeight));
@ -199,9 +195,9 @@ namespace ButcherFactory.BO.LocalBL
return JsonConvert.DeserializeObject<List<ProductBatch>>(json); return JsonConvert.DeserializeObject<List<ProductBatch>>(json);
} }
public static void SubmitDetails(IEnumerable<CarcassSaleOut_Detail> 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<CarcassSaleOut_Detail> 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<string>(RpcPath + "SaleOutStoreRpc/SaveWeightRecord", JsonConvert.SerializeObject(arr), detail.ID); var json = RpcFacade.Call<string>(RpcPath + "SaleOutStoreRpc/SaveWeightRecord", JsonConvert.SerializeObject(arr), detail.ID);
var back = JsonConvert.DeserializeObject<Tuple<decimal?, decimal?, List<ExtensionObj>>>(json); var back = JsonConvert.DeserializeObject<Tuple<decimal?, decimal?, List<ExtensionObj>>>(json);
using (var session = DmoSession.New()) using (var session = DmoSession.New())
@ -239,12 +235,12 @@ namespace ButcherFactory.BO.LocalBL
delete.EExecute(); 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()) using (var session = DmoSession.New())
{ {
session.Insert(detail);
var arr = new List<WeightRecord> { new WeightRecord { Flag = flag, ID = detail.ID, WeightTime = detail.Time, MainUnitNum = detail.Weight, SecondNumber = detail.Number } };
session.Insert(detail);
var arr = new List<WeightRecord> { new WeightRecord { Flag = flag, ID = detail.ID, WeightTime = detail.Time, MainUnitNum = detail.Weight, SecondNumber = detail.Number, ProductTime = productTime } };
var json = RpcFacade.Call<string>(RpcPath + "SaleOutStoreRpc/SaveWeightRecord", JsonConvert.SerializeObject(arr), detail.DetailID); var json = RpcFacade.Call<string>(RpcPath + "SaleOutStoreRpc/SaveWeightRecord", JsonConvert.SerializeObject(arr), detail.DetailID);
var back = JsonConvert.DeserializeObject<Tuple<decimal?, decimal?, List<ExtensionObj>>>(json); var back = JsonConvert.DeserializeObject<Tuple<decimal?, decimal?, List<ExtensionObj>>>(json);
@ -428,6 +424,7 @@ namespace ButcherFactory.BO.LocalBL
public long? ProductBatch_ID { get; set; } public long? ProductBatch_ID { get; set; }
public DateTime WeightTime { get; set; } public DateTime WeightTime { get; set; }
public decimal? MainUnitNum { get; set; } public decimal? MainUnitNum { get; set; }
public decimal? SecondNumber { get; set; }
public decimal? SecondNumber { get; set; }
public DateTime? ProductTime { get; set; }
} }
} }

+ 17
- 10
ButcherFactory.Form/CarcassSaleOut2_/CarcassSaleOutForm.cs View File

@ -44,7 +44,8 @@ namespace ButcherFactory.CarcassSaleOut2_
internal long? storeID; internal long? storeID;
long? batchID; long? batchID;
bool already = false; bool already = false;
bool scanCode = true;
bool scanCode = true;
DateTime? mProductTime = null;
public CarcassSaleOutForm() public CarcassSaleOutForm()
{ {
@ -58,11 +59,17 @@ namespace ButcherFactory.CarcassSaleOut2_
uScanPanel1.AfterScan += uScanPanel1_AfterScan; uScanPanel1.AfterScan += uScanPanel1_AfterScan;
productBatchSelect.SelectedIndexChanged += delegate 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; sendGridView.CellFormatting += sendGridView_CellFormatting;
@ -216,8 +223,8 @@ namespace ButcherFactory.CarcassSaleOut2_
{ {
if (orderGridView.CurrentRow == null) if (orderGridView.CurrentRow == null)
throw new Exception("请选择配货明细"); 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(); dg.ShowDialog();
if (dg.Changed) if (dg.Changed)
BindOrderGrid(detail.SaleOutStore_ID); BindOrderGrid(detail.SaleOutStore_ID);
@ -276,8 +283,8 @@ namespace ButcherFactory.CarcassSaleOut2_
if (subList.Any(x => !x.Filled)) if (subList.Any(x => !x.Filled))
throw new Exception("有未扫码的明细"); throw new Exception("有未扫码的明细");
var detailID = (long)orderGridView.CurrentRow.Cells[0].Value; 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) foreach (var item in subList)
weightRecord.Remove(item); weightRecord.Remove(item);
var idx = weightRecord.Count; var idx = weightRecord.Count;


+ 4
- 4
ButcherFactory.Form/CarcassSaleOut2_/CarcassSaleOutReadForm.cs View File

@ -231,8 +231,8 @@ namespace ButcherFactory.CarcassSaleOut2_
{ {
if (orderGridView.CurrentRow == null) if (orderGridView.CurrentRow == null)
throw new Exception("请选择配货明细"); 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(); dg.ShowDialog();
if (dg.Changed) if (dg.Changed)
BindOrderGrid(detail.SaleOutStore_ID); BindOrderGrid(detail.SaleOutStore_ID);
@ -291,8 +291,8 @@ namespace ButcherFactory.CarcassSaleOut2_
if (subList.Any(x => !x.Filled)) if (subList.Any(x => !x.Filled))
throw new Exception("有未扫码的明细"); throw new Exception("有未扫码的明细");
var detailID = (long)orderGridView.CurrentRow.Cells[0].Value; 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) foreach (var item in subList)
weightRecord.Remove(item); weightRecord.Remove(item);
var idx = weightRecord.Count; var idx = weightRecord.Count;


+ 4
- 4
ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutForm.cs View File

@ -193,8 +193,8 @@ namespace ButcherFactory.CarcassSaleOut_
{ {
if (orderGridView.CurrentRow == null) if (orderGridView.CurrentRow == null)
throw new Exception("请选择配货明细"); 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(); dg.ShowDialog();
if (dg.Changed) if (dg.Changed)
BindOrderGrid(detail.SaleOutStore_ID); BindOrderGrid(detail.SaleOutStore_ID);
@ -253,8 +253,8 @@ namespace ButcherFactory.CarcassSaleOut_
if (subList.Any(x => !x.Filled)) if (subList.Any(x => !x.Filled))
throw new Exception("有未扫码的明细"); throw new Exception("有未扫码的明细");
var detailID = (long)orderGridView.CurrentRow.Cells[0].Value; 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) foreach (var item in subList)
weightRecord.Remove(item); weightRecord.Remove(item);
var idx = weightRecord.Count; var idx = weightRecord.Count;


+ 31
- 29
ButcherFactory.Form/Dialogs/AddWeightRecord.cs View File

@ -17,40 +17,42 @@ namespace ButcherFactory.Dialogs
public partial class AddWeightRecord : Form public partial class AddWeightRecord : Form
{ {
SaleOutStore_Detail mDetail; 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(); InitializeComponent();
mDetail = detail; mDetail = detail;
mBatchID = batchID; mBatchID = batchID;
numberInput.Text = "1"; 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) private void cancelBtn_Click(object sender, EventArgs e)


+ 10
- 8
ButcherFactory.Form/Dialogs/WeightRecordDialog.cs View File

@ -20,12 +20,14 @@ namespace ButcherFactory.Dialogs
SaleOutStore_Detail mDetail; SaleOutStore_Detail mDetail;
long? mBatchID = null; long? mBatchID = null;
public bool Changed = false; 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(); InitializeComponent();
mDetail = detail; mDetail = detail;
mBatchID = batchID;
mBatchID = batchID;
mProductTime = productTime;
if (readOnly) if (readOnly)
{ {
addBtn.Enabled = false; addBtn.Enabled = false;
@ -111,11 +113,11 @@ namespace ButcherFactory.Dialogs
} }
private void addBtn_Click(object sender, EventArgs e) 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;
} }
} }


Loading…
Cancel
Save