Browse Source

权限设置,日期格式添加,单盘打印调整

章政 6 years ago
parent
commit
2e32aa7832

+ 10 - 94
UAS-出货标签管理(吉利通)/CustomerRule.Designer.cs

@@ -58,18 +58,12 @@
             this.cu_print_checkdatecode = new System.Windows.Forms.CheckBox();
             this.label6 = new System.Windows.Forms.Label();
             this.groupBox2 = new System.Windows.Forms.GroupBox();
-            this.groupBox3 = new System.Windows.Forms.GroupBox();
-            this.radioButton5 = new System.Windows.Forms.RadioButton();
-            this.radioButton4 = new System.Windows.Forms.RadioButton();
-            this.radioButton3 = new System.Windows.Forms.RadioButton();
-            this.radioButton2 = new System.Windows.Forms.RadioButton();
-            this.radioButton1 = new System.Windows.Forms.RadioButton();
             this.FormatExample = new System.Windows.Forms.Label();
             this.FormatExample1 = new System.Windows.Forms.Label();
+            this.cu_print_dateformat = new System.Windows.Forms.TextBox();
             ((System.ComponentModel.ISupportInitialize)(this.cu_print_papercount)).BeginInit();
             this.groupBox1.SuspendLayout();
             this.groupBox2.SuspendLayout();
-            this.groupBox3.SuspendLayout();
             this.SuspendLayout();
             // 
             // cu_print_midlotno
@@ -389,84 +383,6 @@
             this.groupBox2.TabIndex = 67;
             this.groupBox2.TabStop = false;
             // 
-            // groupBox3
-            // 
-            this.groupBox3.Controls.Add(this.radioButton5);
-            this.groupBox3.Controls.Add(this.radioButton4);
-            this.groupBox3.Controls.Add(this.radioButton3);
-            this.groupBox3.Controls.Add(this.radioButton2);
-            this.groupBox3.Controls.Add(this.radioButton1);
-            this.groupBox3.Location = new System.Drawing.Point(290, 540);
-            this.groupBox3.Name = "groupBox3";
-            this.groupBox3.Size = new System.Drawing.Size(660, 45);
-            this.groupBox3.TabIndex = 68;
-            this.groupBox3.TabStop = false;
-            // 
-            // radioButton5
-            // 
-            this.radioButton5.AutoSize = true;
-            this.radioButton5.Font = new System.Drawing.Font("微软雅黑", 9F);
-            this.radioButton5.Location = new System.Drawing.Point(576, 15);
-            this.radioButton5.Name = "radioButton5";
-            this.radioButton5.Size = new System.Drawing.Size(62, 21);
-            this.radioButton5.TabIndex = 63;
-            this.radioButton5.TabStop = true;
-            this.radioButton5.Text = "表达式";
-            this.radioButton5.UseVisualStyleBackColor = true;
-            this.radioButton5.Visible = false;
-            // 
-            // radioButton4
-            // 
-            this.radioButton4.AutoSize = true;
-            this.radioButton4.Font = new System.Drawing.Font("微软雅黑", 9F);
-            this.radioButton4.Location = new System.Drawing.Point(147, 15);
-            this.radioButton4.Name = "radioButton4";
-            this.radioButton4.Size = new System.Drawing.Size(80, 21);
-            this.radioButton4.TabIndex = 62;
-            this.radioButton4.TabStop = true;
-            this.radioButton4.Text = "M/d/yyyy";
-            this.radioButton4.UseVisualStyleBackColor = true;
-            this.radioButton4.CheckedChanged += new System.EventHandler(this.DateFormat_CheckedChanged);
-            // 
-            // radioButton3
-            // 
-            this.radioButton3.AutoSize = true;
-            this.radioButton3.Font = new System.Drawing.Font("微软雅黑", 9F);
-            this.radioButton3.Location = new System.Drawing.Point(426, 15);
-            this.radioButton3.Name = "radioButton3";
-            this.radioButton3.Size = new System.Drawing.Size(62, 21);
-            this.radioButton3.TabIndex = 61;
-            this.radioButton3.TabStop = true;
-            this.radioButton3.Text = "表达式";
-            this.radioButton3.UseVisualStyleBackColor = true;
-            this.radioButton3.Visible = false;
-            // 
-            // radioButton2
-            // 
-            this.radioButton2.AutoSize = true;
-            this.radioButton2.Font = new System.Drawing.Font("微软雅黑", 9F);
-            this.radioButton2.Location = new System.Drawing.Point(290, 15);
-            this.radioButton2.Name = "radioButton2";
-            this.radioButton2.Size = new System.Drawing.Size(100, 21);
-            this.radioButton2.TabIndex = 60;
-            this.radioButton2.TabStop = true;
-            this.radioButton2.Text = "yyyy/MM/dd";
-            this.radioButton2.UseVisualStyleBackColor = true;
-            this.radioButton2.CheckedChanged += new System.EventHandler(this.DateFormat_CheckedChanged);
-            // 
-            // radioButton1
-            // 
-            this.radioButton1.AutoSize = true;
-            this.radioButton1.Font = new System.Drawing.Font("微软雅黑", 9F);
-            this.radioButton1.Location = new System.Drawing.Point(11, 15);
-            this.radioButton1.Name = "radioButton1";
-            this.radioButton1.Size = new System.Drawing.Size(68, 21);
-            this.radioButton1.TabIndex = 59;
-            this.radioButton1.TabStop = true;
-            this.radioButton1.Text = "M/d/yy";
-            this.radioButton1.UseVisualStyleBackColor = true;
-            this.radioButton1.CheckedChanged += new System.EventHandler(this.DateFormat_CheckedChanged);
-            // 
             // FormatExample
             // 
             this.FormatExample.AutoSize = true;
