Browse Source

Merge branch 'master' of ssh://10.10.101.21/source/mes-client

Hcsy 8 years ago
parent
commit
7eb507a980

+ 0 - 8
UAS-出货标签管理/Login.cs

@@ -39,13 +39,9 @@ namespace UAS_LabelMachine
             IP.Text = Properties.Settings.Default.IPAddress;
             //如果上次的用户名不为空则直接跳到密码输入框
             if (UserName.Text != "")
-            {
                 PassWord.Select();
-            }
             if (!Directory.Exists("Log"))//若文件夹不存在则新建文件夹   
-            {
                 Directory.CreateDirectory("Log"); //新建文件夹   
-            }
             string sysdisc = Environment.GetEnvironmentVariable("windir").Substring(0, 1);
             if (!Directory.Exists(sysdisc + @":\打印标签"))
                 Directory.CreateDirectory(sysdisc + @":\打印标签");
@@ -59,9 +55,7 @@ namespace UAS_LabelMachine
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 if (MasterCombox.SelectedValue == dt.Rows[i]["ma_user"])
-                {
                     Ms_Pwd = dt.Rows[i]["ms_pwd"].ToString();
-                }
             }
             //切换至用户选择的数据源
             string ConnectionString = "Data Source=" + IP.Text + "/orcl;User ID=" + MasterCombox.SelectedValue + ";PassWord=" + Ms_Pwd;
@@ -87,9 +81,7 @@ namespace UAS_LabelMachine
                 Close();
             }
             else
-            {
                 MessageBox.Show("用户名或者密码错误!");
-            }
         }
 
         /// <summary>

+ 14 - 4
UAS-出货标签管理/PublicMethod/DataHelper.cs

@@ -95,7 +95,6 @@ namespace UAS_LabelMachine
         {
             DataTable dt = new DataTable();
             string sql = "select " + Field + " from " + TableName + " where " + Condition;
-            Console.WriteLine(sql);
             command = new OracleCommand(sql, connection);
             OracleDataAdapter ad = new OracleDataAdapter();
             ad.SelectCommand = command;
@@ -199,6 +198,19 @@ namespace UAS_LabelMachine
             return dt;
         }
 
+        /// <summary>
+        /// 通过表名和获取单行的记录
+        /// </summary>
+        public DataTable getFieldsDatasByCondition(string sql)
+        {
+            DataTable dt = new DataTable();
+            command = new OracleCommand(sql, connection);
+            OracleDataAdapter ad = new OracleDataAdapter(command);
+            ad.Fill(dt);
+            command.Dispose();
+            return dt;
+        }
+
         /// <summary>
         /// 将DataTable导入到指定的表中
         /// </summary>
@@ -730,7 +742,7 @@ namespace UAS_LabelMachine
                 return false;
             }
         }
-        int count = 0;
+
         /// <summary>
         /// 直接执行SQL,同时传入SQL的类型
         /// </summary>
@@ -739,7 +751,6 @@ namespace UAS_LabelMachine
         /// <returns></returns>
         public object ExecuteSql(string SQL, string Type, params object[] names)
         {
-            Console.WriteLine(SQL);
             object result = null;
             command = new OracleCommand(SQL, connection);
             //用来拼接参数的
@@ -770,7 +781,6 @@ namespace UAS_LabelMachine
                     command.Parameters.Add(new OracleParameter(addpar[i].ToString(), OracleDbType.Varchar2, names[i], ParameterDirection.Input));
                 }
             }
-
             switch (Type.ToUpper())
             {
                 case "SELECT":

+ 24 - 8
UAS-出货标签管理/SetLoadingWindow.Designer.cs

@@ -29,32 +29,47 @@
         private void InitializeComponent()
         {
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SetLoadingWindow));
+            this.CancelThread = new System.Windows.Forms.Button();
             this.loadingCircle1 = new UAS_LabelMachine.CustomControl.SetLoading.LoadingCircle();
             this.SuspendLayout();
             // 
+            // CancelThread
+            // 
+            this.CancelThread.Location = new System.Drawing.Point(155, 144);
+            this.CancelThread.Name = "CancelThread";
+            this.CancelThread.Size = new System.Drawing.Size(75, 26);
+            this.CancelThread.TabIndex = 1;
+            this.CancelThread.Text = "取消";
+            this.CancelThread.UseVisualStyleBackColor = true;
+            this.CancelThread.Click += new System.EventHandler(this.CancelThread_Click);
+            // 
             // loadingCircle1
             // 
             this.loadingCircle1.Active = false;
             this.loadingCircle1.Color = System.Drawing.Color.DarkGray;
-            this.loadingCircle1.InnerCircleRadius = 8;
-            this.loadingCircle1.Location = new System.Drawing.Point(106, 52);
+            this.loadingCircle1.InnerCircleRadius = 5;
+            this.loadingCircle1.Location = new System.Drawing.Point(141, 65);
+            this.loadingCircle1.Margin = new System.Windows.Forms.Padding(4);
             this.loadingCircle1.Name = "loadingCircle1";
-            this.loadingCircle1.NumberSpoke = 10;
-            this.loadingCircle1.OuterCircleRadius = 10;
+            this.loadingCircle1.NumberSpoke = 12;
+            this.loadingCircle1.OuterCircleRadius = 11;
             this.loadingCircle1.RotationSpeed = 100;
-            this.loadingCircle1.Size = new System.Drawing.Size(75, 50);
-            this.loadingCircle1.SpokeThickness = 4;
+            this.loadingCircle1.Size = new System.Drawing.Size(100, 62);
+            this.loadingCircle1.SpokeThickness = 2;
+            this.loadingCircle1.StylePreset = UAS_LabelMachine.CustomControl.SetLoading.LoadingCircle.StylePresets.MacOSX;
             this.loadingCircle1.TabIndex = 0;
             this.loadingCircle1.Text = "loadingCircle1";
             // 
             // SetLoadingWindow
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(284, 158);
+            this.ClientSize = new System.Drawing.Size(379, 198);
+            this.Controls.Add(this.CancelThread);
             this.Controls.Add(this.loadingCircle1);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+            this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.Name = "SetLoadingWindow";
             this.Text = "SetLoadingWindow";
             this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SetLoadingWindow_FormClosing);
@@ -66,5 +81,6 @@
         #endregion
 
         private CustomControl.SetLoading.LoadingCircle loadingCircle1;
