Browse Source

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

Hcsy 7 years ago
parent
commit
e97d580745

+ 18 - 6
PLCDataReader/Main.Designer.cs

@@ -111,6 +111,7 @@ namespace UAS_PLCDataReader
             this.dc_id = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dc_code = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dc_name = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.dc_ifng = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dc_type = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dc_typename = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dc_dataindex = new DevExpress.XtraGrid.Columns.GridColumn();
@@ -1039,6 +1040,7 @@ namespace UAS_PLCDataReader
             this.dc_id,
             this.dc_code,
             this.dc_name,
+            this.dc_ifng,
             this.dc_type,
             this.dc_typename,
             this.dc_dataindex,
@@ -1060,7 +1062,7 @@ namespace UAS_PLCDataReader
             this.CommandSetCheckedColumn.FieldName = "CHECKEDCOLUMN";
             this.CommandSetCheckedColumn.Name = "CommandSetCheckedColumn";
             this.CommandSetCheckedColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
-            this.CommandSetCheckedColumn.Tag = "0";
+            this.CommandSetCheckedColumn.Tag = "1";
             this.CommandSetCheckedColumn.Visible = true;
             this.CommandSetCheckedColumn.VisibleIndex = 0;
             this.CommandSetCheckedColumn.Width = 39;
@@ -1094,6 +1096,15 @@ namespace UAS_PLCDataReader
             this.dc_name.VisibleIndex = 2;
             this.dc_name.Width = 61;
             // 
+            // dc_ifng
+            // 
+            this.dc_ifng.Caption = "是否NG";
+            this.dc_ifng.ColumnEdit = this.CheckEditCommandSet;
+            this.dc_ifng.FieldName = "DC_IFNG";
+            this.dc_ifng.Name = "dc_ifng";
+            this.dc_ifng.Visible = true;
+            this.dc_ifng.VisibleIndex = 4;
+            // 
             // dc_type
             // 
             this.dc_type.Caption = "指令值";
@@ -1117,7 +1128,7 @@ namespace UAS_PLCDataReader
             this.dc_dataindex.FieldName = "DC_DATAINDEX";
             this.dc_dataindex.Name = "dc_dataindex";
             this.dc_dataindex.Visible = true;
-            this.dc_dataindex.VisibleIndex = 4;
+            this.dc_dataindex.VisibleIndex = 5;
             this.dc_dataindex.Width = 62;
             // 
             // dc_value
@@ -1126,7 +1137,7 @@ namespace UAS_PLCDataReader
             this.dc_value.FieldName = "DC_VALUE";
             this.dc_value.Name = "dc_value";
             this.dc_value.Visible = true;
-            this.dc_value.VisibleIndex = 5;
+            this.dc_value.VisibleIndex = 6;
             this.dc_value.Width = 128;
             // 
             // dc_sendcoding
@@ -1159,7 +1170,7 @@ namespace UAS_PLCDataReader
             this.dc_man.Name = "dc_man";
             this.dc_man.OptionsColumn.AllowEdit = false;
             this.dc_man.Visible = true;
-            this.dc_man.VisibleIndex = 7;
+            this.dc_man.VisibleIndex = 8;
             this.dc_man.Width = 126;
             // 
             // dc_date
@@ -1171,7 +1182,7 @@ namespace UAS_PLCDataReader
             this.dc_date.Name = "dc_date";
             this.dc_date.OptionsColumn.AllowEdit = false;
             this.dc_date.Visible = true;
-            this.dc_date.VisibleIndex = 8;
+            this.dc_date.VisibleIndex = 9;
             this.dc_date.Width = 107;
             // 
             // repositoryItemDateEdit1
@@ -1189,7 +1200,7 @@ namespace UAS_PLCDataReader
             this.db_name.FieldName = "DB_NAME";
             this.db_name.Name = "db_name";
             this.db_name.Visible = true;
-            this.db_name.VisibleIndex = 6;
+            this.db_name.VisibleIndex = 7;
             this.db_name.Width = 47;
             // 
             // PageDeviceNetSetting
@@ -2678,5 +2689,6 @@ namespace UAS_PLCDataReader
         private CheckEdit CheckOUTQTY;
         private CheckEdit CheckPARAM;
         private CheckEdit CheckINQTY;
+        private DevExpress.XtraGrid.Columns.GridColumn dc_ifng;
     }
 }

+ 2 - 3
PLCDataReader/Main.cs

@@ -191,7 +191,7 @@ namespace UAS_PLCDataReader
             ButtonDeleteCommandSet.Grid = GridPollingSetting;
 
             //指令设置界面
