|
|
|
@ -36,7 +36,8 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
Thread uploadData; |
|
|
|
Thread checkInStoreState; |
|
|
|
Thread initTask; |
|
|
|
BindingList<SegmentProduction> historyList; |
|
|
|
BindingList<SegmentProduction> historyList; |
|
|
|
BindingList<TotalCode> allCode; |
|
|
|
Dictionary<string, List<ClientGoodsSet_Detail>> goodsSetDic; |
|
|
|
long? batchID; |
|
|
|
DateTime? batchDate; |
|
|
|
@ -88,7 +89,7 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
if (checkInStoreState != null && checkInStoreState.IsAlive) |
|
|
|
checkInStoreState.Abort(); |
|
|
|
} |
|
|
|
WeightDetails mCache; |
|
|
|
public WeightDetails mCache; |
|
|
|
protected override void OnLoad(EventArgs e) |
|
|
|
{ |
|
|
|
base.OnLoad(e); |
|
|
|
@ -215,11 +216,15 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
{ |
|
|
|
if (batchID == null) |
|
|
|
throw new Exception("请先选择批次"); |
|
|
|
if (_totalCode == null || _codePanel == null) |
|
|
|
{ |
|
|
|
throw new Exception(string.Format("请先选择总码!")); |
|
|
|
} |
|
|
|
var weight = uWeightControl1.Weight; |
|
|
|
//#if DEBUG
|
|
|
|
// if (weight == 0)
|
|
|
|
// weight = (item.StandardWeightLow ?? 4.0m) + 0.1m;
|
|
|
|
//#endif
|
|
|
|
#if DEBUG
|
|
|
|
if (weight == 0) |
|
|
|
weight = (item.StandardWeightLow ?? 4.0m) + 0.1m; |
|
|
|
#endif
|
|
|
|
if (weight == 0) |
|
|
|
throw new Exception("重量不能为0"); |
|
|
|
if (item.StandardWeight.HasValue) |
|
|
|
@ -289,12 +294,13 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
var btn = sender as ColorButton; |
|
|
|
var detail = btn.Tag as ClientGoodsSet_Detail; |
|
|
|
var weight = uWeightControl1.Weight; |
|
|
|
//#if DEBUG
|
|
|
|
// if (weight == 0)
|
|
|
|
// weight = (detail.StandardWeightLow ?? 4.0m) + 0.1m;
|
|
|
|
//#endif
|
|
|
|
#if DEBUG
|
|
|
|
if (weight == 0) |
|
|
|
weight = (detail.StandardWeightLow ?? 4.0m) + 0.1m; |
|
|
|
#endif
|
|
|
|
if (weight == 0) |
|
|
|
throw new Exception("重量不能为0"); |
|
|
|
|
|
|
|
if (detail.StandardWeight.HasValue) |
|
|
|
{ |
|
|
|
if (weight < (detail.StandardWeightLow ?? 0) || weight > (detail.StandardWeightUp ?? 0)) |
|
|
|
@ -322,14 +328,22 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
entity.StandardPic = detail.StandardPic; |
|
|
|
if (!string.IsNullOrEmpty(statisticNumberBox.Text)) |
|
|
|
entity.StatisticNumber = decimal.Parse(statisticNumberBox.Text); |
|
|
|
if (_totalCode == null || _codePanel==null) |
|
|
|
{ |
|
|
|
throw new Exception(string.Format("请先选择总码!" )); |
|
|
|
} |
|
|
|
entity.TotalCode_ID = _totalCode.ID; |
|
|
|
SegmentProductionBL.InsertAndSetGroupID(entity, batchDate.Value); |
|
|
|
entity.Goods_Code = detail.Goods_Code; |
|
|
|
entity.Goods_Name = detail.Goods_Name; |
|
|
|
entity.Goods_Spec = detail.Goods_Spec; |
|
|
|
entity.MainUnit = detail.MainUnit; |
|
|
|
entity.ShotPrintName = detail.ShotPrintName; |
|
|
|
|
|
|
|
|
|
|
|
_codePanel.Add(initSegmentBt(entity)); |
|
|
|
|
|
|
|
historyList.Insert(0, entity); |
|
|
|
|
|
|
|
if (historyList.Count > 30) |
|
|
|
historyList.RemoveAt(30); |
|
|
|
if (barPrintCheck.Checked) |
|
|
|
@ -344,33 +358,99 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
} |
|
|
|
} |
|
|
|
GoodsLabel.Text = detail.Goods_Name; |
|
|
|
historyDataGrid.FirstDisplayedScrollingRowIndex = 0; |
|
|
|
historyDataGrid.ClearSelection(); |
|
|
|
historyDataGrid.Refresh(); |
|
|
|
|
|
|
|
var thd = new Thread(new ParameterizedThreadStart(RefreshTask)); |
|
|
|
thd.Start(entity); |
|
|
|
} |
|
|
|
|
|
|
|
void RefreshTask(object obj) |
|
|
|
{ |
|
|
|
var entity = obj as SegmentProduction; |
|
|
|
var list = SegmentProductionBL.GetProductTask(batchDate ?? DateTime.Today, entity); |
|
|
|
this.Invoke(new Action(() => |
|
|
|
{ |
|
|
|
taskDataGrid.DataSource = list; |
|
|
|
taskDataGrid.Refresh(); |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SegmentProduction current; |
|
|
|
ColorButton _labelBt; |
|
|
|
private ColorButton initSegmentBt(SegmentProduction entity) |
|
|
|
{ |
|
|
|
var bt = new ColorButton() { Text = entity.ShortCode }; |
|
|
|
bt.Tag = entity; |
|
|
|
bt.Width = 90; |
|
|
|
bt.Height = 35; |
|
|
|
bt.Font = new Font("黑体", 13, FontStyle.Bold); |
|
|
|
bt.BackColor = Color.DarkCyan; |
|
|
|
bt.SelectedColor = Color.DarkOrange; |
|
|
|
bt.Click += delegate |
|
|
|
{ |
|
|
|
bt.Selected = !bt.Selected; |
|
|
|
if (bt.Selected) |
|
|
|
{ |
|
|
|
current = entity; |
|
|
|
_labelBt = bt; |
|
|
|
GoodsLabel.Text = entity.Goods_Name; |
|
|
|
if (_codePanel != null) |
|
|
|
{ |
|
|
|
_codePanel.Button.Selected = false; |
|
|
|
_codePanel.Button.Invalidate(); |
|
|
|
} |
|
|
|
_totalCode = null; |
|
|
|
_codePanel = null; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_labelBt = null; |
|
|
|
current = null; |
|
|
|
GoodsLabel.Text = ""; |
|
|
|
} |
|
|
|
foreach (var bt2 in segmentButtons) |
|
|
|
{ |
|
|
|
if (bt2.Text != entity.ShortCode && bt2.Selected) |
|
|
|
{ |
|
|
|
bt2.Selected = false; |
|
|
|
bt2.Invalidate(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
segmentButtons.Add(bt); |
|
|
|
return bt; |
|
|
|
} |
|
|
|
|
|
|
|
void RefreshTask(object obj) |
|
|
|
{ |
|
|
|
var entity = obj as SegmentProduction; |
|
|
|
var list = SegmentProductionBL.GetProductTask(batchDate ?? DateTime.Today, entity); |
|
|
|
this.Invoke(new Action(() => |
|
|
|
{ |
|
|
|
taskDataGrid.DataSource = list; |
|
|
|
taskDataGrid.Refresh(); |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
List<ColorButton> codeButtons = new List<ColorButton>(0); |
|
|
|
List<ColorButton> segmentButtons = new List<ColorButton>(0); |
|
|
|
|
|
|
|
void BindGrid() |
|
|
|
{ |
|
|
|
historyList = SegmentProductionBL.GetListByState(true); |
|
|
|
historyDataGrid.DataSource = historyList; |
|
|
|
historyDataGrid.Refresh(); |
|
|
|
|
|
|
|
historyList = SegmentProductionBL.GetListByState(true); |
|
|
|
allCode = SegmentProductionBL.GetTotalCode(DateTime.Now); |
|
|
|
|
|
|
|
RefreshCodePanel(); |
|
|
|
|
|
|
|
var first = historyList.FirstOrDefault(); |
|
|
|
if (first != null) |
|
|
|
GoodsLabel.Text = first.Goods_Name; |
|
|
|
} |
|
|
|
|
|
|
|
private void RefreshCodePanel() |
|
|
|
{ |
|
|
|
flowLayoutPanel3.Controls.Clear(); |
|
|
|
codeButtons.Clear(); |
|
|
|
foreach (var item in allCode) |
|
|
|
{ |
|
|
|
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)); |
|
|
|
} |
|
|
|
flowLayoutPanel3.Controls.Add(n); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void UpLoadLocalData() |
|
|
|
@ -410,8 +490,8 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
{ |
|
|
|
foreach (var item in tag) |
|
|
|
historyList.Remove(item); |
|
|
|
historyDataGrid.ClearSelection(); |
|
|
|
historyDataGrid.Refresh(); |
|
|
|
//historyDataGrid.ClearSelection();
|
|
|
|
//historyDataGrid.Refresh();
|
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -439,13 +519,13 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
{ |
|
|
|
if (historyList.Count == 0) |
|
|
|
throw new Exception("请先选择要补打的记录"); |
|
|
|
SegmentProduction item; |
|
|
|
var row = historyDataGrid.SelectedRows; |
|
|
|
if (row.Count > 0) |
|
|
|
item = row[0].DataBoundItem as SegmentProduction; |
|
|
|
else |
|
|
|
item = historyList.First(); |
|
|
|
var template = config.Template; |
|
|
|
SegmentProduction item; |
|
|
|
|
|
|
|
if (current != null) |
|
|
|
item = current; |
|
|
|
else |
|
|
|
item = historyList.First(); |
|
|
|
var template = config.Template; |
|
|
|
var goodsType = SegmentProductionBL.GetGoodsType(item.Goods_ID); |
|
|
|
if (goodsType.HasValue) |
|
|
|
template = goodsType == 0 ? "SegmentProductionPrint.html" : "SegmentProductionPrint1.html"; |
|
|
|
@ -459,30 +539,68 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
private void templateBtn_Click(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
new TemplateSelector(config).ShowDialog(); |
|
|
|
} |
|
|
|
|
|
|
|
private void deleteBtn_Click(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
var row = historyDataGrid.SelectedRows; |
|
|
|
if (row.Count == 0) |
|
|
|
return; |
|
|
|
if (MessageBox.Show("确定删除选中记录?", "删除确认", MessageBoxButtons.OKCancel) != DialogResult.OK) |
|
|
|
return; |
|
|
|
var tag = historyDataGrid.SelectedRows[0].DataBoundItem as SegmentProduction; |
|
|
|
if (tag.CreateTime.AddMinutes(1) < DateTime.Now) |
|
|
|
{ |
|
|
|
MessageBox.Show("已超出可删除时间范围"); |
|
|
|
return; |
|
|
|
} |
|
|
|
SegmentProductionBL.Delete(tag); |
|
|
|
//SegmentProductionBL.SetAsDelete(tag.ID, tag.BarCode);
|
|
|
|
historyList.Remove(tag); |
|
|
|
historyDataGrid.DataSource = historyList; |
|
|
|
historyDataGrid.ClearSelection(); |
|
|
|
historyDataGrid.Refresh(); |
|
|
|
|
|
|
|
var thd = new Thread(new ParameterizedThreadStart(RefreshTask)); |
|
|
|
thd.Start(tag); |
|
|
|
} |
|
|
|
|
|
|
|
private void deleteBtn_Click(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
if (_totalCode == null || _codePanel == null) |
|
|
|
{ |
|
|
|
if (current == null) |
|
|
|
return; |
|
|
|
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("已超出可删除时间范围"); |
|
|
|
return; |
|
|
|
} |
|
|
|
SegmentProduction d = current; |
|
|
|
SegmentProductionBL.Delete(d); |
|
|
|
historyList.Remove(d); |
|
|
|
if (_labelBt != null) |
|
|
|
{ |
|
|
|
var parent=_labelBt.Parent; |
|
|
|
parent.Controls.Remove(_labelBt); |
|
|
|
} |
|
|
|
//RefreshCodePanel();
|
|
|
|
var thd = new Thread(new ParameterizedThreadStart(RefreshTask)); |
|
|
|
thd.Start(d); |
|
|
|
current = null; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var deleteList = historyList.Where(x => x.TotalCode_ID == _totalCode.ID).ToList(); |
|
|
|
|
|
|
|
SegmentProductionBL.DeleteTotalCode(_totalCode); |
|
|
|
allCode.Remove(_totalCode); |
|
|
|
codeButtons.Remove(_codePanel.Button); |
|
|
|
foreach (var item in deleteList) |
|
|
|
{ |
|
|
|
historyList.Remove(item); |
|
|
|
var thd = new Thread(new ParameterizedThreadStart(RefreshTask)); |
|
|
|
thd.Start(item); |
|
|
|
} |
|
|
|
flowLayoutPanel3.Controls.Remove(_codePanel); |
|
|
|
// RefreshCodePanel();
|
|
|
|
current = null; |
|
|
|
if (allCode.Count > 0) |
|
|
|
{ |
|
|
|
_totalCode = allCode[0]; |
|
|
|
_codePanel = (CodePanel)flowLayoutPanel3.Controls[0]; |
|
|
|
_codePanel.Button.Selected = true; |
|
|
|
_codePanel.Button.Invalidate(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_totalCode = null; |
|
|
|
_codePanel = null; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void logBtn_Click(object sender, EventArgs e) |
|
|
|
@ -545,5 +663,86 @@ namespace ButcherFactory.SegmentProductionAuto_ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
CodePanel _codePanel; |
|
|
|
TotalCode _totalCode; |
|
|
|
private void colorButton1_Click(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
var n = new CodePanel(); |
|
|
|
|
|
|
|
var tCode = SegmentProductionBL.InsertTotalCode(new TotalCode()); |
|
|
|
allCode.Insert(0, tCode); |
|
|
|
AddCodeButton(n, tCode,true); |
|
|
|
flowLayoutPanel3.Controls.Add(n); |
|
|
|
flowLayoutPanel3.Controls.SetChildIndex(n, 0); |
|
|
|
} |
|
|
|
|
|
|
|
private void AddCodeButton(CodePanel n, TotalCode tCode,bool add=false) |
|
|
|
{ |
|
|
|
n.Button.Tag = tCode; |
|
|
|
n.Button.Text = tCode.ShortCode; |
|
|
|
n.Button.Click += delegate |
|
|
|
{ |
|
|
|
current = null; |
|
|
|
n.Button.Selected = !n.Button.Selected; |
|
|
|
if (n.Button.Selected) |
|
|
|
{ |
|
|
|
_codePanel = n; |
|
|
|
_totalCode = tCode; |
|
|
|
if (_labelBt != null) |
|
|
|
{ |
|
|
|
_labelBt.Selected = false; |
|
|
|
_labelBt.Invalidate(); |
|
|
|
} |
|
|
|
_labelBt = null; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_codePanel = null; |
|
|
|
_totalCode = null; |
|
|
|
} |
|
|
|
foreach (var bt in codeButtons) |
|
|
|
{ |
|
|
|
if (bt.Text != n.Button.Text && bt.Selected) |
|
|
|
{ |
|
|
|
bt.Selected = false; |
|
|
|
bt.Invalidate(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
if (add) |
|
|
|
{ |
|
|
|
_codePanel = n; |
|
|
|
n.Button.Selected = true; |
|
|
|
_totalCode = tCode; |
|
|
|
foreach (var bt in codeButtons) |
|
|
|
{ |
|
|
|
if (bt.Selected) |
|
|
|
{ |
|
|
|
bt.Selected = false; |
|
|
|
bt.Invalidate(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
codeButtons.Add(n.Button); |
|
|
|
} |
|
|
|
|
|
|
|
private void colorButton2_Click(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
if (_totalCode == null || _codePanel == null) |
|
|
|
{ |
|
|
|
throw new Exception(string.Format("请先选择总码!")); |
|
|
|
} |
|
|
|
var dmos= historyList.Where(x => x.TotalCode_ID == _totalCode.ID).ToArray(); |
|
|
|
if (dmos.Length == 0) |
|
|
|
{ |
|
|
|
throw new Exception(string.Format("此码不包含任何产品!")); |
|
|
|
} |
|
|
|
NotAuto.SegmentSumCodePrint.Print(dmos, "SegmentSumCode.html"); |
|
|
|
var log = new SegmentLog(dmos[0].TotalCode_Code, "总码"); |
|
|
|
log.Message = string.Format("总码:{0} ", dmos[0].TotalCode_Code); |
|
|
|
SegmentProductionBL.InsertLog(log); |
|
|
|
} |
|
|
|
} |
|
|
|
} |