@@ -486,14 +402,21 @@
             this.FormatExample1.Size = new System.Drawing.Size(0, 21);
             this.FormatExample1.TabIndex = 70;
             // 
+            // cu_print_dateformat
+            // 
+            this.cu_print_dateformat.Location = new System.Drawing.Point(301, 556);
+            this.cu_print_dateformat.Name = "cu_print_dateformat";
+            this.cu_print_dateformat.Size = new System.Drawing.Size(114, 21);
+            this.cu_print_dateformat.TabIndex = 71;
+            // 
             // CustomerRule
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1082, 634);
+            this.Controls.Add(this.cu_print_dateformat);
             this.Controls.Add(this.FormatExample1);
             this.Controls.Add(this.FormatExample);
-            this.Controls.Add(this.groupBox3);
             this.Controls.Add(this.groupBox2);
             this.Controls.Add(this.label6);
             this.Controls.Add(this.cu_print_checkdatecode);
@@ -528,8 +451,6 @@
             this.groupBox1.PerformLayout();
             this.groupBox2.ResumeLayout(false);
             this.groupBox2.PerformLayout();
-            this.groupBox3.ResumeLayout(false);
-            this.groupBox3.PerformLayout();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -565,13 +486,8 @@
         private System.Windows.Forms.CheckBox cu_print_checkdatecode;
         private System.Windows.Forms.Label label6;
         private System.Windows.Forms.GroupBox groupBox2;
-        private System.Windows.Forms.GroupBox groupBox3;
-        private System.Windows.Forms.RadioButton radioButton5;
-        private System.Windows.Forms.RadioButton radioButton4;
-        private System.Windows.Forms.RadioButton radioButton3;
-        private System.Windows.Forms.RadioButton radioButton2;
-        private System.Windows.Forms.RadioButton radioButton1;
         private System.Windows.Forms.Label FormatExample;
         private System.Windows.Forms.Label FormatExample1;
+        private System.Windows.Forms.TextBox cu_print_dateformat;
     }
 }

+ 2 - 1
UAS-出货标签管理(吉利通)/CustomerRule.cs

@@ -50,7 +50,7 @@ namespace UAS_LabelMachine
             {
                 CUCODE = e.Node.Tag.ToString();
                 sql.Clear();
-                sql.Append("select cu_print_midlotno,cu_print_midspec,cu_print_checkdatecode,cu_print_recheck,cu_print_midpo,cu_print_midprod,nvl(cu_print_custprodmatchmodel,'Equal')cu_print_custprodmatchmodel,cu_print_outlotno,cu_print_outspec,cu_print_outpo");
+                sql.Append("select cu_print_midlotno,cu_print_midspec,cu_print_dateformat,cu_print_checkdatecode,cu_print_recheck,cu_print_midpo,cu_print_midprod,nvl(cu_print_custprodmatchmodel,'Equal')cu_print_custprodmatchmodel,cu_print_outlotno,cu_print_outspec,cu_print_outpo");
                 sql.Append(",cu_print_outprod,cu_print_checkonly,nvl(cu_print_papercount,0)cu_print_papercount,cu_print_regexpression from customer where cu_code='" + e.Node.Tag + "'");
                 dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 if (dt.Rows.Count > 0)
@@ -100,6 +100,7 @@ namespace UAS_LabelMachine
             sql.Append("cu_print_custprodmatchmodel='" + (Equal.Checked ? "Equal" : "Expression") + "',");
             sql.Append("cu_print_recheck='" + (CustProdAndSpec.Checked ? "CP" : "BR") + "',");
             sql.Append("cu_print_checkdatecode='" + (cu_print_checkdatecode.Checked ? -1 : 0) + "',");
+            sql.Append("cu_print_dateformat='" + cu_print_dateformat.Text + "',");
             sql.Append("cu_print_regexpression=:cu_print_regexpression where cu_code='" + CUCODE + "'");
             dh.ExecuteSql(sql.ToString(), "update", cu_print_regexpression.Text);
             MessageBox.Show("保存成功!", "提示");

+ 0 - 2
UAS-出货标签管理(吉利通)/Entity/SystemInf.cs

@@ -6,8 +6,6 @@
 
         public static AccessDBHelper adh;
 
-        public static AccessDBHelper front_adh;
-
         public static AccessDBHelper back_adh;
     }
 }

+ 0 - 4
UAS-出货标签管理(吉利通)/Login.cs