-            GridCommandSetting.GetDataSQL = "select 0 CHECKEDCOLUMN,dc_id,dc_code,dc_name,dc_type,case when dc_type='INQTY' then '投入' when dc_type='NGQTY' then '不良' when dc_type='OUTQTY' then '产出' when dc_type='TEMPERATURE' then '温度' when dc_type='PARAM1' then '参数1' when dc_type='PARAM2' then '参数2' when dc_type='PARAM3' then '参数3' when dc_type='PARAM4' then '参数4' when dc_type='PARAM5' then '参数5' when dc_type='PARAM6' then '参数6' when dc_type='PARAM7' then '参数7' when dc_type='PARAM8' then '参数8' when dc_type='PARAM9' then '参数9' when dc_type='PARAM10' then '参数10' when dc_type='PARAM3' then '参数3'  end dc_typename,dc_value,dc_dataindex,dc_sendcoding,dc_receivecoding,db_name,dc_man,dc_date from devicecommand left join devicebrand on db_code=dc_debrand ".ToUpper();
+            GridCommandSetting.GetDataSQL = "select 0 CHECKEDCOLUMN,dc_id,dc_code,dc_ifng,dc_name,dc_type,case when dc_type='INQTY' then '投入' when dc_type='NGQTY' then '不良' when dc_type='OUTQTY' then '产出' when dc_type='TEMPERATURE' then '温度' when dc_type='PARAM1' then '参数1' when dc_type='PARAM2' then '参数2' when dc_type='PARAM3' then '参数3' when dc_type='PARAM4' then '参数4' when dc_type='PARAM5' then '参数5' when dc_type='PARAM6' then '参数6' when dc_type='PARAM7' then '参数7' when dc_type='PARAM8' then '参数8' when dc_type='PARAM9' then '参数9' when dc_type='PARAM10' then '参数10' when dc_type='PARAM3' then '参数3'  end dc_typename,dc_value,dc_dataindex,dc_sendcoding,dc_receivecoding,db_name,dc_man,dc_date from devicecommand left join devicebrand on db_code=dc_debrand ".ToUpper();
             GridCommandSetting.TableName = "devicecommand";
             GridCommandSetting.ID = "dc_id";
             GridCommandSetting.InsertSQL = "insert into devicecommand(dc_id,dc_code,dc_name,dc_value,dc_debrand,dc_sendcoding,dc_receivecoding,dc_man,dc_date,dc_dataindex,dc_type) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_value,'" + BaseUtil.GetComboxEditValue(Brand) + "',:dc_sendcoding,:dc_receivecoding,'" + User.UserName + "',sysdate,:dc_dataindex,:dc_type)";