+        private System.Windows.Forms.Button CancelThread;
     }
 }

+ 6 - 0
UAS-出货标签管理/SetLoadingWindow.cs

@@ -27,6 +27,7 @@ namespace UAS_LabelMachine.PublicForm
             loadingCircle1.OuterCircleRadius = 20;
             loadingCircle1.InnerCircleRadius = 12;
             loadingCircle1.Active = true;
+            
             LoadingThread.Start();
             //在本窗体新建一个进程用来判断传递的进程是否执行结束
             Thread t1 = new Thread(SetLoadFinish);
@@ -49,5 +50,10 @@ namespace UAS_LabelMachine.PublicForm
                 e.Cancel=true;
             }
         }
+
+        private void CancelThread_Click(object sender, EventArgs e)
+        {
+            LoadingThread.Abort();
+        }
     }
 }

+ 33 - 34
UAS-出货标签管理/UAS_出货标签管理.Designer.cs

@@ -90,7 +90,7 @@
             this.dataGridViewTextBoxColumn22 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn23 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.MidSource = new System.Windows.Forms.BindingSource(this.components);
-            this.ChooseAll = new UAS_LabelMachine.CustomControl.ChooseAllButton();
+            this.ChooseAll = new System.Windows.Forms.Button();
             this.pr_code = new UAS_LabelMachine.CustomControl.SearchTextBox();
             this.CollectionProcess = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
             this.Capacity = new System.Windows.Forms.Label();
@@ -732,13 +732,13 @@
             // 
             // ChooseAll
             // 
-            this.ChooseAll.Location = new System.Drawing.Point(5, 317);
-            this.ChooseAll.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.ChooseAll.Location = new System.Drawing.Point(3, 315);
             this.ChooseAll.Name = "ChooseAll";
-            this.ChooseAll.Size = new System.Drawing.Size(53, 25);
-            this.ChooseAll.TabIndex = 70;
+            this.ChooseAll.Size = new System.Drawing.Size(51, 27);
+            this.ChooseAll.TabIndex = 84;
             this.ChooseAll.Text = "全选";
             this.ChooseAll.UseVisualStyleBackColor = true;
+            this.ChooseAll.Click += new System.EventHandler(this.ChooseAll_Click);
             // 
             // pr_code
             // 
@@ -782,7 +782,7 @@
             // 
             this.Capacity.AutoSize = true;
             this.Capacity.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Capacity.Location = new System.Drawing.Point(80, 91);
+            this.Capacity.Location = new System.Drawing.Point(80, 79);
             this.Capacity.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.Capacity.Name = "Capacity";
             this.Capacity.Size = new System.Drawing.Size(0, 20);
@@ -792,7 +792,7 @@
             // 
             this.Process_midboxcode.AutoSize = true;
             this.Process_midboxcode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process_midboxcode.Location = new System.Drawing.Point(80, 146);
+            this.Process_midboxcode.Location = new System.Drawing.Point(80, 134);
             this.Process_midboxcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.Process_midboxcode.Name = "Process_midboxcode";
             this.Process_midboxcode.Size = new System.Drawing.Size(18, 20);
@@ -803,7 +803,7 @@
             // 
             this.Process_outboxcode.AutoSize = true;
             this.Process_outboxcode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process_outboxcode.Location = new System.Drawing.Point(80, 116);
+            this.Process_outboxcode.Location = new System.Drawing.Point(80, 104);
             this.Process_outboxcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.Process_outboxcode.Name = "Process_outboxcode";
             this.Process_outboxcode.Size = new System.Drawing.Size(18, 20);
@@ -815,7 +815,7 @@
             this.TotalCount.AutoSize = true;
             this.TotalCount.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.TotalCount.ForeColor = System.Drawing.Color.Blue;
-            this.TotalCount.Location = new System.Drawing.Point(125, 31);
+            this.TotalCount.Location = new System.Drawing.Point(125, 19);
             this.TotalCount.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.TotalCount.Name = "TotalCount";
             this.TotalCount.Size = new System.Drawing.Size(18, 20);
@@ -826,7 +826,7 @@
             // 
             this.label17.AutoSize = true;
             this.label17.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label17.Location = new System.Drawing.Point(108, 31);
+            this.label17.Location = new System.Drawing.Point(108, 19);
             this.label17.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label17.Name = "label17";
             this.label17.Size = new System.Drawing.Size(15, 20);
@@ -838,7 +838,7 @@
             this.CollectedCount.AutoSize = true;
             this.CollectedCount.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.CollectedCount.ForeColor = System.Drawing.Color.Red;
-            this.CollectedCount.Location = new System.Drawing.Point(84, 31);
+            this.CollectedCount.Location = new System.Drawing.Point(84, 19);
             this.CollectedCount.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.CollectedCount.Name = "CollectedCount";
             this.CollectedCount.Size = new System.Drawing.Size(18, 20);
@@ -849,7 +849,7 @@
             // 
             this.label14.AutoSize = true;
             this.label14.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label14.Location = new System.Drawing.Point(13, 117);
+            this.label14.Location = new System.Drawing.Point(13, 105);
             this.label14.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label14.Name = "label14";
             this.label14.Size = new System.Drawing.Size(39, 20);
@@ -860,7 +860,7 @@
             // 
             this.label11.AutoSize = true;
             this.label11.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label11.Location = new System.Drawing.Point(13, 146);
+            this.label11.Location = new System.Drawing.Point(13, 134);
             this.label11.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label11.Name = "label11";
             this.label11.Size = new System.Drawing.Size(39, 20);
@@ -871,7 +871,7 @@
             // 
             this.label13.AutoSize = true;
             this.label13.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label13.Location = new System.Drawing.Point(13, 66);
+            this.label13.Location = new System.Drawing.Point(13, 54);
             this.label13.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label13.Name = "label13";
             this.label13.Size = new System.Drawing.Size(54, 20);
@@ -882,7 +882,7 @@
             // 
             this.Installed.AutoSize = true;
             this.Installed.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Installed.Location = new System.Drawing.Point(80, 66);
+            this.Installed.Location = new System.Drawing.Point(80, 54);
             this.Installed.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.Installed.Name = "Installed";
             this.Installed.Size = new System.Drawing.Size(0, 20);