@@ -12,8 +12,6 @@ namespace UAS_LabelMachine
     public partial class Login : Form
     {
         DataHelper dh;
-        //前端操作
-        AccessDBHelper adh;
         //后端操作
         AccessDBHelper adh1;
         //数据上传操作
@@ -38,11 +36,9 @@ namespace UAS_LabelMachine
             dh = new DataHelper();
             //启动时压缩数据库
             BaseUtil.CompactAccessDB("LabelPrint.accdb");
-            adh = new AccessDBHelper("LabelPrint.accdb");
             adh1 = new AccessDBHelper("LabelPrint.accdb");
             adh2 = new AccessDBHelper("LabelPrint.accdb");
             SystemInf.dh = dh;
-            SystemInf.front_adh = adh;
             SystemInf.back_adh = adh1;
             SystemInf.adh = adh2;
             //获取账套信息

+ 15 - 4
UAS-出货标签管理(吉利通)/PowerSetting.Designer.cs

@@ -41,6 +41,7 @@
             this.lpp_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.em_na = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.lpp_manual = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.lpp_cleandetail = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             ((System.ComponentModel.ISupportInitialize)(this.PowerSetDGV)).BeginInit();
             this.SuspendLayout();
             // 
@@ -53,7 +54,8 @@
             this.lpp_emcode,
             this.lpp_id,
             this.em_na,
-            this.lpp_manual});
+            this.lpp_manual,
+            this.lpp_cleandetail});
             this.PowerSetDGV.Location = new System.Drawing.Point(0, 55);
             this.PowerSetDGV.Name = "PowerSetDGV";
             this.PowerSetDGV.RowTemplate.Height = 23;
@@ -88,7 +90,7 @@
             this.si_expression4_label.AutoSize = true;
             this.si_expression4_label.BackColor = System.Drawing.Color.Transparent;
             this.si_expression4_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.si_expression4_label.Location = new System.Drawing.Point(286, 20);
+            this.si_expression4_label.Location = new System.Drawing.Point(276, 19);
             this.si_expression4_label.Name = "si_expression4_label";
             this.si_expression4_label.Size = new System.Drawing.Size(74, 21);
             this.si_expression4_label.TabIndex = 57;
@@ -97,7 +99,7 @@
             // em_code
             // 
             this.em_code.ID = null;
-            this.em_code.Location = new System.Drawing.Point(107, 20);
+            this.em_code.Location = new System.Drawing.Point(100, 20);
             this.em_code.Name = "em_code";
             this.em_code.Size = new System.Drawing.Size(157, 21);
             this.em_code.Str = null;
@@ -111,7 +113,7 @@
             this.label1.AutoSize = true;
             this.label1.BackColor = System.Drawing.Color.Transparent;
             this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label1.Location = new System.Drawing.Point(9, 20);
+            this.label1.Location = new System.Drawing.Point(9, 19);
             this.label1.Name = "label1";
             this.label1.Size = new System.Drawing.Size(74, 21);
             this.label1.TabIndex = 59;
@@ -159,6 +161,14 @@
             this.lpp_manual.HeaderText = "允许手动采集";
             this.lpp_manual.Name = "lpp_manual";
             // 
+            // lpp_cleandetail
+            // 
+            this.lpp_cleandetail.DataPropertyName = "lpp_cleandetail";
+            this.lpp_cleandetail.HeaderText = "允许重置条码";
+            this.lpp_cleandetail.Name = "lpp_cleandetail";
+            this.lpp_cleandetail.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+            this.lpp_cleandetail.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
+            // 
             // PowerSetting
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -194,5 +204,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn lpp_id;
         private System.Windows.Forms.DataGridViewTextBoxColumn em_na;
         private System.Windows.Forms.DataGridViewCheckBoxColumn lpp_manual;
+        private System.Windows.Forms.DataGridViewCheckBoxColumn lpp_cleandetail;
     }
 }

+ 3 - 3
UAS-出货标签管理(吉利通)/PowerSetting.cs

@@ -35,8 +35,8 @@ namespace UAS_LabelMachine
             {
                 sql.Clear();
                 sql.Append("MERGE INTO labelprintpower alias1 USING (select '" + dt.Rows[i]["em_code"].ToString() + "' em_code from  dual) alias2 ");
-                sql.Append("ON (alias1.lpp_emcode=alias2.em_code) WHEN MATCHED THEN  UPDATE  SET lpp_manual = '" + dt.Rows[i]["lpp_manual"].ToString() + "' ");
-                sql.Append("WHEN NOT MATCHED THEN INSERT (lpp_id,lpp_emcode,lpp_manual) VALUES (labelprintpower_seq.nextval,");
+                sql.Append("ON (alias1.lpp_emcode=alias2.em_code) WHEN MATCHED THEN  UPDATE  SET lpp_manual = '" + dt.Rows[i]["lpp_manual"].ToString() + "', ");
+                sql.Append("lpp_cleandetail = '" + dt.Rows[i]["lpp_cleandetail"].ToString() + "' WHEN NOT MATCHED THEN INSERT (lpp_id,lpp_emcode,lpp_manual) VALUES (labelprintpower_seq.nextval,");
                 sql.Append(" '" + dt.Rows[i]["em_code"].ToString() + "', '" + dt.Rows[i]["lpp_manual"].ToString() + "')");
                 SQLS.Add(sql.ToString());
             }
@@ -46,7 +46,7 @@ namespace UAS_LabelMachine
 
         private void LoadData()
         {
-            string sql = "select em_code,em_name,lpp_id,lpp_emcode,lpp_manual from employee left join labelprintpower on em_code = lpp_emcode " + condition;
+            string sql = "select em_code,em_name,lpp_id,lpp_emcode,lpp_manual,lpp_cleandetail from employee left join labelprintpower on em_code = lpp_emcode " + condition;
             dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             BaseUtil.FillDgvWithDataTable(PowerSetDGV, dt);
         }

+ 21 - 0
UAS-出货标签管理(吉利通)/PowerSetting.resx

@@ -132,6 +132,9 @@
   <metadata name="lpp_manual.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="lpp_cleandetail.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="SaveGrid.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