@@ -410,7 +410,7 @@ namespace UAS_PLCDataReader
         /// <param name="e"></param>
         private void ButtonSaveCommand_Click(object sender, EventArgs e)
         {
-            GridCommandSetting.InsertSQL = "insert into devicecommand(dc_id,dc_code,dc_name,dc_value,dc_debrand,dc_sendcoding,dc_receivecoding,dc_man,dc_date,dc_dataindex,dc_type) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_value,'" + BaseUtil.GetComboxEditValue(Brand) + "',:dc_sendcoding,:dc_receivecoding,'" + User.UserName + "',sysdate,:dc_dataindex,:dc_type)";
+            GridCommandSetting.InsertSQL = "insert into devicecommand(dc_id,dc_code,dc_name,dc_value,dc_debrand,dc_sendcoding,dc_receivecoding,dc_man,dc_date,dc_dataindex,dc_type,dc_ifng) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_value,'" + BaseUtil.GetComboxEditValue(Brand) + "',:dc_sendcoding,:dc_receivecoding,'" + User.UserName + "',sysdate,:dc_dataindex,:dc_type,:dc_ifng)";
             ButtonSaveCommand.DoSaveAfterHandler(true);
             sql.Clear();
             sql.Append("update devicecommand set dc_man='" + User.UserName + "',dc_date=sysdate where dc_id=:dc_id");
@@ -430,7 +430,6 @@ namespace UAS_PLCDataReader
         {
             if (PageCommandSet.PageVisible)
             {
-
                 DataTable dt = (DataTable)SystemInf.dh.ExecuteSql("select * from devicebrand", "select");
                 BaseUtil.FillComBoxEditWidthDataTable(Brand, "db_name", "db_code", dt);
                 GridCommandSetting.Condition = " where dc_debrand='" + BaseUtil.GetComboxEditValue(Brand) + "' order by dc_code,dc_dataindex";

+ 2 - 2
PLCDataReader/PublicMethod/LogicHandler.cs

@@ -241,14 +241,14 @@ namespace UAS_PLCDataReader.PublicMethod
             StringBuilder sql = new StringBuilder();
             sql.Clear();
             sql.Append("update DeviceRunstatus set dr_qty='" + INQTY + "',dr_okqty='" + OUTQTY + "',dr_TEMPERATURE='" + TEMPERATURE + "',");
-            sql.Append("dr_ngqty='"+NGQTY+"',dr_value1='" + PARAM1 + "',dr_value2='" + PARAM2 + "',dr_value3='" + PARAM3 + "',dr_value4='" + PARAM4 + "',dr_value5='" + PARAM5 + "',dr_value6='" + PARAM6 + "',dr_value7='" + PARAM7 + "',dr_value8='" + PARAM8 + "',dr_value9='" + PARAM9 + "',dr_value10='" + PARAM10 + "',dr_updatedate=sysdate where dr_decode='" + Decode + "'");
+            sql.Append("dr_ngqty='" + NGQTY + "',dr_value1='" + PARAM1 + "',dr_value2='" + PARAM2 + "',dr_value3='" + PARAM3 + "',dr_value4='" + PARAM4 + "',dr_value5='" + PARAM5 + "',dr_value6='" + PARAM6 + "',dr_value7='" + PARAM7 + "',dr_value8='" + PARAM8 + "',dr_value9='" + PARAM9 + "',dr_value10='" + PARAM10 + "',dr_updatedate=sysdate where dr_decode='" + Decode + "'");
             Main.QueueUpdateDevice.Enqueue(sql.ToString());
         }
 
         /// <summary>
         /// 更新设备运行状态
         /// </summary>
-        /// <param name="dh"></param>
+        /// <param name="dh"></param> 
         /// <param name="iDecode"></param>
         /// <param name="iDename"></param>
         /// <param name="iDestatus"></param>

+ 1 - 0
PLCDataReader/UAS_PLCDataReader.csproj

@@ -328,6 +328,7 @@
     <EmbeddedResource Include="MainWindow.resx">
       <DependentUpon>MainWindow.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="Properties\licenses.licx" />
     <EmbeddedResource Include="Properties\Resources.resx">
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>

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

@@ -170,12 +170,12 @@ namespace UAS_LabelMachine
             command.Dispose();
         }
 
-        public void DeleleFile(string accessFile )
+        public void DeleleFile(string accessFile)
         {
             var dbe = new Microsoft.Office.Interop.Access.Dao.DBEngine();
             try
             {
-                string tempFile = Path.Combine(Path.GetDirectoryName(accessFile),Path.GetRandomFileName() + Path.GetExtension(accessFile));
+                string tempFile = Path.Combine(Path.GetDirectoryName(accessFile), Path.GetRandomFileName() + Path.GetExtension(accessFile));
                 dbe.CompactDatabase(accessFile, tempFile);
                 FileInfo temp = new FileInfo(tempFile);
                 temp.CopyTo(accessFile, true);
@@ -211,7 +211,7 @@ namespace UAS_LabelMachine
             //    }
             //}
             sb.Clear();
-            sb.Append("insert into "+ TableName+" (");
+            sb.Append("insert into " + TableName + " (");
             string field = "";
             string valuefield = "";
             for (int i = 0; i < dt.Columns.Count; i++)
@@ -803,24 +803,24 @@ namespace UAS_LabelMachine
         /// <param name="TableName"></param>
         /// <param name="update"></param>
         /// <param name="condition"></param>
-        public string UpdateByCondition(string TableName, string update, string condition)
+        public int UpdateByCondition(string TableName, string update, string condition)
         {
             string sql = "update " + TableName + " set " + update + " where " + condition;
             command = new OleDbCommand(sql, this._odcConnection);
-
+            int Rowcount = 0;
             Reconnect(command);
             try
             {
-                command.ExecuteNonQuery();
+                Rowcount = command.ExecuteNonQuery();
             }
             catch (Exception)
             {
                 command.Connection = new OleDbConnection(this._connectionString);
                 command.Connection.Open();
-                command.ExecuteNonQuery();
+                Rowcount = command.ExecuteNonQuery();
             }
             command.Dispose();
-            return sql;
+            return Rowcount;
         }
 
         /// <summary>
@@ -1007,7 +1007,7 @@ namespace UAS_LabelMachine
             {
                 if (!dt2.Columns.Contains(item.ToString()))
                 {
-                    ExecuteSql("alter table "+ tablename + " add [" + item.ToString() + "] varchar(200) NULL", "update");
+                    ExecuteSql("alter table " + tablename + " add [" + item.ToString() + "] varchar(200) NULL", "update");
                 }
             }
         }

+ 21 - 4
UAS-出货标签管理(吉利通)/PublicMethod/LogicHandler.cs

@@ -1,4 +1,5 @@
-using System.Data;
+using System;
+using System.Data;
 using UAS_LabelMachine.Entity;
 
 namespace UAS_LabelMachine.PublicMethod
@@ -36,21 +37,37 @@ namespace UAS_LabelMachine.PublicMethod
             adh.UpdateByCondition("prodiobarcode", "pib_ifpick=-1,pib_modify=-1", "pib_id=" + iPibID);
         }
 
+        /// <summary>
+        /// 获取十六进制字节数组
+        /// </summary>
+        /// <param name="Data"></param>
+        /// <returns></returns>
+        public static byte[] SendPLCData(string Data)
+        {
+            byte[] arr = new byte[1];
+            arr[0] = (byte)Convert.ToInt32(Data, 16);
+            return arr;
+        }
+
         /// <summary>
         /// 检测数据库未上传的数据,根据设置的上传条数上传数据
         /// </summary>
         /// <param name="iInoutno"></param>
-        public static void CheckUploadData(string iInoutno, int iUploadNum)
+        public static bool CheckUploadData(string iInoutno, int iUploadNum)
         {
-            DataTable dt = (DataTable)adh.ExecuteSql("select pib_id,pib_lotno,pib_ifmodify,pib_datecode,pib_ifpick,-1 as pib_ifupload,pib_ifprint,pib_ifrecheck from prodiobarcode where pib_inoutno='" + iInoutno + "'  and pib_ifupload<>-1", "select");
+            DataTable dt = (DataTable)adh.ExecuteSql("select pib_id,pib_lotno,pib_ifmodify,pib_datecode,pib_ifpick,-1 as pib_ifupload,pib_ifprint,pib_ifrecheck from prodiobarcode where pib_inoutno='" + iInoutno + "'  and pib_ifupload=0 and pib_ifrecheck=-1", "select");
             //如果本地需要上传的数据已经达到了需要上传的条数
             if (iUploadNum <= dt.Rows.Count)
             {
                 //上传数据
                 dh.SaveDataTable(dt, "prodiobarcode", "pib_id");
                 //更新本地数据为已上传
-                adh.UpdateByCondition("prodiobarcode", "pib_ifupload=-1", "pib_inoutno='" + iInoutno + "' and pib_ifmodify=-1 and pib_ifupload<>-1");
+                if (adh.UpdateByCondition("prodiobarcode", "pib_ifupload=-1", "pib_inoutno='" + iInoutno + "' and pib_ifrecheck=-1 and pib_ifupload<>-1") > 0)
+                {
+                    return true;
+                }
             }
+            return false;
         }
     }
 }

+ 7 - 5
UAS-出货标签管理(吉利通)/UAS_出货标签管理.Designer.cs

@@ -70,7 +70,6 @@
             this.ListButtonMenu = new System.Windows.Forms.ListBox();
             this.pi_date = new System.Windows.Forms.Label();
             this.ExportFileDialog = new System.Windows.Forms.FolderBrowserDialog();