@@ -892,7 +892,7 @@
             // 
             this.Process.AutoSize = true;
             this.Process.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process.Location = new System.Drawing.Point(13, 31);
+            this.Process.Location = new System.Drawing.Point(13, 19);
             this.Process.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.Process.Name = "Process";
             this.Process.Size = new System.Drawing.Size(54, 20);
@@ -996,7 +996,6 @@
             this.LabelInf.Size = new System.Drawing.Size(1456, 407);
             this.LabelInf.TabIndex = 27;
             this.LabelInf.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.LabelInf_CellPainting);
-            this.LabelInf.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.LabelInf_CellValueChanged);
             this.LabelInf.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.LabelInf_DataError);
             // 
             // Choose
@@ -1014,7 +1013,7 @@
             this.pib_id1.HeaderText = "pib_id";
             this.pib_id1.Name = "pib_id1";
             this.pib_id1.Visible = false;
-            this.pib_id1.Width = 66;
+            this.pib_id1.Width = 84;
             // 
             // pib_pdno
             // 
@@ -1080,7 +1079,7 @@
             this.DateCode1.HeaderText = "DateCode1";
             this.DateCode1.Name = "DateCode1";
             this.DateCode1.Visible = false;
-            this.DateCode1.Width = 84;
+            this.DateCode1.Width = 108;
             // 
             // pib_qty
             // 
@@ -1179,7 +1178,7 @@
             // 
             this.ViVoPlate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.ViVoPlate.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ViVoPlate.Location = new System.Drawing.Point(102, 201);
+            this.ViVoPlate.Location = new System.Drawing.Point(102, 203);
             this.ViVoPlate.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.ViVoPlate.Name = "ViVoPlate";
             this.ViVoPlate.Size = new System.Drawing.Size(91, 33);
@@ -1201,7 +1200,7 @@
             // 
             this.SingleLabelPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.SingleLabelPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelPrint.Location = new System.Drawing.Point(102, 248);
+            this.SingleLabelPrint.Location = new System.Drawing.Point(102, 250);
             this.SingleLabelPrint.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.SingleLabelPrint.Name = "SingleLabelPrint";
             this.SingleLabelPrint.Size = new System.Drawing.Size(91, 33);
@@ -1214,7 +1213,7 @@
             // 
             this.SingleLabelAutoPrint.AutoSize = true;
             this.SingleLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(9, 141);
+            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(9, 137);
             this.SingleLabelAutoPrint.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.SingleLabelAutoPrint.Name = "SingleLabelAutoPrint";
             this.SingleLabelAutoPrint.Size = new System.Drawing.Size(91, 24);
@@ -1272,7 +1271,7 @@
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label5.Location = new System.Drawing.Point(8, 217);
+            this.label5.Location = new System.Drawing.Point(8, 205);
             this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label5.Name = "label5";
             this.label5.Size = new System.Drawing.Size(39, 20);
@@ -1283,7 +1282,7 @@
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label4.Location = new System.Drawing.Point(7, 179);
+            this.label4.Location = new System.Drawing.Point(7, 167);
             this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(39, 20);
@@ -1303,7 +1302,7 @@
             // 
             this.label15.AutoSize = true;
             this.label15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label15.Location = new System.Drawing.Point(119, 181);
+            this.label15.Location = new System.Drawing.Point(119, 169);
             this.label15.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label15.Name = "label15";
             this.label15.Size = new System.Drawing.Size(24, 20);
@@ -1335,7 +1334,7 @@
             // 
             this.MidLabelAutoPrint.AutoSize = true;
             this.MidLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.MidLabelAutoPrint.Location = new System.Drawing.Point(12, 141);
+            this.MidLabelAutoPrint.Location = new System.Drawing.Point(12, 137);
             this.MidLabelAutoPrint.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.MidLabelAutoPrint.Name = "MidLabelAutoPrint";
             this.MidLabelAutoPrint.Size = new System.Drawing.Size(91, 24);
@@ -1385,7 +1384,7 @@
             // LogingOut
             // 
             this.LogingOut.AutoSize = true;
-            this.LogingOut.Location = new System.Drawing.Point(166, 18);
+            this.LogingOut.Location = new System.Drawing.Point(166, 6);
             this.LogingOut.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.LogingOut.Name = "LogingOut";
             this.LogingOut.Size = new System.Drawing.Size(52, 27);
@@ -1423,7 +1422,7 @@
             // 
             this.label10.AutoSize = true;
             this.label10.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label10.Location = new System.Drawing.Point(11, 221);
+            this.label10.Location = new System.Drawing.Point(11, 209);
             this.label10.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label10.Name = "label10";
             this.label10.Size = new System.Drawing.Size(39, 20);
@@ -1447,7 +1446,7 @@
             // 
             this.label9.AutoSize = true;
             this.label9.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label9.Location = new System.Drawing.Point(120, 261);
+            this.label9.Location = new System.Drawing.Point(120, 249);
             this.label9.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label9.Name = "label9";
             this.label9.Size = new System.Drawing.Size(39, 20);
@@ -1471,7 +1470,7 @@
             // 
             this.label8.AutoSize = true;
             this.label8.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label8.Location = new System.Drawing.Point(11, 261);
+            this.label8.Location = new System.Drawing.Point(11, 249);
             this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label8.Name = "label8";
             this.label8.Size = new System.Drawing.Size(39, 20);
@@ -1482,7 +1481,7 @@
             // 
             this.label6.AutoSize = true;
             this.label6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label6.Location = new System.Drawing.Point(8, 177);
+            this.label6.Location = new System.Drawing.Point(8, 165);
             this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label6.Name = "label6";
             this.label6.Size = new System.Drawing.Size(39, 20);
@@ -1540,7 +1539,7 @@
             // 
             this.OutBoxLabelAutoPrint.AutoSize = true;
             this.OutBoxLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.OutBoxLabelAutoPrint.Location = new System.Drawing.Point(12, 137);
+            this.OutBoxLabelAutoPrint.Location = new System.Drawing.Point(10, 135);
             this.OutBoxLabelAutoPrint.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.OutBoxLabelAutoPrint.Name = "OutBoxLabelAutoPrint";
             this.OutBoxLabelAutoPrint.Size = new System.Drawing.Size(91, 24);
@@ -1566,6 +1565,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(233)))), ((int)(((byte)(206)))));
             this.ClientSize = new System.Drawing.Size(1461, 857);
+            this.Controls.Add(this.ChooseAll);
             this.Controls.Add(this.GetGridOnly);
             this.Controls.Add(this.PowerSetting);
             this.Controls.Add(this.AllCollected);
@@ -1573,7 +1573,6 @@
             this.Controls.Add(this.Fresh);
             this.Controls.Add(this.pi_cardcode_label);
             this.Controls.Add(this.pi_cardcode);
-            this.Controls.Add(this.ChooseAll);
             this.Controls.Add(this.pib_id);
             this.Controls.Add(this.pr_code);
             this.Controls.Add(this.CleanDetail);
@@ -1712,7 +1711,6 @@
         private CustomControl.SearchTextBox sg_code;
         private CustomControl.SearchTextBox pr_code;
         private System.Windows.Forms.Label pib_id;
-        private CustomControl.ChooseAllButton ChooseAll;
         private System.Windows.Forms.Label Process_midboxcode;
         private System.Windows.Forms.Label Process_outboxcode;
         private System.Windows.Forms.Label Capacity;
@@ -1744,6 +1742,7 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn22;
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn23;
         private System.Windows.Forms.BindingSource MidSource;
+        private System.Windows.Forms.Button ChooseAll;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_id1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_pdno;

+ 326 - 100
UAS-出货标签管理/UAS_出货标签管理.cs

@@ -11,7 +11,6 @@ using LabelManager2;
 using UAS_LabelMachine.PublicMethod;
 using UAS_LabelMachine.Entity;
 using UAS_特殊解析规则;
-using System.Globalization;
 using UAS_LabelMachine.CustomControl.GroupBoxWithBorder;
 using UAS_LabelMachine.PublicForm;
 using System.Threading;
@@ -36,7 +35,6 @@ namespace UAS_LabelMachine
         /// </summary>
         List<string> PrintedVivoOutboxCode = new List<string>();
         StringBuilder sql = new StringBuilder();
-
         /// <summary>
         /// CodeSoft新建打印机引擎
         /// </summary>
@@ -93,21 +91,51 @@ namespace UAS_LabelMachine
         object[] ItemData;
 
         Dictionary<string, string> CollectData;
-
+        //缓存单盘数据数据的DataTable
+        DataTable SingleBoxCacheData;
+        /// <summary>
+        /// 存放单盘的ID
+        /// </summary>
+        List<string> SingleID = new List<string>();
+        /// <summary>
+        /// 单盘的打印参数
+        /// </summary>
+        List<string> SingleBoxArgument = new List<string>();
+        /// <summary>
+        /// 中盒缓存数据
+        /// </summary>
+        DataTable MidBoxCacheData;
+        /// <summary>
+        /// 存放中盒的ID和盒号
+        /// </summary>
+        Dictionary<string, string> MidIDAndOutboxcode = new Dictionary<string, string>();
+        /// <summary>
+        /// 中盒的打印参数
+        /// </summary>
+        List<string> MidBoxArgument = new List<string>();
+        /// <summary>
+        /// 全部采集
+        /// </summary>
         bool AllCollect = false;
         /// <summary>
+        /// 是否全选
+        /// </summary>
+        bool AllChecked = false;
+        /// <summary>
         /// 是否获取过箱号
         /// </summary>
         bool GetPackingCode = false;
         /*用于存放采集项目的Grid信息*/
         Dictionary<string, Dictionary<string, string>> SiItem;
-
+        int CloumnCount = 0;
         /*需要重绘的Cell*/
         Dictionary<DataGridViewCell, bool> PaintCell = new Dictionary<DataGridViewCell, bool>();
         //使用二维数组进行排序
         ArrayList<ArrayList<string>> ScanData;
         ArrayList<string> GetData;
 
+
+
         public UAS_出货标签打印()
         {
             InitializeComponent();
@@ -139,13 +167,15 @@ namespace UAS_LabelMachine
             LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
             dh = new DataHelper();
             CheckForIllegalCrossThreadCalls = false;
+            CloumnCount = LabelInf.Columns.Count;
             pi_inoutno.Focus();
             //将本地读取的打印机设置进Combox,并选中默认打印机
             if (User.UserAccountType == "admin")
             {
                 PowerSetting.Visible = true;
             }
-
+            MidBoxCacheData = new DataTable();
+            SingleBoxCacheData = new DataTable();
             sg_code.FormName = Name;
             sg_code.SetValueField = new string[] { "sg_code" };
             sg_code.SelectField = "sg_code # 策略编号 ,sg_name # 策略名称,sg_brand # 品牌,sg_separator # 分隔符";
@@ -156,7 +186,6 @@ namespace UAS_LabelMachine
             pr_code.TableName = "prodiodetail";
             pr_code.SelectField = "pd_pdno # 行号,pd_prodcode # 物料编号";
 
-            ChooseAll.ChooseAll(LabelInf);
             CollectionUnit.Text = "盘";
             Point pt = new Point();
             int ScreenWidth = Screen.GetWorkingArea(pt).Width;
@@ -1054,6 +1083,13 @@ namespace UAS_LabelMachine
                     pi_cardcode.Text = dt.Rows[0]["pi_cardcode"].ToString();
                     PI_ID = dt.Rows[0]["pi_id"].ToString();
                     LoadGridData(sender, e);
+                    //重新输入单号后清除缓存
+                    MidBoxArgument.Clear();
+                    MidBoxCacheData.Clear();
+                    BaseUtil.CleanDataTable(MidBoxCacheData);
+                    SingleBoxArgument.Clear();
+                    SingleBoxCacheData.Clear();
+                    BaseUtil.CleanDataTable(SingleBoxCacheData);
                     //刷新采集进度
                     RefreshProcessData();
                     //设置当前的最大箱号
@@ -1062,19 +1098,11 @@ namespace UAS_LabelMachine
                         string outboxcode = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
                         //如果包含有-,则需要解析
                         if (outboxcode.Contains("-"))
-                        {
                             if (int.Parse(outboxcode.Split('-')[0] == "" ? "1" : outboxcode.Split('-')[0]) > MaxOutBoxCode)
-                            {
                                 MaxOutBoxCode = int.Parse(outboxcode.Split('-')[0]);
-                            }
-                        }
-                        else
-                        {
+                            else
                             if (int.Parse(outboxcode == "" ? "1" : outboxcode) > MaxOutBoxCode)
-                            {
                                 MaxOutBoxCode = int.Parse(outboxcode);
-                            }
-                        }
                     }
                     thread = new Thread(GetInOutInfAndLabelFile);
                     stw = new SetLoadingWindow(thread, "正在获取打印标签");
@@ -1098,10 +1126,33 @@ namespace UAS_LabelMachine
             dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
             if (dt.Rows.Count > 0)
             {
+                //每次打印清除之前缓存的行号和ID,后面会判断需要打印的数据重新加载
+                MidIDAndOutboxcode.Clear();
+                SingleID.Clear();
                 //获取全部的中盒号
                 Dictionary<string, bool> outboxcode1 = new Dictionary<string, bool>();
                 //判断所有盒号为该盒的是否勾选已采集
                 outboxcode1.Add(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString(), true);
+                for (int i = 0; i < LabelInf.Rows.Count; i++)
+                {
+                    if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "True")
+                    {
+                        SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
+                        //如果不存在中盒号则进行添加
+                        if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
+                            MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
+                    }  
+                }
+                if (SingleID.ToArray().Length == 0)
+                {
+                    MessageBox.Show("选择的行未勾选采集或者已打印");
+                    return;
+                }
+                //打印的时候如果不存在数据开始缓存
+                if (MidBoxCacheData.Rows.Count == 0)
+                    GetMidBoxData();
+                if (SingleBoxCacheData.Rows.Count == 0)
+                    GetSingleBoxData();
                 for (int i = 0; i < LabelInf.RowCount; i++)
                 {
                     if (i + 1 < LabelInf.RowCount)
@@ -1122,6 +1173,7 @@ namespace UAS_LabelMachine
                 }
                 //用于判断用户是否勾选了行
                 int CheckedRowCount = 0;
+                string[] arg = SingleBoxArgument.ToArray();
                 //打印所有的选中行
                 for (int i = 0; i < LabelInf.RowCount; i++)
                 {
@@ -1133,57 +1185,39 @@ namespace UAS_LabelMachine
                         //以标签模板的参数为基准,循环取数
                         try
                         {
+                            string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
+                            DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
+                            StringBuilder ParamLog = new StringBuilder();
                             for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
                             {
-                                //将维护的模板参数和模板本身的参数名称进行比对
-                                for (int k = 0; k < dt.Rows.Count; k++)
+                                if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode1"))
                                 {
-                                    //名称相等的时候,取SQL进行值的查询
-                                    if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == dt.Rows[k]["lp_name"].ToString())
-                                    {
-                                        //获取打印执行的SQL
-                                        string sql = dt.Rows[k]["lp_sql"].ToString();
-                                        if (sql.IndexOf("{") == 0)
-                                        {
-                                            SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
-                                            LogManager.DoLog("打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + dt.Rows[k]["lp_sql"].ToString() + ",取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
-                                        }
-                                        else
-                                        {
-                                            sql = sql.Substring(0, sql.IndexOf("{"));
-                                            //获取对应行的pib_id
-                                            string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
-                                            if (sql.ToLower().Contains("pib_lotno"))
-                                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_lotno"].Value.ToString();
-                                            else if (sql.ToLower().Contains("pib_datecode"))
-                                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_datecode"].Value.ToString();
-                                            else if (sql.ToLower().Contains("pib_cusbarcode"))
-                                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_cusbarcode"].Value.ToString();
-                                            else if (sql.ToLower().Contains("pib_cusoutboxcode"))
-                                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_cusoutboxcode"].Value.ToString();
-                                            else
-                                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql + pib_id).ToString();
-                                            LogManager.DoLog("打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + pib_id + ",取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
-                                        }
-                                    }
-                                    else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == "DateCode1")
-                                    {
-                                        if (LabelInf.Rows[i].Cells["DateCode1"].Value != null)
-                                        {
-                                            SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["DateCode1"].Value.ToString();
-                                        }
-                                    }
+                                    if (LabelInf.Rows[i].Cells["DateCode1"].Value != null)
+                                        SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["DateCode1"].Value.ToString();
+                                }
+                                else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("lotno"))
+                                {
+                                    if (LabelInf.Rows[i].Cells["pib_lotno"].Value != null)
+                                        SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_lotno"].Value.ToString();
                                 }
+                                else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode"))
+                                {
+                                    if (LabelInf.Rows[i].Cells["pib_datecode"].Value != null)
+                                        SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_datecode"].Value.ToString();
+                                }
+                                else if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
+                                    SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
+                                ParamLog.AppendLine("打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
                             }
+                            LogManager.DoLog(ParamLog.ToString());
                             //保存参数打印
                             SingleDoc.Save();
                             SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
                             SingleDoc.PrintDocument();
-                            LogManager.DoLog("执行打印单盘,pib_id:" + LabelInf.Rows[i].Cells["pib_id1"].Value.ToString() + ",标签地址" + LabelUrl);
                             //勾选为已打印
                             LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
                         }
-                        catch (Exception ex) { MessageBox.Show(ex.Message); }
+                        catch (Exception ex) { LogManager.DoLog(ex.Message); }
                     }
                     if (MidLabelAutoPrint.Checked && LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True")
                     {
@@ -1214,6 +1248,184 @@ namespace UAS_LabelMachine
             }
         }
 