@@ -145,4 +148,22 @@
         48ufT7++/fX28+vfzz/+UQIABijggAQWaOCBCCao4FEaNejggxBG1NCEFFZoIUIBAQA7
 </value>
   </data>
+  <metadata name="Choose.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="lpp_emcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="lpp_id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="em_na.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="lpp_manual.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="lpp_cleandetail.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
 </root>

+ 0 - 1
UAS-出货标签管理(吉利通)/PublicMethod/AccessDBHelper.cs

@@ -6,7 +6,6 @@ using System.IO;
 using System.Text;
 using System.Windows.Forms;
 
-
 namespace UAS_LabelMachine
 {
     class AccessDBHelper

+ 14 - 2
UAS-出货标签管理(吉利通)/PublicMethod/GlobalEventsHandler.cs

@@ -24,7 +24,7 @@ namespace UAS_Labeling.PublicMethod
             //通过句柄去获取具体触发事件的控件
             Control c = Control.FromHandle(m.HWnd);
             //可进行数据操作的控件需要进行权限的判断,结合WM_LBUTTONDOWN对按钮进行判断
-            if (c != null && m.Msg == WM_LBUTTONDOWN && c is RadioButton)
+            if (c != null && m.Msg == WM_LBUTTONDOWN && (c is RadioButton || c is Button))
             {
                 LogManager.DoLog("点击【" + c.Text + "】");
                 return CheckPower(c);
@@ -45,13 +45,25 @@ namespace UAS_Labeling.PublicMethod
             if (User.UserAccountType != "admin")
             {
                 {
-                    string sql = " select * from labelprintpower where lpp_emcode = '" + User.UserCode + "' and lpp_manual=1";
+                    string sql = " select nvl(lpp_manual,0)lpp_manual,nvl(lpp_cleandetail,0)lpp_cleandetail from labelprintpower where lpp_emcode = '" + User.UserCode + "'";
                     DataTable dt = (DataTable)dh.ExecuteSql(sql, "select");
                     if (dt.Rows.Count > 0)
                     {
                         switch (c.Name)
                         {
                             case "ManualCollection":
+                                if (dt.Rows[0]["lpp_manual"].ToString() == "0")
+                                {
+                                    MessageBox.Show("您没有手动采集的权限,请与管理员联系", "提示");
+                                    return true;
+                                }
+                                break;
+                            case "ResetBarcode":
+                                if (dt.Rows[0]["lpp_cleandetail"].ToString() == "0")
+                                {
+                                    MessageBox.Show("您没有重置条码的权限,请与管理员联系", "提示");
+                                    return true;
+                                }
                                 break;
                             default:
                                 break;

+ 1 - 1
UAS-出货标签管理(吉利通)/UAS-出货标签管理(吉利通).csproj

@@ -103,7 +103,7 @@
       <EmbedInteropTypes>False</EmbedInteropTypes>
     </Reference>
     <Reference Include="Microsoft.Office.Interop.Access.Dao, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
-      <EmbedInteropTypes>True</EmbedInteropTypes>
+      <EmbedInteropTypes>False</EmbedInteropTypes>
       <HintPath>..\packages\Microsoft.Office.Interop.Access.Dao.15.0.4420.1017\lib\net20\Microsoft.Office.Interop.Access.Dao.dll</HintPath>
       <Private>True</Private>
     </Reference>

File diff suppressed because it is too large
+ 985 - 948
UAS-出货标签管理(吉利通)/UAS_出货标签管理.Designer.cs


+ 231 - 266
UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

@@ -26,8 +26,6 @@ namespace UAS_LabelMachine
 
         AccessDBHelper adh;
 
-        AccessDBHelper front_adh;
-
         AccessDBHelper back_adh;
 
         DataTable dt;
@@ -139,7 +137,6 @@ namespace UAS_LabelMachine
             LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
             dh = SystemInf.dh;
             adh = SystemInf.adh;
-            front_adh = SystemInf.front_adh;
             back_adh = SystemInf.back_adh;
             CheckForIllegalCrossThreadCalls = false;
             pi_inoutno.Focus();
@@ -359,6 +356,7 @@ namespace UAS_LabelMachine
                                 AutoPrintMidLabel();
                             LogicHandler.SendDataToPLC(PLC1, PLCInstruct.FrontDataPass, adh);
                             LabelInf.Invalidate();
+                            RefreshProcessData();
                         }
                         break;
                     case "BackendCheck":
@@ -469,7 +467,6 @@ namespace UAS_LabelMachine
                                         {
                                             sql += "and pib_ifrecheck=0";
                                         }
-                                        Console.WriteLine(adh.getRowCount("prodiobarcode","pib_ifrecheck=-1"));
                                         DataTable pndt = (DataTable)adh.ExecuteSql(sql, "select");
                                         if (pndt.Rows[0][0].ToString() != "")
                                         {
@@ -538,7 +535,6 @@ namespace UAS_LabelMachine
                     }
                     else
                     {
-                        Console.WriteLine("行号"+rownum);
                         break;
                     }
                 }
@@ -560,9 +556,6 @@ namespace UAS_LabelMachine
         private bool FrontCheckFunction(string msg, out string ErrorMsg)
         {
             ErrorMsg = "";
-            string year = "0";
-            string month = "0";
-            string day = "0";
             //调用正则验证
             RegexMatch("FrontCheck", msg, out ErrorMsg);
             if (ErrorMsg != "")
@@ -573,180 +566,10 @@ namespace UAS_LabelMachine
             {
                 //获取当前最大的箱号
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value = DateCode;
-                //解析DateCode,将值设置到年月日
-                try
-                {
-                    LogicHandler.GetTimeFromDatecode(DateCode, "", out year, out month, out day);
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_year"].Value = year;
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_month"].Value = month;
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_day"].Value = day;
-                }
-                catch (Exception)
-                {
 
-                }
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value = LotNo;
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_ifmodify"].Value = true;
-                string boxcode = front_adh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode1)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
-                int outboxcode1 = int.Parse(Process_midboxcode.Text == "" ? "1" : Process_midboxcode.Text);
-                boxcode = front_adh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode2)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
-                int outboxcode2 = int.Parse(Process_outboxcode.Text == "" ? "1" : Process_outboxcode.Text);
-                string pd_id = LabelInf.Rows[CurrentRowIndex].Cells["pd_id"].Value.ToString();
-                //如果满容量获取过箱号就不再重复获取了
-                bool GetBarcode = false;
-                //超过中盒容量中盒号+1
-                if (front_adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + outboxcode1) >= MidBoxCapacity.Value)
-                {
-                    outboxcode1 = outboxcode1 + 1;
-                    GetBarcode = true;
-                    LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                    LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, front_adh);
-                }
-                //获取当前的行号
-                int CurrentRowNum = int.Parse(LabelInf.Rows[CurrentRowIndex].Cells["rownum"].Value.ToString());
-                //获取上一行的数据
-                DataTable LastRowData = null;
-                if (CurrentRowNum - 1 > 0)
-                {
-                    LastRowData = (DataTable)front_adh.ExecuteSql("select pib_lotno,pib_custmidboxcode,pib_custoutboxcode,pd_pocode,pd_custprodcode,pd_custprodspec,pib_datecode from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and rownum=" + (CurrentRowNum - 1), "select");
-                    //或者不符合合并条件中盒号+1
-                    if (cu_print_midlotno.Checked)
-                    {
-                        string TempData = LastRowData.Rows[0]["pib_lotno"].ToString();
-                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() && !GetBarcode)
-                        {
-                            LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                            LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, front_adh);
-                            LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
-                            outboxcode1 = outboxcode1 + 1;
-                        }
-                    }
-                    else if (cu_print_midpo.Checked)
-                    {
-                        string TempData = LastRowData.Rows[0]["pd_pocode"].ToString();
-                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
-                        {
-                            LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                            LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, front_adh);
-                            LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
-                            outboxcode1 = outboxcode1 + 1;
-                        }
-                    }
-                    else if (cu_print_midprod.Checked)
-                    {
-                        string TempData = LastRowData.Rows[0]["pd_custprodcode"].ToString();
-                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
-                        {
-                            LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                            LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, front_adh);
-                            LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
-                            outboxcode1 = outboxcode1 + 1;
-                        }
-                    }
-                    else if (cu_print_midspec.Checked)
-                    {
-                        string TempData = LastRowData.Rows[0]["pd_custprodspec"].ToString();
-                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
-                        {
-                            LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                            LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, front_adh);
-                            LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
-                            outboxcode1 = outboxcode1 + 1;
-                        }
-                    }
-                    else if (cu_print_middc.Checked)
-                    {
-                        string TempData = LastRowData.Rows[0]["pib_datecode"].ToString();
-                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
-                        {
-                            LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                            LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, front_adh);
-                            LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
-                            outboxcode1 = outboxcode1 + 1;
-                        }
-                    }
-                    if (LastRowData.Rows[0]["pib_custmidboxcode"].ToString() == MidBoxBarCode)
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = LastRowData.Rows[0]["pib_custmidboxcode"].ToString();
-                    else
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
-                }
-                else
-                {
-                    LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
-                }
-                GetBarcode = false;
-                if (front_adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2=" + outboxcode2) >= OutBoxCapacity.Value)
-                {
-                    GetBarcode = true;
-                    outboxcode2 = outboxcode2 + 1;
-                    LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
-                }
-                else if (CurrentRowNum - 1 > 0)
-                {
-                    //或者不符合合并条件中盒号+1
-                    if (cu_print_outlotno.Checked)
-                    {
-                        string TempData = LastRowData.Rows[0]["pib_lotno"].ToString();
-                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() && !GetBarcode)
-                        {
-                            LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                            LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
-                        }
-                    }
-                    else if (cu_print_outpo.Checked)
-                    {
-                        string TempData = LastRowData.Rows[0]["pd_pocode"].ToString();
-                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
-                        {
-                            LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                            LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
-                        }
-                    }
-                    else if (cu_print_outprod.Checked)
-                    {
-                        string TempData = LastRowData.Rows[0]["pd_custprodcode"].ToString();
-                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
-                        {
-                            LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                            LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
-                        }
-                    }
-                    else if (cu_print_outspec.Checked)
-                    {
-                        string TempData = LastRowData.Rows[0]["pd_custprodspec"].ToString();
-                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
-                        {
-                            LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                            LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
-                        }
-                    }
-                    else if (cu_print_outdc.Checked)
-                    {
-                        string TempData = LastRowData.Rows[0]["pib_datecode"].ToString();
-                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
-                        {
-                            LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                            LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
-                        }
-                    }
-                    if (OutBoxBarCode == LastRowData.Rows[0]["pib_custoutboxcode"].ToString())
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = LastRowData.Rows[0]["pib_custoutboxcode"].ToString();
-                    else
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
-                }
-                else
-                {
-                    LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
-                }
-                //设置中盒外箱号
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value = outboxcode1;
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value = outboxcode2;
-                string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
-                front_adh.ExecuteSql("update prodiobarcode set pib_year=" + year + ",pib_month=" + month + ",pib_day=" + day + ",pib_outboxcode2=" + outboxcode2 + ",pib_outboxcode1=" + outboxcode1 + ",pib_custoutboxcode='" + OutBoxBarCode + "',pib_custmidboxcode='" + MidBoxBarCode + "',pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1,pib_ifmodify=-1 where pib_id=" + pib_id, "update");
-                LabelInf.Invalidate();
+                SetOutboxBarcode();
                 return true;
             }
         }