-            this.MidSource = new System.Windows.Forms.BindingSource(this.components);
             this.GetGridOnly = new System.Windows.Forms.CheckBox();
             this.RefreshDBConnect = new System.Windows.Forms.Timer(this.components);
             this.label3 = new System.Windows.Forms.Label();
@@ -220,7 +219,7 @@
             this.OutBoxCombox = new System.Windows.Forms.ComboBox();
             this.BackendCheck = new UAS_LabelMachine.CustomControl.SerialPortWithTag();
             this.FrontendCheck = new UAS_LabelMachine.CustomControl.SerialPortWithTag();
-            ((System.ComponentModel.ISupportInitialize)(this.MidSource)).BeginInit();
+            this.PLC1 = new UAS_LabelMachine.CustomControl.SerialPortWithTag();
             this.CollectionProcess.SuspendLayout();
             this.groupBox2.SuspendLayout();
             this.groupBox1.SuspendLayout();
@@ -1146,7 +1145,7 @@
             // 
             this.label22.AutoSize = true;
             this.label22.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label22.Location = new System.Drawing.Point(8, 238);
+            this.label22.Location = new System.Drawing.Point(8, 239);
             this.label22.Name = "label22";
             this.label22.Size = new System.Drawing.Size(56, 17);
             this.label22.TabIndex = 95;
@@ -2270,6 +2269,10 @@
             // 
             this.FrontendCheck.Tag = "FrontendCheck";
             // 
+            // PLC1
+            // 
+            this.PLC1.Tag = "PLC1";
+            // 
             // UAS_出货标签打印
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -2319,7 +2322,6 @@
             this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.贴标机条码打印_FormClosing);
             this.Load += new System.EventHandler(this.贴标机条码打印_Load);
             this.SizeChanged += new System.EventHandler(this.贴标机条码打印_SizeChanged);
-            ((System.ComponentModel.ISupportInitialize)(this.MidSource)).EndInit();
             this.CollectionProcess.ResumeLayout(false);
             this.CollectionProcess.PerformLayout();
             this.groupBox2.ResumeLayout(false);
@@ -2459,7 +2461,6 @@
         private System.Windows.Forms.ListBox ListButtonMenu;
         private System.Windows.Forms.Label pi_date;
         private System.Windows.Forms.FolderBrowserDialog ExportFileDialog;
-        private System.Windows.Forms.BindingSource MidSource;
         private System.Windows.Forms.CheckBox GetGridOnly;
         private System.Windows.Forms.Timer RefreshDBConnect;
         private System.Windows.Forms.Label label3;
@@ -2544,5 +2545,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode2;
+        private CustomControl.SerialPortWithTag PLC1;
     }
 }

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

@@ -214,6 +214,15 @@ namespace UAS_LabelMachine
                 port.Read(readBuffer, 0, len); //将数据读入缓存
                 string msg = Encoding.ASCII.GetString(readBuffer, 0, len); //获取出入库产品编号
                 string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
+                int pib_pdno = int.Parse(LabelInf.Rows[CurrentRowIndex].Cells["pib_pdno"].Value.ToString());
+                if (DetailRange.Checked)
+                {
+                    //不在范围内的不进行处理
+                    if (!(pib_pdno >= DetailRange1.Value && pib_pdno <= DetailRange2.Value))
+                    {
+                        return;
+                    }
+                }
                 switch (port.Tag)
                 {
                     case "FrontendCheck":
@@ -264,11 +273,11 @@ namespace UAS_LabelMachine
                                 {
                                     DateCode = matchs[index].Value;
                                 }
-                                LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value = DateCode;
+                                LabelInfDataTable.Rows[CurrentRowIndex]["pib_datecode"] = DateCode;
                                 break;
                             case "LotNo":
                                 LotNo = matchs[index].Value;
-                                LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value = LotNo;
+                                LabelInfDataTable.Rows[CurrentRowIndex]["pib_lotno"] = LotNo;
                                 break;
                             case "PN":
                                 PN = matchs[index].Value;
@@ -298,12 +307,14 @@ namespace UAS_LabelMachine
                     LabelInf.Refresh();
                 }
             }
-            LabelInf.Rows[CurrentRowIndex].Cells["pib_ifpick"].Value = true;
+            LabelInfDataTable.Rows[CurrentRowIndex]["pib_ifpick"] = true;
             LabelInf.Refresh();
         }
 
         private void BackendCheckFunction(string msg, string pib_id)
         {
+            Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff"));
+            DataTable dtt = LabelInf.DataSource as DataTable;
             string[] msgArr = msg.Split('@');
             //需要校验2项数据,完成校验后此项的值需要为2则表示校验成功
             int checkItemCount = 0;
@@ -350,7 +361,7 @@ namespace UAS_LabelMachine
                 MessageBox.Show("复核不通过");
                 return;
             }
-            LabelInf.Rows[CurrentRowIndex].Cells["pib_ifrecheck"].Value = true;
+            LabelInfDataTable.Rows[CurrentRowIndex]["pib_ifrecheck"] = true;
             adh.ExecuteSql("update prodiobarcode set pib_ifrecheck=-1 where pib_id=" + pib_id, "update");
             LabelInf.Refresh();
             //获取当前最大的箱号
@@ -389,14 +400,26 @@ namespace UAS_LabelMachine
                         outboxcode1 = outboxcode1 + 1;
                 }
             }
-            LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value = outboxcode1;
-            LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value = outboxcode2;
+            LabelInfDataTable.Rows[CurrentRowIndex]["pib_outboxcode1"] = outboxcode1;
+            LabelInfDataTable.Rows[CurrentRowIndex]["pib_outboxcode2"] = outboxcode2;
             adh.ExecuteSql("update prodiobarcode set pib_outboxcode2=" + outboxcode2 + ",pib_outboxcode1=" + outboxcode1 + ",pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1 where pib_id=" + pib_id, "update");
             LabelInf.Refresh();
             if (CurrentRowIndex + 1 < LabelInf.Rows.Count)
                 CurrentRowIndex = CurrentRowIndex + 1;
             RefreshProcessData();
