From bd3cfd613a2760addf088817c884b88e4ca8e6b6 Mon Sep 17 00:00:00 2001 From: luanhui <1029149336@qq.com> Date: Fri, 10 Nov 2017 17:45:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=20automapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BO/BO.csproj | 2 + BO/BO/Dtos/SyncBaseDto.cs | 16 ++ BO/BO/LocalSyncBase.cs | 3 + BO/BarCodeScan/BwpBarCodeUtil.cs | 47 +++++ BO/LocalDmoSession.cs | 2 + BO/SyncToServerBase.cs | 44 +++-- .../ButcherManageClient.csproj | 4 + ButcherManageClient/Program.cs | 6 + .../LocalSyncBO/TrunksIousOutInStoreRecord.cs | 13 ++ ...to.cs => TrunksIousOutInStoreRecordDto.cs} | 8 +- .../Rpc/TrunksIousOutInStoreRecordRpc.cs | 6 +- .../TrunksIousOutInStore.csproj | 5 +- .../TrunksIousOutInStoreForm.Designer.cs | 185 ++++++++++-------- .../TrunksIousOutInStoreForm.cs | 64 +++--- 14 files changed, 273 insertions(+), 132 deletions(-) create mode 100644 BO/BO/Dtos/SyncBaseDto.cs create mode 100644 BO/BarCodeScan/BwpBarCodeUtil.cs rename TrunksIousOutInStore/Rpc/{TrunksIousOutInStoreFormDto.cs => TrunksIousOutInStoreRecordDto.cs} (76%) diff --git a/BO/BO.csproj b/BO/BO.csproj index 91c7bcf..55f1f27 100644 --- a/BO/BO.csproj +++ b/BO/BO.csproj @@ -64,6 +64,7 @@ + @@ -85,6 +86,7 @@ + diff --git a/BO/BO/Dtos/SyncBaseDto.cs b/BO/BO/Dtos/SyncBaseDto.cs new file mode 100644 index 0000000..987650b --- /dev/null +++ b/BO/BO/Dtos/SyncBaseDto.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BO.BO.Dtos +{ + public class SyncBaseDto + { + public long? Service_ID { get; set; } + public long? Client_ID { get; set; } + public long? B3_ID { get; set; } + public string CreateUserName { get; set; } + } +} diff --git a/BO/BO/LocalSyncBase.cs b/BO/BO/LocalSyncBase.cs index 5e290e3..1cd7d99 100644 --- a/BO/BO/LocalSyncBase.cs +++ b/BO/BO/LocalSyncBase.cs @@ -11,6 +11,9 @@ namespace BO.BO [KeyField("ID", KeyGenType.identity)] public abstract class LocalSyncBase { + + public abstract string GetDtoJson(); + /// /// 本地自增ID /// diff --git a/BO/BarCodeScan/BwpBarCodeUtil.cs b/BO/BarCodeScan/BwpBarCodeUtil.cs new file mode 100644 index 0000000..383d80e --- /dev/null +++ b/BO/BarCodeScan/BwpBarCodeUtil.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BO.BarCodeScan +{ + public class BwpBarCodeUtil + { + /// + /// 根据按键获取字符串 + /// + /// + /// + public static string GetStringByKeyKeyEventArgs(KeyEventArgs e) + { + if (e.KeyData == (Keys.D7 | Keys.Shift)) + { + return "&"; + } + if (e.KeyData == (Keys.ProcessKey | Keys.Shift)) + { + return "&"; + } + + if (e.KeyData == (Keys.Oem2)) + { + return "/"; + } + if (e.KeyData == (Keys.Oem2 | Keys.Shift)) + { + return "?"; + } + + if (e.KeyData == (Keys.Oemplus)) + { + return "="; + } + + char keyvalue = (char)e.KeyValue; + var str = keyvalue.ToString(); + return str; + } + } +} diff --git a/BO/LocalDmoSession.cs b/BO/LocalDmoSession.cs index 7fde59f..2aa1cba 100644 --- a/BO/LocalDmoSession.cs +++ b/BO/LocalDmoSession.cs @@ -146,6 +146,8 @@ namespace BO // detail.Sync = false; update.Columns.Add(new DQUpdateColumn(p, type.GetProperty(p).GetValue(detail))); } + update.Columns.Add(new DQUpdateColumn("WillBeUpdated", true)); + session.ExecuteNonQuery(update); session.Commit(); } diff --git a/BO/SyncToServerBase.cs b/BO/SyncToServerBase.cs index d5df033..c646983 100644 --- a/BO/SyncToServerBase.cs +++ b/BO/SyncToServerBase.cs @@ -27,9 +27,16 @@ namespace BO { lock (lockSucessedObj) { - var forList = LocalDmoSession.GetNeedSyncList(); - //所有集合长度为0时 - return forList.WillInsertList.Count == 0 && forList.WillUpdateList.Count == 0 &&forList.WillDeleteList.Count == 0; + try + { + var forList = LocalDmoSession.GetNeedSyncList(); + //所有集合长度为0时 + return forList.WillInsertList.Count == 0 && forList.WillUpdateList.Count == 0 && forList.WillDeleteList.Count == 0; + } + catch (Exception e) + { + return false; + } } } @@ -37,27 +44,34 @@ namespace BO { lock (lockObj) { - var forList = LocalDmoSession.GetNeedSyncList(); - foreach (T record in forList.WillInsertList) + try { - Insert(record); - } + var forList = LocalDmoSession.GetNeedSyncList(); + foreach (T record in forList.WillInsertList) + { + Insert(record); + } - foreach (T record in forList.WillUpdateList) - { - Update(record); - } + foreach (T record in forList.WillUpdateList) + { + Update(record); + } - foreach (T record in forList.WillDeleteList) + foreach (T record in forList.WillDeleteList) + { + Delete(record); + } + } + catch (Exception e) { - Delete(record); + } } } private long Insert(T record) { - var json = JsonConvert.SerializeObject(record); + var json = record.GetDtoJson(); var serviceid = RpcFacade.Call(InsertRpcUrl, json); LocalDmoSession.UpdateAfterInsertSynced(record.ID, serviceid); return serviceid; @@ -65,7 +79,7 @@ namespace BO private void Update(T record) { - var json = JsonConvert.SerializeObject(record); + var json = record.GetDtoJson(); RpcFacade.Call(UpdateRpcUrl, json); LocalDmoSession.UpdateAfterUpdateSynced(record.ID); } diff --git a/ButcherManageClient/ButcherManageClient.csproj b/ButcherManageClient/ButcherManageClient.csproj index eba66e0..a3f0c23 100644 --- a/ButcherManageClient/ButcherManageClient.csproj +++ b/ButcherManageClient/ButcherManageClient.csproj @@ -35,6 +35,10 @@ pig [128x128].ico + + False + bin\Debug\AutoMapper.dll + False ..\..\..\..\BwpB3Project\tsref\Debug\Forks.JsonRpc.Client.dll diff --git a/ButcherManageClient/Program.cs b/ButcherManageClient/Program.cs index f2421d2..1386230 100644 --- a/ButcherManageClient/Program.cs +++ b/ButcherManageClient/Program.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; +using AutoMapper; namespace ButcherManageClient { @@ -32,6 +33,11 @@ namespace ButcherManageClient } else { +// Mapper.Initialize(cfg => { +// cfg.AddProfile(); +// cfg.CreateMap(); +// }); + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Login()); diff --git a/TrunksIousOutInStore/LocalSyncBO/TrunksIousOutInStoreRecord.cs b/TrunksIousOutInStore/LocalSyncBO/TrunksIousOutInStoreRecord.cs index 8b50f03..7858671 100644 --- a/TrunksIousOutInStore/LocalSyncBO/TrunksIousOutInStoreRecord.cs +++ b/TrunksIousOutInStore/LocalSyncBO/TrunksIousOutInStoreRecord.cs @@ -1,6 +1,9 @@ using System; +using AutoMapper; using BO.BO; using Forks.EnterpriseServices.DomainObjects2; +using Newtonsoft.Json; +using TrunksIousOutInStore.Rpc; namespace TrunksIousOutInStore.LocalSyncBO { @@ -23,6 +26,16 @@ namespace TrunksIousOutInStore.LocalSyncBO public decimal? Weight { get; set; } public string CarcassStatus{ get; set; }// 胴体状态 + public override string GetDtoJson() + { + var config = new MapperConfiguration(cfg => { + cfg.CreateMap(); + }); + var mapper = config.CreateMapper(); + var dto = mapper.Map(this); + dto.Client_ID = this.ID; + return JsonConvert.SerializeObject(dto); + } } public class CarcassStatus diff --git a/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreFormDto.cs b/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordDto.cs similarity index 76% rename from TrunksIousOutInStore/Rpc/TrunksIousOutInStoreFormDto.cs rename to TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordDto.cs index ad876e8..1a9e31e 100644 --- a/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreFormDto.cs +++ b/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordDto.cs @@ -1,8 +1,10 @@ -namespace TrunksIousOutInStore.Rpc +using BO.BO.Dtos; + +namespace TrunksIousOutInStore.Rpc { - public class TrunksIousOutInStoreFormDto + public class TrunksIousOutInStoreRecordDto: SyncBaseDto { - public long ID { get; set; } + public string BarCode { get; set; } public string Goods_Name { get; set; } public string Goods_Spec { get; set; } diff --git a/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordRpc.cs b/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordRpc.cs index 5ba9dd7..05ecc40 100644 --- a/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordRpc.cs +++ b/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordRpc.cs @@ -45,17 +45,17 @@ namespace TrunksIousOutInStore.Rpc protected override string InsertRpcUrl { - get { return ""; } + get { return "/MainSystem/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc/Insert"; } } protected override string UpdateRpcUrl { - get { return ""; } + get { return "/MainSystem/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc/Update"; } } protected override string DeleteRpcUrl { - get { return ""; } + get { return "/MainSystem/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc/Delete"; } } } diff --git a/TrunksIousOutInStore/TrunksIousOutInStore.csproj b/TrunksIousOutInStore/TrunksIousOutInStore.csproj index f7ab903..f10e268 100644 --- a/TrunksIousOutInStore/TrunksIousOutInStore.csproj +++ b/TrunksIousOutInStore/TrunksIousOutInStore.csproj @@ -33,6 +33,9 @@ false + + ..\ButcherManageClient\bin\Debug\AutoMapper.dll + False ..\..\..\tsref\Debug\Forks.EnterpriseServices.dll @@ -62,7 +65,7 @@ - + diff --git a/TrunksIousOutInStore/TrunksIousOutInStoreForm.Designer.cs b/TrunksIousOutInStore/TrunksIousOutInStoreForm.Designer.cs index b89958f..5a090a1 100644 --- a/TrunksIousOutInStore/TrunksIousOutInStoreForm.Designer.cs +++ b/TrunksIousOutInStore/TrunksIousOutInStoreForm.Designer.cs @@ -51,23 +51,24 @@ this.splitContainer3 = new System.Windows.Forms.SplitContainer(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.gridChecked = new BWP.WinFormControl.UDataGridView(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.gridUnCheck = new System.Windows.Forms.DataGridView(); - this.flpGoods = new System.Windows.Forms.FlowLayoutPanel(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.timerChectNetStatus = new System.Windows.Forms.Timer(this.components); - this.timerSyncToService = new System.Windows.Forms.Timer(this.components); - this.timerCheckSyncSucessed = new System.Windows.Forms.Timer(this.components); this.序号 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.条码 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.产品名称 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.数量 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.重量 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.gridUnCheck = new System.Windows.Forms.DataGridView(); this.uncheck序号 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uncheck条码 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uncheck产品名称 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uncheck数量 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uncheck重量 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.flpClass = new System.Windows.Forms.FlowLayoutPanel(); + this.flpGoods = new System.Windows.Forms.FlowLayoutPanel(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.timerChectNetStatus = new System.Windows.Forms.Timer(this.components); + this.timerSyncToService = new System.Windows.Forms.Timer(this.components); + this.timerCheckSyncSucessed = new System.Windows.Forms.Timer(this.components); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -116,8 +117,6 @@ this.panel1.Controls.Add(this.enableWeight); this.panel1.Controls.Add(this.panel2); this.panel1.Controls.Add(this.btnWeightSet); - this.panel1.Controls.Add(this.btnSycnStatus); - this.panel1.Controls.Add(this.btnNetStatus); this.panel1.Location = new System.Drawing.Point(11, 3); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(1251, 100); @@ -171,9 +170,9 @@ // this.btnSycnStatus.Enabled = false; this.btnSycnStatus.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnSycnStatus.Location = new System.Drawing.Point(655, 28); + this.btnSycnStatus.Location = new System.Drawing.Point(61, 83); this.btnSycnStatus.Name = "btnSycnStatus"; - this.btnSycnStatus.Size = new System.Drawing.Size(114, 46); + this.btnSycnStatus.Size = new System.Drawing.Size(120, 46); this.btnSycnStatus.TabIndex = 0; this.btnSycnStatus.Text = "同步完成"; this.btnSycnStatus.UseVisualStyleBackColor = true; @@ -182,7 +181,7 @@ // this.btnNetStatus.Enabled = false; this.btnNetStatus.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnNetStatus.Location = new System.Drawing.Point(450, 28); + this.btnNetStatus.Location = new System.Drawing.Point(61, 14); this.btnNetStatus.Name = "btnNetStatus"; this.btnNetStatus.Size = new System.Drawing.Size(120, 46); this.btnNetStatus.TabIndex = 0; @@ -201,7 +200,9 @@ this.splitContainer2.Panel1.Controls.Add(this.cbxBaiTiaoStatus); this.splitContainer2.Panel1.Controls.Add(this.label2); this.splitContainer2.Panel1.Controls.Add(this.btnCreateBill); + this.splitContainer2.Panel1.Controls.Add(this.btnSycnStatus); this.splitContainer2.Panel1.Controls.Add(this.btnSubmit); + this.splitContainer2.Panel1.Controls.Add(this.btnNetStatus); // // splitContainer2.Panel2 // @@ -221,7 +222,7 @@ "分割领用", "入销售库", "销售出库"}); - this.cbxBaiTiaoStatus.Location = new System.Drawing.Point(45, 144); + this.cbxBaiTiaoStatus.Location = new System.Drawing.Point(41, 197); this.cbxBaiTiaoStatus.Name = "cbxBaiTiaoStatus"; this.cbxBaiTiaoStatus.Size = new System.Drawing.Size(167, 35); this.cbxBaiTiaoStatus.TabIndex = 34; @@ -230,7 +231,7 @@ // this.label2.AutoSize = true; this.label2.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(45, 117); + this.label2.Location = new System.Drawing.Point(41, 170); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(106, 24); this.label2.TabIndex = 1; @@ -239,7 +240,7 @@ // btnCreateBill // this.btnCreateBill.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnCreateBill.Location = new System.Drawing.Point(45, 368); + this.btnCreateBill.Location = new System.Drawing.Point(41, 275); this.btnCreateBill.Name = "btnCreateBill"; this.btnCreateBill.Size = new System.Drawing.Size(156, 46); this.btnCreateBill.TabIndex = 0; @@ -250,7 +251,7 @@ // btnSubmit // this.btnSubmit.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnSubmit.Location = new System.Drawing.Point(45, 259); + this.btnSubmit.Location = new System.Drawing.Point(45, 451); this.btnSubmit.Name = "btnSubmit"; this.btnSubmit.Size = new System.Drawing.Size(156, 46); this.btnSubmit.TabIndex = 0; @@ -272,6 +273,7 @@ // // splitContainer3.Panel2 // + this.splitContainer3.Panel2.Controls.Add(this.flpClass); this.splitContainer3.Panel2.Controls.Add(this.flpGoods); this.splitContainer3.Size = new System.Drawing.Size(1015, 610); this.splitContainer3.SplitterDistance = 726; @@ -329,6 +331,43 @@ this.gridChecked.Size = new System.Drawing.Size(693, 320); this.gridChecked.TabIndex = 4; // + // 序号 + // + this.序号.DataPropertyName = "ID"; + this.序号.HeaderText = "序号"; + this.序号.Name = "序号"; + this.序号.ReadOnly = true; + // + // 条码 + // + this.条码.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.条码.DataPropertyName = "BarCode"; + this.条码.HeaderText = "条码"; + this.条码.Name = "条码"; + this.条码.ReadOnly = true; + // + // 产品名称 + // + this.产品名称.DataPropertyName = "Goods_Name"; + this.产品名称.HeaderText = "产品名称"; + this.产品名称.Name = "产品名称"; + this.产品名称.ReadOnly = true; + this.产品名称.Width = 120; + // + // 数量 + // + this.数量.DataPropertyName = "Number"; + this.数量.HeaderText = "数量"; + this.数量.Name = "数量"; + this.数量.ReadOnly = true; + // + // 重量 + // + this.重量.DataPropertyName = "Weight"; + this.重量.HeaderText = "重量"; + this.重量.Name = "重量"; + this.重量.ReadOnly = true; + // // groupBox1 // this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -379,74 +418,6 @@ this.gridUnCheck.Size = new System.Drawing.Size(699, 200); this.gridUnCheck.TabIndex = 3; // - // flpGoods - // - this.flpGoods.Dock = System.Windows.Forms.DockStyle.Fill; - this.flpGoods.Location = new System.Drawing.Point(0, 0); - this.flpGoods.Name = "flpGoods"; - this.flpGoods.Size = new System.Drawing.Size(286, 608); - this.flpGoods.TabIndex = 0; - // - // timer1 - // - this.timer1.Enabled = true; - this.timer1.Interval = 3000; - this.timer1.Tick += new System.EventHandler(this.timer1_Tick); - // - // timerChectNetStatus - // - this.timerChectNetStatus.Enabled = true; - this.timerChectNetStatus.Interval = 2000; - this.timerChectNetStatus.Tick += new System.EventHandler(this.timerChectNetStatus_Tick); - // - // timerSyncToService - // - this.timerSyncToService.Interval = 5000; - this.timerSyncToService.Tick += new System.EventHandler(this.timerSyncToService_Tick); - // - // timerCheckSyncSucessed - // - this.timerCheckSyncSucessed.Enabled = true; - this.timerCheckSyncSucessed.Interval = 4000; - this.timerCheckSyncSucessed.Tick += new System.EventHandler(this.timerCheckSyncSucessed_Tick); - // - // 序号 - // - this.序号.DataPropertyName = "ID"; - this.序号.HeaderText = "序号"; - this.序号.Name = "序号"; - this.序号.ReadOnly = true; - // - // 条码 - // - this.条码.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.条码.DataPropertyName = "BarCode"; - this.条码.HeaderText = "条码"; - this.条码.Name = "条码"; - this.条码.ReadOnly = true; - // - // 产品名称 - // - this.产品名称.DataPropertyName = "Goods_Name"; - this.产品名称.HeaderText = "产品名称"; - this.产品名称.Name = "产品名称"; - this.产品名称.ReadOnly = true; - this.产品名称.Width = 120; - // - // 数量 - // - this.数量.DataPropertyName = "Number"; - this.数量.HeaderText = "数量"; - this.数量.Name = "数量"; - this.数量.ReadOnly = true; - // - // 重量 - // - this.重量.DataPropertyName = "Weight"; - this.重量.HeaderText = "重量"; - this.重量.Name = "重量"; - this.重量.ReadOnly = true; - // // uncheck序号 // this.uncheck序号.DataPropertyName = "ID"; @@ -485,6 +456,51 @@ this.uncheck重量.Name = "uncheck重量"; this.uncheck重量.ReadOnly = true; // + // flpClass + // + this.flpClass.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.flpClass.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.flpClass.Location = new System.Drawing.Point(3, 11); + this.flpClass.Name = "flpClass"; + this.flpClass.Size = new System.Drawing.Size(283, 76); + this.flpClass.TabIndex = 1; + // + // flpGoods + // + this.flpGoods.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.flpGoods.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.flpGoods.Location = new System.Drawing.Point(0, 117); + this.flpGoods.Name = "flpGoods"; + this.flpGoods.Size = new System.Drawing.Size(289, 491); + this.flpGoods.TabIndex = 0; + // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Interval = 3000; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // timerChectNetStatus + // + this.timerChectNetStatus.Enabled = true; + this.timerChectNetStatus.Interval = 2000; + this.timerChectNetStatus.Tick += new System.EventHandler(this.timerChectNetStatus_Tick); + // + // timerSyncToService + // + this.timerSyncToService.Enabled = true; + this.timerSyncToService.Interval = 5000; + this.timerSyncToService.Tick += new System.EventHandler(this.timerSyncToService_Tick); + // + // timerCheckSyncSucessed + // + this.timerCheckSyncSucessed.Enabled = true; + this.timerCheckSyncSucessed.Interval = 4000; + this.timerCheckSyncSucessed.Tick += new System.EventHandler(this.timerCheckSyncSucessed_Tick); + // // TrunksIousOutInStoreForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -561,5 +577,6 @@ private System.Windows.Forms.DataGridViewTextBoxColumn uncheck产品名称; private System.Windows.Forms.DataGridViewTextBoxColumn uncheck数量; private System.Windows.Forms.DataGridViewTextBoxColumn uncheck重量; + private System.Windows.Forms.FlowLayoutPanel flpClass; } } \ No newline at end of file diff --git a/TrunksIousOutInStore/TrunksIousOutInStoreForm.cs b/TrunksIousOutInStore/TrunksIousOutInStoreForm.cs index 383b401..74b7ba5 100644 --- a/TrunksIousOutInStore/TrunksIousOutInStoreForm.cs +++ b/TrunksIousOutInStore/TrunksIousOutInStoreForm.cs @@ -28,7 +28,7 @@ namespace TrunksIousOutInStore private readonly string ClientGoodsSetApplyClient = "白条出入库"; public const string DATA_PATH = "LocalData/TrunksIousOutInStore"; - // BardCodeHooK BarCode = new BardCodeHooK(); +// BardCodeHooK BarCode = new BardCodeHooK(); #region weightNeed SerialPort weightPort; @@ -57,7 +57,7 @@ namespace TrunksIousOutInStore // syncToServer.Abort(); }; - // BarCode.BarCodeEvent += new BardCodeHooK.BardCodeDeletegate(BarCode_BarCodeEvent); +// BarCode.BarCodeEvent += new BardCodeHooK.BardCodeDeletegate(BarCode_BarCodeEvent); if (!Directory.Exists(DATA_PATH)) { @@ -80,15 +80,10 @@ namespace TrunksIousOutInStore { if (barCode.IsValid) { - // using (var sw=new StreamWriter("d:\\1122.txt",true)) - // { - // sw.Write(barCode.BarCode); - // } - // MessageBox.Show(barCode.BarCode); - // MessageBox.Show(barCode.OriginalBarCode); - var code = UrlUtil.GetBarCode(barCode.BarCode.Trim()); - var goodsName = UrlUtil.GetGoodsName(barCode.BarCode); - doInsertUnSubmit(code, goodsName, null); +// var code = UrlUtil.GetBarCode(barCode.BarCode.Trim()); +// var goodsName = UrlUtil.GetGoodsName(barCode.BarCode); +var code = barCode.BarCode.Trim(); + doInsertUnSubmit(code, "", null); } } } @@ -391,7 +386,7 @@ namespace TrunksIousOutInStore private void TrunksIousOutInStoreForm_Load(object sender, EventArgs e) { - // BarCode.Start(); +// BarCode.Start(); InitLocalList(); @@ -402,12 +397,34 @@ namespace TrunksIousOutInStore private void InitGoodsControl() { + flpClass.Controls.Clear(); + foreach (IGrouping grouping in mLocaList.Where(x=>!string.IsNullOrWhiteSpace(x.Name)).GroupBy(x=>x.Name)) + { + var btn = CreateClassButton(grouping.Key); + flpClass.Controls.Add(btn); + } + } + + private Button CreateClassButton(string text) + { + var btn = new Button(){Text = text}; + btn.Width = 100; + btn.Height = 60; + btn.Click += BtnClass_Click; + return btn; + } + + private void BtnClass_Click(object sender, EventArgs e) + { + var btnClass = sender as Button; flpGoods.Controls.Clear(); - foreach (TrunksIousOutInStoreClientGoodsSet set in mLocaList) + foreach (TrunksIousOutInStoreClientGoodsSet set in mLocaList.Where(x=>x.Name== btnClass.Text)) { var btn = CreateGoodsSetButton(set); flpGoods.Controls.Add(btn); } + GridUnCheckFocus(); + Application.DoEvents(); } private Button CreateGoodsSetButton(TrunksIousOutInStoreClientGoodsSet set) @@ -529,11 +546,10 @@ namespace TrunksIousOutInStore private void TrunksIousOutInStoreForm_FormClosed(object sender, FormClosedEventArgs e) { - // BarCode.Stop(); +// BarCode.Stop(); } - #region 检查网络畅通 private void timerChectNetStatus_Tick(object sender, EventArgs e) { @@ -600,20 +616,15 @@ namespace TrunksIousOutInStore } BwpBarCodes barCodes = new BwpBarCodes(); + private void TrunksIousOutInStoreForm_KeyDown(object sender, KeyEventArgs e) { - - TimeSpan ts = DateTime.Now.Subtract(barCodes.Time); - - char keyvalue = (char) e.KeyValue; - var str = keyvalue.ToString(); - if (e.Shift) + if (e.KeyData == (Keys.ShiftKey | Keys.Shift)) { - if (e.KeyValue == 16) - { - str = ":"; - } + return; } + TimeSpan ts = DateTime.Now.Subtract(barCodes.Time); + var str = BwpBarCodeUtil.GetStringByKeyKeyEventArgs(e); barCodes.StringBuilder.Append(str); if (ts.TotalMilliseconds < 50) @@ -631,7 +642,8 @@ namespace TrunksIousOutInStore { - MessageBox.Show(barCodes.BarCode); +// MessageBox.Show(barCodes.BarCode); + doInsertUnSubmit(barCodes.BarCode, "", null); barCodes.StringBuilder = new StringBuilder(); } }