+        /// <summary>
+        /// 缓存单盘的数据
+        /// </summary>
+        private void GetSingleBoxData()
+        {
+            StringBuilder pib_id_string = new StringBuilder();
+            //id数组
+            string[] pib_id_arr = SingleID.ToArray();
+            //id个数
+            int pib_id_length = pib_id_arr.Length;
+            //将所有的列存在在这里
+            List<DataTable> AllSingleBoxCacheData = new List<DataTable>();
+
+            //每五百条拼接一次条件
+            int fivehundred_count = pib_id_length / 500 + 1;
+            //当前打印的索引
+            int CurrentCount = 0;
+            for (int i = 0; i < fivehundred_count; i++)
+            {
+                //本次循环的数量
+                int count = 0;
+                pib_id_string.Append("(");
+                if (i + 1 == fivehundred_count)
+                    count = pib_id_length - i * 500;
+                else
+                    count = 500;
+                //当前执行的索引
+                int LastCount = CurrentCount;
+                for (int j = CurrentCount; j < LastCount + count - 1; j++)
+                {
+                    pib_id_string.Append(pib_id_arr[j] + ",");
+                    CurrentCount = CurrentCount + 1;
+                }
+                pib_id_string.Append(pib_id_arr[CurrentCount]);
+                pib_id_string.Append(")");
+                if (i + 1 != fivehundred_count)
+                    pib_id_string.Append(" or pib_id in ");
+            }
+
+            //手动添加ID列
+            DataColumn datacolumn = new DataColumn("pib_id");
+            SingleBoxCacheData.Columns.Add(datacolumn);
+            //获取打印的SQL
+            for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
+            {
+                //将维护的模板参数和模板本身的参数名称进行比对
+                for (int k = 0; k < dt.Rows.Count; k++)
+                {
+                    if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == dt.Rows[k]["lp_name"].ToString())
+                    {
+                        DataColumn dc = new DataColumn(SingleDoc.Variables.FreeVariables.Item(j + 1).Name);
+                        SingleBoxCacheData.Columns.Add(dc);
+                        SingleBoxArgument.Add(SingleDoc.Variables.FreeVariables.Item(j + 1).Name);
+                        string sql = dt.Rows[k]["lp_sql"].ToString();
+                        sql = sql.Substring(0, sql.IndexOf("{"));
+                        sql = sql.Substring(0, sql.LastIndexOf("="));
+                        DataTable temp = dh.getFieldsDatasByCondition(sql + " in " + pib_id_string.ToString());
+                        temp.Columns[0].ColumnName = SingleDoc.Variables.FreeVariables.Item(j + 1).Name;
+                        AllSingleBoxCacheData.Add(temp);
+                    }
+                }
+            }
+            DataTable[] Temp = AllSingleBoxCacheData.ToArray();
+            //将所有数据写入到CacheData中
+            if (Temp.Length > 0)
+                for (int i = 0; i < Temp[0].Rows.Count; i++)
+                {
+                    DataRow dr = SingleBoxCacheData.NewRow();
+                    dr["pib_id"] = pib_id_arr[i];
+                    //由于之前加了一个ID列,导致j从1开始
+                    for (int j = 1; j < SingleBoxCacheData.Columns.Count; j++)
+                    {
+                        dr[Temp[j - 1].Columns[0].ColumnName] = Temp[j - 1].Rows[i][0].ToString();
+                    }
+                    SingleBoxCacheData.Rows.Add(dr);
+                }
+        }
+
+        /// <summary>
+        /// 缓存中盒的数据
+        /// </summary>
+        private void GetMidBoxData()
+        {
+            StringBuilder pib_condition_string = new StringBuilder();
+            StringBuilder pib_qtycondition_string = new StringBuilder();
+            //id数组
+            string[] pib_id_arr = MidIDAndOutboxcode.Keys.ToArray();
+            string[] pib_outbox_arr = MidIDAndOutboxcode.Values.ToArray();
+            //记录一个ID用来取中盒的数量
+            string pib_id = pib_id_arr[0];
+            //id个数
+            int pib_id_length = pib_id_arr.Length;
+            //将所有的列存在在这里
+            List<DataTable> AllMidBoxCacheData = new List<DataTable>();
+            //每五百条拼接一次条件
+            int fivehundred_count = pib_id_length / 900 + 1;
+            //当前打印的索引
+            int CurrentCount = 0;
+            for (int i = 0; i < fivehundred_count; i++)
+            {
+                //本次循环的数量
+                int count = 0;
+                pib_condition_string.Append("(");
+                pib_qtycondition_string.Append("(");
+                if (i + 1 == fivehundred_count)
+                    count = pib_id_length - i * 900;
+                else
+                    count = 900;
+                //当前执行的索引
+                int LastCount = CurrentCount;
+                for (int j = LastCount; j < LastCount + count - 1; j++)
+                {
+                    pib_condition_string.Append(pib_id_arr[j] + ",");
+                    pib_qtycondition_string.Append(pib_outbox_arr[j] + ",");
+                    CurrentCount = CurrentCount + 1;
+                }
+                pib_condition_string.Append(pib_id_arr[CurrentCount]);
+                pib_qtycondition_string.Append(pib_outbox_arr[CurrentCount]);
+                pib_condition_string.Append(")");
+                pib_qtycondition_string.Append(")");
+                if (i + 1 != fivehundred_count)
+                    pib_condition_string.Append(" or pib_id in ");
+            }
+            //手动添加ID列
+            DataColumn IDColumn = new DataColumn("pib_id");
+            DataColumn OutBoxColumn = new DataColumn("pib_outboxcode1");
+            MidBoxCacheData.Columns.Add(IDColumn);
+            MidBoxCacheData.Columns.Add(OutBoxColumn);
+            string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
+            DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
+            for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
+            {
+                //将维护的模板参数和模板本身的参数名称进行比对
+                for (int k = 0; k < dt.Rows.Count; k++)
+                {
+                    if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == dt.Rows[k]["lp_name"].ToString())
+                    {
+                        DataColumn dc = new DataColumn(MidDoc.Variables.FreeVariables.Item(j + 1).Name);
+                        MidBoxCacheData.Columns.Add(dc);
+                        MidBoxArgument.Add(MidDoc.Variables.FreeVariables.Item(j + 1).Name);
+                        string sql = dt.Rows[k]["lp_sql"].ToString();
+                        if (sql.ToLower().Contains("pib_qty"))
+                        {
+                            sql = sql.Substring(0, sql.IndexOf("{")) + pib_id + sql.Substring(sql.IndexOf("}") + 1);
+                            sql = sql.Substring(0, sql.LastIndexOf("=")) + " in " + pib_qtycondition_string.ToString() + sql.Substring(sql.LastIndexOf("}") + 1);
+                            Console.WriteLine(sql);
+                        }
+                        else
+                        {
+                            sql = sql.Substring(0, sql.IndexOf("{"));
+                            sql = sql.Substring(0, sql.LastIndexOf("="));
+                            sql = sql + " in " + pib_condition_string.ToString();
+                        }
+                        DataTable temp = dh.getFieldsDatasByCondition(sql);
+                        temp.Columns[0].ColumnName = MidDoc.Variables.FreeVariables.Item(j + 1).Name;
+                        AllMidBoxCacheData.Add(temp);
+                    }
+                }
+            }
+            DataTable[] Temp = AllMidBoxCacheData.ToArray();
+            //将所有数据写入到CacheData中
+            if (Temp.Length > 0)
+            {
+                for (int i = 0; i < Temp[0].Rows.Count; i++)
+                {
+                    DataRow dr = MidBoxCacheData.NewRow();
+                    dr["pib_id"] = pib_id_arr[i];
+                    dr["pib_outboxcode1"] = pib_outbox_arr[i];
+                    //由于之前加了一个ID列和箱号,导致j从2开始
+                    for (int j = 2; j < MidBoxCacheData.Columns.Count; j++)
+                    {
+                        dr[Temp[j - 2].Columns[0].ColumnName] = Temp[j - 2].Rows[i][0].ToString();
+                    }
+                    MidBoxCacheData.Rows.Add(dr);
+                }
+            }
+        }
+
         private void SingleLabelPrint_Click(object sender, EventArgs e)
         {
             if (SingleLabelCombox.Text != "")
@@ -1273,9 +1485,7 @@ namespace UAS_LabelMachine
                 stw.ShowDialog();
             }
             else
