diff --git a/BO/BO/Bill/GradeAndWeight/GradeAndWeight_Detail.cs b/BO/BO/Bill/GradeAndWeight/GradeAndWeight_Detail.cs
index 242f8df..8da7904 100644
--- a/BO/BO/Bill/GradeAndWeight/GradeAndWeight_Detail.cs
+++ b/BO/BO/Bill/GradeAndWeight/GradeAndWeight_Detail.cs
@@ -16,9 +16,6 @@ namespace BO.BO.Bill
///
public long SID { get; set; }
- [NonDmoProperty]
- public bool ReadWeight { get; set; }
-
public long? OrderDetail_ID { get; set; }
public int? Order { get; set; }
@@ -39,11 +36,6 @@ namespace BO.BO.Bill
public DateTime Time { get; set; }
- // public string Shortcut { get; set; }//快捷键
-
- public bool IsLostWeight { get; set; }//是否丢称重
-
-
///
/// ServerID
///
diff --git a/BO/BO/Bill/WeightBill/WeightBill.cs b/BO/BO/Bill/WeightBill/WeightBill.cs
index acaa174..fa62cab 100644
--- a/BO/BO/Bill/WeightBill/WeightBill.cs
+++ b/BO/BO/Bill/WeightBill/WeightBill.cs
@@ -57,16 +57,10 @@ namespace BO.BO
public decimal? ShackPrice { get; set; }
- public decimal? ShackMoney
- {
- get
- {
- var v = ShackPrice * ShackWeight;
- if (v.HasValue)
- return decimal.Round(v.Value, 2);
- return null;
- }
- }
+ //棚前单价= (棚前金额+经检费- 猪场扣款)/棚前重量
+ //棚前金额 = 棚前单价*棚前重量-经检费+猪场扣款
+
+ public decimal? ShackMoney { get; set; }
public decimal? JingJianFee { get; set; }
diff --git a/BO/Utils/AfterLoginUtil.cs b/BO/Utils/AfterLoginUtil.cs
index 9bd60b4..4508900 100644
--- a/BO/Utils/AfterLoginUtil.cs
+++ b/BO/Utils/AfterLoginUtil.cs
@@ -19,25 +19,25 @@ namespace BO.Utils
public static class AfterLoginUtil
{
- static List> roleToAssemblies = new List>(){new Tuple("排宰员",@"C:\BwpB3Project\src\B3ButcherManageClient\ButcherOrder\bin\Debug\ButcherOrder"),
- new Tuple("过磅员",@"C:\BwpB3Project\src\B3ButcherManageClient\ButcherWeight\bin\Debug\ButcherWeight"),
- new Tuple("验质员",@"C:\BwpB3Project\src\B3ButcherManageClient\QualityAndOrder\bin\Debug\QualityAndOrder"),
- new Tuple("定级员",@"C:\BwpB3Project\src\B3ButcherManageClient\WeighAndGrading\bin\Debug\WeighAndGrading"),
- new Tuple("窒晕员",@"C:\BwpB3Project\src\B3ButcherManageClient\OrderConfirm\bin\Debug\OrderConfirm"),
- new Tuple("掉猪处理员",@"C:\BwpB3Project\src\B3ButcherManageClient\DropPigReOrder\bin\Debug\DropPigReOrder"),
- new Tuple("配货员",@"D:\BWP\BWPB3\src\B3ButcherManageClient\Distribution\bin\Debug\Distribution")
+ // static List> roleToAssemblies = new List>(){new Tuple("排宰员",@"C:\BwpB3Project\src\B3ButcherManageClient\ButcherOrder\bin\Debug\ButcherOrder"),
+ //new Tuple("过磅员",@"C:\BwpB3Project\src\B3ButcherManageClient\ButcherWeight\bin\Debug\ButcherWeight"),
+ // new Tuple("验质员",@"C:\BwpB3Project\src\B3ButcherManageClient\QualityAndOrder\bin\Debug\QualityAndOrder"),
+ // new Tuple("定级员",@"C:\BwpB3Project\src\B3ButcherManageClient\WeighAndGrading\bin\Debug\WeighAndGrading"),
+ // new Tuple("窒晕员",@"C:\BwpB3Project\src\B3ButcherManageClient\OrderConfirm\bin\Debug\OrderConfirm"),
+ // new Tuple("掉猪处理员",@"C:\BwpB3Project\src\B3ButcherManageClient\DropPigReOrder\bin\Debug\DropPigReOrder"),
+ // new Tuple("配货员",@"D:\BWP\BWPB3\src\B3ButcherManageClient\Distribution\bin\Debug\Distribution")
- };
+ //};
- //static List> roleToAssemblies = new List>()
- // {
- // new Tuple("排宰员",@"ButcherOrder"),
- // new Tuple("过磅员",@"ButcherWeight"),
- // new Tuple("验质员",@"QualityAndOrder"),
- // new Tuple("定级员",@"WeighAndGrading"),
- // new Tuple("窒晕员",@"OrderConfirm"),
- // new Tuple("掉猪处理员",@"DropPigReOrder"),
- // };
+ static List> roleToAssemblies = new List>()
+ {
+ new Tuple("排宰员",@"ButcherOrder"),
+ new Tuple("过磅员",@"ButcherWeight"),
+ new Tuple("验质员",@"QualityAndOrder"),
+ new Tuple("定级员",@"WeighAndGrading"),
+ new Tuple("窒晕员",@"OrderConfirm"),
+ new Tuple("掉猪处理员",@"DropPigReOrder"),
+ };
@@ -47,10 +47,10 @@ namespace BO.Utils
if (first == null)
throw new Exception("未注册的角色");
//#if debug
- var filePath = string.Format("{0}.dll", first.Item2);
+ //var filePath = string.Format("{0}.dll", first.Item2);
//#endif
//#if !debug
- //var filePath = Path.Combine(Application.StartupPath, string.Format("{0}.dll", first.Item2));
+ var filePath = Path.Combine(Application.StartupPath, string.Format("{0}.dll", first.Item2));
//#endif
if (!File.Exists(filePath))
throw new Exception("相关模块不存在");
diff --git a/BO/Utils/BaseInfoRpcUtil.cs b/BO/Utils/BaseInfoRpcUtil.cs
index bbd9f7a..52b3a88 100644
--- a/BO/Utils/BaseInfoRpcUtil.cs
+++ b/BO/Utils/BaseInfoRpcUtil.cs
@@ -38,10 +38,10 @@ namespace BO.Utils
return result;
}
- public static List> GetLivestockList()
+ public static List> GetLivestockList()
{
var list = RpcFacade.Call("/MainSystem/B3ClientService/Rpcs/BaseInfoRpc/GetLivestock");
- return serializer.Deserialize>>(list);
+ return serializer.Deserialize>>(list);
}
}
}
diff --git a/BO/Utils/BillRpc/GradeAndWeightRpc.cs b/BO/Utils/BillRpc/GradeAndWeightRpc.cs
index 729e6b4..568cf0c 100644
--- a/BO/Utils/BillRpc/GradeAndWeightRpc.cs
+++ b/BO/Utils/BillRpc/GradeAndWeightRpc.cs
@@ -218,14 +218,14 @@ namespace BO.Utils.BillRpc
}
}
- public static void Update(GradeAndWeight_Detail detail, GradeAndWeight dmo)
+ public static void Update(GradeAndWeight_Detail detail, GradeAndWeight toEntity)
{
- if (dmo == null)
+ if (toEntity == null)
{
throw new Exception(string.Format("请选择左侧的{0}顺序", detail.Technics_Name));
}
- detail.Order = dmo.Order;
- detail.OrderDetail_ID = dmo.OrderDetail_ID;
+ detail.Order = toEntity.Order;
+ detail.OrderDetail_ID = toEntity.OrderDetail_ID;
Update(detail, "OrderDetail_ID", "Order", "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name");
}
@@ -234,7 +234,7 @@ namespace BO.Utils.BillRpc
ClearUnSyncDelete();
var syncs = GetAllNeedSyncDetails();
foreach (var detail in syncs)
- {
+ {
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc/UpdateOrInsertDetailOrDelete";
var id = RpcFacade.Call(method, serializer.Serialize(detail));
if (detail.IsDeleted)
diff --git a/BWP.WinFormControl/UDatePicker.cs b/BWP.WinFormControl/UDatePicker.cs
index 1d78bd6..5ab89a1 100644
--- a/BWP.WinFormControl/UDatePicker.cs
+++ b/BWP.WinFormControl/UDatePicker.cs
@@ -60,6 +60,8 @@ namespace BWP.WinFormControl
protected override void OnClick(EventArgs e)
{
+ if (!this.Enabled)
+ return;
var cs = new CalendarSelecter();
if (cs.ShowDialog() == true)
{
diff --git a/ButcherWeight/WeightForm.cs b/ButcherWeight/WeightForm.cs
index 47cdac0..741eb0f 100644
--- a/ButcherWeight/WeightForm.cs
+++ b/ButcherWeight/WeightForm.cs
@@ -283,6 +283,15 @@ namespace ButcherWeight
}
else
Dmo.ShackPrice = null;
+ if (!string.IsNullOrEmpty(penMoneyInput.Text))
+ {
+ decimal pm = 0;
+ if (!decimal.TryParse(penMoneyInput.Text.Trim(), out pm))
+ throw new Exception("棚前金额输入错误");
+ Dmo.ShackMoney = pm;
+ }
+ else
+ Dmo.ShackMoney = null;
if (!string.IsNullOrEmpty(jingjianInput.Text))
{
decimal jjf = 0;
diff --git a/WeighAndGrading/GradeFrom.Designer.cs b/WeighAndGrading/GradeFrom.Designer.cs
index b6549cf..1187778 100644
--- a/WeighAndGrading/GradeFrom.Designer.cs
+++ b/WeighAndGrading/GradeFrom.Designer.cs
@@ -101,12 +101,6 @@
this.btnStartWeight = new System.Windows.Forms.Button();
this.btnStopWeight = new System.Windows.Forms.Button();
this.dataConfirmBtn = new System.Windows.Forms.Button();
- this.label5 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.label9 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.tangGridView)).BeginInit();
this.groupBox2.SuspendLayout();
@@ -792,79 +786,13 @@
this.dataConfirmBtn.UseVisualStyleBackColor = true;
this.dataConfirmBtn.Click += new System.EventHandler(this.dataConfirmBtn_Click);
//
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Font = new System.Drawing.Font("宋体", 15F);
- this.label5.Location = new System.Drawing.Point(524, 8);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(69, 20);
- this.label5.TabIndex = 45;
- this.label5.Text = "烫褪:";
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Font = new System.Drawing.Font("宋体", 15F);
- this.label6.Location = new System.Drawing.Point(524, 45);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(69, 20);
- this.label6.TabIndex = 46;
- this.label6.Text = "毛剥:";
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Font = new System.Drawing.Font("宋体", 15F);
- this.label7.Location = new System.Drawing.Point(583, 10);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(179, 20);
- this.label7.TabIndex = 47;
- this.label7.Text = "5000 头 500000 KG";
- //
- // label9
- //
- this.label9.AutoSize = true;
- this.label9.Font = new System.Drawing.Font("宋体", 15F);
- this.label9.Location = new System.Drawing.Point(524, 81);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(69, 20);
- this.label9.TabIndex = 49;
- this.label9.Text = "合计:";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Font = new System.Drawing.Font("宋体", 15F);
- this.label3.Location = new System.Drawing.Point(583, 47);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(179, 20);
- this.label3.TabIndex = 50;
- this.label3.Text = "5000 头 500000 KG";
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Font = new System.Drawing.Font("宋体", 15F);
- this.label8.Location = new System.Drawing.Point(583, 85);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(179, 20);
- this.label8.TabIndex = 51;
- this.label8.Text = "5000 头 500000 KG";
- //
// GradeFrom
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1438, 845);
- this.Controls.Add(this.label8);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label9);
- this.Controls.Add(this.label7);
this.Controls.Add(this.dataConfirmBtn);
- this.Controls.Add(this.label6);
this.Controls.Add(this.btnStopWeight);
- this.Controls.Add(this.label5);
this.Controls.Add(this.btnStartWeight);
this.Controls.Add(this.dropPigBtn);
this.Controls.Add(this.lblSucessed);
@@ -974,11 +902,5 @@
private System.Windows.Forms.DataGridViewTextBoxColumn H_Livestock_Name;
private System.Windows.Forms.DataGridViewTextBoxColumn H_Weight;
private System.Windows.Forms.DataGridViewTextBoxColumn H_Time;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.Label label9;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label8;
}
}
\ No newline at end of file
diff --git a/WeighAndGrading/GradeFrom.cs b/WeighAndGrading/GradeFrom.cs
index 0146baf..6edff15 100644
--- a/WeighAndGrading/GradeFrom.cs
+++ b/WeighAndGrading/GradeFrom.cs
@@ -51,9 +51,10 @@ namespace WeighAndGrading
bool connection = false;
SerialPort weightPort;
int maxIndex = 0;
- ConcurrentQueue noLivestockList;
+ readonly ConcurrentQueue noLivestockList;
- Thread syncWork;
+ bool onWorking = false;
+ Thread syncTangGrid, syncMaoGrid, syncDetailGrid;
Thread syncToServer;
#region weightNeed
private IDataFormat _dataFormat;
@@ -71,6 +72,10 @@ namespace WeighAndGrading
maoGridView.AutoGenerateColumns = false;
maoGridView.DataSource = null;
historyGrid.AutoGenerateColumns = false;
+ historyGrid.DataSource = null;
+ tangList = new List();
+ maoList = new List();
+ noLivestockList = new ConcurrentQueue();
if (!Directory.Exists(DATA_PATH))
Directory.CreateDirectory(DATA_PATH);
connection = ButcherAppContext.Context.UserConfig.Connection;
@@ -81,8 +86,12 @@ namespace WeighAndGrading
{
if (_inQueryThread != null && _inQueryThread.IsAlive)
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)
syncToServer.Abort();
};
@@ -97,7 +106,6 @@ namespace WeighAndGrading
return;
}
btn.Enabled = false;
- SetlblSucessVisibleTrue();
var livestockTag = btn.Tag as CTuple;
var tech = livestockTag.Item3 == TANG_TECH ? "烫褪" : "毛剥";
@@ -109,75 +117,57 @@ namespace WeighAndGrading
}
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();
- var stack = new Stack();
-
- //找到锁定的最大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();
btn.Enabled = true;
}
+ void UpdateDetial(GradeAndWeight_Detail detail, CTuple 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 { "Order", "OrderDetail_ID", "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name" };
+ if (techIsEmpty)
+ ResetQueue();
+ }
+
+ void ResetQueue()
+ {
+ ClearQuery();
+ var stack = new Stack();
+ 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()
{
var livestocks = new List>();
@@ -227,91 +217,105 @@ namespace WeighAndGrading
private void syncBtn_Click(object sender, EventArgs e)
{
details = LocalGradeAndWeightBL.GetDetails(butcherTimeInput.Date.Value, 50);
- FillQueue();
- BindDetailGrid();
+ ResetQueue();
if (details.Any())
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.ForeColor = Color.White;
}
else
{
- syncWork.Abort();
syncBtn.BackColor = Color.FromKnownColor(KnownColor.Control);
syncBtn.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
}
}
- void Sync()
+ void RefreshTangData()
{
- var bc = new BackgroundWorker();
- bc.DoWork += Bc_DoWork;
- bc.RunWorkerCompleted += Bc_RunWorkerCompleted;
while (true)
{
- if (!bc.IsBusy)
+ GetLeftList(ref tangList, true);
+ this.Invoke(new InvokeHandler(delegate
{
- bc.RunWorkerAsync();
- }
+ BindTangGrid();
+ }));
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();
- var stack = new Stack();
- 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 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 list, bool tang)
{
VerifyConnection();
if (connection)
{
try
{
- tangList = GradeAndWeightRpc.GetGradeAndWeightList(butcherTimeInput.Date.Value, true);
+ list = GradeAndWeightRpc.GetGradeAndWeightList(butcherTimeInput.Date.Value, tang);
}
catch (TimeoutException) { }
}
- else
- {
- if (tangList == null)
- tangList = new List();
- }
}
void BindTangGrid()
@@ -348,31 +352,8 @@ namespace WeighAndGrading
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();
- }
- }
-
void BindMaoGrid()
{
-
maoGridView.DataSource = maoList.OrderBy(x => x.Order).OrderBy(x => x.Finish).ToList();
if (maoEntity == null && maoGridView.CurrentRow != null)
{
@@ -407,15 +388,19 @@ namespace WeighAndGrading
void BindDetailGrid()
{
- historyGrid.DataSource = null;
- if (details.Any())
- historyGrid.DataSource = details;
+ historyGrid.DataSource = details;
foreach (DataGridViewRow row in historyGrid.Rows)
{
if ((bool)row.Cells["H_IsDrop"].Value)
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
{
if (rightRoll != -1)
@@ -489,8 +474,7 @@ namespace WeighAndGrading
return;
}
StartPrintEntity(modifyDetail.Technics_Name, modifyDetail.Index);
- modifyDetail = null;
- modifyPanel.Hide();
+ cancelBtn_Click(sender, EventArgs.Empty);
}
private void configBtn_Click(object sender, EventArgs e)
@@ -745,7 +729,19 @@ namespace WeighAndGrading
disBtn = null;
}
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
{
@@ -771,21 +767,12 @@ namespace WeighAndGrading
SetBtnUnCheck(disBtn);
disBtn = null;
}
- //如果手动点击新增明细,则明细的重量=0
entity.Weight = 0;
- entity.IsLostWeight = true;
-
- if (details.Count == 50)
- details.RemoveAt(49);
- details.Insert(0, entity);
LocalGradeAndWeightBL.Insert(entity);
-
- //这里绑定界面 东旭说不应该放到锁了 不知道怎么改
- BindDetailGrid();
-
+ details.Insert(0, entity);
+ AfterAddBindDetailGrid();
}
-
if (currentRow != null)
{
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)
{
lock (_obj)
@@ -833,20 +828,25 @@ namespace WeighAndGrading
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);
-
+ details.Insert(0, entity);
noLivestockList.Enqueue(entity);
}
-
- BindDetailGrid();
+ AfterAddBindDetailGrid();
}
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;
modifyPanel.Hide();
}
@@ -868,57 +868,18 @@ namespace WeighAndGrading
modifyDetail.IsDeleted = true;
LocalGradeAndWeightBL.Update(modifyDetail, "IsDeleted");
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)
{
- //重新赋值 队列
- //重新设置没有级别的
- noLivestockList = new ConcurrentQueue();
- var stackNoLiveStock = new Stack();
- //把没有级别的记录加进去
- 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;
modifyPanel.Hide();
}
- BindDetailGrid();
+ if (details.Any())
+ historyGrid.DataSource = details;
+ historyGrid.Refresh();
+ //BindDetailByClick();
}
private void historyGrid_CellClick(object sender, DataGridViewCellEventArgs e)
@@ -926,7 +887,19 @@ namespace WeighAndGrading
if (e.RowIndex < 0)
return;
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;
+ historyGrid.Refresh();
stateLabel.Text = string.Format("您正在修改序号为 {0} 的信息", modifyDetail.Index);
modifyPanel.Show();
}
@@ -968,9 +941,6 @@ namespace WeighAndGrading
}
entity.Finish = true;
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;
BindTangGrid();
}
@@ -1012,9 +982,6 @@ namespace WeighAndGrading
}
entity.Finish = true;
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;
BindMaoGrid();
}
@@ -1059,9 +1026,7 @@ namespace WeighAndGrading
{
modifyDetail.Weight = (modifyDetail.Weight ?? 0) - Convert.ToDecimal(btn.Tag);
LocalGradeAndWeightBL.Update(modifyDetail, "Weight");
- historyGrid.Refresh();
- modifyDetail = null;
- modifyPanel.Hide();
+ cancelBtn_Click(sender, EventArgs.Empty);
}
};
discontPanel.Controls.Add(btn);
@@ -1079,9 +1044,7 @@ namespace WeighAndGrading
{
modifyDetail.IsDrop = !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;
- private void InitScrollBar2()
+ private void InitDetailScrollBar()
{
vScrollBar2.Maximum = (historyGrid.RowCount - historyGrid.DisplayedRowCount(false) + 30) * historyGrid.RowTemplate.Height;
vScrollBar2.Minimum = 0;
@@ -1189,19 +1152,17 @@ namespace WeighAndGrading
{
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);
@@ -1222,5 +1183,14 @@ namespace WeighAndGrading
File.Delete(changeFlagPath);
}
}
+
+ void ClearQuery()
+ {
+ if (noLivestockList == null)
+ return;
+ GradeAndWeight_Detail r;
+ while (noLivestockList.TryDequeue(out r))
+ { }
+ }
}
}
diff --git a/WeighAndGrading/GradeFrom.resx b/WeighAndGrading/GradeFrom.resx
index f123d58..06ecffd 100644
--- a/WeighAndGrading/GradeFrom.resx
+++ b/WeighAndGrading/GradeFrom.resx
@@ -117,6 +117,39 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
True
@@ -135,6 +168,15 @@
True
+
+ True
+
+
+ True
+
+
+ True
+
True
@@ -153,6 +195,24 @@
True
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
True
@@ -183,4 +243,61 @@
True
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
\ No newline at end of file