liuwf 1 year ago
parent 8483b3bee0
commit 45f18cfc36

@ -1460,11 +1460,18 @@ namespace Khd.Core.Wpf.Form
{ {
try try
{ {
if (!string.IsNullOrEmpty(txtInBox.Text) && !string.IsNullOrEmpty(txtInBarCode.Text)) if (!string.IsNullOrEmpty(txtInBox.Text) && !string.IsNullOrEmpty(txtInBarCode.Text))
{ {
using var scope = _host.Services.CreateScope(); using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>(); using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
if (txtInScan.Text == "")
{
MessageBox.Show("请先输入数量"); return;
}
decimal amount = decimal.Parse(txtInScan.Text); decimal amount = decimal.Parse(txtInScan.Text);
// 计算入库后当前总数量,仅用来提示使用
decimal? totalMessage = 0;
if (amount <= 0) if (amount <= 0)
{ {
MessageBox.Show("入库数量需大于0"); MessageBox.Show("入库数量需大于0");
@ -1513,6 +1520,7 @@ namespace Khd.Core.Wpf.Form
wmsRawStock.totalAmount += amount; wmsRawStock.totalAmount += amount;
dbContext.WmsRawStock.Update(wmsRawStock); dbContext.WmsRawStock.Update(wmsRawStock);
dbContext.SaveChanges(); dbContext.SaveChanges();
totalMessage = wmsRawStock.totalAmount;
} }
} }
@ -1542,15 +1550,16 @@ namespace Khd.Core.Wpf.Form
}; };
dbContext.WmsRawStock.Add(newRawStock); dbContext.WmsRawStock.Add(newRawStock);
dbContext.SaveChanges(); dbContext.SaveChanges();
totalMessage = newRawStock.totalAmount;
} }
txtInBox.Focus(); txtInBox.Focus();
MsgText.Text = "入库成功!"; MsgText.Text = $"入库成功!当前库存:{totalMessage}";
txtInBox.Text = string.Empty; txtInBox.Text = string.Empty;
txtInBarCode.Text = string.Empty; txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty; txtInScan.Text = string.Empty;
txtInBarCode.Focus();
} }
else else
{ {
@ -1730,7 +1739,7 @@ namespace Khd.Core.Wpf.Form
else else
{ {
txtInScan.Text = (material.batchFlag == "1") ? "0.00" : "1.00"; txtInScan.Text = (material.batchFlag == "1") ? "" : "1.00";
if (mesBaseMaterialInfo.BatchFlag == "0") if (mesBaseMaterialInfo.BatchFlag == "0")
@ -2446,9 +2455,10 @@ namespace Khd.Core.Wpf.Form
{ {
try try
{ {
BasePlcpoint basePlcpoint = SystemData.BasePlcpoints.First(t => t.plcpointNo == "canReceive"); BasePlcpoint basePlcpoint = SystemData.BasePlcpoints.First(t => t.plcpointNo == "canReceive");
SystemData.PlcDic[1].WriteToPoint(basePlcpoint.plcpointAddress, "1", basePlcpoint.plcpointLength.ToString()); SystemData.PlcDic[1].WriteToPoint(basePlcpoint.plcpointAddress, "1", basePlcpoint.plcpointLength.ToString());
MessageBox.Show("一键收料发送成功"); MsgText.Text = "一键收料发送成功";
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -2460,7 +2470,7 @@ namespace Khd.Core.Wpf.Form
{ {
if (item.Value.IP == ex.Message) if (item.Value.IP == ex.Message)
{ {
MessageBox.Show("PLC断开连接正在重连!"); MsgText.Text = "PLC断开连接正在重连!";
SystemData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Slot, item.Value.Rack); SystemData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Slot, item.Value.Rack);
SystemData.PlcDic[item.Key].Open(); SystemData.PlcDic[item.Key].Open();
break; break;
@ -2470,7 +2480,7 @@ namespace Khd.Core.Wpf.Form
} }
catch catch
{ {
MessageBox.Show("PLC连接失败!"); MsgText.Text = "PLC连接失败!";
} }
} }
} }

Loading…
Cancel
Save