|
|
@ -51,9 +51,10 @@ namespace WeighAndGrading |
|
|
bool connection = false; |
|
|
bool connection = false; |
|
|
SerialPort weightPort; |
|
|
SerialPort weightPort; |
|
|
int maxIndex = 0; |
|
|
int maxIndex = 0; |
|
|
ConcurrentQueue<GradeAndWeight_Detail> noLivestockList; |
|
|
|
|
|
|
|
|
readonly ConcurrentQueue<GradeAndWeight_Detail> noLivestockList; |
|
|
|
|
|
|
|
|
Thread syncWork; |
|
|
|
|
|
|
|
|
bool onWorking = false; |
|
|
|
|
|
Thread syncTangGrid, syncMaoGrid, syncDetailGrid; |
|
|
Thread syncToServer; |
|
|
Thread syncToServer; |
|
|
#region weightNeed
|
|
|
#region weightNeed
|
|
|
private IDataFormat _dataFormat; |
|
|
private IDataFormat _dataFormat; |
|
|
@ -71,6 +72,10 @@ namespace WeighAndGrading |
|
|
maoGridView.AutoGenerateColumns = false; |
|
|
maoGridView.AutoGenerateColumns = false; |
|
|
maoGridView.DataSource = null; |
|
|
maoGridView.DataSource = null; |
|
|
historyGrid.AutoGenerateColumns = false; |
|
|
historyGrid.AutoGenerateColumns = false; |
|
|
|
|
|
historyGrid.DataSource = null; |
|
|
|
|
|
tangList = new List<GradeAndWeight>(); |
|
|
|
|
|
maoList = new List<GradeAndWeight>(); |
|
|
|
|
|
noLivestockList = new ConcurrentQueue<GradeAndWeight_Detail>(); |
|
|
if (!Directory.Exists(DATA_PATH)) |
|
|
if (!Directory.Exists(DATA_PATH)) |
|
|
Directory.CreateDirectory(DATA_PATH); |
|
|
Directory.CreateDirectory(DATA_PATH); |
|
|
connection = ButcherAppContext.Context.UserConfig.Connection; |
|
|
connection = ButcherAppContext.Context.UserConfig.Connection; |
|
|
@ -81,8 +86,12 @@ namespace WeighAndGrading |
|
|
{ |
|
|
{ |
|
|
if (_inQueryThread != null && _inQueryThread.IsAlive) |
|
|
if (_inQueryThread != null && _inQueryThread.IsAlive) |
|
|
DisableWeight(); |
|
|
DisableWeight(); |
|
|
if (syncWork != null && syncWork.IsAlive) |
|
|
|
|
|
syncWork.Abort(); |
|
|
|
|
|
|
|
|
if (syncTangGrid != null && syncTangGrid.IsAlive) |
|
|
|
|
|
syncTangGrid.Abort(); |
|
|
|
|
|
if (syncMaoGrid != null && syncMaoGrid.IsAlive) |
|
|
|
|
|
syncMaoGrid.Abort(); |
|
|
|
|
|
if (syncDetailGrid != null && syncDetailGrid.IsAlive) |
|
|
|
|
|
syncDetailGrid.Abort(); |
|
|
if (syncToServer != null && syncToServer.IsAlive) |
|
|
if (syncToServer != null && syncToServer.IsAlive) |
|
|
syncToServer.Abort(); |
|
|
syncToServer.Abort(); |
|
|
}; |
|
|
}; |
|
|
@ -97,7 +106,6 @@ namespace WeighAndGrading |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
btn.Enabled = false; |
|
|
btn.Enabled = false; |
|
|
SetlblSucessVisibleTrue(); |
|
|
|
|
|
|
|
|
|
|
|
var livestockTag = btn.Tag as CTuple<long, string, short, string>; |
|
|
var livestockTag = btn.Tag as CTuple<long, string, short, string>; |
|
|
var tech = livestockTag.Item3 == TANG_TECH ? "烫褪" : "毛剥"; |
|
|
var tech = livestockTag.Item3 == TANG_TECH ? "烫褪" : "毛剥"; |
|
|
@ -109,75 +117,57 @@ namespace WeighAndGrading |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
var needUpdate = modifyDetail.Technics != livestockTag.Item3; |
|
|
|
|
|
StartPrintEntity(tech, modifyDetail.Index); |
|
|
|
|
|
modifyDetail.Livestock_ID = livestockTag.Item1; |
|
|
|
|
|
modifyDetail.Livestock_Name = livestockTag.Item2; |
|
|
|
|
|
modifyDetail.Technics = livestockTag.Item3; |
|
|
|
|
|
modifyDetail.Technics_Name = livestockTag.Item3 == TANG_TECH ? "烫褪" : "毛剥"; |
|
|
|
|
|
if (needUpdate) |
|
|
|
|
|
{ |
|
|
|
|
|
if (modifyDetail.Technics == 0)//毛剥 到 烫褪
|
|
|
|
|
|
{ |
|
|
|
|
|
LocalGradeAndWeightBL.Update(modifyDetail, tangEntity); |
|
|
|
|
|
if (modifyDetail.Order.HasValue) |
|
|
|
|
|
{ |
|
|
|
|
|
var first = maoList.First(x => x.Order == modifyDetail.Order); |
|
|
|
|
|
first.Already -= 1; |
|
|
|
|
|
maoGridView.Refresh(); |
|
|
|
|
|
} |
|
|
|
|
|
tangEntity.Already += 1; |
|
|
|
|
|
tangGridView.Refresh(); |
|
|
|
|
|
} |
|
|
|
|
|
else//烫褪 到 毛剥
|
|
|
|
|
|
{ |
|
|
|
|
|
LocalGradeAndWeightBL.Update(modifyDetail, maoEntity); |
|
|
|
|
|
if (modifyDetail.Order.HasValue) |
|
|
|
|
|
{ |
|
|
|
|
|
var first = tangList.First(x => x.Order == modifyDetail.Order); |
|
|
|
|
|
first.Already -= 1; |
|
|
|
|
|
tangGridView.Refresh(); |
|
|
|
|
|
} |
|
|
|
|
|
maoEntity.Already += 1; |
|
|
|
|
|
maoGridView.Refresh(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
LocalGradeAndWeightBL.Update(modifyDetail, "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name"); |
|
|
|
|
|
|
|
|
|
|
|
noLivestockList = new ConcurrentQueue<GradeAndWeight_Detail>(); |
|
|
|
|
|
var stack = new Stack<GradeAndWeight_Detail>(); |
|
|
|
|
|
|
|
|
|
|
|
//找到锁定的最大id
|
|
|
|
|
|
long suodingmaxsid = 0; |
|
|
|
|
|
var lostweightlist = details.Where(x => x.IsLostWeight).ToList(); |
|
|
|
|
|
if (lostweightlist.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
suodingmaxsid = lostweightlist.Max(x => x.SID); |
|
|
|
|
|
} |
|
|
|
|
|
//把没有级别的记录加进去
|
|
|
|
|
|
var livestockNoNameList = details.Where(x => string.IsNullOrWhiteSpace(x.Livestock_Name)); |
|
|
|
|
|
foreach (var item in livestockNoNameList) |
|
|
|
|
|
{ |
|
|
|
|
|
if (item.SID > suodingmaxsid) |
|
|
|
|
|
{ |
|
|
|
|
|
stack.Push(item); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
while (stack.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
noLivestockList.Enqueue(stack.Pop()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
historyGrid.Refresh(); |
|
|
|
|
|
modifyDetail = null; |
|
|
|
|
|
modifyPanel.Hide(); |
|
|
|
|
|
|
|
|
UpdateDetial(modifyDetail, livestockTag); |
|
|
|
|
|
cancelBtn_Click(btn, EventArgs.Empty); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SetlblSucessVisibleTrue(); |
|
|
SetlblSucessVisibleFalse(); |
|
|
SetlblSucessVisibleFalse(); |
|
|
btn.Enabled = true; |
|
|
btn.Enabled = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UpdateDetial(GradeAndWeight_Detail detail, CTuple<long, string, short, string> btnTag) |
|
|
|
|
|
{ |
|
|
|
|
|
var techIsEmpty = detail.Technics == null; |
|
|
|
|
|
var diff = detail.Technics.HasValue && detail.Technics != btnTag.Item3; |
|
|
|
|
|
detail.Livestock_ID = btnTag.Item1; |
|
|
|
|
|
detail.Livestock_Name = btnTag.Item2; |
|
|
|
|
|
detail.Technics = btnTag.Item3; |
|
|
|
|
|
detail.Technics_Name = detail.Technics == 0 ? "烫褪" : "毛剥"; |
|
|
|
|
|
var current = btnTag.Item3 == 0 ? tangEntity : maoEntity; |
|
|
|
|
|
if (current != null) |
|
|
|
|
|
{ |
|
|
|
|
|
detail.Order = current.Order; |
|
|
|
|
|
detail.OrderDetail_ID = current.OrderDetail_ID; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
detail.Order = null; |
|
|
|
|
|
detail.OrderDetail_ID = null; |
|
|
|
|
|
} |
|
|
|
|
|
var updateFileNames = new List<string> { "Order", "OrderDetail_ID", "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name" }; |
|
|
|
|
|
if (techIsEmpty) |
|
|
|
|
|
ResetQueue(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ResetQueue() |
|
|
|
|
|
{ |
|
|
|
|
|
ClearQuery(); |
|
|
|
|
|
var stack = new Stack<GradeAndWeight_Detail>(); |
|
|
|
|
|
foreach (var item in details) |
|
|
|
|
|
{ |
|
|
|
|
|
if (item.Technics == null) |
|
|
|
|
|
stack.Push(item); |
|
|
|
|
|
else |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
while (stack.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var bottom = stack.Pop(); |
|
|
|
|
|
if (bottom.Weight.HasValue) |
|
|
|
|
|
noLivestockList.Enqueue(bottom); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void AddLivestockBtn() |
|
|
void AddLivestockBtn() |
|
|
{ |
|
|
{ |
|
|
var livestocks = new List<CTuple<long, string, short, string>>(); |
|
|
var livestocks = new List<CTuple<long, string, short, string>>(); |
|
|
@ -227,91 +217,105 @@ namespace WeighAndGrading |
|
|
private void syncBtn_Click(object sender, EventArgs e) |
|
|
private void syncBtn_Click(object sender, EventArgs e) |
|
|
{ |
|
|
{ |
|
|
details = LocalGradeAndWeightBL.GetDetails(butcherTimeInput.Date.Value, 50); |
|
|
details = LocalGradeAndWeightBL.GetDetails(butcherTimeInput.Date.Value, 50); |
|
|
FillQueue(); |
|
|
|
|
|
BindDetailGrid(); |
|
|
|
|
|
|
|
|
ResetQueue(); |
|
|
if (details.Any()) |
|
|
if (details.Any()) |
|
|
maxIndex = details.First().Index; |
|
|
maxIndex = details.First().Index; |
|
|
if (syncWork == null || !syncWork.IsAlive) |
|
|
|
|
|
|
|
|
ThreadStartOrAbort(ref syncTangGrid, RefreshTangData); |
|
|
|
|
|
ThreadStartOrAbort(ref syncMaoGrid, RefreshMaoData); |
|
|
|
|
|
ThreadStartOrAbort(ref syncDetailGrid, RefreshDetailData); |
|
|
|
|
|
ChangeSyncBtnState(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ThreadStartOrAbort(ref Thread thread, ThreadStart task) |
|
|
|
|
|
{ |
|
|
|
|
|
if (thread == null || !thread.IsAlive) |
|
|
|
|
|
{ |
|
|
|
|
|
thread = new Thread(task); |
|
|
|
|
|
thread.Start(); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
thread.Abort(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ChangeSyncBtnState() |
|
|
|
|
|
{ |
|
|
|
|
|
onWorking = !onWorking; |
|
|
|
|
|
butcherTimeInput.Enabled = !onWorking; |
|
|
|
|
|
if (onWorking) |
|
|
{ |
|
|
{ |
|
|
syncWork = new Thread(Sync); |
|
|
|
|
|
syncWork.Start(); |
|
|
|
|
|
syncBtn.BackColor = Color.FromArgb(15, 215, 107); |
|
|
syncBtn.BackColor = Color.FromArgb(15, 215, 107); |
|
|
syncBtn.ForeColor = Color.White; |
|
|
syncBtn.ForeColor = Color.White; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
syncWork.Abort(); |
|
|
|
|
|
syncBtn.BackColor = Color.FromKnownColor(KnownColor.Control); |
|
|
syncBtn.BackColor = Color.FromKnownColor(KnownColor.Control); |
|
|
syncBtn.ForeColor = Color.FromKnownColor(KnownColor.ControlText); |
|
|
syncBtn.ForeColor = Color.FromKnownColor(KnownColor.ControlText); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Sync() |
|
|
|
|
|
|
|
|
void RefreshTangData() |
|
|
{ |
|
|
{ |
|
|
var bc = new BackgroundWorker(); |
|
|
|
|
|
bc.DoWork += Bc_DoWork; |
|
|
|
|
|
bc.RunWorkerCompleted += Bc_RunWorkerCompleted; |
|
|
|
|
|
while (true) |
|
|
while (true) |
|
|
{ |
|
|
{ |
|
|
if (!bc.IsBusy) |
|
|
|
|
|
|
|
|
GetLeftList(ref tangList, true); |
|
|
|
|
|
this.Invoke(new InvokeHandler(delegate |
|
|
{ |
|
|
{ |
|
|
bc.RunWorkerAsync(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
BindTangGrid(); |
|
|
|
|
|
})); |
|
|
Thread.Sleep(5000); |
|
|
Thread.Sleep(5000); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void Bc_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) |
|
|
|
|
|
|
|
|
void RefreshMaoData() |
|
|
{ |
|
|
{ |
|
|
this.BeginInvoke(new Action(() => |
|
|
|
|
|
|
|
|
while (true) |
|
|
{ |
|
|
{ |
|
|
BindTangGrid(); |
|
|
|
|
|
BindMaoGrid(); |
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void Bc_DoWork(object sender, DoWorkEventArgs e) |
|
|
|
|
|
{ |
|
|
|
|
|
BindTangGridFortangList(); |
|
|
|
|
|
BindMaoGridFromaoList(); |
|
|
|
|
|
|
|
|
GetLeftList(ref maoList, false); |
|
|
|
|
|
this.Invoke(new InvokeHandler(delegate |
|
|
|
|
|
{ |
|
|
|
|
|
BindMaoGrid(); |
|
|
|
|
|
})); |
|
|
|
|
|
Thread.Sleep(5000); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void FillQueue() |
|
|
|
|
|
|
|
|
void RefreshDetailData() |
|
|
{ |
|
|
{ |
|
|
noLivestockList = new ConcurrentQueue<GradeAndWeight_Detail>(); |
|
|
|
|
|
var stack = new Stack<GradeAndWeight_Detail>(); |
|
|
|
|
|
foreach (var item in details) |
|
|
|
|
|
{ |
|
|
|
|
|
if (item.Livestock_ID == 0 || item.Weight == null || string.IsNullOrWhiteSpace(item.Livestock_Name)) |
|
|
|
|
|
stack.Push(item); |
|
|
|
|
|
else |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
while (stack.Count > 0) |
|
|
|
|
|
|
|
|
details = LocalGradeAndWeightBL.GetDetails(butcherTimeInput.Date.Value, 50); |
|
|
|
|
|
this.Invoke(new InvokeHandler(delegate |
|
|
{ |
|
|
{ |
|
|
var bottom = stack.Pop(); |
|
|
|
|
|
if (bottom.Weight.HasValue) |
|
|
|
|
|
noLivestockList.Enqueue(bottom); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
BindDetailGrid(); |
|
|
|
|
|
})); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void BindTangGridFortangList() |
|
|
|
|
|
|
|
|
//void BindLeftByClick(List<GradeAndWeight> list, bool tang)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// GetLeftList(ref list, tang);
|
|
|
|
|
|
// if (tang)
|
|
|
|
|
|
// BindTangGrid();
|
|
|
|
|
|
// else
|
|
|
|
|
|
// BindMaoGrid();
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//void BindDetailByClick()
|
|
|
|
|
|
//{
|
|
|
|
|
|
// details = LocalGradeAndWeightBL.GetDetails(butcherTimeInput.Date.Value, 50);
|
|
|
|
|
|
// BindDetailGrid();
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
void GetLeftList(ref List<GradeAndWeight> list, bool tang) |
|
|
{ |
|
|
{ |
|
|
VerifyConnection(); |
|
|
VerifyConnection(); |
|
|
if (connection) |
|
|
if (connection) |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
tangList = GradeAndWeightRpc.GetGradeAndWeightList(butcherTimeInput.Date.Value, true); |
|
|
|
|
|
|
|
|
list = GradeAndWeightRpc.GetGradeAndWeightList(butcherTimeInput.Date.Value, tang); |
|
|
} |
|
|
} |
|
|
catch (TimeoutException) { } |
|
|
catch (TimeoutException) { } |
|
|
} |
|
|
} |
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
if (tangList == null) |
|
|
|
|
|
tangList = new List<GradeAndWeight>(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void BindTangGrid() |
|
|
void BindTangGrid() |
|
|
@ -348,31 +352,8 @@ namespace WeighAndGrading |
|
|
tangGridView.Refresh(); |
|
|
tangGridView.Refresh(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void BindMaoGridFromaoList() |
|
|
|
|
|
{ |
|
|
|
|
|
VerifyConnection(); |
|
|
|
|
|
if (connection) |
|
|
|
|
|
{ |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
if (butcherTimeInput.Date.HasValue) |
|
|
|
|
|
{ |
|
|
|
|
|
maoList = GradeAndWeightRpc.GetGradeAndWeightList(butcherTimeInput.Date.Value, false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
catch (TimeoutException) { } |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
if (maoList == null) |
|
|
|
|
|
maoList = new List<GradeAndWeight>(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void BindMaoGrid() |
|
|
void BindMaoGrid() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
maoGridView.DataSource = maoList.OrderBy(x => x.Order).OrderBy(x => x.Finish).ToList(); |
|
|
maoGridView.DataSource = maoList.OrderBy(x => x.Order).OrderBy(x => x.Finish).ToList(); |
|
|
if (maoEntity == null && maoGridView.CurrentRow != null) |
|
|
if (maoEntity == null && maoGridView.CurrentRow != null) |
|
|
{ |
|
|
{ |
|
|
@ -407,15 +388,19 @@ namespace WeighAndGrading |
|
|
|
|
|
|
|
|
void BindDetailGrid() |
|
|
void BindDetailGrid() |
|
|
{ |
|
|
{ |
|
|
historyGrid.DataSource = null; |
|
|
|
|
|
if (details.Any()) |
|
|
|
|
|
historyGrid.DataSource = details; |
|
|
|
|
|
|
|
|
historyGrid.DataSource = details; |
|
|
foreach (DataGridViewRow row in historyGrid.Rows) |
|
|
foreach (DataGridViewRow row in historyGrid.Rows) |
|
|
{ |
|
|
{ |
|
|
if ((bool)row.Cells["H_IsDrop"].Value) |
|
|
if ((bool)row.Cells["H_IsDrop"].Value) |
|
|
row.DefaultCellStyle.BackColor = Color.Red; |
|
|
row.DefaultCellStyle.BackColor = Color.Red; |
|
|
|
|
|
if (modifyDetail != null && modifyDetail.SID == (long)row.Cells["H_SID"].Value) |
|
|
|
|
|
{ |
|
|
|
|
|
modifyDetail = row.DataBoundItem as GradeAndWeight_Detail; |
|
|
|
|
|
row.DefaultCellStyle.BackColor = maoGridView.RowsDefaultCellStyle.SelectionBackColor; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
InitScrollBar2(); |
|
|
|
|
|
|
|
|
InitDetailScrollBar(); |
|
|
|
|
|
historyGrid.ClearSelection(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
if (rightRoll != -1) |
|
|
if (rightRoll != -1) |
|
|
@ -489,8 +474,7 @@ namespace WeighAndGrading |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
StartPrintEntity(modifyDetail.Technics_Name, modifyDetail.Index); |
|
|
StartPrintEntity(modifyDetail.Technics_Name, modifyDetail.Index); |
|
|
modifyDetail = null; |
|
|
|
|
|
modifyPanel.Hide(); |
|
|
|
|
|
|
|
|
cancelBtn_Click(sender, EventArgs.Empty); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void configBtn_Click(object sender, EventArgs e) |
|
|
private void configBtn_Click(object sender, EventArgs e) |
|
|
@ -745,7 +729,19 @@ namespace WeighAndGrading |
|
|
disBtn = null; |
|
|
disBtn = null; |
|
|
} |
|
|
} |
|
|
LocalGradeAndWeightBL.Update(first, "OrderDetail_ID", "Order", "Date", "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name", "Weight"); |
|
|
LocalGradeAndWeightBL.Update(first, "OrderDetail_ID", "Order", "Date", "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name", "Weight"); |
|
|
historyGrid.Refresh(); |
|
|
|
|
|
|
|
|
var tag = details.FirstOrDefault(x => x.SID == first.SID); |
|
|
|
|
|
if (first != null) |
|
|
|
|
|
{ |
|
|
|
|
|
tag.Date = first.Date; |
|
|
|
|
|
tag.Livestock_ID = first.Livestock_ID; |
|
|
|
|
|
tag.Livestock_Name = first.Livestock_Name; |
|
|
|
|
|
tag.Order = first.Order; |
|
|
|
|
|
tag.OrderDetail_ID = first.OrderDetail_ID; |
|
|
|
|
|
tag.Technics = first.Technics; |
|
|
|
|
|
tag.Technics_Name = first.Technics_Name; |
|
|
|
|
|
tag.Weight = first.Weight; |
|
|
|
|
|
historyGrid.Refresh(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else//add
|
|
|
else//add
|
|
|
{ |
|
|
{ |
|
|
@ -771,21 +767,12 @@ namespace WeighAndGrading |
|
|
SetBtnUnCheck(disBtn); |
|
|
SetBtnUnCheck(disBtn); |
|
|
disBtn = null; |
|
|
disBtn = null; |
|
|
} |
|
|
} |
|
|
//如果手动点击新增明细,则明细的重量=0
|
|
|
|
|
|
entity.Weight = 0; |
|
|
entity.Weight = 0; |
|
|
entity.IsLostWeight = true; |
|
|
|
|
|
|
|
|
|
|
|
if (details.Count == 50) |
|
|
|
|
|
details.RemoveAt(49); |
|
|
|
|
|
details.Insert(0, entity); |
|
|
|
|
|
LocalGradeAndWeightBL.Insert(entity); |
|
|
LocalGradeAndWeightBL.Insert(entity); |
|
|
|
|
|
|
|
|
//这里绑定界面 东旭说不应该放到锁了 不知道怎么改
|
|
|
|
|
|
BindDetailGrid(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
details.Insert(0, entity); |
|
|
|
|
|
AfterAddBindDetailGrid(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentRow != null) |
|
|
if (currentRow != null) |
|
|
{ |
|
|
{ |
|
|
currentRow.Already = n + 1; |
|
|
currentRow.Already = n + 1; |
|
|
@ -822,6 +809,14 @@ namespace WeighAndGrading |
|
|
})); |
|
|
})); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void AfterAddBindDetailGrid() |
|
|
|
|
|
{ |
|
|
|
|
|
if (details.Count > 50) |
|
|
|
|
|
details.RemoveAt(50); |
|
|
|
|
|
BindDetailGrid(); |
|
|
|
|
|
// BindDetailByClick();
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void AddWeightDetail(decimal weight) |
|
|
void AddWeightDetail(decimal weight) |
|
|
{ |
|
|
{ |
|
|
lock (_obj) |
|
|
lock (_obj) |
|
|
@ -833,20 +828,25 @@ namespace WeighAndGrading |
|
|
entity.Weight = (entity.Weight ?? 0) + weight; |
|
|
entity.Weight = (entity.Weight ?? 0) + weight; |
|
|
entity.Time = DateTime.Now; |
|
|
entity.Time = DateTime.Now; |
|
|
entity.Date = butcherTimeInput.Date.Value; |
|
|
entity.Date = butcherTimeInput.Date.Value; |
|
|
if (details.Count == 50) |
|
|
|
|
|
details.RemoveAt(49); |
|
|
|
|
|
details.Insert(0, entity); |
|
|
|
|
|
|
|
|
|
|
|
LocalGradeAndWeightBL.Insert(entity); |
|
|
LocalGradeAndWeightBL.Insert(entity); |
|
|
|
|
|
|
|
|
|
|
|
details.Insert(0, entity); |
|
|
noLivestockList.Enqueue(entity); |
|
|
noLivestockList.Enqueue(entity); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BindDetailGrid(); |
|
|
|
|
|
|
|
|
AfterAddBindDetailGrid(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void cancelBtn_Click(object sender, EventArgs e) |
|
|
private void cancelBtn_Click(object sender, EventArgs e) |
|
|
{ |
|
|
{ |
|
|
|
|
|
foreach (DataGridViewRow row in historyGrid.Rows) |
|
|
|
|
|
{ |
|
|
|
|
|
if (modifyDetail.SID == (long)row.Cells["H_SID"].Value) |
|
|
|
|
|
{ |
|
|
|
|
|
row.DefaultCellStyle.BackColor = historyGrid.RowsDefaultCellStyle.BackColor; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
historyGrid.Refresh(); |
|
|
modifyDetail = null; |
|
|
modifyDetail = null; |
|
|
modifyPanel.Hide(); |
|
|
modifyPanel.Hide(); |
|
|
} |
|
|
} |
|
|
@ -868,57 +868,18 @@ namespace WeighAndGrading |
|
|
modifyDetail.IsDeleted = true; |
|
|
modifyDetail.IsDeleted = true; |
|
|
LocalGradeAndWeightBL.Update(modifyDetail, "IsDeleted"); |
|
|
LocalGradeAndWeightBL.Update(modifyDetail, "IsDeleted"); |
|
|
details.Remove(modifyDetail); |
|
|
details.Remove(modifyDetail); |
|
|
if (modifyDetail.Order > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
if (modifyDetail.Technics == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (DataGridViewRow row in tangGridView.Rows) |
|
|
|
|
|
{ |
|
|
|
|
|
if ((int)row.Cells["T_Order"].Value == modifyDetail.Order.Value) |
|
|
|
|
|
{ |
|
|
|
|
|
var r = row.DataBoundItem as GradeAndWeight; |
|
|
|
|
|
r.Already -= 1; |
|
|
|
|
|
tangGridView.Refresh(); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (DataGridViewRow row in maoGridView.Rows) |
|
|
|
|
|
{ |
|
|
|
|
|
if ((int)row.Cells["M_Order"].Value == modifyDetail.Order.Value) |
|
|
|
|
|
{ |
|
|
|
|
|
var r = row.DataBoundItem as GradeAndWeight; |
|
|
|
|
|
r.Already -= 1; |
|
|
|
|
|
maoGridView.Refresh(); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (modifyDetail.Technics == null) |
|
|
if (modifyDetail.Technics == null) |
|
|
{ |
|
|
{ |
|
|
//重新赋值 队列
|
|
|
|
|
|
//重新设置没有级别的
|
|
|
|
|
|
noLivestockList = new ConcurrentQueue<GradeAndWeight_Detail>(); |
|
|
|
|
|
var stackNoLiveStock = new Stack<GradeAndWeight_Detail>(); |
|
|
|
|
|
//把没有级别的记录加进去
|
|
|
|
|
|
foreach (var item in details) |
|
|
|
|
|
{ |
|
|
|
|
|
if (item.Technics.HasValue) |
|
|
|
|
|
break; |
|
|
|
|
|
stackNoLiveStock.Push(item); |
|
|
|
|
|
} |
|
|
|
|
|
while (stackNoLiveStock.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
noLivestockList.Enqueue(stackNoLiveStock.Pop()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
ResetQueue(); |
|
|
} |
|
|
} |
|
|
|
|
|
BindDetailGrid(); |
|
|
modifyDetail = null; |
|
|
modifyDetail = null; |
|
|
modifyPanel.Hide(); |
|
|
modifyPanel.Hide(); |
|
|
} |
|
|
} |
|
|
BindDetailGrid(); |
|
|
|
|
|
|
|
|
if (details.Any()) |
|
|
|
|
|
historyGrid.DataSource = details; |
|
|
|
|
|
historyGrid.Refresh(); |
|
|
|
|
|
//BindDetailByClick();
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void historyGrid_CellClick(object sender, DataGridViewCellEventArgs e) |
|
|
private void historyGrid_CellClick(object sender, DataGridViewCellEventArgs e) |
|
|
@ -926,7 +887,19 @@ namespace WeighAndGrading |
|
|
if (e.RowIndex < 0) |
|
|
if (e.RowIndex < 0) |
|
|
return; |
|
|
return; |
|
|
var currentRow = historyGrid.CurrentRow.DataBoundItem as GradeAndWeight_Detail; |
|
|
var currentRow = historyGrid.CurrentRow.DataBoundItem as GradeAndWeight_Detail; |
|
|
|
|
|
if (modifyDetail != null) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (DataGridViewRow row in historyGrid.Rows) |
|
|
|
|
|
{ |
|
|
|
|
|
if (modifyDetail.SID == (long)row.Cells["H_SID"].Value) |
|
|
|
|
|
{ |
|
|
|
|
|
row.DefaultCellStyle.BackColor = historyGrid.RowsDefaultCellStyle.BackColor; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
modifyDetail = currentRow; |
|
|
modifyDetail = currentRow; |
|
|
|
|
|
historyGrid.Refresh(); |
|
|
stateLabel.Text = string.Format("您正在修改序号为 {0} 的信息", modifyDetail.Index); |
|
|
stateLabel.Text = string.Format("您正在修改序号为 {0} 的信息", modifyDetail.Index); |
|
|
modifyPanel.Show(); |
|
|
modifyPanel.Show(); |
|
|
} |
|
|
} |
|
|
@ -968,9 +941,6 @@ namespace WeighAndGrading |
|
|
} |
|
|
} |
|
|
entity.Finish = true; |
|
|
entity.Finish = true; |
|
|
LocalGradeAndWeightBL.SetGradeFinish(entity.Order, butcherTimeInput.Date.Value, TANG_TECH); |
|
|
LocalGradeAndWeightBL.SetGradeFinish(entity.Order, butcherTimeInput.Date.Value, TANG_TECH); |
|
|
//var first = tangList.FirstOrDefault(x => x.OrderDetail_ID == entity.OrderDetail_ID);
|
|
|
|
|
|
//if (first != null)
|
|
|
|
|
|
// first.Finish = true;
|
|
|
|
|
|
tangEntity = null; |
|
|
tangEntity = null; |
|
|
BindTangGrid(); |
|
|
BindTangGrid(); |
|
|
} |
|
|
} |
|
|
@ -1012,9 +982,6 @@ namespace WeighAndGrading |
|
|
} |
|
|
} |
|
|
entity.Finish = true; |
|
|
entity.Finish = true; |
|
|
LocalGradeAndWeightBL.SetGradeFinish(entity.Order, butcherTimeInput.Date.Value, MAO_TECH); |
|
|
LocalGradeAndWeightBL.SetGradeFinish(entity.Order, butcherTimeInput.Date.Value, MAO_TECH); |
|
|
//var first = maoList.FirstOrDefault(x => x.OrderDetail_ID == entity.OrderDetail_ID);
|
|
|
|
|
|
//if (first != null)
|
|
|
|
|
|
// first.Finish = true;
|
|
|
|
|
|
maoEntity = null; |
|
|
maoEntity = null; |
|
|
BindMaoGrid(); |
|
|
BindMaoGrid(); |
|
|
} |
|
|
} |
|
|
@ -1059,9 +1026,7 @@ namespace WeighAndGrading |
|
|
{ |
|
|
{ |
|
|
modifyDetail.Weight = (modifyDetail.Weight ?? 0) - Convert.ToDecimal(btn.Tag); |
|
|
modifyDetail.Weight = (modifyDetail.Weight ?? 0) - Convert.ToDecimal(btn.Tag); |
|
|
LocalGradeAndWeightBL.Update(modifyDetail, "Weight"); |
|
|
LocalGradeAndWeightBL.Update(modifyDetail, "Weight"); |
|
|
historyGrid.Refresh(); |
|
|
|
|
|
modifyDetail = null; |
|
|
|
|
|
modifyPanel.Hide(); |
|
|
|
|
|
|
|
|
cancelBtn_Click(sender, EventArgs.Empty); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
discontPanel.Controls.Add(btn); |
|
|
discontPanel.Controls.Add(btn); |
|
|
@ -1079,9 +1044,7 @@ namespace WeighAndGrading |
|
|
{ |
|
|
{ |
|
|
modifyDetail.IsDrop = !modifyDetail.IsDrop; |
|
|
modifyDetail.IsDrop = !modifyDetail.IsDrop; |
|
|
LocalGradeAndWeightBL.Update(modifyDetail, "IsDrop"); |
|
|
LocalGradeAndWeightBL.Update(modifyDetail, "IsDrop"); |
|
|
BindDetailGrid(); |
|
|
|
|
|
modifyDetail = null; |
|
|
|
|
|
modifyPanel.Hide(); |
|
|
|
|
|
|
|
|
cancelBtn_Click(sender, EventArgs.Empty); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1136,7 +1099,7 @@ namespace WeighAndGrading |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int rightRoll = -1; |
|
|
int rightRoll = -1; |
|
|
private void InitScrollBar2() |
|
|
|
|
|
|
|
|
private void InitDetailScrollBar() |
|
|
{ |
|
|
{ |
|
|
vScrollBar2.Maximum = (historyGrid.RowCount - historyGrid.DisplayedRowCount(false) + 30) * historyGrid.RowTemplate.Height; |
|
|
vScrollBar2.Maximum = (historyGrid.RowCount - historyGrid.DisplayedRowCount(false) + 30) * historyGrid.RowTemplate.Height; |
|
|
vScrollBar2.Minimum = 0; |
|
|
vScrollBar2.Minimum = 0; |
|
|
@ -1189,19 +1152,17 @@ namespace WeighAndGrading |
|
|
{ |
|
|
{ |
|
|
while (true) |
|
|
while (true) |
|
|
{ |
|
|
{ |
|
|
|
|
|
VerifyConnection(); |
|
|
|
|
|
if (connection) |
|
|
{ |
|
|
{ |
|
|
VerifyConnection(); |
|
|
|
|
|
if (connection) |
|
|
|
|
|
|
|
|
try |
|
|
{ |
|
|
{ |
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
SyncDiscontToSever(); |
|
|
|
|
|
LocalGradeAndWeightBL.Sync(); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
File.WriteAllText(string.Format("{0:yyyyMMddHHmmss}log.txt", DateTime.Now), "错误:" + ex.Message + " \n详细信息:" + ex.StackTrace); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
SyncDiscontToSever(); |
|
|
|
|
|
LocalGradeAndWeightBL.Sync(); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
File.WriteAllText(string.Format("{0:yyyyMMddHHmmss}log.txt", DateTime.Now), "错误:" + ex.Message + " \n详细信息:" + ex.StackTrace); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
Thread.Sleep(2000); |
|
|
Thread.Sleep(2000); |
|
|
@ -1222,5 +1183,14 @@ namespace WeighAndGrading |
|
|
File.Delete(changeFlagPath); |
|
|
File.Delete(changeFlagPath); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ClearQuery() |
|
|
|
|
|
{ |
|
|
|
|
|
if (noLivestockList == null) |
|
|
|
|
|
return; |
|
|
|
|
|
GradeAndWeight_Detail r; |
|
|
|
|
|
while (noLivestockList.TryDequeue(out r)) |
|
|
|
|
|
{ } |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |