diff --git a/B3ButcherManageClient.sln b/B3ButcherManageClient.sln index db2de42..8a12bf7 100644 --- a/B3ButcherManageClient.sln +++ b/B3ButcherManageClient.sln @@ -31,6 +31,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SegmentationWeight", "Segme EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SegmentationInStore", "SegmentationInStore\SegmentationInStore.csproj", "{7528B945-C2CC-4266-83BD-D2214140C4BD}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ByProductWeight", "ByProductWeight\ByProductWeight.csproj", "{C5696A7D-0BEB-474A-A478-FD0543E72ABF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -91,6 +93,10 @@ Global {7528B945-C2CC-4266-83BD-D2214140C4BD}.Debug|Any CPU.Build.0 = Debug|Any CPU {7528B945-C2CC-4266-83BD-D2214140C4BD}.Release|Any CPU.ActiveCfg = Release|Any CPU {7528B945-C2CC-4266-83BD-D2214140C4BD}.Release|Any CPU.Build.0 = Release|Any CPU + {C5696A7D-0BEB-474A-A478-FD0543E72ABF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5696A7D-0BEB-474A-A478-FD0543E72ABF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5696A7D-0BEB-474A-A478-FD0543E72ABF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5696A7D-0BEB-474A-A478-FD0543E72ABF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ByProductWeight/ByProductWeight.csproj b/ByProductWeight/ByProductWeight.csproj new file mode 100644 index 0000000..f61ef12 --- /dev/null +++ b/ByProductWeight/ByProductWeight.csproj @@ -0,0 +1,109 @@ + + + + + Debug + AnyCPU + {C5696A7D-0BEB-474A-A478-FD0543E72ABF} + Library + Properties + ByProductWeight + ByProductWeight + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\tsref\Debug\Forks.JsonRpc.Client.dll + + + False + ..\..\..\tsref\Debug\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + Form + + + ByProductWeightForm.cs + + + + Form + + + ByProductWeightGoodsSetForm.cs + + + + + + Form + + + WeightSettingFrom.cs + + + + + + + + ByProductWeightForm.cs + + + ByProductWeightGoodsSetForm.cs + + + WeightSettingFrom.cs + + + + + {8968f14a-c7c7-4751-96ce-b114fbfd65ef} + BO + + + {a782b23e-be6d-4f51-b5cb-5cd259ba97cc} + BWP.WinFormControl + + + + + \ No newline at end of file diff --git a/ByProductWeight/ByProductWeightContext.cs b/ByProductWeight/ByProductWeightContext.cs new file mode 100644 index 0000000..a81b007 --- /dev/null +++ b/ByProductWeight/ByProductWeightContext.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using BO.Utils; + +namespace ByProductWeight +{ + + public static class ByProductWeightContext + { + private static string loginConfigPath = Application.StartupPath + "\\ByProductWeightConfig.xml"; + private static ByProductWeightConfig _config; + public static ByProductWeightConfig Config + { + get + { + if (_config == null) + _config = CreateConfig(); + return _config; + } + } + static ByProductWeightConfig CreateConfig() + { + var config = new ByProductWeightConfig(); + if (!File.Exists(loginConfigPath)) + { + XmlUtil.SerializerObjToFile(config, loginConfigPath); + } + else + config = XmlUtil.DeserializeFromFile(loginConfigPath); + return config; + } + + public static void Save() + { + if (string.IsNullOrEmpty(_config.WeightSet)) + throw new Exception("请选择称型号"); + if (string.IsNullOrEmpty(_config.ComSet)) + throw new Exception("请选择Com口"); + if (_config.RateSet == null) + throw new Exception("请选择波特率"); + if (_config.BitSet == null) + throw new Exception("请选择数据位"); + if (string.IsNullOrEmpty(_config.Format)) + throw new Exception("请填写显示格式"); + try + { + string.Format("{0:" + _config.Format + "}", 1); + } + catch (Exception ex) + { + throw new Exception("显示格式填写错误\n" + ex.Message); + } + XmlUtil.SerializerObjToFile(_config, loginConfigPath); + } + } + + public class ByProductWeightConfig + { + public string WeightSet { get; set; } + + public string ComSet { get; set; } + + public int? RateSet { get; set; } + + public int? BitSet { get; set; } + + public string Format { get; set; } + + public decimal? Discont { get; set; } + + public int WeightType { get; set; } + + public decimal MinWeight { get; set; } + + public decimal MaxWeight { get; set; } + } +} diff --git a/ByProductWeight/ByProductWeightForm.Designer.cs b/ByProductWeight/ByProductWeightForm.Designer.cs new file mode 100644 index 0000000..cc17053 --- /dev/null +++ b/ByProductWeight/ByProductWeightForm.Designer.cs @@ -0,0 +1,478 @@ +namespace ByProductWeight +{ + partial class ByProductWeightForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.lblGoodsName = new System.Windows.Forms.Label(); + this.lblWeight = new System.Windows.Forms.Label(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.lblNumber = new System.Windows.Forms.Label(); + 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.flpGoods = new System.Windows.Forms.FlowLayoutPanel(); + this.flpClass = new System.Windows.Forms.FlowLayoutPanel(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); + this.btnWeightSet = new System.Windows.Forms.Button(); + this.lblChengZhong = new System.Windows.Forms.Label(); + this.btnGoodsSet = new System.Windows.Forms.Button(); + this.enableWeight = new System.Windows.Forms.CheckBox(); + this.panel2 = new System.Windows.Forms.Panel(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.panel1 = new System.Windows.Forms.Panel(); + this.uDataGridView1 = new BWP.WinFormControl.UDataGridView(); + this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.tableLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); + this.splitContainer2.Panel1.SuspendLayout(); + this.splitContainer2.Panel2.SuspendLayout(); + this.splitContainer2.SuspendLayout(); + this.panel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.uDataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // label1 + // + this.label1.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.label1.Location = new System.Drawing.Point(4, 1); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(274, 50); + this.label1.TabIndex = 0; + this.label1.Text = "产品"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label2 + // + this.label2.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.label2.Location = new System.Drawing.Point(285, 1); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(139, 50); + this.label2.TabIndex = 0; + this.label2.Text = "数量"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label3 + // + this.label3.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.label3.Location = new System.Drawing.Point(431, 1); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(83, 50); + this.label3.TabIndex = 0; + this.label3.Text = "重量"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lblGoodsName + // + this.lblGoodsName.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.lblGoodsName.Location = new System.Drawing.Point(4, 52); + this.lblGoodsName.Name = "lblGoodsName"; + this.lblGoodsName.Size = new System.Drawing.Size(274, 45); + this.lblGoodsName.TabIndex = 0; + this.lblGoodsName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lblWeight + // + this.lblWeight.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.lblWeight.Location = new System.Drawing.Point(431, 52); + this.lblWeight.Name = "lblWeight"; + this.lblWeight.Size = new System.Drawing.Size(83, 45); + this.lblWeight.TabIndex = 0; + this.lblWeight.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanel1.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; + this.tableLayoutPanel1.ColumnCount = 3; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 65.90909F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 34.09091F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 88F)); + this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.label2, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.label3, 2, 0); + this.tableLayoutPanel1.Controls.Add(this.lblGoodsName, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.lblNumber, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.lblWeight, 2, 1); + this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 4); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 2; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 53.57143F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 46.42857F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(518, 98); + this.tableLayoutPanel1.TabIndex = 0; + // + // lblNumber + // + this.lblNumber.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.lblNumber.Location = new System.Drawing.Point(285, 52); + this.lblNumber.Name = "lblNumber"; + this.lblNumber.Size = new System.Drawing.Size(139, 45); + this.lblNumber.TabIndex = 0; + this.lblNumber.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // 毛重 + // + this.毛重.DataPropertyName = "MaoWeight"; + this.毛重.HeaderText = "毛重"; + this.毛重.Name = "毛重"; + this.毛重.ReadOnly = true; + this.毛重.Width = 80; + // + // 净重 + // + this.净重.DataPropertyName = "JingWeight"; + this.净重.HeaderText = "净重"; + this.净重.Name = "净重"; + this.净重.ReadOnly = true; + this.净重.Width = 80; + // + // 产品 + // + this.产品.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.产品.DataPropertyName = "Goods_Name"; + this.产品.HeaderText = "产品"; + this.产品.MinimumWidth = 100; + this.产品.Name = "产品"; + this.产品.ReadOnly = true; + // + // 条码 + // + this.条码.DataPropertyName = "BarCode"; + this.条码.HeaderText = "条码"; + this.条码.Name = "条码"; + this.条码.ReadOnly = true; + // + // 序号 + // + this.序号.DataPropertyName = "ID"; + this.序号.HeaderText = "序号"; + this.序号.Name = "序号"; + this.序号.ReadOnly = true; + this.序号.Width = 80; + // + // 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(4, 87); + this.flpGoods.Name = "flpGoods"; + this.flpGoods.Size = new System.Drawing.Size(494, 395); + this.flpGoods.TabIndex = 1; + // + // 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(4, 4); + this.flpClass.Name = "flpClass"; + this.flpClass.Size = new System.Drawing.Size(494, 76); + this.flpClass.TabIndex = 0; + // + // splitContainer2 + // + this.splitContainer2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer2.Location = new System.Drawing.Point(0, 0); + this.splitContainer2.Name = "splitContainer2"; + // + // splitContainer2.Panel1 + // + this.splitContainer2.Panel1.Controls.Add(this.flpGoods); + this.splitContainer2.Panel1.Controls.Add(this.flpClass); + // + // splitContainer2.Panel2 + // + this.splitContainer2.Panel2.Controls.Add(this.uDataGridView1); + this.splitContainer2.Panel2.Controls.Add(this.tableLayoutPanel1); + this.splitContainer2.Size = new System.Drawing.Size(1041, 487); + this.splitContainer2.SplitterDistance = 515; + this.splitContainer2.SplitterWidth = 1; + this.splitContainer2.TabIndex = 0; + // + // btnWeightSet + // + this.btnWeightSet.Font = new System.Drawing.Font("宋体", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnWeightSet.Location = new System.Drawing.Point(249, 53); + this.btnWeightSet.Name = "btnWeightSet"; + this.btnWeightSet.Size = new System.Drawing.Size(111, 33); + this.btnWeightSet.TabIndex = 0; + this.btnWeightSet.Text = "称设置"; + this.btnWeightSet.UseVisualStyleBackColor = true; + this.btnWeightSet.Click += new System.EventHandler(this.btnWeightSet_Click); + // + // lblChengZhong + // + this.lblChengZhong.AutoSize = true; + this.lblChengZhong.Font = new System.Drawing.Font("宋体", 30F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.lblChengZhong.ForeColor = System.Drawing.Color.Red; + this.lblChengZhong.Location = new System.Drawing.Point(15, 18); + this.lblChengZhong.Name = "lblChengZhong"; + this.lblChengZhong.Size = new System.Drawing.Size(97, 40); + this.lblChengZhong.TabIndex = 0; + this.lblChengZhong.Text = "0.00"; + // + // btnGoodsSet + // + this.btnGoodsSet.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnGoodsSet.Location = new System.Drawing.Point(427, 23); + this.btnGoodsSet.Name = "btnGoodsSet"; + this.btnGoodsSet.Size = new System.Drawing.Size(114, 63); + this.btnGoodsSet.TabIndex = 34; + this.btnGoodsSet.Text = "产品设置"; + this.btnGoodsSet.UseVisualStyleBackColor = true; + this.btnGoodsSet.Click += new System.EventHandler(this.btnGoodsSet_Click); + // + // enableWeight + // + this.enableWeight.AutoCheck = false; + this.enableWeight.AutoSize = true; + this.enableWeight.Font = new System.Drawing.Font("宋体", 18F); + this.enableWeight.Location = new System.Drawing.Point(249, 8); + this.enableWeight.Name = "enableWeight"; + this.enableWeight.Size = new System.Drawing.Size(125, 28); + this.enableWeight.TabIndex = 33; + this.enableWeight.Text = "启用称重"; + this.enableWeight.UseVisualStyleBackColor = true; + this.enableWeight.Click += new System.EventHandler(this.enableWeight_Click); + // + // panel2 + // + this.panel2.BackColor = System.Drawing.Color.Black; + this.panel2.Controls.Add(this.lblChengZhong); + this.panel2.Location = new System.Drawing.Point(3, 8); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(237, 78); + this.panel2.TabIndex = 32; + // + // splitContainer1 + // + this.splitContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.panel1); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); + this.splitContainer1.Size = new System.Drawing.Size(1041, 587); + this.splitContainer1.SplitterDistance = 99; + this.splitContainer1.SplitterWidth = 1; + this.splitContainer1.TabIndex = 1; + // + // panel1 + // + this.panel1.Controls.Add(this.btnGoodsSet); + this.panel1.Controls.Add(this.enableWeight); + this.panel1.Controls.Add(this.panel2); + this.panel1.Controls.Add(this.btnWeightSet); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(1039, 97); + this.panel1.TabIndex = 2; + // + // uDataGridView1 + // + this.uDataGridView1.AllowUserToAddRows = false; + this.uDataGridView1.AllowUserToDeleteRows = false; + this.uDataGridView1.AllowUserToResizeColumns = false; + this.uDataGridView1.AllowUserToResizeRows = false; + dataGridViewCellStyle7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.uDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle7; + this.uDataGridView1.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.uDataGridView1.BackgroundColor = System.Drawing.Color.White; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.uDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle8; + this.uDataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.uDataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.dataGridViewTextBoxColumn1, + this.dataGridViewTextBoxColumn2, + this.dataGridViewTextBoxColumn3, + this.dataGridViewTextBoxColumn4, + this.dataGridViewTextBoxColumn5}); + this.uDataGridView1.Location = new System.Drawing.Point(3, 108); + this.uDataGridView1.MultiSelect = false; + this.uDataGridView1.Name = "uDataGridView1"; + this.uDataGridView1.ReadOnly = true; + this.uDataGridView1.RowHeadersVisible = false; + dataGridViewCellStyle9.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle9.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.uDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle9; + this.uDataGridView1.RowTemplate.Height = 23; + this.uDataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.uDataGridView1.Size = new System.Drawing.Size(518, 374); + this.uDataGridView1.TabIndex = 2; + // + // dataGridViewTextBoxColumn1 + // + this.dataGridViewTextBoxColumn1.DataPropertyName = "ID"; + this.dataGridViewTextBoxColumn1.HeaderText = "序号"; + this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; + this.dataGridViewTextBoxColumn1.ReadOnly = true; + this.dataGridViewTextBoxColumn1.Width = 80; + // + // dataGridViewTextBoxColumn2 + // + this.dataGridViewTextBoxColumn2.DataPropertyName = "BarCode"; + this.dataGridViewTextBoxColumn2.HeaderText = "条码"; + this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; + this.dataGridViewTextBoxColumn2.ReadOnly = true; + // + // dataGridViewTextBoxColumn3 + // + this.dataGridViewTextBoxColumn3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.dataGridViewTextBoxColumn3.DataPropertyName = "Goods_Name"; + this.dataGridViewTextBoxColumn3.HeaderText = "产品"; + this.dataGridViewTextBoxColumn3.MinimumWidth = 100; + this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3"; + this.dataGridViewTextBoxColumn3.ReadOnly = true; + // + // dataGridViewTextBoxColumn4 + // + this.dataGridViewTextBoxColumn4.DataPropertyName = "JingWeight"; + this.dataGridViewTextBoxColumn4.HeaderText = "净重"; + this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4"; + this.dataGridViewTextBoxColumn4.ReadOnly = true; + this.dataGridViewTextBoxColumn4.Width = 80; + // + // dataGridViewTextBoxColumn5 + // + this.dataGridViewTextBoxColumn5.DataPropertyName = "MaoWeight"; + this.dataGridViewTextBoxColumn5.HeaderText = "毛重"; + this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5"; + this.dataGridViewTextBoxColumn5.ReadOnly = true; + this.dataGridViewTextBoxColumn5.Width = 80; + // + // ByProductWeightForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1041, 587); + this.Controls.Add(this.splitContainer1); + this.Name = "ByProductWeightForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "副产品称重"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.Load += new System.EventHandler(this.ByProductWeightForm_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.splitContainer2.Panel1.ResumeLayout(false); + this.splitContainer2.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); + this.splitContainer2.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.panel2.PerformLayout(); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.uDataGridView1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label lblGoodsName; + private System.Windows.Forms.Label lblWeight; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label lblNumber; + private System.Windows.Forms.DataGridViewTextBoxColumn 毛重; + private System.Windows.Forms.DataGridViewTextBoxColumn 净重; + private System.Windows.Forms.DataGridViewTextBoxColumn 产品; + private System.Windows.Forms.DataGridViewTextBoxColumn 条码; + private System.Windows.Forms.DataGridViewTextBoxColumn 序号; + private System.Windows.Forms.FlowLayoutPanel flpGoods; + private System.Windows.Forms.FlowLayoutPanel flpClass; + private System.Windows.Forms.SplitContainer splitContainer2; + private System.Windows.Forms.Button btnWeightSet; + private System.Windows.Forms.Label lblChengZhong; + private System.Windows.Forms.Button btnGoodsSet; + private System.Windows.Forms.CheckBox enableWeight; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.Panel panel1; + private BWP.WinFormControl.UDataGridView uDataGridView1; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn5; + } +} \ No newline at end of file diff --git a/ByProductWeight/ByProductWeightForm.cs b/ByProductWeight/ByProductWeightForm.cs new file mode 100644 index 0000000..83fddef --- /dev/null +++ b/ByProductWeight/ByProductWeightForm.cs @@ -0,0 +1,406 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO.Ports; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; +using BO.Utils; +using BWP.WinFormControl.WeightDataFormat; +using ByProductWeight.Rpc; +using ByProductWeight.Rpc.Dto; + +namespace ByProductWeight +{ + public partial class ByProductWeightForm : Form,IAfterLogin + { + + public string RoleName { get { return "副产品计数"; } } + public Form Generate() + { + return this; + } + + #region weightNeed + SerialPort weightPort; + private IDataFormat _dataFormat; + private Thread _inQueryThread; + private bool _mainProcessIsRun; + readonly StringBuilder _dataStrBuilder = new StringBuilder(); + #endregion + + + + List mSetList ; + + + BindingList mWeightRecords; + public ByProductWeightForm() + { + InitializeComponent(); + uDataGridView1.AutoGenerateColumns = false; + weightPort = new SerialPort(); + this.FormClosing += delegate + { + if (_inQueryThread != null && _inQueryThread.IsAlive) + DisableWeight(); + // if (syncWork != null && syncWork.IsAlive) + // syncWork.Abort(); + // if (syncToServer != null && syncToServer.IsAlive) + // syncToServer.Abort(); + }; + } + #region weightNeed + void OpenSerialPort() + { + if (enableWeight.Checked) + return; + if (ByProductWeightContext.Config.RateSet == null) + throw new Exception("请先配置称相关信息"); + + weightPort.PortName = ByProductWeightContext.Config.ComSet; + weightPort.BaudRate = ByProductWeightContext.Config.RateSet.Value; + weightPort.DataBits = ByProductWeightContext.Config.BitSet.Value; + weightPort.ReadBufferSize = 4096 * 100; + if (!string.IsNullOrEmpty(ByProductWeightContext.Config.Format)) + format = "{0:{format}}".Replace("{format}", ByProductWeightContext.Config.Format); + + switch (ByProductWeightContext.Config.WeightSet) + { + case "IND560": + _dataFormat = new IND560DataFormat(); + break; + case "Xk3124": + _dataFormat = new Xk3124DataFormat(); + break; + case "Xk3190A9": + _dataFormat = new Xk3190A9DataFormat(); + break; + default: + _dataFormat = new Xk3190D10DataFormat(); + break; + } + if (!weightPort.IsOpen) + { + try + { + weightPort.Open(); + } + catch (InvalidOperationException) + { + MessageBox.Show(@"指定的端口已打开"); + } + catch (UnauthorizedAccessException) + { + MessageBox.Show(@"对端口的访问被拒绝"); + } + } + } + + void ReadData() + { + _inQueryThread = new Thread(InQuery); + _inQueryThread.Start(); + } + + string format = "{0:0.00}"; + + private void InQuery() + { + while (_mainProcessIsRun) + { + int availableCount = weightPort.BytesToRead; + if (availableCount == 0) + { + Thread.Sleep(1); + } + char[] buffer = new char[availableCount]; + if (!weightPort.IsOpen) + { + continue; + } + weightPort.Read(buffer, 0, availableCount); + foreach (var c in buffer) + { + if (c == _dataFormat.Beginchar) + { + _dataStrBuilder.Clear(); + _dataStrBuilder.Append(c); + } + else if (c == _dataFormat.Endchar && _dataStrBuilder.Length == _dataFormat.DataLength - 1) + { + _dataStrBuilder.Append(c); + bool isStatic; + string str; + if (_dataFormat.ParseAscii(_dataStrBuilder.ToString(), out str, out isStatic)) + { + if (ByProductWeightContext.Config.WeightType == 0) + { + if (string.IsNullOrEmpty(str)) + str = "0"; + this.Invoke(new Action(delegate () + { + lblChengZhong.Text = string.Format(format, decimal.Parse(str)); + if (str != "0") + { + + //doInsertUnSubmit("", decimal.Parse(lblChengZhong.Text)); + //todo 这里不需要逻辑 点击存货的时候判断是否在误差范围内 + } + })); + } + else + { + decimal num = 0; + if (decimal.TryParse(str, out num)) + { + this.Invoke(new Action(delegate () + { + lblChengZhong.Text = string.Format(format, num); + })); + // LocalGradeAndWeightBL.SaveWeightData(num); + WeighAvgControl.Add(num, isStatic); + } + if (WeighAvgControl.TryGetValue(out num)) + { + this.Invoke(new Action(delegate () + { + //lblChengZhong.Text = string.Format(format, num); + if (str != "0") + { + //doInsertUnSubmit("", decimal.Parse(string.Format(format, num))); + //todo 这里不需要逻辑 点击存货的时候判断是否在误差范围内 + } + })); + } + } + } + _dataStrBuilder.Clear(); + } + else if (_dataStrBuilder.Length != 0) + { + _dataStrBuilder.Append(c); + } + } + } + } + + private class WeighAvgControl + { + public static bool TryGetValue(out decimal result) + { + List> list; + if (mWeighList.TryDequeue(out list)) + { + var r = list.Where(x => x.Item2).Select(x => x.Item1).GroupBy(x => x); + var firstOrDefault = r.OrderByDescending(x => x.Count()).FirstOrDefault(); + if (firstOrDefault != null) + { + result = firstOrDefault.Key; + return true; + } + result = 0; + return false; + } + result = 0; + return false; + } + + static ConcurrentQueue>> mWeighList = new ConcurrentQueue>>(); + + static List> _list = new List>(); + + public static void Add(decimal value, bool isStatic) + { + if (value >= ByProductWeightContext.Config.MinWeight && value <= ByProductWeightContext.Config.MaxWeight) + { + _list.Add(new Tuple(value, isStatic)); + } + else + { + if (_list.Count > 0) + { + mWeighList.Enqueue(_list); + _list = new List>(); + } + } + } + } + + void DisableWeight() + { + _mainProcessIsRun = false; + lblChengZhong.Text = string.Format(format, 0); + format = "{0:0.00}"; + Thread.Sleep(10); + if (_inQueryThread.IsAlive) + { + _inQueryThread.Abort(); + } + if (weightPort.IsOpen) + weightPort.Close(); + } + + public void enableWeight_Click(object sender, EventArgs e) + { + if (!enableWeight.Checked) + { + OpenSerialPort(); + _mainProcessIsRun = true; + ReadData(); + } + else + { + DisableWeight(); + } + enableWeight.CheckState = enableWeight.Checked ? CheckState.Unchecked : CheckState.Checked; + } + #endregion + + private void ByProductWeightForm_Load(object sender, EventArgs e) + { + mWeightRecords = new BindingList();//以后可能取数据库中没做完的,比如做着做着突然断点 + RefreshUi(); + InitControl(); + } + + private void InitControl() + { + mSetList = + XmlUtil.DeserializeFromFile>( + ByProductWeightGoodsSetForm.ByProductWeightGoodsSetFileName).Where(x => x.IsSelected).ToList(); + if (mSetList.Count < 1) + { + return; + } + + flpClass.Controls.Clear(); + foreach (IGrouping grouping in mSetList.GroupBy(x => x.Name)) + { + var btnClass = CreateClassButton(grouping.Key); + flpClass.Controls.Add(btnClass); + } + + } + private Button CreateClassButton(string text) + { + var btn = new Button(); + btn.Text = text; + btn.Click += Btn_Click; + btn.Width = 100; + btn.Height = 60; + return btn; + + } + private void Btn_Click(object sender, EventArgs e) + { + var text = (sender as Button).Text; + foreach (Button cbutton in flpClass.Controls) + { + if (cbutton.Text == text) + { + cbutton.BackColor = Color.Aqua; + } + else + { + cbutton.BackColor = SystemColors.Control; + } + } + + flpGoods.Controls.Clear(); + foreach (ByProductWeightGoodsSet set in mSetList.Where(x => x.Name == text)) + { + var btnGoods = CreateGoodsButton(set); + flpGoods.Controls.Add(btnGoods); + } + + } + + private Button CreateGoodsButton(ByProductWeightGoodsSet set) + { + var btn = new Button(); + btn.Text = set.Goods_Name; + btn.Tag = set; + btn.Click += BtnGoods_Click; + btn.Width = 100; + btn.Height = 60; + return btn; + } + + private void BtnGoods_Click(object sender, EventArgs e) + { + var btn = sender as Button; + var set = btn.Tag as ByProductWeightGoodsSet; + + //todo 打印条码 + + var weight = 100m; + //添加记录 + var record = GetRecordBySet(set, weight); + var id = ByProductWeightRecordRpc.Insert(record); + record.ID = id; + mWeightRecords.Add(record); + + RefreshUi(); + + } + private ByProductWeightRecord GetRecordBySet(ByProductWeightGoodsSet set, decimal maoWeight) + { + var record = new ByProductWeightRecord(); + record.Goods_ID = set.Goods_ID; + record.BarCode = "";//todo 条码规则 + record.Goods_Name = set.Goods_Name; + record.Goods_Spec = set.Goods_Spec; + record.BiaoShi = "";//todo 标识 + record.MaoWeight = maoWeight; + record.PiWeight = 10; + + // record.JingWeight = record.MaoWeight - record.PiWeight; + + if (set.Goods_MainUnitRatio > 0) + { + record.JingWeight = set.Goods_MainUnitRatio; + } + else + { + record.JingWeight = record.MaoWeight - record.PiWeight; + } + + record.CardBarCode = "车条码"; //todo + + return record; + } + + void RefreshUi() + { + if (mWeightRecords.Count < 1) + { + return; + } + lblGoodsName.Text = mWeightRecords.First().Goods_Name; + lblNumber.Text = mWeightRecords.Count.ToString(); + lblWeight.Text = mWeightRecords.Sum(x => x.JingWeight).ToString(); + + uDataGridView1.DataSource = mWeightRecords; + } + private void btnWeightSet_Click(object sender, EventArgs e) + { + var form = new WeightSettingFrom(); + form.ShowDialog(); + } + + private void btnGoodsSet_Click(object sender, EventArgs e) + { + var f = new ByProductWeightGoodsSetForm(); + if (f.ShowDialog() == DialogResult.OK) + { + InitControl(); + } + } + } +} diff --git a/ByProductWeight/ByProductWeightForm.resx b/ByProductWeight/ByProductWeightForm.resx new file mode 100644 index 0000000..6314da4 --- /dev/null +++ b/ByProductWeight/ByProductWeightForm.resx @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 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 + + \ No newline at end of file diff --git a/ByProductWeight/ByProductWeightGoodsSet.cs b/ByProductWeight/ByProductWeightGoodsSet.cs new file mode 100644 index 0000000..66562d4 --- /dev/null +++ b/ByProductWeight/ByProductWeightGoodsSet.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BO.BO.Dtos; + +namespace ByProductWeight +{ + public class ByProductWeightGoodsSet : ClientGoodsSetDto + { + public bool IsSelected { get; set; } + } +} diff --git a/ByProductWeight/ByProductWeightGoodsSetForm.Designer.cs b/ByProductWeight/ByProductWeightGoodsSetForm.Designer.cs new file mode 100644 index 0000000..733c2da --- /dev/null +++ b/ByProductWeight/ByProductWeightGoodsSetForm.Designer.cs @@ -0,0 +1,118 @@ +namespace ByProductWeight +{ + partial class ByProductWeightGoodsSetForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.flpGoods = new System.Windows.Forms.FlowLayoutPanel(); + this.btnSave = new System.Windows.Forms.Button(); + this.flpClass = new System.Windows.Forms.FlowLayoutPanel(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // 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(1143, 525); + this.flpGoods.TabIndex = 0; + // + // btnSave + // + this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnSave.Font = new System.Drawing.Font("宋体", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnSave.Location = new System.Drawing.Point(1001, 3); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(114, 64); + this.btnSave.TabIndex = 1; + this.btnSave.Text = "保存"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // 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.Location = new System.Drawing.Point(3, 3); + this.flpClass.Name = "flpClass"; + this.flpClass.Size = new System.Drawing.Size(991, 64); + this.flpClass.TabIndex = 0; + // + // splitContainer1 + // + this.splitContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.btnSave); + this.splitContainer1.Panel1.Controls.Add(this.flpClass); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.flpGoods); + this.splitContainer1.Size = new System.Drawing.Size(1145, 600); + this.splitContainer1.SplitterDistance = 72; + this.splitContainer1.SplitterWidth = 1; + this.splitContainer1.TabIndex = 1; + // + // ByProductWeightGoodsSetForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1145, 600); + this.Controls.Add(this.splitContainer1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ByProductWeightGoodsSetForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "产品配置"; + this.Load += new System.EventHandler(this.ByProductWeightGoodsSetForm_Load); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.FlowLayoutPanel flpGoods; + private System.Windows.Forms.Button btnSave; + private System.Windows.Forms.FlowLayoutPanel flpClass; + private System.Windows.Forms.SplitContainer splitContainer1; + } +} \ No newline at end of file diff --git a/ByProductWeight/ByProductWeightGoodsSetForm.cs b/ByProductWeight/ByProductWeightGoodsSetForm.cs new file mode 100644 index 0000000..6d0a7b9 --- /dev/null +++ b/ByProductWeight/ByProductWeightGoodsSetForm.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using BO.BO.Dtos; +using BO.Utils; +using BO.Utils.BillRpc; + +namespace ByProductWeight +{ + public partial class ByProductWeightGoodsSetForm : Form + { + public readonly static string ByProductWeightGoodsSetFileName = "ByProductWeightGoodsSet.xml"; + private List mLocaList; + private List mWillDeleteList; + public ByProductWeightGoodsSetForm() + { + InitializeComponent(); + } + + private void ByProductWeightGoodsSetForm_Load(object sender, EventArgs e) + { + mLocaList = XmlUtil.DeserializeFromFile>(ByProductWeightGoodsSetFileName); + + var fromRpclist = ClientGoodsSetRpc.GetList(); + foreach (ClientGoodsSetDto rpcSet in fromRpclist) + { + var set = new ByProductWeightGoodsSet(); + set.Name = rpcSet.Name; + set.Goods_ID = rpcSet.Goods_ID; + set.Goods_Name = rpcSet.Goods_Name; + set.Goods_Code = rpcSet.Goods_Code; + set.Goods_Spec = rpcSet.Goods_Spec; + + var fd = mLocaList.FirstOrDefault(x => x.Goods_ID == set.Goods_ID); + if (fd != null) + { + fd.Name = set.Name; + fd.Goods_Name = set.Goods_Name; + fd.Goods_Code = set.Goods_Code; + fd.Goods_Spec = set.Goods_Spec; + } + else + { + mLocaList.Add(set); + } + } + + InitControl(); + } + private void InitControl() + { + flpClass.Controls.Clear(); + foreach (var grouping in mLocaList.GroupBy(x => x.Name)) + { + var btn = CreateClassButton(grouping.Key); + flpClass.Controls.Add(btn); + + } + } + private Button CreateClassButton(string text) + { + var button = new Button(); + button.Text = text; + button.Click += classButton_Click; + button.Width = 100; + button.Height = 60; + return button; + + } + private void classButton_Click(object sender, EventArgs e) + { + var btn = sender as Button; + foreach (Button cbutton in flpClass.Controls) + { + if (btn.Text == cbutton.Text) + { + cbutton.BackColor = Color.Aqua; + } + else + { + cbutton.BackColor = SystemColors.Control; + } + } + + + flpGoods.Controls.Clear(); + foreach (ByProductWeightGoodsSet set in mLocaList.Where(x => x.Name == btn.Text)) + { + var button = CreateGoodsButton(set); + flpGoods.Controls.Add(button); + } + + } + private Button CreateGoodsButton(ByProductWeightGoodsSet set) + { + var btn = new Button(); + btn.Text = set.Goods_Name; + btn.Tag = set; + btn.Click += GoodsBtn_Click; + btn.Width = 100; + btn.Height = 60; + if (set.IsSelected) + { + btn.BackColor = Color.Aqua; + } + + return btn; + } + + private void GoodsBtn_Click(object sender, EventArgs e) + { + var btn = sender as Button; + var set = btn.Tag as ByProductWeightGoodsSet; + if (btn.BackColor == Color.Aqua) + { + set.IsSelected = false; + btn.BackColor = SystemColors.Control; + } + else + { + set.IsSelected = true; + btn.BackColor = Color.Aqua; + } + } + + private void btnSave_Click(object sender, EventArgs e) + { + if (mLocaList != null) + { + XmlUtil.SerializerObjToFile(mLocaList, ByProductWeightGoodsSetFileName); + DialogResult = DialogResult.OK; + } + Close(); + } + } +} diff --git a/ByProductWeight/ByProductWeightGoodsSetForm.resx b/ByProductWeight/ByProductWeightGoodsSetForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ByProductWeight/ByProductWeightGoodsSetForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ByProductWeight/Properties/AssemblyInfo.cs b/ByProductWeight/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2c261eb --- /dev/null +++ b/ByProductWeight/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("ByProductWeight")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ByProductWeight")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +//将 ComVisible 设置为 false 将使此程序集中的类型 +//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("c5696a7d-0beb-474a-a478-fd0543e72abf")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ByProductWeight/Rpc/ByProductWeightRecordRpc.cs b/ByProductWeight/Rpc/ByProductWeightRecordRpc.cs new file mode 100644 index 0000000..10238e2 --- /dev/null +++ b/ByProductWeight/Rpc/ByProductWeightRecordRpc.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ByProductWeight.Rpc.Dto; +using Forks.JsonRpc.Client; +using Newtonsoft.Json; + +namespace ByProductWeight.Rpc +{ + public class ByProductWeightRecordRpc + { + public static long Insert(ByProductWeightRecord record) + { + var json = JsonConvert.SerializeObject(record); + var id = RpcFacade.Call("/MainSystem/B3ClientService/Rpcs/BillRpc/ByProductWeightRecordRpc/Insert", json); + return id; + } + } +} diff --git a/ByProductWeight/Rpc/Dto/ByProductWeightRecord.cs b/ByProductWeight/Rpc/Dto/ByProductWeightRecord.cs new file mode 100644 index 0000000..dffbb86 --- /dev/null +++ b/ByProductWeight/Rpc/Dto/ByProductWeightRecord.cs @@ -0,0 +1,22 @@ +using System; + +namespace ByProductWeight.Rpc.Dto +{ + [Serializable] + public class ByProductWeightRecord + { + public long ID { get; set; } + + public string BarCode { get; set; }//条码 + + public long Goods_ID { get; set; } + public string Goods_Name { get; set; } + public string Goods_Spec { get; set; } + + public decimal PiWeight { get; set; }//皮重 + public decimal MaoWeight { get; set; }//毛重 + public decimal JingWeight { get; set; }//净重 + public string CardBarCode { get; set; }//放产品的车的条码 + public string BiaoShi { get; set; }//用来记录那个工作台或者哪台触摸屏做的 + } +} diff --git a/ByProductWeight/WeightSettingFrom.Designer.cs b/ByProductWeight/WeightSettingFrom.Designer.cs new file mode 100644 index 0000000..540339b --- /dev/null +++ b/ByProductWeight/WeightSettingFrom.Designer.cs @@ -0,0 +1,291 @@ +namespace ByProductWeight +{ + partial class WeightSettingFrom + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.maxInput = new BWP.WinFormControl.UTextBoxWithPad(); + this.minInput = new BWP.WinFormControl.UTextBoxWithPad(); + this.label8 = new System.Windows.Forms.Label(); + this.weightReadType = new System.Windows.Forms.ComboBox(); + this.label7 = new System.Windows.Forms.Label(); + this.discont = new BWP.WinFormControl.UTextBoxWithPad(); + this.format = new BWP.WinFormControl.UTextBoxWithPad(); + this.label6 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.closeBtn = new System.Windows.Forms.Button(); + this.saveBtn = new System.Windows.Forms.Button(); + this.bitSet = new System.Windows.Forms.ComboBox(); + this.rateSet = new System.Windows.Forms.ComboBox(); + this.comSet = new System.Windows.Forms.ComboBox(); + this.weightSet = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // maxInput + // + this.maxInput.Font = new System.Drawing.Font("宋体", 12F); + this.maxInput.Location = new System.Drawing.Point(262, 370); + this.maxInput.Name = "maxInput"; + this.maxInput.Size = new System.Drawing.Size(55, 26); + this.maxInput.TabIndex = 86; + this.maxInput.Type = BWP.WinFormControl.UTextBoxWithPad.TextBoxType.Number; + // + // minInput + // + this.minInput.Font = new System.Drawing.Font("宋体", 12F); + this.minInput.Location = new System.Drawing.Point(196, 370); + this.minInput.Name = "minInput"; + this.minInput.Size = new System.Drawing.Size(55, 26); + this.minInput.TabIndex = 85; + this.minInput.Type = BWP.WinFormControl.UTextBoxWithPad.TextBoxType.Number; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("宋体", 15F); + this.label8.Location = new System.Drawing.Point(74, 370); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(109, 20); + this.label8.TabIndex = 84; + this.label8.Text = "有效区间:"; + // + // weightReadType + // + this.weightReadType.Font = new System.Drawing.Font("宋体", 15F); + this.weightReadType.FormattingEnabled = true; + this.weightReadType.Location = new System.Drawing.Point(196, 323); + this.weightReadType.Name = "weightReadType"; + this.weightReadType.Size = new System.Drawing.Size(121, 28); + this.weightReadType.TabIndex = 83; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 15F); + this.label7.Location = new System.Drawing.Point(74, 326); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(109, 20); + this.label7.TabIndex = 82; + this.label7.Text = "读取方式:"; + // + // discont + // + this.discont.Font = new System.Drawing.Font("宋体", 14F); + this.discont.Location = new System.Drawing.Point(196, 274); + this.discont.Name = "discont"; + this.discont.Size = new System.Drawing.Size(121, 29); + this.discont.TabIndex = 81; + this.discont.Type = BWP.WinFormControl.UTextBoxWithPad.TextBoxType.Number; + // + // format + // + this.format.Font = new System.Drawing.Font("宋体", 14F); + this.format.Location = new System.Drawing.Point(196, 226); + this.format.Name = "format"; + this.format.Size = new System.Drawing.Size(121, 29); + this.format.TabIndex = 80; + this.format.Type = BWP.WinFormControl.UTextBoxWithPad.TextBoxType.Number; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("宋体", 15F); + this.label6.Location = new System.Drawing.Point(74, 283); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(69, 20); + this.label6.TabIndex = 79; + this.label6.Text = "扣重:"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("宋体", 15F); + this.label5.Location = new System.Drawing.Point(74, 232); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(109, 20); + this.label5.TabIndex = 78; + this.label5.Text = "显示格式:"; + // + // closeBtn + // + this.closeBtn.Font = new System.Drawing.Font("宋体", 15F); + this.closeBtn.Location = new System.Drawing.Point(212, 416); + this.closeBtn.Name = "closeBtn"; + this.closeBtn.Size = new System.Drawing.Size(75, 35); + this.closeBtn.TabIndex = 77; + this.closeBtn.Text = "关闭"; + this.closeBtn.UseVisualStyleBackColor = true; + this.closeBtn.Click += new System.EventHandler(this.closeBtn_Click); + // + // saveBtn + // + this.saveBtn.Font = new System.Drawing.Font("宋体", 15F); + this.saveBtn.Location = new System.Drawing.Point(106, 416); + this.saveBtn.Name = "saveBtn"; + this.saveBtn.Size = new System.Drawing.Size(75, 35); + this.saveBtn.TabIndex = 76; + this.saveBtn.Text = "保存"; + this.saveBtn.UseVisualStyleBackColor = true; + this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click); + // + // bitSet + // + this.bitSet.Font = new System.Drawing.Font("宋体", 15F); + this.bitSet.FormattingEnabled = true; + this.bitSet.Location = new System.Drawing.Point(196, 179); + this.bitSet.Name = "bitSet"; + this.bitSet.Size = new System.Drawing.Size(121, 28); + this.bitSet.TabIndex = 73; + // + // rateSet + // + this.rateSet.Font = new System.Drawing.Font("宋体", 15F); + this.rateSet.FormattingEnabled = true; + this.rateSet.Location = new System.Drawing.Point(196, 127); + this.rateSet.Name = "rateSet"; + this.rateSet.Size = new System.Drawing.Size(121, 28); + this.rateSet.TabIndex = 74; + // + // comSet + // + this.comSet.Font = new System.Drawing.Font("宋体", 15F); + this.comSet.FormattingEnabled = true; + this.comSet.Location = new System.Drawing.Point(196, 77); + this.comSet.Name = "comSet"; + this.comSet.Size = new System.Drawing.Size(121, 28); + this.comSet.TabIndex = 75; + // + // weightSet + // + this.weightSet.Font = new System.Drawing.Font("宋体", 15F); + this.weightSet.FormattingEnabled = true; + this.weightSet.Location = new System.Drawing.Point(196, 29); + this.weightSet.Name = "weightSet"; + this.weightSet.Size = new System.Drawing.Size(121, 28); + this.weightSet.TabIndex = 72; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 15F); + this.label4.Location = new System.Drawing.Point(74, 182); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(89, 20); + this.label4.TabIndex = 71; + this.label4.Text = "数据位:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 15F); + this.label3.Location = new System.Drawing.Point(74, 130); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(89, 20); + this.label3.TabIndex = 70; + this.label3.Text = "波特率:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 15F); + this.label2.Location = new System.Drawing.Point(74, 80); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(89, 20); + this.label2.TabIndex = 69; + this.label2.Text = "端口号:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 15F); + this.label1.Location = new System.Drawing.Point(74, 32); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(89, 20); + this.label1.TabIndex = 68; + this.label1.Text = "称型号:"; + // + // WeightSettingFrom + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(391, 481); + this.Controls.Add(this.maxInput); + this.Controls.Add(this.minInput); + this.Controls.Add(this.label8); + this.Controls.Add(this.weightReadType); + this.Controls.Add(this.label7); + this.Controls.Add(this.discont); + this.Controls.Add(this.format); + this.Controls.Add(this.label6); + this.Controls.Add(this.label5); + this.Controls.Add(this.closeBtn); + this.Controls.Add(this.saveBtn); + this.Controls.Add(this.bitSet); + this.Controls.Add(this.rateSet); + this.Controls.Add(this.comSet); + this.Controls.Add(this.weightSet); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "WeightSettingFrom"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "称重设置"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private BWP.WinFormControl.UTextBoxWithPad maxInput; + private BWP.WinFormControl.UTextBoxWithPad minInput; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.ComboBox weightReadType; + private System.Windows.Forms.Label label7; + private BWP.WinFormControl.UTextBoxWithPad discont; + private BWP.WinFormControl.UTextBoxWithPad format; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Button closeBtn; + private System.Windows.Forms.Button saveBtn; + private System.Windows.Forms.ComboBox bitSet; + private System.Windows.Forms.ComboBox rateSet; + private System.Windows.Forms.ComboBox comSet; + private System.Windows.Forms.ComboBox weightSet; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/ByProductWeight/WeightSettingFrom.cs b/ByProductWeight/WeightSettingFrom.cs new file mode 100644 index 0000000..84f8a37 --- /dev/null +++ b/ByProductWeight/WeightSettingFrom.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ByProductWeight +{ + public partial class WeightSettingFrom : Form + { + List weight = new List { "IND560", "Xk3124", "Xk3190A9", "Xk3190D10" }; + List com = new List { "COM1", "COM2", "COM3", "COM4", "COM5" }; + List rate = new List { "4800", "7200", "9600" }; + List bit = new List { "5", "6", "7", "8" }; + List weightRead = new List { "稳定读取", "连续发送" }; + public WeightSettingFrom() + { + InitializeComponent(); + weightSet.DataSource = weight; + comSet.DataSource = com; + rateSet.DataSource = rate; + bitSet.DataSource = bit; + weightReadType.DataSource = weightRead; + if (!string.IsNullOrEmpty(ByProductWeightContext.Config.WeightSet)) + weightSet.SelectedIndex = weight.IndexOf(ByProductWeightContext.Config.WeightSet); + else + weightSet.SelectedIndex = 0; + if (!string.IsNullOrEmpty(ByProductWeightContext.Config.ComSet)) + comSet.SelectedIndex = com.IndexOf(ByProductWeightContext.Config.ComSet); + else + comSet.SelectedIndex = 0; + if (ByProductWeightContext.Config.RateSet.HasValue) + rateSet.SelectedIndex = rate.IndexOf(ByProductWeightContext.Config.RateSet.ToString()); + else + rateSet.SelectedIndex = 2; + if (ByProductWeightContext.Config.BitSet.HasValue) + bitSet.SelectedIndex = bit.IndexOf(ByProductWeightContext.Config.BitSet.ToString()); + else + bitSet.SelectedIndex = 3; + if (string.IsNullOrEmpty(ByProductWeightContext.Config.Format)) + format.Text = "0.00"; + else + format.Text = ByProductWeightContext.Config.Format; + if (ByProductWeightContext.Config.Discont == null) + discont.Text = "0.00"; + else + discont.Text = ByProductWeightContext.Config.Discont.ToString(); + weightReadType.SelectedIndex = ByProductWeightContext.Config.WeightType; + minInput.Text = ByProductWeightContext.Config.MinWeight.ToString(); + maxInput.Text = ByProductWeightContext.Config.MaxWeight.ToString(); + } + + private void saveBtn_Click(object sender, EventArgs e) + { + ByProductWeightContext.Config.WeightSet = weight[this.weightSet.SelectedIndex]; + ByProductWeightContext.Config.ComSet = com[this.comSet.SelectedIndex]; + ByProductWeightContext.Config.RateSet = int.Parse(rate[this.rateSet.SelectedIndex]); + ByProductWeightContext.Config.BitSet = int.Parse(bit[this.bitSet.SelectedIndex]); + ByProductWeightContext.Config.Format = format.Text; + ByProductWeightContext.Config.WeightType = weightReadType.SelectedIndex; + if (ByProductWeightContext.Config.WeightType == 1) + { + decimal min = 0; + decimal max = 0; + if (!decimal.TryParse(minInput.Text.Trim(), out min)) + throw new Exception("连续发送时 必须输入有效区间"); + if (!decimal.TryParse(maxInput.Text.Trim(), out max)) + throw new Exception("连续发送时 必须输入有效区间"); + ByProductWeightContext.Config.MinWeight = min; + ByProductWeightContext.Config.MaxWeight = max; + } + if (!string.IsNullOrEmpty(discont.Text)) + { + decimal v; + if (decimal.TryParse(discont.Text, out v)) + ByProductWeightContext.Config.Discont = v; + else + throw new Exception("扣重格式输入不正确"); + } + else + ByProductWeightContext.Config.Discont = 0; + ByProductWeightContext.Save(); + MessageBox.Show("保存成功!"); + } + + private void closeBtn_Click(object sender, EventArgs e) + { + Close(); + } + } +} diff --git a/ByProductWeight/WeightSettingFrom.resx b/ByProductWeight/WeightSettingFrom.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ByProductWeight/WeightSettingFrom.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ByProductWeight/副产品称重.txt b/ByProductWeight/副产品称重.txt new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/ByProductWeight/副产品称重.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/SegmentationWeight/SegmentationWeightForm.Designer.cs b/SegmentationWeight/SegmentationWeightForm.Designer.cs index 83dcdfe..2605de3 100644 --- a/SegmentationWeight/SegmentationWeightForm.Designer.cs +++ b/SegmentationWeight/SegmentationWeightForm.Designer.cs @@ -28,9 +28,9 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.panel1 = new System.Windows.Forms.Panel(); this.btnGoodsSet = new System.Windows.Forms.Button(); @@ -84,7 +84,7 @@ // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); - this.splitContainer1.Size = new System.Drawing.Size(1041, 547); + this.splitContainer1.Size = new System.Drawing.Size(1041, 587); this.splitContainer1.SplitterDistance = 99; this.splitContainer1.SplitterWidth = 1; this.splitContainer1.TabIndex = 0; @@ -104,7 +104,7 @@ // btnGoodsSet // this.btnGoodsSet.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnGoodsSet.Location = new System.Drawing.Point(461, 23); + this.btnGoodsSet.Location = new System.Drawing.Point(437, 23); this.btnGoodsSet.Name = "btnGoodsSet"; this.btnGoodsSet.Size = new System.Drawing.Size(114, 63); this.btnGoodsSet.TabIndex = 34; @@ -154,6 +154,7 @@ this.btnWeightSet.TabIndex = 0; this.btnWeightSet.Text = "称设置"; this.btnWeightSet.UseVisualStyleBackColor = true; + this.btnWeightSet.Click += new System.EventHandler(this.btnWeightSet_Click); // // splitContainer2 // @@ -172,8 +173,8 @@ // this.splitContainer2.Panel2.Controls.Add(this.uDataGridView1); this.splitContainer2.Panel2.Controls.Add(this.tableLayoutPanel1); - this.splitContainer2.Size = new System.Drawing.Size(1041, 447); - this.splitContainer2.SplitterDistance = 553; + this.splitContainer2.Size = new System.Drawing.Size(1041, 487); + this.splitContainer2.SplitterDistance = 556; this.splitContainer2.SplitterWidth = 1; this.splitContainer2.TabIndex = 0; // @@ -181,18 +182,20 @@ // this.flpGoods.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); + this.flpGoods.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.flpGoods.Location = new System.Drawing.Point(4, 87); this.flpGoods.Name = "flpGoods"; - this.flpGoods.Size = new System.Drawing.Size(541, 355); + this.flpGoods.Size = new System.Drawing.Size(541, 395); this.flpGoods.TabIndex = 1; // // 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(4, 4); this.flpClass.Name = "flpClass"; - this.flpClass.Size = new System.Drawing.Size(544, 76); + this.flpClass.Size = new System.Drawing.Size(547, 76); this.flpClass.TabIndex = 0; // // uDataGridView1 @@ -201,20 +204,20 @@ this.uDataGridView1.AllowUserToDeleteRows = false; this.uDataGridView1.AllowUserToResizeColumns = false; this.uDataGridView1.AllowUserToResizeRows = false; - dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.uDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle13.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.uDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; this.uDataGridView1.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.uDataGridView1.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.uDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle14.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.uDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; this.uDataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.uDataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.序号, @@ -227,12 +230,12 @@ this.uDataGridView1.Name = "uDataGridView1"; this.uDataGridView1.ReadOnly = true; this.uDataGridView1.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.uDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle15.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.uDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle15; this.uDataGridView1.RowTemplate.Height = 23; this.uDataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.uDataGridView1.Size = new System.Drawing.Size(483, 334); + this.uDataGridView1.Size = new System.Drawing.Size(483, 374); this.uDataGridView1.TabIndex = 1; // // 序号 @@ -283,7 +286,7 @@ this.tableLayoutPanel1.ColumnCount = 3; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 65.90909F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 34.09091F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 86F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 88F)); this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.label2, 1, 0); this.tableLayoutPanel1.Controls.Add(this.label3, 2, 0); @@ -295,7 +298,7 @@ this.tableLayoutPanel1.RowCount = 2; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 53.57143F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 46.42857F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(486, 98); + this.tableLayoutPanel1.Size = new System.Drawing.Size(479, 98); this.tableLayoutPanel1.TabIndex = 0; // // label1 @@ -305,7 +308,7 @@ | System.Windows.Forms.AnchorStyles.Right))); this.label1.Location = new System.Drawing.Point(4, 1); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(254, 50); + this.label1.Size = new System.Drawing.Size(249, 50); this.label1.TabIndex = 0; this.label1.Text = "产品"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -315,9 +318,9 @@ this.label2.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.label2.Location = new System.Drawing.Point(265, 1); + this.label2.Location = new System.Drawing.Point(260, 1); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(129, 50); + this.label2.Size = new System.Drawing.Size(125, 50); this.label2.TabIndex = 0; this.label2.Text = "数量"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -327,9 +330,9 @@ this.label3.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.label3.Location = new System.Drawing.Point(401, 1); + this.label3.Location = new System.Drawing.Point(392, 1); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(81, 50); + this.label3.Size = new System.Drawing.Size(83, 50); this.label3.TabIndex = 0; this.label3.Text = "重量"; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -341,7 +344,7 @@ | System.Windows.Forms.AnchorStyles.Right))); this.lblGoodsName.Location = new System.Drawing.Point(4, 52); this.lblGoodsName.Name = "lblGoodsName"; - this.lblGoodsName.Size = new System.Drawing.Size(254, 45); + this.lblGoodsName.Size = new System.Drawing.Size(249, 45); this.lblGoodsName.TabIndex = 0; this.lblGoodsName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -350,9 +353,9 @@ this.lblNumber.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.lblNumber.Location = new System.Drawing.Point(265, 52); + this.lblNumber.Location = new System.Drawing.Point(260, 52); this.lblNumber.Name = "lblNumber"; - this.lblNumber.Size = new System.Drawing.Size(129, 45); + this.lblNumber.Size = new System.Drawing.Size(125, 45); this.lblNumber.TabIndex = 0; this.lblNumber.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -361,9 +364,9 @@ this.lblWeight.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.lblWeight.Location = new System.Drawing.Point(401, 52); + this.lblWeight.Location = new System.Drawing.Point(392, 52); this.lblWeight.Name = "lblWeight"; - this.lblWeight.Size = new System.Drawing.Size(81, 45); + this.lblWeight.Size = new System.Drawing.Size(83, 45); this.lblWeight.TabIndex = 0; this.lblWeight.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -371,7 +374,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1041, 547); + this.ClientSize = new System.Drawing.Size(1041, 587); this.Controls.Add(this.splitContainer1); this.MinimizeBox = false; this.Name = "SegmentationWeightForm"; diff --git a/SegmentationWeight/SegmentationWeightForm.cs b/SegmentationWeight/SegmentationWeightForm.cs index 063253f..b23814e 100644 --- a/SegmentationWeight/SegmentationWeightForm.cs +++ b/SegmentationWeight/SegmentationWeightForm.cs @@ -29,8 +29,7 @@ namespace SegmentationWeight readonly StringBuilder _dataStrBuilder = new StringBuilder(); #endregion - - List mSetList = XmlUtil.DeserializeFromFile>(SegmentationWeightGoodsSetForm.SegmentationWeightGoodsSetFileName).Where(x => x.IsSelected).ToList(); + private List mSetList; BindingList mWeightRecords; @@ -275,7 +274,7 @@ namespace SegmentationWeight private void InitControl() { - + mSetList = XmlUtil.DeserializeFromFile>(SegmentationWeightGoodsSetForm.SegmentationWeightGoodsSetFileName).Where(x => x.IsSelected).ToList(); if (mSetList.Count < 1) { return; @@ -396,5 +395,11 @@ namespace SegmentationWeight { return this; } + + private void btnWeightSet_Click(object sender, EventArgs e) + { + var form=new WeightSettingFrom(); + form.ShowDialog(); + } } } diff --git a/WeighAndGrading/GradeFrom.cs b/WeighAndGrading/GradeFrom.cs index b2835fe..25b1629 100644 --- a/WeighAndGrading/GradeFrom.cs +++ b/WeighAndGrading/GradeFrom.cs @@ -1239,8 +1239,20 @@ namespace WeighAndGrading png = "working.png"; var imgPath = Path.Combine(Application.StartupPath, "BWP.WinFormControl.dll"); var s = Assembly.LoadFile(imgPath).GetManifestResourceStream("BWP.WinFormControl.Images." + png); - statePic.Image = Image.FromStream(s); - statePic.Refresh(); + if (this.InvokeRequired) + { + this.BeginInvoke(new Action(() => + { + statePic.Image = Image.FromStream(s); + statePic.Refresh(); + })); + } + else + { + statePic.Image = Image.FromStream(s); + statePic.Refresh(); + } + last = connection; } @@ -1267,7 +1279,7 @@ namespace WeighAndGrading { while (true) { - this.Invoke(new InvokeHandler(delegate () +// this.Invoke(new InvokeHandler(delegate () { VerifyConnection(); if (connection) @@ -1284,7 +1296,8 @@ namespace WeighAndGrading File.WriteAllText(string.Format("{0:yyyyMMddHHmmss}log.txt", DateTime.Now), "错误:" + ex.Message + " \n详细信息:" + ex.StackTrace); } } - })); + } +// )); Thread.Sleep(2000); } }