|
|
|
@ -37,6 +37,7 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
Thread checkInStoreState; |
|
|
|
Thread initTask; |
|
|
|
BindingList<SegmentProduction> historyList; |
|
|
|
BindingList<long?> deleteList; |
|
|
|
BindingList<TotalCode> allCode; |
|
|
|
Dictionary<string, List<ClientGoodsSet_Detail>> goodsSetDic; |
|
|
|
long? batchID; |
|
|
|
@ -339,8 +340,8 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
entity.Goods_Spec = detail.Goods_Spec; |
|
|
|
entity.MainUnit = detail.MainUnit; |
|
|
|
entity.ShotPrintName = detail.ShotPrintName; |
|
|
|
|
|
|
|
_codePanel.Add(initSegmentBt(entity)); |
|
|
|
|
|
|
|
_codePanel.Add(initSegmentBt(entity, _codePanel,_totalCode),true); |
|
|
|
|
|
|
|
historyList.Insert(0, entity); |
|
|
|
|
|
|
|
@ -365,15 +366,17 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
|
|
|
|
SegmentProduction current; |
|
|
|
ColorButton _labelBt; |
|
|
|
private ColorButton initSegmentBt(SegmentProduction entity) |
|
|
|
private ColorButton initSegmentBt(SegmentProduction entity, CodePanel parent, TotalCode tCode) |
|
|
|
{ |
|
|
|
var bt = new ColorButton() { Text = entity.ShortCode }; |
|
|
|
bt.Tag = entity; |
|
|
|
bt.Width = 90; |
|
|
|
bt.Width = 98; |
|
|
|
bt.Height = 35; |
|
|
|
bt.Font = new Font("黑体", 13, FontStyle.Bold); |
|
|
|
bt.BackColor = Color.DarkCyan; |
|
|
|
bt.SelectedColor = Color.DarkOrange; |
|
|
|
bt.Font = new Font("黑体", 15, FontStyle.Bold); |
|
|
|
bt.ForeColor = Color.Black; |
|
|
|
bt.BackColor = System.Drawing.SystemColors.ButtonFace; |
|
|
|
|
|
|
|
bt.SelectedColor = Color.Cyan; |
|
|
|
bt.Click += delegate |
|
|
|
{ |
|
|
|
bt.Selected = !bt.Selected; |
|
|
|
@ -387,8 +390,10 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
_codePanel.Button.Selected = false; |
|
|
|
_codePanel.Button.Invalidate(); |
|
|
|
} |
|
|
|
_totalCode = null; |
|
|
|
_codePanel = null; |
|
|
|
parent.Button.Selected = true; |
|
|
|
parent.Button.Invalidate(); |
|
|
|
_totalCode = tCode; |
|
|
|
_codePanel = parent; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
@ -427,6 +432,7 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
void BindGrid() |
|
|
|
{ |
|
|
|
historyList = SegmentProductionBL.GetListByState(true); |
|
|
|
deleteList = SegmentProductionBL.GetInStoreList(); |
|
|
|
allCode = SegmentProductionBL.GetTotalCode(DateTime.Now); |
|
|
|
|
|
|
|
RefreshCodePanel(); |
|
|
|
@ -442,12 +448,16 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
codeButtons.Clear(); |
|
|
|
foreach (var item in allCode) |
|
|
|
{ |
|
|
|
var details = historyList.Where(x => x.TotalCode_ID == item.ID); |
|
|
|
if (deleteList.Contains(item.ID)) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
var details = historyList.Where(x => x.TotalCode_ID == item.ID); |
|
|
|
var n = new CodePanel(); |
|
|
|
AddCodeButton(n, item); |
|
|
|
foreach (var seg in details) |
|
|
|
{ |
|
|
|
n.Add(initSegmentBt(seg)); |
|
|
|
n.Add(initSegmentBt(seg,n,item)); |
|
|
|
} |
|
|
|
flowLayoutPanel3.Controls.Add(n); |
|
|
|
} |
|
|
|
@ -479,25 +489,47 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
if (netStateWatch1.NetState) |
|
|
|
{ |
|
|
|
if (historyList.Any()) |
|
|
|
{ |
|
|
|
var arr = historyList.Reverse().Take(20); |
|
|
|
{ |
|
|
|
int c = 50; |
|
|
|
if (historyList.Count() < 50) |
|
|
|
{ |
|
|
|
c = historyList.Count; |
|
|
|
} |
|
|
|
var arr = historyList.Reverse().Take(c); |
|
|
|
var inStored = SegmentProductionBL.GetInStoreState(arr.Select(x => x.BarCode).ToList()); |
|
|
|
var tag = arr.Where(x => inStored.Contains(x.BarCode)); |
|
|
|
if (tag.Any()) |
|
|
|
{ |
|
|
|
SegmentProductionBL.SetInStored(tag.Select(x => x.ID).ToList()); |
|
|
|
this.Invoke(new Action(() => |
|
|
|
{ |
|
|
|
{ |
|
|
|
var groupByTotal = tag.GroupBy(x => x.TotalCode_ID); |
|
|
|
foreach (var item2 in groupByTotal) |
|
|
|
{ |
|
|
|
var f = codeButtons.FirstOrDefault(x => ((TotalCode)x.Tag).ID == item2.Key); |
|
|
|
if (f != null) |
|
|
|
{ |
|
|
|
flowLayoutPanel3.Controls.Remove(f.Parent); |
|
|
|
codeButtons.Remove(f); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
foreach (var item in tag) |
|
|
|
historyList.Remove(item); |
|
|
|
//historyDataGrid.ClearSelection();
|
|
|
|
//historyDataGrid.Refresh();
|
|
|
|
historyList.Remove(item); |
|
|
|
|
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
this.Invoke(new Action(() => |
|
|
|
{ |
|
|
|
msglbl.Text = "ERROR" + ex.Message ?? string.Empty; |
|
|
|
})); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
Thread.Sleep(5000); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -543,15 +575,12 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
|
|
|
|
private void deleteBtn_Click(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
if (_totalCode == null || _codePanel == null) |
|
|
|
{ |
|
|
|
if (current == null) |
|
|
|
return; |
|
|
|
//if (_totalCode == null || _codePanel == null)
|
|
|
|
if (current != null) |
|
|
|
{ |
|
|
|
if (MessageBox.Show("确定删除选中记录?", "删除确认", MessageBoxButtons.OKCancel) != DialogResult.OK) |
|
|
|
return; |
|
|
|
|
|
|
|
//var tag = historyDataGrid.SelectedRows[0].DataBoundItem as SegmentProduction;
|
|
|
|
|
|
|
|
|
|
|
|
if (current.CreateTime.AddMinutes(1) < DateTime.Now) |
|
|
|
{ |
|
|
|
MessageBox.Show("已超出可删除时间范围"); |
|
|
|
@ -565,15 +594,19 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
var parent=_labelBt.Parent; |
|
|
|
parent.Controls.Remove(_labelBt); |
|
|
|
} |
|
|
|
//RefreshCodePanel();
|
|
|
|
|
|
|
|
var thd = new Thread(new ParameterizedThreadStart(RefreshTask)); |
|
|
|
thd.Start(d); |
|
|
|
current = null; |
|
|
|
} |
|
|
|
else |
|
|
|
else if (_totalCode != null && _codePanel != null) |
|
|
|
{ |
|
|
|
var deleteList = historyList.Where(x => x.TotalCode_ID == _totalCode.ID).ToList(); |
|
|
|
|
|
|
|
if (deleteList.Count > 0) |
|
|
|
{ |
|
|
|
MessageBox.Show("总码下已有条码,不允许直接删除总码"); |
|
|
|
return; |
|
|
|
} |
|
|
|
SegmentProductionBL.DeleteTotalCode(_totalCode); |
|
|
|
allCode.Remove(_totalCode); |
|
|
|
codeButtons.Remove(_codePanel.Button); |
|
|
|
@ -683,10 +716,11 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
n.Button.Text = tCode.ShortCode; |
|
|
|
n.Button.Click += delegate |
|
|
|
{ |
|
|
|
current = null; |
|
|
|
|
|
|
|
n.Button.Selected = !n.Button.Selected; |
|
|
|
if (n.Button.Selected) |
|
|
|
{ |
|
|
|
{ |
|
|
|
current = null; |
|
|
|
_codePanel = n; |
|
|
|
_totalCode = tCode; |
|
|
|
if (_labelBt != null) |
|
|
|
@ -738,6 +772,10 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
if (dmos.Length == 0) |
|
|
|
{ |
|
|
|
throw new Exception(string.Format("此码不包含任何产品!")); |
|
|
|
} |
|
|
|
foreach (var item in dmos) |
|
|
|
{ |
|
|
|
item.TotalCode_Code = _totalCode.BarCode; |
|
|
|
} |
|
|
|
NotAuto.SegmentSumCodePrint.Print(dmos, "SegmentSumCode.html"); |
|
|
|
var log = new SegmentLog(dmos[0].TotalCode_Code, "总码"); |
|
|
|
|