@@ -919,14 +742,13 @@ namespace UAS_LabelMachine
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_month"].Value = month;
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_day"].Value = day;
                     }
-                    catch (Exception){}
+                    catch (Exception) { }
                     LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value = LotNo;
                     LabelInf.Rows[CurrentRowIndex].Cells["pib_ifmodify"].Value = true;
                     LabelInf.Rows[CurrentRowIndex].Cells["pib_ifrecheck"].Value = true;
                     LabelInf.Rows[CurrentRowIndex].Cells["pib_ifpick"].Value = true;
-                    back_adh.ExecuteSQLTran("update prodiobarcode set pib_year=" + year + ",pib_month=" + month + ",pib_day=" + day + ",pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1,pib_ifmodify=-1,pib_ifrecheck=-1 where pib_id=" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value);
-                    Console.WriteLine("勾选行数"+ back_adh.getRowCount("prodiobarcode", "pib_ifrecheck=-1"));
-                    Console.WriteLine("勾选行数"+adh.getRowCount("prodiobarcode", "pib_ifrecheck=-1"));
+                    adh.ExecuteSQLTran("update prodiobarcode set pib_year=" + year + ",pib_month=" + month + ",pib_day=" + day + ",pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1,pib_ifmodify=-1,pib_ifrecheck=-1 where pib_id=" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value);
+                    LogicHandler.CheckUploadData(pi_inoutno.Text, UploadNum);
                     LabelInf.Invalidate();
                     return true;
                 }
