Browse Source

in的方式只支持1000的缓存,现在修改为每500 or in

章政 8 years ago
parent
commit
f49187b786

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

@@ -55,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;
@@ -83,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;
     }
 }

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

@@ -27,6 +27,9 @@ namespace UAS_LabelMachine.PublicForm
             loadingCircle1.OuterCircleRadius = 20;
             loadingCircle1.InnerCircleRadius = 12;
             loadingCircle1.Active = true;
+            if (Text != "正在获取打印标签") {
+                CancelThread.Visible = false;
+            }
             LoadingThread.Start();
             //在本窗体新建一个进程用来判断传递的进程是否执行结束
             Thread t1 = new Thread(SetLoadFinish);
@@ -49,5 +52,10 @@ namespace UAS_LabelMachine.PublicForm
                 e.Cancel=true;
             }
         }
+
+        private void CancelThread_Click(object sender, EventArgs e)
+        {
+            LoadingThread.Abort();
+        }
     }
 }

+ 31 - 32
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, 85);
             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, 140);
             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, 110);
             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, 25);
             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, 25);
             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, 25);
             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, 111);
             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, 140);
             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, 60);
             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, 60);
             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, 25);
             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
@@ -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(106, 205);
             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(106, 252);
             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, 135);
             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, 211);
             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, 173);
             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, 175);
             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, 135);
             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, 12);
             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, 215);
             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, 255);
             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, 255);
             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, 171);
             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(12, 131);
             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;
@@ -1763,5 +1761,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode2;
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifpick;
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifprint;
+        private System.Windows.Forms.Button ChooseAll;
     }
 }

+ 147 - 73
UAS-出货标签管理/UAS_出货标签管理.cs

@@ -94,14 +94,22 @@ namespace UAS_LabelMachine
 
         Dictionary<string, string> CollectData;
 
+        /// <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>();
         //使用二维数组进行排序
@@ -139,6 +147,7 @@ namespace UAS_LabelMachine
             LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
             dh = new DataHelper();
             CheckForIllegalCrossThreadCalls = false;
+            CloumnCount = LabelInf.Columns.Count;
             pi_inoutno.Focus();
             //将本地读取的打印机设置进Combox,并选中默认打印机
             if (User.UserAccountType == "admin")
@@ -156,7 +165,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;
@@ -1062,19 +1070,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, "正在获取打印标签");
@@ -1102,6 +1102,85 @@ namespace UAS_LabelMachine
                 Dictionary<string, bool> outboxcode1 = new Dictionary<string, bool>();
                 //判断所有盒号为该盒的是否勾选已采集
                 outboxcode1.Add(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString(), true);
+                List<string> pib_id_list = new List<string>();
+                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")
+                        pib_id_list.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
+                }
+                if (pib_id_list.ToArray().Length == 0)
+                {
+                    MessageBox.Show("必须已采集的数据才能进行打印");
+                    return;
+                }
+                StringBuilder pib_id_string = new StringBuilder();
+                //id数组
+                string[] pib_id_arr = pib_id_list.ToArray();
+                //id个数
+                int pib_id_length = pib_id_arr.Length;
+                //将所有的列存在在这里
+                List<DataTable> AllCacheData = new List<DataTable>();
+                List<string> Argument = new List<string>();
+                int fivehundred_count = pib_id_length / 500 + 1;
+                for (int i = 0; i < fivehundred_count; i++)
+                {
+                    pib_id_string.Append("(");
+                    int count = 0;
+                    if (i + 1 == fivehundred_count)
+                        count = pib_id_length - i * 500;
+                    else
+                        count = 500;
+                    for (int j = 0; j < count; j++)
+                    {
+                        if (j + 1 == count)
+                            pib_id_string.Append(pib_id_arr[j]);
+                        else
+                            pib_id_string.Append(pib_id_arr[j] + ",");
+                    }
+                    pib_id_string.Append(")");
+                    if (i + 1 != fivehundred_count)
+                        pib_id_string.Append(" or pib_id in ");
+
+                }
+                //缓存数据的DataTable
+                DataTable CacheData = new DataTable();
+                //手动添加ID列
+                DataColumn datacolumn = new DataColumn("pib_id");
+                CacheData.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);
+                            CacheData.Columns.Add(dc);
+                            Argument.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;
+                            AllCacheData.Add(temp);
+                        }
+                    }
+                }
+                DataTable[] Temp = AllCacheData.ToArray();
+                //将所有数据写入到CacheData中
+                if (Temp.Length > 0)
+                    for (int i = 0; i < Temp[0].Rows.Count; i++)
+                    {
+                        DataRow dr = CacheData.NewRow();
+                        dr["pib_id"] = pib_id_arr[i];
+                        //由于之前加了一个ID列,导致j从1开始
+                        for (int j = 1; j < CacheData.Columns.Count; j++)
+                        {
+                            dr[Temp[j - 1].Columns[0].ColumnName] = Temp[j - 1].Rows[i][0].ToString();
+                        }
+                        CacheData.Rows.Add(dr);
+                    }
                 for (int i = 0; i < LabelInf.RowCount; i++)
                 {
                     if (i + 1 < LabelInf.RowCount)
@@ -1122,9 +1201,11 @@ namespace UAS_LabelMachine
                 }
                 //用于判断用户是否勾选了行
                 int CheckedRowCount = 0;
+                string[] arg = Argument.ToArray();
                 //打印所有的选中行
                 for (int i = 0; i < LabelInf.RowCount; 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")
                     {
@@ -1133,52 +1214,35 @@ namespace UAS_LabelMachine
                         //以标签模板的参数为基准,循环取数
                         try
                         {
+                            string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
+                            DataRow[] dr = CacheData.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();
+                            //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;
@@ -1793,21 +1857,21 @@ 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)
@@ -1815,19 +1879,13 @@ namespace UAS_LabelMachine
             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;
-                }
+                    LabelInf.Rows[i].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;
-                }
+                    LabelInf.Rows[i].Cells[CloumnCount - 2].Value = false;
                 AllCollect = false;
             }
         }
@@ -2019,5 +2077,21 @@ namespace UAS_LabelMachine
                     MessageBox.Show("请先维护外箱号");
             }
         }
+
+        private void ChooseAll_Click(object sender, EventArgs e)
+        {
+            if (AllChecked)
+            {
+                for (int i = 0; i < LabelInf.RowCount; i++)
+                    LabelInf.Rows[i].Cells[0].Value = false;
+                AllChecked = false;
+            }
+            else
+            {
+                for (int i = 0; i < LabelInf.RowCount; i++)
+                    LabelInf.Rows[i].Cells[0].Value = true;
+                AllChecked = true;
+            }
+        }
     }
 }