-            LogicHandler.CheckUploadData(pi_inoutno.Text, UploadNum);
+            if (CurrentRowIndex - 10 > 0)
+                LabelInf.FirstDisplayedScrollingRowIndex = CurrentRowIndex - 10;
+            //如果成功上传了数据
+            if (LogicHandler.CheckUploadData(pi_inoutno.Text, UploadNum))
+            {
+                for (int i = 0; i < dtt.Rows.Count; i++)
+                {
+                    if (dtt.Rows[i]["pib_ifrecheck"].ToString() != "0" && dtt.Rows[i]["pib_ifupload"].ToString() == "0")
+                    {
+                        dtt.Rows[i]["pib_ifupload"] = -1;
+                    }
+                }
+            }
         }
 
         //只执行一次窗体自适应
@@ -459,10 +482,9 @@ namespace UAS_LabelMachine
             if (CollectVeProdCodePass && CollectQTYPass)
             {
                 //如果按盒号采集,所有的此盒的均更新为
-                DataTable dt = (DataTable)MidSource.DataSource;
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_ifpick"].Value = true;
+                LabelInfDataTable.Rows[CurrentRowIndex]["pib_ifpick"] = true;
                 LogicHandler.UpdateRowPicked(LabelInf.Rows[CurrentRowIndex].Cells["pib_id"].Value);
-                LabelInf.Rows[CurrentRowIndex].Cells["Choose"].Value = true;
+                LabelInfDataTable.Rows[CurrentRowIndex]["Choose"] = true;
                 //勾选了单盘自动打印
                 if (SingleLabelAutoPrint.Checked)
                 {
@@ -517,7 +539,7 @@ namespace UAS_LabelMachine
             SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
             SingleDoc.PrintDocument();
             LogicHandler.UpdateRowPrinted(pib_id);
-            LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
+            LabelInfDataTable.Rows[CurrentRowIndex]["pib_ifprint"] = true;
         }
 
         //关闭窗口前提示用户确认
@@ -841,7 +863,7 @@ namespace UAS_LabelMachine
                                 }
                             }
                             //勾选为已打印
-                            LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
+                            LabelInfDataTable.Rows[i]["pib_ifprint"] = true;
                         }
                         catch (Exception ex) { LogManager.DoLog(ex.Message); }
                     }
@@ -874,9 +896,9 @@ namespace UAS_LabelMachine
                         {
                             for (int i = begin - 1; i < end; i++)
                             {
-                                LabelInf.Rows[i].Cells["Choose"].Value = true;
-                                LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
-                                LabelInf.Rows[i].Cells["pib_ifprint"].Value = false;
+                                LabelInfDataTable.Rows[i]["Choose"] = true;
+                                LabelInfDataTable.Rows[i]["pib_ifpick"] = true;
+                                LabelInfDataTable.Rows[i]["pib_ifprint"] = false;
                             }
                         }
                         else
@@ -1169,7 +1191,7 @@ namespace UAS_LabelMachine
             if (LabelInf.Rows.Count > 0)
             {
                 //设置初始化的采集进度
-                int Count = 0;
+                int Count = Count = adh.getRowCount("prodiobarcode", "pib_ifrecheck=-1");
                 string midboxcode = "";
                 string outboxcode = "";
                 if (CurrentRowIndex - 1 >= 0)
@@ -1178,11 +1200,6 @@ namespace UAS_LabelMachine
                     midboxcode = LabelInf.Rows[CurrentRowIndex - 1].Cells["pib_outboxcode1"].Value.ToString();
                 }
                 //未超出当前范围的时候
-                for (int i = 0; i < LabelInf.RowCount; i++)
-                {
-                    if (LabelInf.Rows[i].Cells["pib_ifrecheck"].FormattedValue.ToString() == "True")
-                        Count++;
-                }
                 int midboxcount = adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + (midboxcode == "" ? "0" : midboxcode));
                 int outboxcount = adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2=" + (outboxcode == "" ? "0" : outboxcode));
                 midboxProcess.Text = midboxcount + "/" + MidBoxCapacity.Value;
@@ -1191,7 +1208,7 @@ namespace UAS_LabelMachine
                 Process_midboxcode.Text = midboxcode;
                 Process_outboxcode.Text = outboxcode;
                 //设置当前总数和已采集数量
-                CollectedCount.Text = Count.ToString() + "/" + LabelInf.Rows.Count;
+                CollectedCount.Text = Count + "/" + PageNum.Text;
             }
         }
 
@@ -1203,6 +1220,7 @@ namespace UAS_LabelMachine
         int PageSize = 1000;
         int DataSize = 0;
         int MaxPageSize = 0;
+        DataTable LabelInfDataTable;
         /// <summary>
         /// 自定义函数  加载明细行的数据,多处使用添加进函数
         /// </summary>