@@ -971,39 +793,12 @@ namespace UAS_LabelMachine
             }
         }
 
-        private void AutoPrintSingleLabel()
+        private bool AutoPrintSingleLabel()
         {
             //用标签本身的变量作为最外层的循环条件去匹配;
-            string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
-            sql.Clear();
-            for (int i = 0; i < SingleDoc.Variables.FormVariables.Count; i++)
-            {
-                DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(i + 1).Name.ToLower() + "'");
-                if (dr1.Length > 0)
-                {
-                    sql.Append(dr1[0]["lp_sql"].ToString() + ",");
-                }
-            }
-            sql.Append("1,");
-            DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
-            for (int i = 0; i < SingleDoc.Variables.FormVariables.Count; i++)
-            {
-                DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(i + 1).Name.ToLower() + "'");
-                if (dr1.Length > 0)
-                {
-                    SingleDoc.Variables.FormVariables.Item(i + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
-                }
-                if (SingleDoc.Variables.FormVariables.Item(i + 1).Value == "")
-                {
-                    dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(i + 1).Name.ToLower() + "'");
-                    if (dr1.Length > 0)
-                        SingleDoc.Variables.FormVariables.Item(i + 1).Value = dr1[0]["lp_sql"].ToString();
-                }
-            }
-            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-            SingleDoc.PrintDocument();
-            LogicHandler.UpdateRowPrinted(pib_id);
+            SinglePrint(LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString());
             LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
+            return true;
         }
 
         //关闭窗口前提示用户确认
@@ -1135,7 +930,7 @@ namespace UAS_LabelMachine
                     //}
                     //获取客户自定义设置
                     sql.Clear();
-                    sql.Append("select cu_print_middc,cu_print_outdc,cu_print_checkdatecode,cu_print_midlotno,nvl(cu_print_custprodmatchmodel,'Equal')cu_print_custprodmatchmodel,cu_print_midspec,cu_print_midpo,cu_print_midprod,cu_print_outlotno,cu_print_outspec,cu_print_outpo");
+                    sql.Append("select cu_print_middc,cu_print_outdc,cu_print_dateformat,cu_print_checkdatecode,cu_print_midlotno,nvl(cu_print_custprodmatchmodel,'Equal')cu_print_custprodmatchmodel,cu_print_midspec,cu_print_midpo,cu_print_midprod,cu_print_outlotno,cu_print_outspec,cu_print_outpo");
                     sql.Append(",cu_print_outprod,cu_print_checkonly,nvl(cu_print_papercount,0)cu_print_papercount,cu_print_regexpression,cu_print_recheck from customer where cu_code='" + pi_cardcode.Text + "'");
                     dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                     if (dt.Rows.Count > 0)
@@ -1188,8 +983,6 @@ namespace UAS_LabelMachine
                     SingleBoxArgument.Clear();
                     MidIDAndOutboxcode.Clear();
                     SingleID.Clear();
-                    //刷新采集进度
-                    RefreshProcessData();
                     thread = new Thread(GetInOutInfAndLabelFile);
                     stw = new SetLoadingWindow(thread, "正在获取打印标签");
                     BaseUtil.SetFormCenter(stw);
