diff --git a/ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs b/ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs index 357e83c..067143c 100644 --- a/ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs +++ b/ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs @@ -14,6 +14,10 @@ namespace ButcherFactory.BO [NonDmoProperty] public List Details { get { return mDetails; } } + private List mGoods = new List(); + [NonDmoProperty] + public List Goods { get { return mGoods; } } + [NonDmoProperty] public bool Stopped { get; set; } } @@ -27,7 +31,6 @@ namespace ButcherFactory.BO public long Goods_ID { get; set; } - [NonDmoProperty] [ReferenceTo(typeof(Goods), "Name")] [Join("Goods_ID", "ID")] public string Goods_Name { get; set; } diff --git a/ButcherFactory.BO/BaseInfo/Goods.cs b/ButcherFactory.BO/BaseInfo/Goods.cs index 082d673..25166b6 100644 --- a/ButcherFactory.BO/BaseInfo/Goods.cs +++ b/ButcherFactory.BO/BaseInfo/Goods.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; namespace ButcherFactory.BO { [MapToTable("Butcher_Goods")] + [KeyField("ID", KeyGenType.assigned)] public class Goods : BaseInfo { public string MainUnit { get; set; } diff --git a/ButcherFactory.BO/ButcherFactory.BO.csproj b/ButcherFactory.BO/ButcherFactory.BO.csproj index 2d34d71..2d2d3be 100644 --- a/ButcherFactory.BO/ButcherFactory.BO.csproj +++ b/ButcherFactory.BO/ButcherFactory.BO.csproj @@ -57,13 +57,13 @@ + - diff --git a/ButcherFactory.BO/LocalBL/CarcassInStoreBL.cs b/ButcherFactory.BO/LocalBL/CarcassInStoreBL.cs index e973072..4b1174a 100644 --- a/ButcherFactory.BO/LocalBL/CarcassInStoreBL.cs +++ b/ButcherFactory.BO/LocalBL/CarcassInStoreBL.cs @@ -17,47 +17,79 @@ namespace ButcherFactory.BO.LocalBL public static class CarcassInStoreBL { const string RpcPath = @"/MainSystem/B3ClientService/Rpcs/CarcassInStoreRpc/"; - public static bool DoWithPadData(long? workUnitID, long? productBatch) + static Dictionary _goodsNames = new Dictionary(); + public static List DoWithPadData(long? workUnitID, long? productBatch) { - bool changed = false; var json = RpcFacade.Call(RpcPath + "GetUnSyncPadData"); - var data = JsonConvert.DeserializeObject>(json).OrderBy(x => x.ID); + var data = JsonConvert.DeserializeObject>(json); + var list = new List(); + if (data.Count == 0) + return list; using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection)) { foreach (var item in data) { - if (UpdateIfExist(item, session)) - continue; - changed = true; - var entity = new CarcassInStore(); - entity.FromPad = true; - entity.WorkUnit_ID = workUnitID; - entity.ProductBatch_ID = productBatch; - entity.UserID = AppContext.Worker.ID; - entity.BarCode = item.BarCode; - entity.Goods_ID = item.Goods_ID; - session.Insert(entity); + var id = UpdateIfExist(item, session); + if (id.HasValue) + { + var exist = new CarcassInStore(); + list.Add(exist); + exist.ID = id.Value; + exist.Goods_ID = item.Goods_ID; + exist.Goods_Name = GetGoodsName(item.Goods_ID, session); + } + else + { + var entity = CreateCarcassInStore(item); + entity.WorkUnit_ID = workUnitID; + entity.ProductBatch_ID = productBatch; + entity.Goods_Name = GetGoodsName(item.Goods_ID, session); + session.Insert(entity); + list.Add(entity); + } } session.Commit(); } var backInfo = data.Select(x => new IDRowVersion { ID = x.ID, RowVersion = x.RowVersion }); RpcFacade.Call(RpcPath + "SetPadDataSync", JsonConvert.SerializeObject(backInfo)); - return changed; + return list; + } + + private static CarcassInStore CreateCarcassInStore(PadCarcassInStore item) + { + var entity = new CarcassInStore(); + entity.FromPad = true; + entity.UserID = AppContext.Worker.ID; + entity.BarCode = item.BarCode; + entity.Goods_ID = item.Goods_ID; + return entity; } - static bool UpdateIfExist(PadCarcassInStore data, IDmoSession session) + static string GetGoodsName(long id, IDmoSession session) + { + if (!_goodsNames.ContainsKey(id)) + { + var query = new DQueryDom(new JoinAlias(typeof(Goods))); + query.Columns.Add(DQSelectColumn.Field("Name")); + query.Where.Conditions.Add(DQCondition.EQ("ID", id)); + _goodsNames.Add(id, query.EExecuteScalar(session)); + } + return _goodsNames[id]; + } + + static long? UpdateIfExist(PadCarcassInStore data, IDmoSession session) { var query = new DQueryDom(new JoinAlias(typeof(CarcassInStore))); query.Columns.Add(DQSelectColumn.Field("ID")); query.Where.Conditions.Add(DQCondition.EQ("BarCode", data.BarCode)); var id = (long?)session.ExecuteScalar(query); if (id == null) - return false; + return null; Update(id.Value, "Goods_ID", data.Goods_ID, session); - return true; + return id.Value; } - public static void Update(long id, string fileName, object value, IDmoSession session) + static void Update(long id, string fileName, object value, IDmoSession session) { var update = new DQUpdateDom(typeof(CarcassInStore)); update.Where.Conditions.Add(DQCondition.EQ("ID", id)); @@ -67,6 +99,15 @@ namespace ButcherFactory.BO.LocalBL session.ExecuteNonQuery(update); } + public static void Update(long id, string fileName, object value) + { + using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection)) + { + Update(id, fileName, value, session); + session.Commit(); + } + } + public static long Insert(CarcassInStore entity) { using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection)) @@ -77,13 +118,13 @@ namespace ButcherFactory.BO.LocalBL } } - public static BindingList GetLocalDataWithState(bool submit) + public static BindingList GetLocalDataWithState(bool history) { var query = new DQueryDom(new JoinAlias(typeof(CarcassInStore))); query.Columns.Add(DQSelectColumn.Field("ID")); query.Columns.Add(DQSelectColumn.Field("BarCode")); query.Columns.Add(DQSelectColumn.Field("Goods_Name")); - if (submit) + if (history) { query.Columns.Add(DQSelectColumn.Field("Weight")); query.Columns.Add(DQSelectColumn.Field("BeforeWeight")); @@ -92,6 +133,7 @@ namespace ButcherFactory.BO.LocalBL } else query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("Weight"))); + query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); var result = new BindingList(); using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection)) { @@ -104,7 +146,7 @@ namespace ButcherFactory.BO.LocalBL entity.ID = (long)reader[0]; entity.BarCode = (string)reader[1]; entity.Goods_Name = (string)reader[2]; - if (submit) + if (history) { entity.Weight = (decimal)reader[3]; entity.BeforeWeight = (decimal?)reader[4]; diff --git a/ButcherFactory.BO/Rpcs/BaseInfoSyncRpc.cs b/ButcherFactory.BO/Rpcs/BaseInfoSyncRpc.cs index 5fc5783..bbc4127 100644 --- a/ButcherFactory.BO/Rpcs/BaseInfoSyncRpc.cs +++ b/ButcherFactory.BO/Rpcs/BaseInfoSyncRpc.cs @@ -71,6 +71,8 @@ namespace ButcherFactory.BO.Rpcs session.Insert(entity); foreach (var detail in entity.Details) session.Insert(detail); + foreach (var goods in entity.Goods) + session.AddUpdateOrInsert(goods); } } } diff --git a/ButcherFactory.BO/Utils/Extensions.cs b/ButcherFactory.BO/Utils/Extensions.cs index 35bafb8..20d9f6d 100644 --- a/ButcherFactory.BO/Utils/Extensions.cs +++ b/ButcherFactory.BO/Utils/Extensions.cs @@ -13,6 +13,29 @@ namespace ButcherFactory.BO { public static class Extensions { + public static object EExecuteScalar(this DQueryDom query, IDmoSession session) + { + return session.ExecuteScalar(query); + } + + public static object EExecuteScalar(this DQueryDom query) + { + using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection)) + { + return query.EExecuteScalar(session); + } + } + + public static T EExecuteScalar(this DQueryDom query, IDmoSession session) + { + return (T)query.EExecuteScalar(session); + } + + public static T EExecuteScalar(this DQueryDom query) + { + return (T)query.EExecuteScalar(); + } + public static Tuple EExecuteScalar(this DQueryDom query, IDmoSession session) { var list = query.EExecuteList(session); diff --git a/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.Designer.cs b/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.Designer.cs index 1714cc3..7886c49 100644 --- a/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.Designer.cs +++ b/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.Designer.cs @@ -31,37 +31,53 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CarcassInStoreForm)); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.closeBtn = new WinFormControl.UButton(); - this.uTimerLabel1 = new WinFormControl.UTimerLabel(); this.productBatchSelect = new System.Windows.Forms.ComboBox(); this.workUnitSelect = new System.Windows.Forms.ComboBox(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.closeBtn = new WinFormControl.UButton(); + this.uTimerLabel1 = new WinFormControl.UTimerLabel(); this.uScanPanel1 = new WinFormControl.UScanPanel(); this.netStateWatch1 = new WinFormControl.NetStateWatch(); this.uWeightControl1 = new WinFormControl.UWeightControl(); this.uLabel1 = new WinFormControl.ULabel(); this.uLabel2 = new WinFormControl.ULabel(); - this.splitContainer2 = new System.Windows.Forms.SplitContainer(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); this.historyDataGrid = new WinFormControl.UDataGridView(); this.uLabel4 = new WinFormControl.ULabel(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); this.needSubmitGrid = new WinFormControl.UDataGridView(); this.uLabel3 = new WinFormControl.ULabel(); + this.U_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.U_BarCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.U_Goods_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.U_Weight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.H_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.H_BarCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.H_Goods_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.H_Weight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.H_BeforeWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.H_Discont = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); this.splitContainer2.Panel1.SuspendLayout(); + this.splitContainer2.Panel2.SuspendLayout(); this.splitContainer2.SuspendLayout(); this.groupBox2.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.historyDataGrid)).BeginInit(); this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.historyDataGrid)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.needSubmitGrid)).BeginInit(); this.SuspendLayout(); // @@ -96,6 +112,84 @@ this.splitContainer1.SplitterDistance = 86; this.splitContainer1.TabIndex = 0; // + // productBatchSelect + // + this.productBatchSelect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.productBatchSelect.Font = new System.Drawing.Font("宋体", 15F); + this.productBatchSelect.FormattingEnabled = true; + this.productBatchSelect.Location = new System.Drawing.Point(843, 47); + this.productBatchSelect.Name = "productBatchSelect"; + this.productBatchSelect.Size = new System.Drawing.Size(170, 28); + this.productBatchSelect.TabIndex = 4; + // + // workUnitSelect + // + this.workUnitSelect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.workUnitSelect.Font = new System.Drawing.Font("宋体", 15F); + this.workUnitSelect.FormattingEnabled = true; + this.workUnitSelect.Location = new System.Drawing.Point(843, 11); + this.workUnitSelect.Name = "workUnitSelect"; + this.workUnitSelect.Size = new System.Drawing.Size(170, 28); + this.workUnitSelect.TabIndex = 3; + // + // splitContainer2 + // + this.splitContainer2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.splitContainer2.IsSplitterFixed = true; + this.splitContainer2.Location = new System.Drawing.Point(0, 0); + this.splitContainer2.Name = "splitContainer2"; + // + // splitContainer2.Panel1 + // + this.splitContainer2.Panel1.BackColor = System.Drawing.Color.Transparent; + this.splitContainer2.Panel1.Controls.Add(this.groupBox2); + this.splitContainer2.Panel1.Controls.Add(this.groupBox1); + // + // splitContainer2.Panel2 + // + this.splitContainer2.Panel2.BackColor = System.Drawing.Color.Transparent; + this.splitContainer2.Panel2.Controls.Add(this.flowLayoutPanel1); + this.splitContainer2.Size = new System.Drawing.Size(1164, 521); + this.splitContainer2.SplitterDistance = 840; + this.splitContainer2.TabIndex = 0; + // + // groupBox2 + // + this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox2.Controls.Add(this.historyDataGrid); + this.groupBox2.Controls.Add(this.uLabel4); + this.groupBox2.Location = new System.Drawing.Point(11, 254); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Padding = new System.Windows.Forms.Padding(5); + this.groupBox2.Size = new System.Drawing.Size(815, 254); + this.groupBox2.TabIndex = 1; + this.groupBox2.TabStop = false; + // + // groupBox1 + // + this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox1.Controls.Add(this.needSubmitGrid); + this.groupBox1.Controls.Add(this.uLabel3); + this.groupBox1.Location = new System.Drawing.Point(11, 15); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Padding = new System.Windows.Forms.Padding(5); + this.groupBox1.Size = new System.Drawing.Size(815, 226); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(318, 519); + this.flowLayoutPanel1.TabIndex = 0; + // // closeBtn // this.closeBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -113,6 +207,7 @@ this.closeBtn.TabIndex = 9; this.closeBtn.Text = "关 闭"; this.closeBtn.UseVisualStyleBackColor = true; + this.closeBtn.Click += new System.EventHandler(this.closeBtn_Click); // // uTimerLabel1 // @@ -120,33 +215,13 @@ this.uTimerLabel1.AutoSize = true; this.uTimerLabel1.BackColor = System.Drawing.Color.Transparent; this.uTimerLabel1.Font = new System.Drawing.Font("黑体", 12F); - this.uTimerLabel1.Format = "M月d日 H:m:ss"; + this.uTimerLabel1.Format = "M月d日 H:mm:ss"; this.uTimerLabel1.Location = new System.Drawing.Point(1024, 53); this.uTimerLabel1.Name = "uTimerLabel1"; this.uTimerLabel1.Size = new System.Drawing.Size(128, 16); this.uTimerLabel1.TabIndex = 8; this.uTimerLabel1.Text = "3月30日 8:54:07"; // - // productBatchSelect - // - this.productBatchSelect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.productBatchSelect.Font = new System.Drawing.Font("宋体", 15F); - this.productBatchSelect.FormattingEnabled = true; - this.productBatchSelect.Location = new System.Drawing.Point(843, 47); - this.productBatchSelect.Name = "productBatchSelect"; - this.productBatchSelect.Size = new System.Drawing.Size(170, 28); - this.productBatchSelect.TabIndex = 4; - // - // workUnitSelect - // - this.workUnitSelect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.workUnitSelect.Font = new System.Drawing.Font("宋体", 15F); - this.workUnitSelect.FormattingEnabled = true; - this.workUnitSelect.Location = new System.Drawing.Point(843, 11); - this.workUnitSelect.Name = "workUnitSelect"; - this.workUnitSelect.Size = new System.Drawing.Size(170, 28); - this.workUnitSelect.TabIndex = 3; - // // uScanPanel1 // this.uScanPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -197,42 +272,6 @@ this.uLabel2.TabIndex = 6; this.uLabel2.Text = "生产批次:"; // - // splitContainer2 - // - this.splitContainer2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; - this.splitContainer2.IsSplitterFixed = true; - this.splitContainer2.Location = new System.Drawing.Point(0, 0); - this.splitContainer2.Name = "splitContainer2"; - // - // splitContainer2.Panel1 - // - this.splitContainer2.Panel1.BackColor = System.Drawing.Color.Transparent; - this.splitContainer2.Panel1.Controls.Add(this.groupBox2); - this.splitContainer2.Panel1.Controls.Add(this.groupBox1); - // - // splitContainer2.Panel2 - // - this.splitContainer2.Panel2.BackColor = System.Drawing.Color.Transparent; - this.splitContainer2.Size = new System.Drawing.Size(1164, 521); - this.splitContainer2.SplitterDistance = 836; - this.splitContainer2.TabIndex = 0; - // - // groupBox2 - // - this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox2.Controls.Add(this.historyDataGrid); - this.groupBox2.Controls.Add(this.uLabel4); - this.groupBox2.Location = new System.Drawing.Point(11, 254); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Padding = new System.Windows.Forms.Padding(5); - this.groupBox2.Size = new System.Drawing.Size(811, 254); - this.groupBox2.TabIndex = 1; - this.groupBox2.TabStop = false; - // // historyDataGrid // this.historyDataGrid.AllowUserToAddRows = false; @@ -248,17 +287,25 @@ dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.historyDataGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; this.historyDataGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.historyDataGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.H_ID, + this.H_BarCode, + this.H_Goods_Name, + this.H_Weight, + this.H_BeforeWeight, + this.H_Discont}); this.historyDataGrid.Dock = System.Windows.Forms.DockStyle.Fill; this.historyDataGrid.Location = new System.Drawing.Point(5, 19); this.historyDataGrid.MultiSelect = false; this.historyDataGrid.Name = "historyDataGrid"; + this.historyDataGrid.ReadOnly = true; this.historyDataGrid.RowHeadersVisible = false; - dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.historyDataGrid.RowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.historyDataGrid.RowsDefaultCellStyle = dataGridViewCellStyle6; this.historyDataGrid.RowTemplate.Height = 23; this.historyDataGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.historyDataGrid.Size = new System.Drawing.Size(801, 230); + this.historyDataGrid.Size = new System.Drawing.Size(805, 230); this.historyDataGrid.TabIndex = 2; // // uLabel4 @@ -272,45 +319,38 @@ this.uLabel4.TabIndex = 1; this.uLabel4.Text = "已提交"; // - // groupBox1 - // - this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox1.Controls.Add(this.needSubmitGrid); - this.groupBox1.Controls.Add(this.uLabel3); - this.groupBox1.Location = new System.Drawing.Point(11, 15); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Padding = new System.Windows.Forms.Padding(5); - this.groupBox1.Size = new System.Drawing.Size(811, 226); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - // // needSubmitGrid // this.needSubmitGrid.AllowUserToAddRows = false; this.needSubmitGrid.AllowUserToDeleteRows = false; this.needSubmitGrid.AllowUserToResizeColumns = false; this.needSubmitGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.needSubmitGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.needSubmitGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle7; this.needSubmitGrid.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.White; - dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.needSubmitGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.needSubmitGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle8; this.needSubmitGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.needSubmitGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.U_ID, + this.U_BarCode, + this.U_Goods_Name, + this.U_Weight}); this.needSubmitGrid.Dock = System.Windows.Forms.DockStyle.Fill; this.needSubmitGrid.Location = new System.Drawing.Point(5, 19); this.needSubmitGrid.MultiSelect = false; this.needSubmitGrid.Name = "needSubmitGrid"; + this.needSubmitGrid.ReadOnly = true; this.needSubmitGrid.RowHeadersVisible = false; - dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.needSubmitGrid.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle10.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle10.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.needSubmitGrid.RowsDefaultCellStyle = dataGridViewCellStyle10; this.needSubmitGrid.RowTemplate.Height = 23; this.needSubmitGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.needSubmitGrid.Size = new System.Drawing.Size(801, 202); + this.needSubmitGrid.Size = new System.Drawing.Size(805, 202); this.needSubmitGrid.TabIndex = 1; // // uLabel3 @@ -324,6 +364,91 @@ this.uLabel3.TabIndex = 0; this.uLabel3.Text = "待提交"; // + // U_ID + // + this.U_ID.DataPropertyName = "ID"; + this.U_ID.HeaderText = "ID"; + this.U_ID.Name = "U_ID"; + this.U_ID.ReadOnly = true; + this.U_ID.Visible = false; + // + // U_BarCode + // + this.U_BarCode.DataPropertyName = "BarCode"; + this.U_BarCode.HeaderText = "条码"; + this.U_BarCode.Name = "U_BarCode"; + this.U_BarCode.ReadOnly = true; + this.U_BarCode.Width = 400; + // + // U_Goods_Name + // + this.U_Goods_Name.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.U_Goods_Name.DataPropertyName = "Goods_Name"; + this.U_Goods_Name.HeaderText = "产品名称"; + this.U_Goods_Name.Name = "U_Goods_Name"; + this.U_Goods_Name.ReadOnly = true; + // + // U_Weight + // + this.U_Weight.DataPropertyName = "Weight"; + dataGridViewCellStyle9.Format = "#0.######"; + this.U_Weight.DefaultCellStyle = dataGridViewCellStyle9; + this.U_Weight.HeaderText = "重量"; + this.U_Weight.Name = "U_Weight"; + this.U_Weight.ReadOnly = true; + this.U_Weight.Width = 200; + // + // H_ID + // + this.H_ID.DataPropertyName = "ID"; + this.H_ID.HeaderText = "序号"; + this.H_ID.Name = "H_ID"; + this.H_ID.ReadOnly = true; + this.H_ID.Width = 80; + // + // H_BarCode + // + this.H_BarCode.DataPropertyName = "BarCode"; + this.H_BarCode.HeaderText = "条码"; + this.H_BarCode.Name = "H_BarCode"; + this.H_BarCode.ReadOnly = true; + this.H_BarCode.Width = 250; + // + // H_Goods_Name + // + this.H_Goods_Name.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.H_Goods_Name.DataPropertyName = "Goods_Name"; + this.H_Goods_Name.HeaderText = "产品名称"; + this.H_Goods_Name.Name = "H_Goods_Name"; + this.H_Goods_Name.ReadOnly = true; + // + // H_Weight + // + this.H_Weight.DataPropertyName = "Weight"; + dataGridViewCellStyle3.Format = "#0.######"; + this.H_Weight.DefaultCellStyle = dataGridViewCellStyle3; + this.H_Weight.HeaderText = "入库重量"; + this.H_Weight.Name = "H_Weight"; + this.H_Weight.ReadOnly = true; + // + // H_BeforeWeight + // + this.H_BeforeWeight.DataPropertyName = "BeforeWeight"; + dataGridViewCellStyle4.Format = "#0.######"; + this.H_BeforeWeight.DefaultCellStyle = dataGridViewCellStyle4; + this.H_BeforeWeight.HeaderText = "胴体重量"; + this.H_BeforeWeight.Name = "H_BeforeWeight"; + this.H_BeforeWeight.ReadOnly = true; + // + // H_Discont + // + this.H_Discont.DataPropertyName = "Discont"; + dataGridViewCellStyle5.Format = "#0.######"; + this.H_Discont.DefaultCellStyle = dataGridViewCellStyle5; + this.H_Discont.HeaderText = "损耗"; + this.H_Discont.Name = "H_Discont"; + this.H_Discont.ReadOnly = true; + // // CarcassInStoreForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -341,13 +466,14 @@ ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); this.splitContainer2.Panel1.ResumeLayout(false); + this.splitContainer2.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); this.splitContainer2.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.historyDataGrid)).EndInit(); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.historyDataGrid)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.needSubmitGrid)).EndInit(); this.ResumeLayout(false); @@ -372,6 +498,17 @@ private WinFormControl.ULabel uLabel4; private WinFormControl.UDataGridView needSubmitGrid; private WinFormControl.UDataGridView historyDataGrid; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.DataGridViewTextBoxColumn U_ID; + private System.Windows.Forms.DataGridViewTextBoxColumn U_BarCode; + private System.Windows.Forms.DataGridViewTextBoxColumn U_Goods_Name; + private System.Windows.Forms.DataGridViewTextBoxColumn U_Weight; + private System.Windows.Forms.DataGridViewTextBoxColumn H_ID; + private System.Windows.Forms.DataGridViewTextBoxColumn H_BarCode; + private System.Windows.Forms.DataGridViewTextBoxColumn H_Goods_Name; + private System.Windows.Forms.DataGridViewTextBoxColumn H_Weight; + private System.Windows.Forms.DataGridViewTextBoxColumn H_BeforeWeight; + private System.Windows.Forms.DataGridViewTextBoxColumn H_Discont; } diff --git a/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs b/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs index d6075b7..15e04f2 100644 --- a/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs +++ b/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs @@ -11,44 +11,183 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ButcherFactory.Utils; +using ButcherFactory.BO.LocalBL; +using WinFormControl; +using System.Threading; namespace ButcherFactory.CarcassInStore_ { public partial class CarcassInStoreForm : Form, IWithRoleForm { + #region IWithRoleForm + + public List RoleName + { + get { return new List { (short)设备类别.白条入库 }; } + } + + public Form Generate() + { + return this; + } + + #endregion + + Thread syncPadTask; + Thread syncBeforeWeight; + Thread uploadData; + BindingList needSubmitedList; + BindingList historyList; public CarcassInStoreForm() { InitializeComponent(); netStateWatch1.GetConnectState = () => LoginUtil.TestConnection(500); + this.FormClosing += delegate + { + if (syncPadTask != null && syncPadTask.IsAlive) + syncPadTask.Abort(); + if (syncBeforeWeight != null && syncBeforeWeight.IsAlive) + syncBeforeWeight.Abort(); + if (uploadData != null && uploadData.IsAlive) + uploadData.Abort(); + }; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); - SyncBaseInfo(); + var initTask = new Thread(LoadBind); + initTask.Start(); + + syncPadTask = new Thread(SyncPadData); + syncPadTask.Start(); + + uWeightControl1.ReceivedValue += (weight) => + { + this.Invoke(new Action(() => + { + var last = needSubmitedList.LastOrDefault(); + if (last == null) + { + SoundPalyUtil.PlaySound(SoundType.Error); + return; + } + else + { + last.Weight = weight; + CarcassInStoreBL.Update(last.ID, "Weight", weight); + needSubmitedList.Remove(last); + needSubmitGrid.Refresh(); + historyList.Insert(0, last); + historyDataGrid.Refresh(); + SoundPalyUtil.PlaySound(SoundType.ShotSucc); + } + })); + }; } - void SyncBaseInfo() + void LoadBind() { - if (netStateWatch1.NetState) + this.Invoke(new Action(() => { - BaseInfoSyncRpc.SyncGoodsByTag(ApplyClient.白条出入库); - BaseInfoSyncRpc.SyncBaseInfo(); - BaseInfoSyncRpc.SyncBaseInfo(); + if (netStateWatch1.NetState) + { + BaseInfoSyncRpc.SyncGoodsByTag(ApplyClient.白条出入库); + BaseInfoSyncRpc.SyncBaseInfo(); + BaseInfoSyncRpc.SyncBaseInfo(); + } + workUnitSelect.EBindComboBox(); + productBatchSelect.EBindComboBox(); + + BindGoods(); + BindGrid(); + })); + } + + void BindGoods() + { + var goods = CarcassInStoreBL.GetGoodsList(); + foreach (var item in goods) + { + for (var i = 0; i < 10; i++) + { + var btn = new UButton() { Width = 90, Height = 50, Text = item.Goods_Name, Tag = item.ID, Font = new Font("宋体", 15), Margin = new Padding(8, 14, 8, 0), PlaySound = true }; + + flowLayoutPanel1.Controls.Add(btn); + } } + } - workUnitSelect.EBindComboBox(); - productBatchSelect.EBindComboBox(); + void BindGrid() + { + needSubmitedList = CarcassInStoreBL.GetLocalDataWithState(false); + needSubmitGrid.DataSource = needSubmitedList; + needSubmitGrid.Refresh(); + + historyList = CarcassInStoreBL.GetLocalDataWithState(true); + historyDataGrid.DataSource = historyList; + historyDataGrid.Refresh(); } - public List RoleName + void SyncPadData() { - get { return new List { (short)设备类别.白条入库 }; } + while (true) + { + if (this.IsHandleCreated) + { + this.Invoke(new Action(() => + { + if (netStateWatch1.NetState) + { + var list = CarcassInStoreBL.DoWithPadData((long?)workUnitSelect.SelectedValue, (long?)productBatchSelect.SelectedValue); + if (list.Any()) + { + bool n1 = false; + bool n2 = false; + foreach (var item in list) + { + if (string.IsNullOrEmpty(item.BarCode)) + { + var hf = historyList.FirstOrDefault(x => x.ID == item.ID); + if (hf != null) + { + hf.Goods_Name = item.Goods_Name; + n2 = true; + } + else + { + var uf = needSubmitedList.FirstOrDefault(x => x.ID == item.ID); + if (uf != null) + { + uf.Goods_Name = item.Goods_Name; + n1 = true; + } + } + } + else + { + needSubmitedList.Add(item); + var old = needSubmitedList.OrderByDescending(x => x.ID).ToList(); + needSubmitedList.Clear(); + old.ForEach(x => needSubmitedList.Add(x)); + n1 = true; + } + } + if (n1) + needSubmitGrid.Refresh(); + if (n2) + historyDataGrid.Refresh(); + } + } + })); + } + Thread.Sleep(2000); + } } - public Form Generate() + private void closeBtn_Click(object sender, EventArgs e) { - return this; + Close(); } } } diff --git a/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.resx b/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.resx index eee7b44..0d1ddbc 100644 --- a/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.resx +++ b/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.resx @@ -117,12 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True - - - True - @@ -132,52 +126,34 @@ KAgKgoKg1ZsPvpCB0hBohjQAAAAASUVORK5CYII= - - True - - - True - - - True - - - True - - - True - - - True - - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True \ No newline at end of file diff --git a/ButcherFactory.Login/Login.Designer.cs b/ButcherFactory.Login/Login.Designer.cs index 00f4f8f..74dcc83 100644 --- a/ButcherFactory.Login/Login.Designer.cs +++ b/ButcherFactory.Login/Login.Designer.cs @@ -69,6 +69,7 @@ // this.exitBtn.BackgroundImage = global::ButcherFactory.Login.Properties.Resources.cancelBtn; this.exitBtn.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.exitBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.exitBtn.FlatAppearance.BorderSize = 0; this.exitBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.exitBtn.Font = new System.Drawing.Font("黑体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); @@ -127,9 +128,11 @@ // // Login // + this.AcceptButton = this.loginBtn; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage"))); + this.CancelButton = this.exitBtn; this.ClientSize = new System.Drawing.Size(676, 385); this.Controls.Add(this.userNameBox); this.Controls.Add(this.pwdBox);