yibo 8 years ago
parent
commit
c0e1866234
1 changed files with 263 additions and 263 deletions
  1. +263
    -263
      WeighAndGrading/GradeFrom.cs

+ 263
- 263
WeighAndGrading/GradeFrom.cs View File

@ -97,29 +97,29 @@ namespace WeighAndGrading
GradeAndWeight_Detail modifyDetail; GradeAndWeight_Detail modifyDetail;
// private void GradeFrom_KeyPress(object sender, KeyPressEventArgs e)
// {
// Char keyChar = e.KeyChar;
// var key = keyChar.ToString().ToLower();
// foreach (Button btn in ttPanel.Controls)
// {
// var livestockTag = btn.Tag as CTuple<long, string, short, string>;
// if (livestockTag.Item4.ToLower() == key)
// {
// JiBieButtonClick(btn);
// SetJiBieSelectBackColor(btn.Text);
// }
// }
// foreach (Button btn in mbPanel.Controls)
// {
// var livestockTag = btn.Tag as CTuple<long, string, short, string>;
// if (livestockTag.Item4.ToLower() == key)
// {
// JiBieButtonClick(btn);
// SetJiBieSelectBackColor(btn.Text);
// }
// }
// }
// private void GradeFrom_KeyPress(object sender, KeyPressEventArgs e)
// {
// Char keyChar = e.KeyChar;
// var key = keyChar.ToString().ToLower();
// foreach (Button btn in ttPanel.Controls)
// {
// var livestockTag = btn.Tag as CTuple<long, string, short, string>;
// if (livestockTag.Item4.ToLower() == key)
// {
// JiBieButtonClick(btn);
// SetJiBieSelectBackColor(btn.Text);
// }
// }
// foreach (Button btn in mbPanel.Controls)
// {
// var livestockTag = btn.Tag as CTuple<long, string, short, string>;
// if (livestockTag.Item4.ToLower() == key)
// {
// JiBieButtonClick(btn);
// SetJiBieSelectBackColor(btn.Text);
// }
// }
// }
//点击 级别 //点击 级别
void JiBieButtonClick(Button btn) void JiBieButtonClick(Button btn)
@ -131,14 +131,14 @@ namespace WeighAndGrading
} }
SetlblSucessVisibleTrue(); 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 ? "烫褪" : "毛剥";
if (modifyDetail == null) if (modifyDetail == null)
{ {
StartPrintEntity(tech,null);
StartPrintEntity(tech, null);
AddDetail(livestockTag); AddDetail(livestockTag);
} }
else else
@ -150,7 +150,7 @@ namespace WeighAndGrading
modifyDetail.Technics = livestockTag.Item3; modifyDetail.Technics = livestockTag.Item3;
modifyDetail.Technics_Name = livestockTag.Item3 == TANG_TECH ? "烫褪" : "毛剥"; modifyDetail.Technics_Name = livestockTag.Item3 == TANG_TECH ? "烫褪" : "毛剥";
LocalGradeAndWeightBL.Update(modifyDetail, "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name"); LocalGradeAndWeightBL.Update(modifyDetail, "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name");
noLivestockList = new ConcurrentQueue<GradeAndWeight_Detail>(); noLivestockList = new ConcurrentQueue<GradeAndWeight_Detail>();
var stack = new Stack<GradeAndWeight_Detail>(); var stack = new Stack<GradeAndWeight_Detail>();
@ -198,12 +198,12 @@ namespace WeighAndGrading
livestocks = XmlUtil.DeserializeFromFile<List<CTuple<long, string, short, string>>>(fileName); livestocks = XmlUtil.DeserializeFromFile<List<CTuple<long, string, short, string>>>(fileName);
foreach (var item in livestocks) foreach (var item in livestocks)
{ {
var btn = new Button() { Name = "_" + item.Item1, Text = item.Item2 , Tag = item, Size = new Size(90, 75), TextAlign = ContentAlignment.MiddleCenter, Margin = new Padding { All = 15 }, Font = new Font("宋体", 18) };
var btn = new Button() { Name = "_" + item.Item1, Text = item.Item2, Tag = item, Size = new Size(90, 75), TextAlign = ContentAlignment.MiddleCenter, Margin = new Padding { All = 15 }, Font = new Font("宋体", 18) };
btn.Click += (sender, e) => btn.Click += (sender, e) =>
{ {
// btn.Enabled = false;
// Application.DoEvents();
// btn.Enabled = false;
// Application.DoEvents();
JiBieButtonClick(btn); JiBieButtonClick(btn);
#region 改到方法JiBieButtonClick()里了 #region 改到方法JiBieButtonClick()里了
@ -231,8 +231,8 @@ namespace WeighAndGrading
#endregion #endregion
// btn.Enabled = true;
// Application.DoEvents();
// btn.Enabled = true;
// Application.DoEvents();
//var name = livestock.Technics == 0 ? "带皮白条" : "去皮白条"; //var name = livestock.Technics == 0 ? "带皮白条" : "去皮白条";
//Print(name, entity.Index); //Print(name, entity.Index);
@ -327,18 +327,18 @@ namespace WeighAndGrading
{ {
while (true) while (true)
{ {
var bc=new BackgroundWorker();
var bc = new BackgroundWorker();
bc.DoWork += Bc_DoWork; bc.DoWork += Bc_DoWork;
bc.RunWorkerCompleted += Bc_RunWorkerCompleted; bc.RunWorkerCompleted += Bc_RunWorkerCompleted;
if (!bc.IsBusy) if (!bc.IsBusy)
{ {
bc.RunWorkerAsync(); bc.RunWorkerAsync();
} }
// this.Invoke(new InvokeHandler(delegate ()
// {
// BindTangGrid();
// BindMaoGrid();
// }));
// this.Invoke(new InvokeHandler(delegate ()
// {
// BindTangGrid();
// BindMaoGrid();
// }));
Thread.Sleep(5000); Thread.Sleep(5000);
} }
} }
@ -366,7 +366,7 @@ namespace WeighAndGrading
var stack = new Stack<GradeAndWeight_Detail>(); var stack = new Stack<GradeAndWeight_Detail>();
foreach (var item in details) foreach (var item in details)
{ {
if (item.Livestock_ID == 0 || item.Weight == null||string.IsNullOrWhiteSpace(item.Livestock_Name))
if (item.Livestock_ID == 0 || item.Weight == null || string.IsNullOrWhiteSpace(item.Livestock_Name))
stack.Push(item); stack.Push(item);
else else
break; break;
@ -380,7 +380,7 @@ namespace WeighAndGrading
noLivestockList.Enqueue(bottom); noLivestockList.Enqueue(bottom);
} }
} }
@ -438,7 +438,7 @@ namespace WeighAndGrading
tangRoll = -1; tangRoll = -1;
} }
tangGridView.Refresh(); tangGridView.Refresh();
// lblTangTui.Text= "烫褪" + "("+tangList.Sum(x=>x.Number)+")";
// lblTangTui.Text= "烫褪" + "("+tangList.Sum(x=>x.Number)+")";
} }
void BindMaoGridFromaoList() void BindMaoGridFromaoList()
@ -452,7 +452,7 @@ namespace WeighAndGrading
{ {
maoList = GradeAndWeightRpc.GetGradeAndWeightList(butcherTimeInput.Date.Value, false); maoList = GradeAndWeightRpc.GetGradeAndWeightList(butcherTimeInput.Date.Value, false);
} }
} }
catch (TimeoutException) { } catch (TimeoutException) { }
} }
@ -466,7 +466,7 @@ namespace WeighAndGrading
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)
{ {
@ -499,7 +499,7 @@ namespace WeighAndGrading
maoRoll = -1; maoRoll = -1;
} }
maoGridView.Refresh(); maoGridView.Refresh();
// lblMaoBo.Text = "毛剥" + "(" + maoList.Sum(x=>x.Number) + ")";
// lblMaoBo.Text = "毛剥" + "(" + maoList.Sum(x=>x.Number) + ")";
} }
void BindDetailGrid() void BindDetailGrid()
@ -534,11 +534,11 @@ namespace WeighAndGrading
rightRoll = -1; rightRoll = -1;
} }
historyGrid.Refresh(); historyGrid.Refresh();
// SetHistorBackColor();
// ReSetHistorySum();
// SetHistorBackColor();
// ReSetHistorySum();
} }
void StartPrintEntity(string gongyijibie,int? index)
void StartPrintEntity(string gongyijibie, int? index)
{ {
if (!isPrintCheckBox.Checked) if (!isPrintCheckBox.Checked)
{ {
@ -552,7 +552,7 @@ namespace WeighAndGrading
WeightGradePrint.Print(entity); WeightGradePrint.Print(entity);
} }
PrintEntity CreatePrintEntity(string jibie,int? index)
PrintEntity CreatePrintEntity(string jibie, int? index)
{ {
string goodsName; string goodsName;
if (jibie == "烫褪") if (jibie == "烫褪")
@ -563,7 +563,7 @@ namespace WeighAndGrading
{ {
goodsName = "去皮白条"; goodsName = "去皮白条";
} }
var entity = new PrintEntity(); var entity = new PrintEntity();
entity.AccountingUnit_Name = "青岛万福集团股份有限公司"; entity.AccountingUnit_Name = "青岛万福集团股份有限公司";
entity.Goods_Name = goodsName; entity.Goods_Name = goodsName;
@ -585,9 +585,9 @@ namespace WeighAndGrading
} }
string indexCode = maxindex.ToString("D6"); string indexCode = maxindex.ToString("D6");
entity.BarCode = string.Format("WF{0}{1:00000}", DateTime.Today.ToString("yyyyMMdd"), indexCode); entity.BarCode = string.Format("WF{0}{1:00000}", DateTime.Today.ToString("yyyyMMdd"), indexCode);
entity._2DQRCode = string.Format("http://www.bwpsoft.com?code={0}&name={1}", entity.BarCode,goodsName);
entity._2DQRCode = string.Format("http://www.bwpsoft.com?code={0}&name={1}", entity.BarCode, goodsName);
return entity; return entity;
} }
@ -603,14 +603,14 @@ namespace WeighAndGrading
modifyPanel.Hide(); modifyPanel.Hide();
} }
// void Print(object obj)
// {
// var entity = obj as PrintEntity;
// this.Invoke(new Action(() =>
// {
// WeightGradePrint.Print(entity);
// }));
// }
// void Print(object obj)
// {
// var entity = obj as PrintEntity;
// this.Invoke(new Action(() =>
// {
// WeightGradePrint.Print(entity);
// }));
// }
@ -713,7 +713,7 @@ namespace WeighAndGrading
{ {
if (string.IsNullOrEmpty(str)) if (string.IsNullOrEmpty(str))
str = "0"; str = "0";
this.Invoke(new InvokeHandler(delegate ()
this.Invoke(new InvokeHandler(delegate()
{ {
lblChengZhong.Text = string.Format(format, decimal.Parse(str)); lblChengZhong.Text = string.Format(format, decimal.Parse(str));
if (str != "0") if (str != "0")
@ -722,12 +722,12 @@ namespace WeighAndGrading
var allowInterval = GradeContext.Config.AllowInterval; var allowInterval = GradeContext.Config.AllowInterval;
//如果间隔时间内多条的话不处理 //如果间隔时间内多条的话不处理
// var timeSpanTotalSeconds= (DateTime.Now - lastWeightDateTime).TotalSeconds;
// if (Convert.ToDecimal(timeSpanTotalSeconds) > allowInterval)
// {
AddWeightDetail(decimal.Parse(lblChengZhong.Text));
// lastWeightDateTime = DateTime.Now;
// }
// var timeSpanTotalSeconds= (DateTime.Now - lastWeightDateTime).TotalSeconds;
// if (Convert.ToDecimal(timeSpanTotalSeconds) > allowInterval)
// {
AddWeightDetail(decimal.Parse(lblChengZhong.Text));
// lastWeightDateTime = DateTime.Now;
// }
} }
})); }));
@ -738,7 +738,7 @@ namespace WeighAndGrading
decimal num = 0; decimal num = 0;
if (decimal.TryParse(str, out num)) if (decimal.TryParse(str, out num))
{ {
this.Invoke(new InvokeHandler(delegate ()
this.Invoke(new InvokeHandler(delegate()
{ {
lblChengZhong.Text = string.Format(format, num); lblChengZhong.Text = string.Format(format, num);
})); }));
@ -747,7 +747,7 @@ namespace WeighAndGrading
} }
if (WeighAvgControl.TryGetValue(out num)) if (WeighAvgControl.TryGetValue(out num))
{ {
this.Invoke(new InvokeHandler(delegate ()
this.Invoke(new InvokeHandler(delegate()
{ {
//lblChengZhong.Text = string.Format(format, num); //lblChengZhong.Text = string.Format(format, num);
if (str != "0") if (str != "0")
@ -870,80 +870,80 @@ namespace WeighAndGrading
static object _obj = new object(); static object _obj = new object();
// void AddDetail(CTuple<long, string, short, string> livestock)
// {
// lock (_obj)
// {
// var currentRow = livestock.Item3 == 0 ? tangEntity : maoEntity;
// var tech = livestock.Item3 == TANG_TECH ? "烫褪" : "毛剥";
//
// GradeAndWeight_Detail first;
// if (noLivestockList.TryPeek(out first) && first.Livestock_ID == null)
// {
// noLivestockList.TryDequeue(out first);
// if (currentRow != null)
// first.OrderDetail_ID = currentRow.OrderDetail_ID;
// first.Date = butcherTimeInput.Date.Value;
// first.Livestock_ID = livestock.Item1;
// first.Livestock_Name = livestock.Item2;
// first.Technics = livestock.Item3;
// first.Technics_Name = tech;
// if (disBtn != null)
// {
// first.Weight = (first.Weight ?? 0) - Convert.ToDecimal(disBtn.Tag);
// SetBtnUnCheck(disBtn);
// disBtn = null;
// }
// LocalGradeAndWeightBL.Update(first, "OrderDetail_ID", "Date", "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name", "Weight");
// historyGrid.Refresh();
// }
// else//add
// {
// maxIndex++;
// var entity = new GradeAndWeight_Detail();
// entity.Index = maxIndex;
// if (currentRow != null)
// entity.OrderDetail_ID = currentRow.OrderDetail_ID;
// entity.Date = butcherTimeInput.Date.Value;
// entity.Livestock_ID = livestock.Item1;
// entity.Livestock_Name = livestock.Item2;
// entity.Technics = livestock.Item3;
// entity.Technics_Name = tech;
// entity.Time = DateTime.Now;
// entity.Date = butcherTimeInput.Date.Value;
// if (disBtn != null)
// {
// entity.Weight = -Convert.ToDecimal(disBtn.Tag);
// SetBtnUnCheck(disBtn);
// disBtn = null;
// }
// if (details.Count == 50)
// details.RemoveAt(49);
// details.Insert(0, entity);
// LocalGradeAndWeightBL.Insert(entity);
// noWeightList.Enqueue(entity);
// BindDetailGrid();
// }
// if (currentRow != null)
// {
// currentRow.Already = currentRow.Already + 1;
// orderLabel.Text = currentRow.Order.ToString();
// alreadyLabel.Text = currentRow.Already.ToString();
// tangGridView.Refresh();
// }
// else
// {
// orderLabel.Text = string.Empty;
// alreadyLabel.Text = string.Empty;
// }
//
// //计算合计
// ReSetHistorySum();
// }
// }
void AddDetail(CTuple<long, string, short, string> livestock)
// void AddDetail(CTuple<long, string, short, string> livestock)
// {
// lock (_obj)
// {
// var currentRow = livestock.Item3 == 0 ? tangEntity : maoEntity;
// var tech = livestock.Item3 == TANG_TECH ? "烫褪" : "毛剥";
//
// GradeAndWeight_Detail first;
// if (noLivestockList.TryPeek(out first) && first.Livestock_ID == null)
// {
// noLivestockList.TryDequeue(out first);
// if (currentRow != null)
// first.OrderDetail_ID = currentRow.OrderDetail_ID;
// first.Date = butcherTimeInput.Date.Value;
// first.Livestock_ID = livestock.Item1;
// first.Livestock_Name = livestock.Item2;
// first.Technics = livestock.Item3;
// first.Technics_Name = tech;
// if (disBtn != null)
// {
// first.Weight = (first.Weight ?? 0) - Convert.ToDecimal(disBtn.Tag);
// SetBtnUnCheck(disBtn);
// disBtn = null;
// }
// LocalGradeAndWeightBL.Update(first, "OrderDetail_ID", "Date", "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name", "Weight");
// historyGrid.Refresh();
// }
// else//add
// {
// maxIndex++;
// var entity = new GradeAndWeight_Detail();
// entity.Index = maxIndex;
// if (currentRow != null)
// entity.OrderDetail_ID = currentRow.OrderDetail_ID;
// entity.Date = butcherTimeInput.Date.Value;
// entity.Livestock_ID = livestock.Item1;
// entity.Livestock_Name = livestock.Item2;
// entity.Technics = livestock.Item3;
// entity.Technics_Name = tech;
// entity.Time = DateTime.Now;
// entity.Date = butcherTimeInput.Date.Value;
// if (disBtn != null)
// {
// entity.Weight = -Convert.ToDecimal(disBtn.Tag);
// SetBtnUnCheck(disBtn);
// disBtn = null;
// }
// if (details.Count == 50)
// details.RemoveAt(49);
// details.Insert(0, entity);
// LocalGradeAndWeightBL.Insert(entity);
// noWeightList.Enqueue(entity);
// BindDetailGrid();
// }
// if (currentRow != null)
// {
// currentRow.Already = currentRow.Already + 1;
// orderLabel.Text = currentRow.Order.ToString();
// alreadyLabel.Text = currentRow.Already.ToString();
// tangGridView.Refresh();
// }
// else
// {
// orderLabel.Text = string.Empty;
// alreadyLabel.Text = string.Empty;
// }
//
// //计算合计
// ReSetHistorySum();
// }
// }
//点级别
void AddDetail(CTuple<long, string, short, string> livestock)
{ {
lock (_obj) lock (_obj)
{ {
@ -951,9 +951,10 @@ namespace WeighAndGrading
var tech = livestock.Item3 == TANG_TECH ? "烫褪" : "毛剥"; var tech = livestock.Item3 == TANG_TECH ? "烫褪" : "毛剥";
GradeAndWeight_Detail first; GradeAndWeight_Detail first;
if (noLivestockList.TryPeek(out first) && string.IsNullOrWhiteSpace(first.Livestock_Name))
//TryPeek 尝试返回 ConcurrentQueue<T> 开头处的对象但不将其移除
//TryDequeue 尝试移除并返回并发队列开头处的对象。
if (noLivestockList.TryDequeue(out first))
{ {
noLivestockList.TryDequeue(out first);
if (currentRow != null) if (currentRow != null)
first.OrderDetail_ID = currentRow.OrderDetail_ID; first.OrderDetail_ID = currentRow.OrderDetail_ID;
first.Date = butcherTimeInput.Date.Value; first.Date = butcherTimeInput.Date.Value;
@ -998,9 +999,9 @@ namespace WeighAndGrading
details.RemoveAt(49); details.RemoveAt(49);
details.Insert(0, entity); details.Insert(0, entity);
LocalGradeAndWeightBL.Insert(entity); LocalGradeAndWeightBL.Insert(entity);
// noWeightList.Enqueue(entity); // 添加的掉猪明细不加入到没有称重队列
// noWeightList.Enqueue(entity); // 添加的掉猪明细不加入到没有称重队列
BindDetailGrid(); BindDetailGrid();
} }
if (currentRow != null) if (currentRow != null)
{ {
@ -1019,32 +1020,35 @@ namespace WeighAndGrading
} }
//计算合计 //计算合计
// ReSetHistorySum();
// ReSetHistorySum();
} }
} }
void SetlblSucessVisibleFalse() void SetlblSucessVisibleFalse()
{ {
this.Invoke(new Action(() =>
this.Invoke(new InvokeHandler(delegate
{ {
Thread.Sleep(1000); Thread.Sleep(1000);
lblSucessed.Visible = false; lblSucessed.Visible = false;
})); }));
} }
void SetlblSucessVisibleTrue() void SetlblSucessVisibleTrue()
{ {
lblSucessed.Visible = true;
Application.DoEvents();
this.Invoke(new InvokeHandler(delegate
{
lblSucessed.Visible = true;
Application.DoEvents();
}));
} }
// void ReSetHistorySum()
// {
// var tangtui=LocalGradeAndWeightBL.GetTangTuiSumNumber(butcherTimeInput.Date.Value);
// var maobo=LocalGradeAndWeightBL.GetMaoBoSumNumber(butcherTimeInput.Date.Value);
// lblHeJi.Text = "合计: 烫褪("+ tangtui + ") 毛剥("+maobo+")";
// }
// void ReSetHistorySum()
// {
// var tangtui=LocalGradeAndWeightBL.GetTangTuiSumNumber(butcherTimeInput.Date.Value);
// var maobo=LocalGradeAndWeightBL.GetMaoBoSumNumber(butcherTimeInput.Date.Value);
// lblHeJi.Text = "合计: 烫褪("+ tangtui + ") 毛剥("+maobo+")";
// }
void AddWeightDetail(decimal weight) void AddWeightDetail(decimal weight)
@ -1052,36 +1056,36 @@ namespace WeighAndGrading
lock (_obj) lock (_obj)
{ {
weight -= (GradeContext.Config.Discont ?? 0); weight -= (GradeContext.Config.Discont ?? 0);
// GradeAndWeight_Detail first;
// if (noWeightList.TryPeek(out first))
// {
// noWeightList.TryDequeue(out first);
// if (first.Weight < 0)
// first.Weight = (first.Weight ?? 0) + weight;
// else
// first.Weight = weight;
// LocalGradeAndWeightBL.Update(first, "Weight");
// historyGrid.Refresh();
// }
// else//add
// GradeAndWeight_Detail first;
// if (noWeightList.TryPeek(out first))
// {
// noWeightList.TryDequeue(out first);
// if (first.Weight < 0)
// first.Weight = (first.Weight ?? 0) + weight;
// else
// first.Weight = weight;
// LocalGradeAndWeightBL.Update(first, "Weight");
// historyGrid.Refresh();
// }
// else//add
{ {
maxIndex++;
var entity = new GradeAndWeight_Detail();
entity.Index = maxIndex;
entity.Weight = (entity.Weight ?? 0) + weight;
entity.Time = DateTime.Now;
entity.Date = butcherTimeInput.Date.Value;
if (details.Count == 50)
details.RemoveAt(49);
details.Insert(0, entity);
LocalGradeAndWeightBL.Insert(entity);
noLivestockList.Enqueue(entity);
BindDetailGrid();
// SetlblSucessVisibleTrue();
// SetlblSucessVisibleFalse();
maxIndex++;
var entity = new GradeAndWeight_Detail();
entity.Index = maxIndex;
entity.Weight = (entity.Weight ?? 0) + weight;
entity.Time = DateTime.Now;
entity.Date = butcherTimeInput.Date.Value;
if (details.Count == 50)
details.RemoveAt(49);
details.Insert(0, entity);
LocalGradeAndWeightBL.Insert(entity);
noLivestockList.Enqueue(entity);
BindDetailGrid();
// SetlblSucessVisibleTrue();
// SetlblSucessVisibleFalse();
} }
} }
@ -1178,10 +1182,10 @@ namespace WeighAndGrading
noWeightList = new ConcurrentQueue<GradeAndWeight_Detail>(); noWeightList = new ConcurrentQueue<GradeAndWeight_Detail>();
var stackNoWeight = new Stack<GradeAndWeight_Detail>(); var stackNoWeight = new Stack<GradeAndWeight_Detail>();
//把没有重量的记录加进去 //把没有重量的记录加进去
var noWeightDetails = details.Where(x => x.Weight==null);
var noWeightDetails = details.Where(x => x.Weight == null);
foreach (var item in noWeightDetails) foreach (var item in noWeightDetails)
{ {
if (item.SID > suodingmaxsid) if (item.SID > suodingmaxsid)
@ -1221,21 +1225,21 @@ namespace WeighAndGrading
// LocalGradeAndWeightBL.ClearWeightBySID(fuhemaxsid); // LocalGradeAndWeightBL.ClearWeightBySID(fuhemaxsid);
// historyGrid.Refresh();
//
// noWeightList = new ConcurrentQueue<GradeAndWeight_Detail>();
// var stack = new Stack<GradeAndWeight_Detail>();
// foreach (var item in details)
// {
// if (item.SID > fd.SID)
// {
// stack.Push(item);
// }
// }
// while (stack.Count > 0)
// {
// noWeightList.Enqueue(stack.Pop());
// }
// historyGrid.Refresh();
//
// noWeightList = new ConcurrentQueue<GradeAndWeight_Detail>();
// var stack = new Stack<GradeAndWeight_Detail>();
// foreach (var item in details)
// {
// if (item.SID > fd.SID)
// {
// stack.Push(item);
// }
// }
// while (stack.Count > 0)
// {
// noWeightList.Enqueue(stack.Pop());
// }
#endregion #endregion
if (details.Count == 0) if (details.Count == 0)
@ -1279,7 +1283,7 @@ namespace WeighAndGrading
var lostweightlist = details.Where(x => x.IsLostWeight).ToList(); var lostweightlist = details.Where(x => x.IsLostWeight).ToList();
if (lostweightlist.Count > 0) if (lostweightlist.Count > 0)
{ {
suodingmaxsid = lostweightlist.Max(x => x.SID);
suodingmaxsid = lostweightlist.Max(x => x.SID);
} }
//把没有级别的记录加进去 //把没有级别的记录加进去
var livestockNoNameList = details.Where(x => string.IsNullOrWhiteSpace(x.Livestock_Name)); var livestockNoNameList = details.Where(x => string.IsNullOrWhiteSpace(x.Livestock_Name));
@ -1312,13 +1316,13 @@ namespace WeighAndGrading
{ {
maxLockID = lostList.Max(x => x.SID); maxLockID = lostList.Max(x => x.SID);
} }
//赋最大值 //赋最大值
if (mCurrentSlectItem.SID > maxLockID) if (mCurrentSlectItem.SID > maxLockID)
{ {
maxLockID = mCurrentSlectItem.SID; maxLockID = mCurrentSlectItem.SID;
UpdateItemLosted(mCurrentSlectItem.SID); UpdateItemLosted(mCurrentSlectItem.SID);
if (modifyPanel.Visible) if (modifyPanel.Visible)
modifyPanel.Hide(); modifyPanel.Hide();
historyGrid.Refresh(); historyGrid.Refresh();
@ -1338,19 +1342,19 @@ namespace WeighAndGrading
} }
} }
// SetHistorBackColor();
// SetHistorBackColor();
} }
// void SetHistorBackColor()
// {
// foreach (DataGridViewRow row in historyGrid.Rows)
// {
// if ((bool)row.Cells["IsLostWeight"].Value)
// row.DefaultCellStyle.ForeColor = Color.Red;
// }
// }
// void SetHistorBackColor()
// {
// foreach (DataGridViewRow row in historyGrid.Rows)
// {
// if ((bool)row.Cells["IsLostWeight"].Value)
// row.DefaultCellStyle.ForeColor = Color.Red;
// }
// }
private void UpdateItemLosted(long sid) private void UpdateItemLosted(long sid)
{ {
@ -1375,41 +1379,41 @@ namespace WeighAndGrading
mCurrentSlectItem = currentRow; mCurrentSlectItem = currentRow;
if (e.ColumnIndex == 4)
{
if (lastCheckItem != null && lastCheckItem.SID != currentRow.SID)
lastCheckItem.ReadWeight = false;
lastCheckItem = currentRow;
lastCheckItem.ReadWeight = !lastCheckItem.ReadWeight;
//
modifyDetail = null;
if (modifyPanel.Visible)
modifyPanel.Hide();
historyGrid.Refresh();
// if (lastCheckItem.ReadWeight)
// {
// noWeightList = new ConcurrentQueue<GradeAndWeight_Detail>();
// var stack = new Stack<GradeAndWeight_Detail>();
// foreach (var item in details)
// {
// if (item.SID > lastCheckItem.SID)
// {
// stack.Push(item);
// }
//// stack.Push(item);
//// if (item.SID == lastCheckItem.SID)
//// break;
// }
// while (stack.Count > 0)
// noWeightList.Enqueue(stack.Pop());
// }
// else
// {
// FillQueue();
// lastCheckItem = null;
// }
return;
}
if (e.ColumnIndex == 4)
{
if (lastCheckItem != null && lastCheckItem.SID != currentRow.SID)
lastCheckItem.ReadWeight = false;
lastCheckItem = currentRow;
lastCheckItem.ReadWeight = !lastCheckItem.ReadWeight;
//
modifyDetail = null;
if (modifyPanel.Visible)
modifyPanel.Hide();
historyGrid.Refresh();
// if (lastCheckItem.ReadWeight)
// {
// noWeightList = new ConcurrentQueue<GradeAndWeight_Detail>();
// var stack = new Stack<GradeAndWeight_Detail>();
// foreach (var item in details)
// {
// if (item.SID > lastCheckItem.SID)
// {
// stack.Push(item);
// }
//// stack.Push(item);
//// if (item.SID == lastCheckItem.SID)
//// break;
// }
// while (stack.Count > 0)
// noWeightList.Enqueue(stack.Pop());
// }
// else
// {
// FillQueue();
// lastCheckItem = null;
// }
return;
}
modifyDetail = currentRow; modifyDetail = currentRow;
stateLabel.Text = string.Format("您正在修改序号为 {0} 的信息", modifyDetail.Index); stateLabel.Text = string.Format("您正在修改序号为 {0} 的信息", modifyDetail.Index);
modifyPanel.Show(); modifyPanel.Show();
@ -1547,12 +1551,12 @@ namespace WeighAndGrading
{ {
if (modifyDetail == null) if (modifyDetail == null)
{ {
// if (disBtn != null)
// SetBtnUnCheck(disBtn);
// if (disBtn != null)
// SetBtnUnCheck(disBtn);
if (disBtn != btn) if (disBtn != btn)
{ {
disBtn = btn; disBtn = btn;
// SetBtnChecked(disBtn);
// SetBtnChecked(disBtn);
} }
else else
disBtn = null; disBtn = null;
@ -1621,7 +1625,7 @@ namespace WeighAndGrading
vScrollBar2.Minimum = 0; vScrollBar2.Minimum = 0;
vScrollBar2.SmallChange = historyGrid.RowTemplate.Height; vScrollBar2.SmallChange = historyGrid.RowTemplate.Height;
vScrollBar2.LargeChange = historyGrid.RowTemplate.Height * 30; vScrollBar2.LargeChange = historyGrid.RowTemplate.Height * 30;
this.vScrollBar2.Scroll += (sender, e) => this.vScrollBar2.Scroll += (sender, e) =>
{ {
rightRoll = e.NewValue / historyGrid.RowTemplate.Height; rightRoll = e.NewValue / historyGrid.RowTemplate.Height;
@ -1691,7 +1695,7 @@ namespace WeighAndGrading
statePic.Image = Image.FromStream(s); statePic.Image = Image.FromStream(s);
statePic.Refresh(); statePic.Refresh();
} }
last = connection; last = connection;
} }
@ -1702,25 +1706,21 @@ namespace WeighAndGrading
MessageBox.Show("请在上一个界面选择宰杀日期"); MessageBox.Show("请在上一个界面选择宰杀日期");
return; return;
} }
var f=new AbnormalModifyForm(butcherTimeInput.Date.Value);
var f = new AbnormalModifyForm(butcherTimeInput.Date.Value);
f.ShowDialog(); f.ShowDialog();
} }
private void GradeFrom_Load(object sender, EventArgs e) private void GradeFrom_Load(object sender, EventArgs e)
{ {
syncToServer = new Thread(ToServerTask); syncToServer = new Thread(ToServerTask);
syncToServer.Start(); syncToServer.Start();
} }
void ToServerTask() void ToServerTask()
{ {
while (true) while (true)
{ {
// this.Invoke(new InvokeHandler(delegate ()
// this.Invoke(new InvokeHandler(delegate ()
{ {
VerifyConnection(); VerifyConnection();
if (connection) if (connection)
@ -1738,7 +1738,7 @@ namespace WeighAndGrading
} }
} }
} }
// ));
// ));
Thread.Sleep(2000); Thread.Sleep(2000);
} }
} }


Loading…
Cancel
Save