@@ -1210,27 +1228,50 @@ namespace UAS_LabelMachine
         /// <param name="e"></param>
         private void LoadGridData(object sender, EventArgs e)
         {
-            dt = (DataTable)adh.ExecuteSql("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and rownum between " + ((CurrentPage - 1) * PageSize + 1) + " and  " + CurrentPage * PageSize + " order by rownum", "select");
-            if (dt.Rows.Count == 0)
+            sql.Clear();
+            sql.Append("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and rownum ");
+            sql.Append("between " + ((CurrentPage - 1) * PageSize + 1) + " and  " + CurrentPage * PageSize + " ");
+            if (DetailRange.Checked)
+            {
+                sql.Append(" and pib_pdno between " + DetailRange1.Value + " and " + DetailRange2.Value);
+            }
+            sql.Append(" order by rownum");
+            LabelInfDataTable = (DataTable)adh.ExecuteSql(sql.ToString(), "select");
+            if (LabelInfDataTable.Rows.Count == 0)
             {
+                //嵌套查询重置RowNum
                 sql.Clear();
-                sql.Append("select rownum,pd_custprodcode,pib_inoutno,pd_custprodspec,nvl(pib_ifrecheck,0)pib_ifrecheck,nvl(pib_ifupload,0)pib_ifupload,nvl(pib_ifmodify,0)pib_ifmodify,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,");
+                sql.Append("select t.*,rownum from (select pd_custprodcode,pib_inoutno,pd_custprodspec,nvl(pib_ifrecheck,0)pib_ifrecheck,nvl(pib_ifupload,0)pib_ifupload,nvl(pib_ifmodify,0)pib_ifmodify,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,");
                 sql.Append("pib_id,pib_pdid,pib_piid,pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,pib_lotno,pib_datecode,pib_qty,pr_spec,pi_title,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,");
                 sql.Append("pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint from prodiobarcode left join prodinout on pib_piid=pi_id left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and ");
-                sql.Append("pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode where pib_piid='" + PI_ID + "' order by rownum");
-                dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+                sql.Append("pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode where pib_piid='" + PI_ID + "' order by to_number(pib_id))t");
+                LabelInfDataTable = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 //检验查询的字段和本地数据库字段是否匹配
-                adh.AddColumFromDataTable(dt, "prodiobarcode");
+                adh.AddColumFromDataTable(LabelInfDataTable, "prodiobarcode");
                 //将数据保存在本地数据库
-                adh.SaveDataTable(dt, "prodiobarcode");
-                dt = BaseUtil.filterDataTable(dt, "rownum <=" + PageSize);
+                adh.SaveDataTable(LabelInfDataTable, "prodiobarcode");
+                if (!DetailRange.Checked)
+                {
+                    LabelInfDataTable = BaseUtil.filterDataTable(LabelInfDataTable, "rownum <=" + PageSize);
+                }
+                else
+                {
+                    LabelInfDataTable = BaseUtil.filterDataTable(LabelInfDataTable, "rownum <=" + PageSize + " and pib_pdno >= " + DetailRange1.Value + " and pib_pdno<=" + DetailRange2.Value);
+                }
+            }
+            //获取数据总条数
+            if (!DetailRange.Checked)
+            {
+                DataSize = adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "'");
+            }
+            else
+            {
+                DataSize = adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno between " + DetailRange1.Value + " and " + DetailRange2.Value);
             }
-            DataSize = adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "'");
             PageNum.Text = "总数" + DataSize;
             MaxPageSize = DataSize % PageSize == 0 ? DataSize / PageSize : (DataSize / PageSize) + 1;
             PageInf.Text = CurrentPage + "/" + MaxPageSize;
-            MidSource.DataSource = dt;
-            BaseUtil.FillDgvWithDataTable(LabelInf, (DataTable)MidSource.DataSource);
+            BaseUtil.FillDgvWithDataTable(LabelInf, LabelInfDataTable);
             //获取系统设置的上传数量,如参数异常则默认为100
             dt = (DataTable)adh.ExecuteSql("select uploadnum,splitback,splitfront from dataextra", "select");
             if (dt.Rows.Count > 0)
@@ -1450,7 +1491,7 @@ namespace UAS_LabelMachine
             if (result == DialogResult.OK)
             {
                 ExcelHandler eh = new ExcelHandler();
-                DataTable dt = ((DataTable)MidSource.DataSource).Copy();
+                DataTable dt = LabelInfDataTable;
                 for (int i = dt.Columns.Count - 1; i >= 0; i--)
                 {
                     for (int j = 0; j < LabelInf.Columns.Count; j++)
@@ -1598,6 +1639,7 @@ namespace UAS_LabelMachine
                 }
                 DetailRange1.Enabled = false;
                 DetailRange2.Enabled = false;
+                LoadGridData();
             }
             else
             {
@@ -1608,7 +1650,16 @@ namespace UAS_LabelMachine
 
         private void PLCStart_Click(object sender, EventArgs e)
         {
-
+            DataTable dt = (DataTable)adh.ExecuteSql("select * from cominfo", "select");
+            DataRow[] dr = dt.Select("comtype='PLC1'");
+            if (dr.Length > 0)
+            {
+                PLC1.PortName = dr[0]["COM"].ToString();
+                PLC1.Tag = "FrontendCheck";
+                PLC1.BaudRate = int.Parse(dr[0]["BaudRate"].ToString());
+                PLC1.DataReceived += Serial_DataReceived;
+                PLC1.Open();
+            }
         }
 
         private void PLCStop_Click(object sender, EventArgs e)
@@ -1618,12 +1669,16 @@ namespace UAS_LabelMachine
 
         private void ButtonCollectPass_Click(object sender, EventArgs e)
         {
-
+            string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
+            int pib_pdno = int.Parse(LabelInf.Rows[CurrentRowIndex].Cells["pib_pdno"].Value.ToString());
+            FrontCheckFunction("");
         }
 
         private void ButtonRecheckPass_Click(object sender, EventArgs e)
         {
-
+            string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
+            int pib_pdno = int.Parse(LabelInf.Rows[CurrentRowIndex].Cells["pib_pdno"].Value.ToString());
+            BackendCheckFunction("", pib_id);
         }
 
         private void ButtonSetMidBox_Click(object sender, EventArgs e)

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

@@ -120,9 +120,6 @@
   <metadata name="ExportFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>294, 17</value>
   </metadata>
-  <metadata name="MidSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>179, 17</value>
-  </metadata>
   <metadata name="RefreshDBConnect.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>17, 17</value>
   </metadata>
@@ -168,6 +165,9 @@
   <metadata name="FrontendCheck.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>442, 17</value>
   </metadata>
+  <metadata name="PLC1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>721, 18</value>
+  </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>

+ 51 - 15
UAS-出货标签管理(泽天)/UAS_出货标签管理.cs

@@ -342,7 +342,7 @@ namespace UAS_LabelMachine
                 Input.SelectAll();
                 return;
             }