@@ -1289,35 +1082,7 @@ namespace UAS_LabelMachine
                         //以标签模板的参数为基准,循环取数
                         try
                         {
-                            string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
-                            sql.Clear();
-                            for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
-                            {
-                                DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
-                                if (dr1.Length > 0)
-                                {
-                                    sql.Append(dr1[0]["lp_sql"].ToString() + ",");
-                                }
-                            }
-                            sql.Append("1,");
-                            DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
-                            for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
-                            {
-                                DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
-                                if (dr1.Length > 0)
-                                {
-                                    SingleDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
-                                }
-                                if (SingleDoc.Variables.FormVariables.Item(j + 1).Value == "")
-                                {
-                                    dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
-                                    if (dr1.Length > 0)
-                                        SingleDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
-                                }
-                            }
-                            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-                            SingleDoc.PrintDocument();
-                            LogicHandler.UpdateRowPrinted(pib_id);
+                            SinglePrint(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
                             if (MidLabelAutoPrint.Checked)
                             {
                                 //判断当前行的盒号和下一行不相等或者已经是最后一行了
@@ -1338,7 +1103,6 @@ namespace UAS_LabelMachine
                         catch (Exception ex) { LogManager.DoLog(ex.Message); }
                     }
                 }
-                dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
                 if (CheckedRowCount == 0)
                     MessageBox.Show("未勾选打印明细!");
                 else if (CurrentRowIndex + 1 < LabelInf.Rows.Count)
@@ -1822,6 +1586,7 @@ namespace UAS_LabelMachine
             }
             //获取所有的匹配脚本
             ScanGroup = (DataTable)dh.ExecuteSql("select distinct sg_brand,sg_id,sg_name,sg_script from prodiobarcode left join scangroup on pib_brand=sg_brand where pib_inoutno='" + pi_inoutno.Text + "' and sg_id is not null and nvl(sg_autolabel,0)=0", "select");
+            RefreshProcessData();
         }
 
 
@@ -2505,37 +2270,237 @@ namespace UAS_LabelMachine
             DataTable pibid_dt = (DataTable)adh.ExecuteSql("select pib_id from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno=" + pdno, "select");
             for (int i = 0; i < pibid_dt.Rows.Count; i++)
             {
-                string pib_id = pibid_dt.Rows[i]["pib_id"].ToString();
-                sql.Clear();
-                for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
+                SinglePrint(pibid_dt.Rows[i]["pib_id1"].ToString());
+            }
+            setvalueandprint.FindForm().Close();
+        }
+
+
+
+        private void ResetBarcode_Click(object sender, EventArgs e)
+        {
+            string close = MessageBox.Show(this.ParentForm, "是否重置本单据条码", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+            if (close == "Yes")
+            {
+                dh.ExecuteSql("delete from prodiobarcode  where pib_inoutno='" + pi_inoutno.Text + "'", "delete");
+                adh.ExecuteSql("delete from prodiobarcode  where pib_inoutno='" + pi_inoutno.Text + "'", "delete");
+            }
+        }
+
+        private void SetOutboxBarcode()
+        {
+            string year = "0";
+            string month = "0";
+            string day = "0";
+            //解析DateCode,将值设置到年月日
+            try
+            {
+                LogicHandler.GetTimeFromDatecode(DateCode, "", out year, out month, out day);
+                LabelInf.Rows[CurrentRowIndex].Cells["pib_year"].Value = year;
+                LabelInf.Rows[CurrentRowIndex].Cells["pib_month"].Value = month;
+                LabelInf.Rows[CurrentRowIndex].Cells["pib_day"].Value = day;
+            }
+            catch (Exception) { }
+            int outboxcode1 = int.Parse(Process_midboxcode.Text == "" ? "1" : Process_midboxcode.Text);
+            int outboxcode2 = int.Parse(Process_outboxcode.Text == "" ? "1" : Process_outboxcode.Text);
+            string pd_id = LabelInf.Rows[CurrentRowIndex].Cells["pd_id"].Value.ToString();
+            //如果满容量获取过箱号就不再重复获取了
+            bool GetBarcode = false;
+            //超过中盒容量中盒号+1
+            if (adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + outboxcode1) >= MidBoxCapacity.Value)
+            {
+                outboxcode1 = outboxcode1 + 1;
+                GetBarcode = true;
+                LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+            }
+            //获取当前的行号
+            int CurrentRowNum = int.Parse(LabelInf.Rows[CurrentRowIndex].Cells["rownum"].Value.ToString());
+            //获取上一行的数据
+            DataTable LastRowData = null;
+            if (CurrentRowNum - 1 > 0)
+            {
+                LastRowData = (DataTable)adh.ExecuteSql("select pib_lotno,pib_custmidboxcode,pib_custoutboxcode,pd_pocode,pd_custprodcode,pd_custprodspec,pib_datecode from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and rownum=" + (CurrentRowNum - 1), "select");
+                //或者不符合合并条件中盒号+1
+                if (cu_print_midlotno.Checked)
+                {
+                    string TempData = LastRowData.Rows[0]["pib_lotno"].ToString();
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() && !GetBarcode)
+                    {
+                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        outboxcode1 = outboxcode1 + 1;
+                    }
+                }
+                else if (cu_print_midpo.Checked)
                 {
-                    DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
-                    if (dr1.Length > 0)
+                    string TempData = LastRowData.Rows[0]["pd_pocode"].ToString();
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
                     {
-                        sql.Append(dr1[0]["lp_sql"].ToString() + ",");
+                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        outboxcode1 = outboxcode1 + 1;
                     }
                 }
-                sql.Append("1,");
-                DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
-                for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
+                else if (cu_print_midprod.Checked)
                 {
-                    DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
-                    if (dr1.Length > 0)
+                    string TempData = LastRowData.Rows[0]["pd_custprodcode"].ToString();
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
                     {
-                        SingleDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
+                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        outboxcode1 = outboxcode1 + 1;
                     }
-                    if (SingleDoc.Variables.FormVariables.Item(j + 1).Value == "")
+                }
+                else if (cu_print_midspec.Checked)
+                {
+                    string TempData = LastRowData.Rows[0]["pd_custprodspec"].ToString();
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
                     {
-                        dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
-                        if (dr1.Length > 0)
-                            SingleDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
+                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        outboxcode1 = outboxcode1 + 1;
                     }
                 }
-                SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-                SingleDoc.PrintDocument();
-                LogicHandler.UpdateRowPrinted(pib_id);
+                else if (cu_print_middc.Checked)
+                {
+                    string TempData = LastRowData.Rows[0]["pib_datecode"].ToString();
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
+                    {
+                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        outboxcode1 = outboxcode1 + 1;
+                    }
+                }
+                if (LastRowData.Rows[0]["pib_custmidboxcode"].ToString() == MidBoxBarCode)
+                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = LastRowData.Rows[0]["pib_custmidboxcode"].ToString();
+                else
+                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
             }