-            {
                 MessageBox.Show("未维护中盒标签");
-            }
         }
 
         private void OutBoxPrint()
@@ -1352,6 +1562,7 @@ namespace UAS_LabelMachine
         private void MidBoxCodePrint(string la_id, int rowindex)
         {
             DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
+            string[] arg = MidBoxArgument.ToArray();
             for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
             {
                 //将维护的模板参数和模板本身的参数名称进行比对
@@ -1365,7 +1576,6 @@ namespace UAS_LabelMachine
                         string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
                         //获取打印执行的SQL
                         string sql = dt.Rows[k]["lp_sql"].ToString();
-                        //select * from productiobarcode where pib_id={pib_id} and pib_outboxcode1={pib_outboxcode1}
                         try
                         {
                             //获取打印执行的SQL
@@ -1376,33 +1586,34 @@ namespace UAS_LabelMachine
                             }
                             else
                             {
-                                string ExeSQL = "";
-                                if (sql.ToLower().Contains("pib_lotno"))
-                                    MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_lotno"].Value.ToString();
-                                else if (sql.ToLower().Contains("pib_datecode"))
-                                    MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_datecode"].Value.ToString();
-                                else
+                                DataRow[] dr = MidBoxCacheData.Select("pib_outboxcode1='" + pib_outboxcode1 + "'");
+                                Console.WriteLine(pib_outboxcode1);
+                                if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode1"))
+                                {
+                                    if (LabelInf.Rows[rowindex].Cells["DateCode1"].Value != null)
+                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["DateCode1"].Value.ToString();
+                                }
+                                else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("lotno"))
+                                {
+                                    if (LabelInf.Rows[rowindex].Cells["pib_lotno"].Value != null)
+                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_lotno"].Value.ToString();
+                                }
+                                else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode"))
                                 {
-                                    ExeSQL = sql.Substring(0, sql.IndexOf("{")) + pib_id + sql.Substring(sql.IndexOf("}") + 1);
-                                    ExeSQL = ExeSQL.Substring(0, ExeSQL.IndexOf("{")) + pib_outboxcode1;
-                                    MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(ExeSQL).ToString();
+                                    if (LabelInf.Rows[rowindex].Cells["pib_datecode"].Value != null)
+                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_datecode"].Value.ToString();
                                 }
-                                LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + ExeSQL + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
+                                else if (arg.Contains(MidDoc.Variables.FreeVariables.Item(j + 1).Name))
+                                    MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][MidDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
+                                LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
                             }
                         }
                         catch (Exception)
                         {
-                            MessageBox.Show("SQL维护不正确,请检查SQL语句\n" + sql);
+                            LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
                             return;
                         }
                     }
-                    else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == "DateCode1")
-                    {
-                        if (LabelInf.Rows[rowindex].Cells["DateCode1"].Value != null)
-                        {
-                            MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["DateCode1"].Value.ToString();
-                        }
-                    }
                 }
             }
             //保存参数打印
@@ -1563,6 +1774,11 @@ namespace UAS_LabelMachine
             }
         }
 
+        private void LoadGridData()
+        {
+            LoadGridData(new object(), new EventArgs());
+        }
+
         /// <summary>
         /// 自定义函数  加载明细行的数据,多处使用添加进函数
         /// </summary>
@@ -1793,41 +2009,35 @@ namespace UAS_LabelMachine
         /// <param name="e"></param>
         private void LabelInf_CellValueChanged(object sender, DataGridViewCellEventArgs e)
         {
-            if (LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode")
-            {
-                string datecode = LabelInf.Rows[e.RowIndex].Cells["pib_datecode"].Value.ToString();
-                try
-                {
-                    System.DateTime dt = System.DateTime.ParseExact(datecode, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
-                    GregorianCalendar gc = new GregorianCalendar();
-                    int weekOfYear = gc.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
-                    if (weekOfYear < 10)
-                        LabelInf.Rows[e.RowIndex].Cells["DateCode1"].Value = dt.Year.ToString().Substring(2, 2) + "0" + weekOfYear;
-                    else
-                        LabelInf.Rows[e.RowIndex].Cells["DateCode1"].Value = dt.Year.ToString().Substring(2, 2) + weekOfYear;
-                }
-                catch (Exception) { }
-            }
+            //if (LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode")
+            //{
+            //    string datecode = LabelInf.Rows[e.RowIndex].Cells["pib_datecode"].Value.ToString();
+            //    try
+            //    {
+            //        System.DateTime dt = System.DateTime.ParseExact(datecode, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
+            //        GregorianCalendar gc = new GregorianCalendar();
+            //        int weekOfYear = gc.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
+            //        if (weekOfYear < 10)
+            //            LabelInf.Rows[e.RowIndex].Cells["DateCode1"].Value = dt.Year.ToString().Substring(2, 2) + "0" + weekOfYear;
+            //        else
+            //            LabelInf.Rows[e.RowIndex].Cells["DateCode1"].Value = dt.Year.ToString().Substring(2, 2) + weekOfYear;
+            //    }
+            //    catch (Exception) { }
+            //}
         }
 
         private void AllCollected_Click(object sender, EventArgs e)
         {
             if (AllCollect == false)
             {
-                for (int i = 0; i < LabelInf.RowCount; i++)
-                {
-                    if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "False")
-                        LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
-                }
+                foreach (DataGridViewRow dr in LabelInf.Rows)
+                    dr.Cells[CloumnCount - 2].Value = true;
                 AllCollect = true;
             }
             else
             {
-                for (int i = 0; i < LabelInf.RowCount; i++)
-                {
-                    if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True")
-                        LabelInf.Rows[i].Cells["pib_ifpick"].Value = false;
-                }
+                foreach (DataGridViewRow dr in LabelInf.Rows)
+                    dr.Cells[CloumnCount - 2].Value = false;
                 AllCollect = false;
             }
         }
@@ -2019,5 +2229,21 @@ namespace UAS_LabelMachine
                     MessageBox.Show("请先维护外箱号");
             }
         }