-            GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix);
+            GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix, CodeCount);
             List<string> CustBarCode = new List<string>();
             if (!(Radix > 0))
             {
@@ -379,7 +379,6 @@ namespace UAS_LabelMachine
                 MessageBox.Show("未成功插入数据,请核对出货单当前明细", "提示");
             }
             //更新流水号
-            dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum) + "'", "rmn_nrcode='" + (pi_cardcode.Text == "" ? "Default" : pi_cardcode.Text) + "' and rmn_prefix='" + Prefix + "'");
             LoadGridData(new object(), new EventArgs());
             if (LabelInf.Rows.Count > 0)
             {
@@ -598,7 +597,7 @@ namespace UAS_LabelMachine
                     OutBoxNum_Click(new object(), new EventArgs());
                     LoadPrcodeData();
                     //获取条码规则
-                    GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix);
+                    GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix, 1);
                     SingleID.Clear();
                     Input.Focus();
                     ////从后往前找未采集的行
@@ -709,7 +708,7 @@ namespace UAS_LabelMachine
                     {
                         MessageBox.Show("未勾选打印明细", "提示", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                     }
-                    LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印标", "打印成功");
+                    LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印标", "打印成功");
                     dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
                     outboxcode1.Clear();
                 }
@@ -760,7 +759,7 @@ namespace UAS_LabelMachine
             else
             {
                 MessageBox.Show("未维护单盘标签", "提示");
-                LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印标", "打印失败,未维护标签");
+                LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印标", "打印失败,未维护标签");
             }
         }
 
@@ -982,6 +981,7 @@ namespace UAS_LabelMachine
                 }
                 catch (Exception) { }
             }
+            LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印箱标" + OutBoxNum.Text, "打印成功");
             Outboxcode.Clear();
         }
 
@@ -1029,6 +1029,7 @@ namespace UAS_LabelMachine
                     MidReport.Print();
                     dh.UpdateByCondition("prodiobarcode", "pib_midifprint=-1", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1 in (" + pib_outboxcode1 + ")");
                     SelectRowIndex = -1;
+                    LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "打印中盒" + pib_outboxcode1, "打印成功");
                 }
                 Properties.Settings.Default.MPrinter = MidLabelPrinter.Text;
                 Properties.Settings.Default.Save();
@@ -1516,7 +1517,7 @@ namespace UAS_LabelMachine
         /// <param name="MaxNum"></param>
         /// <param name="SerialNumLength"></param>
         /// <param name="Radix"></param>
-        private void GetBarCodeRule(out string Prefix, out string Suffix, out int MaxNum, out int SerialNumLength, out int Radix)
+        private void GetBarCodeRule(out string Prefix, out string Suffix, out int MaxNum, out int SerialNumLength, out int Radix, int Count)
         {
             //获取编码规则
             Prefix = "";
@@ -1574,12 +1575,13 @@ namespace UAS_LabelMachine
                         //设置当前流水
                         if (maxnum == "")
                         {
-                            dh.ExecuteSql("insert into RuleMaxNum(rmn_id,rmn_nrcode,rmn_prefix,rmn_maxnumber) values(RuleMaxNum_seq.nextval,'" + (pi_cardcode.Text == "" ? "Default" : pi_cardcode.Text) + "','" + Prefix + "','1')", "insert");
+                            dh.ExecuteSql("insert into RuleMaxNum(rmn_id,rmn_nrcode,rmn_prefix,rmn_maxnumber) values(RuleMaxNum_seq.nextval,'" + (pi_cardcode.Text == "" ? "Default" : pi_cardcode.Text) + "','" + Prefix + "','" + Count + "')", "insert");
                             MaxNum = 1;
                         }
                         else
                         {
                             MaxNum = int.Parse(maxnum);
+                            dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + Count) + "'", "rmn_nrcode='" + (pi_cardcode.Text == "" ? "Default" : pi_cardcode.Text) + "' and rmn_prefix='" + Prefix + "'");
                         }
                         SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
                         Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
@@ -1750,7 +1752,27 @@ namespace UAS_LabelMachine
         {
             if (LabelInf.Rows.Count > 0)
             {
-                GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix);
+                int GetNumCount = 1;
+                for (int i = 0; i < LabelInf.Rows.Count; i++)
+                {
+                    if (LabelInf.Rows[i].Cells["pib_custoutboxcode"].Value.ToString() == "")
+                    {
+                        if (i + 1 < LabelInf.Rows.Count)
+                        {
+                            string FPrcode = LabelInf.Rows[i].Cells["pib_prodcode"].Value.ToString();
+                            string FPocode = LabelInf.Rows[i].Cells["pd_pocode"].Value.ToString();
+                            string FWhcode = LabelInf.Rows[i].Cells["pib_brand"].Value.ToString();
+                            string BPrcode = LabelInf.Rows[i + 1].Cells["pib_prodcode"].Value.ToString();
+                            string BPocode = LabelInf.Rows[i + 1].Cells["pd_pocode"].Value.ToString();
+                            string BWhcode = LabelInf.Rows[i + 1].Cells["pib_brand"].Value.ToString();
+                            if (FPrcode != BPrcode || FPocode != BPocode || FWhcode != BWhcode)
+                            {
+                                GetNumCount = GetNumCount + 1;
+                            }
+                        }
+                    }
+                }
+                GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix, GetNumCount);
                 List<string> OutBoxCode = new List<string>();
                 List<string> PIBID = new List<string>();
                 for (int i = 0; i < LabelInf.Rows.Count; i++)