-            setvalueandprint.FindForm().Close();
+            else
+            {
+                LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+            }
+            GetBarcode = false;
+            if (adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2=" + outboxcode2) >= OutBoxCapacity.Value)
+            {
+                GetBarcode = true;
+                outboxcode2 = outboxcode2 + 1;
+                LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                Console.WriteLine("1" + OutBoxBarCode);
+                LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+            }
+            else if (CurrentRowNum - 1 > 0)
+            {
+                //或者不符合合并条件中盒号+1
+                if (cu_print_outlotno.Checked)
+                {
+                    string TempData = LastRowData.Rows[0]["pib_lotno"].ToString();
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() && !GetBarcode)
+                    {
+                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                        Console.WriteLine("2" + OutBoxBarCode);
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                    }
+                }
+                else if (cu_print_outpo.Checked)
+                {
+                    string TempData = LastRowData.Rows[0]["pd_pocode"].ToString();
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
+                    {
+                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                        Console.WriteLine("3" + OutBoxBarCode);
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                    }
+                }
+                else if (cu_print_outprod.Checked)
+                {
+                    string TempData = LastRowData.Rows[0]["pd_custprodcode"].ToString();
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
+                    {
+                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                        Console.WriteLine("4" + OutBoxBarCode);
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                    }
+                }
+                else if (cu_print_outspec.Checked)
+                {
+                    string TempData = LastRowData.Rows[0]["pd_custprodspec"].ToString();
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
+                    {
+                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                        Console.WriteLine("5" + OutBoxBarCode);
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                    }
+                }
+                else if (cu_print_outdc.Checked)
+                {
+                    string TempData = LastRowData.Rows[0]["pib_datecode"].ToString();
+                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
+                    {
+                        LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        Console.WriteLine("6" + OutBoxBarCode);
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                    }
+                }
+                if (OutBoxBarCode == LastRowData.Rows[0]["pib_custoutboxcode"].ToString())
+                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = LastRowData.Rows[0]["pib_custoutboxcode"].ToString();
+                else
+                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+            }
+            else
+            {
+                LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                Console.WriteLine("1" + OutBoxBarCode);
+                LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+            }
+            //设置中盒外箱号
+            LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value = outboxcode1;
+            LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value = outboxcode2;
+            string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
+            if (SingleLabelAutoPrint.Checked)
+                adh.ExecuteSql("update prodiobarcode set pib_year=" + year + ",pib_month=" + month + ",pib_day=" + day + ",pib_outboxcode2=" + outboxcode2 + ",pib_outboxcode1=" + outboxcode1 + ",pib_custoutboxcode='" + OutBoxBarCode + "',pib_custmidboxcode='" + MidBoxBarCode + "',pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1,pib_ifmodify=-1,pib_ifprint=-1 where pib_id=" + pib_id, "update");
+            else
+                adh.ExecuteSql("update prodiobarcode set pib_year=" + year + ",pib_month=" + month + ",pib_day=" + day + ",pib_outboxcode2=" + outboxcode2 + ",pib_outboxcode1=" + outboxcode1 + ",pib_custoutboxcode='" + OutBoxBarCode + "',pib_custmidboxcode='" + MidBoxBarCode + "',pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1,pib_ifmodify=-1 where pib_id=" + pib_id, "update");
+            LabelInf.Invalidate();
+        }
+
+        private void SinglePrint(string pib_id)
+        {
+            sql.Clear();
+            for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
+            {
+                DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
+                if (dr1.Length > 0)
+                {
+                    sql.Append(dr1[0]["lp_sql"].ToString() + ",");
+                }
+            }
+            sql.Append("1,");
+            DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
+            for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
+            {
+                DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
+                if (dr1.Length > 0)
+                {
+                    SingleDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
+                }
+                if (SingleDoc.Variables.FormVariables.Item(j + 1).Value == "")
+                {
+                    dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
+                    if (dr1.Length > 0)
+                        SingleDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
+                }
+            }
+            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+            SingleDoc.PrintDocument();
+            LogicHandler.UpdateRowPrinted(pib_id);
         }
     }
 }

Some files were not shown because too many files changed in this diff