+
+        private void ChooseAll_Click(object sender, EventArgs e)
+        {
+            if (AllChecked)
+            {
+                foreach (DataGridViewRow dr in LabelInf.Rows)
+                    dr.Cells[0].Value = false;
+                AllChecked = false;
+            }
+            else
+            {
+                foreach (DataGridViewRow dr in LabelInf.Rows)
+                    dr.Cells[0].Value = true;
+                AllChecked = true;
+            }
+        }
     }
 }

+ 1 - 2
UAS-出货标签管理/客户标签维护.cs

@@ -36,7 +36,6 @@ namespace UAS_LabelMachine
         string LabelPath = "";
         //模板编号的ID
         string CL_ID1;
-
         string CL_ID2;
         //Label表的主键,用于弹窗的传参
         string La_id1;
@@ -230,7 +229,7 @@ namespace UAS_LabelMachine
                         LabelDataGridView.Rows[i].Cells["cl_labelsoft"].Value = LabelSoft;
                     }
                 }
-                string sql = "Insert into customerlabel (cl_ID,cl_custCODE,cl_LABELTYPE,cl_LABELCODE,cl_LABELURL,cl_DETNO,cl_LABELSOFT,cl_ISDEFAULT, cl_date) values( customerlabel_seq.nextval,'" + cu_code.Text + "',:cl_LABELTYPE,:cl_LABELCODE,:cl_LABELURL,:cl_DETNO,:cl_LABELSOFT,:cl_ISDEFAULT,sysdate )";
+                string sql = "Insert into customerlabel (cl_ID,cl_custCODE,cl_LABELTYPE,cl_LABELCODE,cl_LABELURL,cl_DETNO,cl_LABELSOFT,cl_ISDEFAULT, cl_date) values(customerlabel_seq.nextval,'" + cu_code.Text + "',:cl_LABELTYPE,:cl_LABELCODE,:cl_LABELURL,:cl_DETNO,:cl_LABELSOFT,:cl_ISDEFAULT,sysdate)";
                 dh.UpDateTableByCondition(dt.GetChanges(), "customerlabel", "cl_id", sql.ToLower());
                 LoadData();
             }

+ 3 - 9
UAS-出货标签管理/生成条码.cs

@@ -145,7 +145,7 @@ namespace UAS_LabelMachine
                     //}
                     string pib_barcode = dh.getFieldDataByCondition("prodiobarcode", "max(pib_barcode)", "PIB_INOUTNO='" + pi_inoutno.Text + "'").ToString();
                     //中盒数量*中盒容量=需要打印的单盘标签
-                    ArrayList <string> midcode = new ArrayList<string>();
+                    ArrayList<string> midcode = new ArrayList<string>();
                     ArrayList<string> barcode = new ArrayList<string>();
                     //循环中盒号的个数,取当前出入库单最大 的中盒号+1
                     for (int j = 0; j < mid_num; j++)
@@ -176,7 +176,7 @@ namespace UAS_LabelMachine
                     sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,PIB_BARCODE,PIB_PDNO,");
                     sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,PIB_PRODID,PIB_OUTBOXCODE1,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,PIB_CUSTPO,pib_orderdetno)");
                     sql.Append(" values (prodiobarcode_seq.nextval,'" + pd_prodcode + "',sysdate,'" + pi_inoutno.Text + "'," + pi_id + ",:barcode,'" + pd_pdno + "','" + pd_id + "',");
-                    sql.Append("'" + pi_class.Text + "',:pib_inqty,'" + pr_id + "',:midcode,0,0,'" + pd_ordercode + "','','"+pd_orderdetno+"')");
+                    sql.Append("'" + pi_class.Text + "',:pib_inqty,'" + pr_id + "',:midcode,0,0,'" + pd_ordercode + "','','" + pd_orderdetno + "')");
                     dh.BatchInsert(sql.ToString(), new string[] { "barcode", "pib_inqty", "midcode" }, barcode.ToArray(), pib_inqty.ToArray(), midcode.ToArray());
                 }
             }
@@ -391,13 +391,7 @@ namespace UAS_LabelMachine
                     pd_barcodeioqty = "pd_barcodeoutqty";
                 }
                 sql.Clear();
-                sql.Append("select pd_piid,pd_id,pr_id,pr_brand,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty pd_totalqty,pd_ordercode,pd_orderdetno,pd_prodcode,pd_piclass,pd_qty from (select ");
-                sql.Append("pd_piid,pd_id,pr_id,pr_brand,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty,pd_ordercode,pd_orderdetno,pd_prodcode,pd_piclass,");
-                sql.Append("outqty-nvl((select sum(nvl(pib_qty,0)) from PRODIOBARCODE where PIB_PIID=pd_piid and pib_ordercode=pd_ordercode ");
-                sql.Append("and pib_orderdetno=pd_orderdetno),0)pd_qty from (select pd_piid,min(pd_id) pd_id,sum(pd_outqty)outqty,");
-                sql.Append("pd_ordercode,pd_orderdetno,max(pd_prodcode)pd_prodcode,max(pd_piclass)pd_piclass ");
-                sql.Append("from prodiodetail where pd_piclass='出货单' group by pd_piid,pd_ordercode,pd_orderdetno)T left join product on pr_code=pd_prodcode ");
-                sql.Append("where nvl(pr_zxbzs,0)>0)  where  pd_piid='" + pi_id + "'");
+                sql.Append("select * from prodiobarcode_view where  pd_piid='" + pi_id + "'");
                 dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 BaseUtil.FillDgvWithDataTable(ProdIoInfDGV, dt);
             }