@@ -1767,9 +1789,11 @@ namespace UAS_LabelMachine
                         {
                             string FPrcode = LabelInf.Rows[i].Cells["pib_prodcode"].Value.ToString();
                             string FPocode = LabelInf.Rows[i].Cells["pd_pocode"].Value.ToString();
+                            string FWhcode = LabelInf.Rows[i].Cells["pib_brand"].Value.ToString();
                             string BPrcode = LabelInf.Rows[i + 1].Cells["pib_prodcode"].Value.ToString();
                             string BPocode = LabelInf.Rows[i + 1].Cells["pd_pocode"].Value.ToString();
-                            if (FPrcode != BPrcode || FPocode != BPocode)
+                            string BWhcode = LabelInf.Rows[i + 1].Cells["pib_brand"].Value.ToString();
+                            if (FPrcode != BPrcode || FPocode != BPocode || FWhcode != BWhcode)
                             {
                                 MaxNum = MaxNum + 1;
                             }
@@ -1778,8 +1802,6 @@ namespace UAS_LabelMachine
                     }
                 }
                 dh.BatchInsert("update prodiobarcode set pib_custoutboxcode=:pib_custoutboxcode where pib_id=:pib_id and pib_custoutboxcode is null", new string[] { "pib_custoutboxcode", "pib_outboxcode2" }, OutBoxCode.ToArray(), PIBID.ToArray());
-                MaxNum = MaxNum + 1;
-                dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + MaxNum + "'", "rmn_nrcode='" + (pi_cardcode.Text == "" ? "Default" : pi_cardcode.Text) + "' and rmn_prefix='" + Prefix + "'");
                 LoadGridData(sender, e);
             }
         }
@@ -1787,7 +1809,23 @@ namespace UAS_LabelMachine
         private void PackMidBox_Click(object sender, EventArgs e)
         {
             DataTable dt = (DataTable)dh.ExecuteSql("select distinct pib_outboxcode2 from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by pib_outboxcode2", "select");
-            GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix);
+            DataTable dt1 = null;
+            int GetNumCount = 0;
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                dt1 = (DataTable)dh.ExecuteSql("select pib_id,pib_prodcode,pd_custprodcode from prodiobarcode left join prodiodetail on pib_pdid=pd_id where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + dt.Rows[i]["pib_outboxcode2"].ToString() + "' and pib_outboxcode1 is null order by  to_number(pib_id)", "select");
+                //如果不是10的整数倍则为尾盒
+                int tencount = 0;
+                for (int j = 0; j < dt1.Rows.Count; j++)
+                {
+                    if (tencount % MidboxCapacity.Value == 0 || (dt1.Rows[j]["pib_prodcode"].ToString() != dt1.Rows[j - 1]["pib_prodcode"].ToString()) || (dt1.Rows[j]["pd_custprodcode"].ToString() != dt1.Rows[j - 1]["pd_custprodcode"].ToString()))
+                    {
+                        GetNumCount = GetNumCount + 1;
+                    }
+                    tencount = tencount + 1;
+                }
+            }
+            GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix, GetNumCount);
             if (Radix > 0)
             {
                 //生成中盒条码
@@ -1798,7 +1836,7 @@ namespace UAS_LabelMachine
                     List<string> MidBoxCode = new List<string>();
                     List<string> PIBID = new List<string>();
                     List<string> PIBOUTBOXCODE1 = new List<string>();
-                    DataTable dt1 = (DataTable)dh.ExecuteSql("select pib_id,pib_prodcode,pd_custprodcode from prodiobarcode left join prodiodetail on pib_pdid=pd_id where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + dt.Rows[i]["pib_outboxcode2"].ToString() + "' and pib_outboxcode1 is null order by  to_number(pib_id)", "select");
+                    dt1 = (DataTable)dh.ExecuteSql("select pib_id,pib_prodcode,pd_custprodcode from prodiobarcode left join prodiodetail on pib_pdid=pd_id where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + dt.Rows[i]["pib_outboxcode2"].ToString() + "' and pib_outboxcode1 is null order by  to_number(pib_id)", "select");
                     //如果不是10的整数倍则为尾盒
                     int tencount = 0;
                     for (int j = 0; j < dt1.Rows.Count; j++)
@@ -1821,8 +1859,6 @@ namespace UAS_LabelMachine
                     }
                     dh.BatchInsert("update prodiobarcode set pib_custmidboxcode=:pib_custmidboxcode,pib_outboxcode1=:pib_outboxcode1 where pib_id=:pib_id and pib_custmidboxcode is null", new string[] { "pib_custmidboxcode", "pib_outboxcode1", "pib_id" }, MidBoxCode.ToArray(), PIBOUTBOXCODE1.ToArray(), PIBID.ToArray());
                 }
-                MaxNum = MaxNum + 1;
-                dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + MaxNum + "'", "rmn_nrcode='" + (pi_cardcode.Text == "" ? "Default" : pi_cardcode.Text) + "' and rmn_prefix='" + Prefix + "'");
             }
             LoadGridData(sender, e);
         }