Browse Source

优化打印代码

章政 7 years ago
parent
commit
7e86c83267

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

@@ -844,10 +844,21 @@ namespace UAS_LabelMachine
             switch (Type.ToUpper())
             {
                 case "SELECT":
-                    result = new DataTable();
-                    OracleDataAdapter ad = new OracleDataAdapter(command);
-                    ad.Fill((DataTable)result);
-                    ad.Dispose();
+                    try
+                    {
+                        result = new DataTable();
+                        OracleDataAdapter ad = new OracleDataAdapter(command);
+                        ad.Fill((DataTable)result);
+                        ad.Dispose();
+                    }
+                    catch (Exception)
+                    {
+                        command.Connection = new OracleConnection(DBConnectionString);
+                        result = new DataTable();
+                        OracleDataAdapter ad = new OracleDataAdapter(command);
+                        ad.Fill((DataTable)result);
+                        ad.Dispose();
+                    }
                     //成功执行后将重复连接数置为0
                     break;
                 case "DELETE":

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


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

@@ -323,7 +323,6 @@ namespace UAS_LabelMachine
                     case "FrontendCheck":
                         //比对当前箱数量和容量
                         FrontCollect.Text = msg;
-                        Console.WriteLine(System.DateTime.Now.ToString("1" + "yyyy-MM-dd hh:mm:ss fff"));
                         if (!FrontCheckFunction(msg, out ErrorMsg))
                         {
                             LogicHandler.SendDataToPLC(PLC1, PLCInstruct.FrontDataDelete, adh);
@@ -332,7 +331,6 @@ namespace UAS_LabelMachine
                         }
                         else
                         {
-                            Console.WriteLine(System.DateTime.Now.ToString("2" + "yyyy-MM-dd hh:mm:ss fff"));
                             if (cu_print_checkdatecode.Checked)
                             {
                                 string datecode = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString();
@@ -587,7 +585,6 @@ namespace UAS_LabelMachine
         private bool FrontCheckFunction(string msg, out string ErrorMsg)
         {
             ErrorMsg = "";
-            Console.WriteLine(System.DateTime.Now.ToString("1" + "yyyy-MM-dd hh:mm:ss fff"));
             //调用正则验证
             RegexMatch("FrontCheck", msg, out ErrorMsg);
             if (ErrorMsg != "")
@@ -2378,167 +2375,172 @@ namespace UAS_LabelMachine
             int outboxcode2 = Outbox2;
             string pd_id = LabelInf.Rows[CurrentRowIndex].Cells["pd_id"].Value.ToString();
             //如果满容量获取过箱号就不再重复获取了
-            bool GetBarcode = false;
+            //bool GetBarcode = false;
             //获取当前的行号
             decimal CurrentRowNum = decimal.Parse(LabelInf.Rows[CurrentRowIndex].Cells["rownum"].Value.ToString());
             //超过中盒容量中盒号+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);
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
-                LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
+                //GetBarcode = true;
+                //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                //LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                //LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
             }
             else if (CurrentRowNum - 1 > 0)
             {
                 //获取上一行的数据
                 DataTable 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");
-                string custmidboxcode = LastRowData.Rows[0]["pib_custmidboxcode"].ToString();
-                if (custmidboxcode == "")
-                {
-                    LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
-                }
+                //string custmidboxcode = LastRowData.Rows[0]["pib_custmidboxcode"].ToString();
+                //if (custmidboxcode == "")
+                //{
+                //    LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                //    LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                //}
                 //或者不符合合并条件中盒号+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)
+                    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;
+                        //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)
                 {
                     string TempData = LastRowData.Rows[0]["pd_pocode"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
+                    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, adh);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        //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_midprod.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pd_custprodcode"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
+                    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, adh);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        //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_midspec.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pd_custprodspec"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
+                    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, adh);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
+                        //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_middc.Checked)
                 {
                     string TempData = LastRowData.Rows[0]["pib_datecode"].ToString();
-                    if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
+                    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;
+                        //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;
+                //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;
+                //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                //LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
             }
-            GetBarcode = false;
+            //GetBarcode = false;
             if (adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2=" + outboxcode2) >= OutBoxCapacity.Value)
             {
-                GetBarcode = true;
+                //GetBarcode = true;
                 outboxcode2 = outboxcode2 + 1;
-                LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
             }
             else if (CurrentRowNum - 1 > 0)
             {
                 //获取上一行数据
                 DataTable 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");
-                string custoutboxcode = LastRowData.Rows[0]["pib_custoutboxcode"].ToString();
-                if (custoutboxcode == "")
-                {
-                    LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                    LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
-                }
+                //string custoutboxcode = LastRowData.Rows[0]["pib_custoutboxcode"].ToString();
+                //if (custoutboxcode == "")
+                //{
+                //    LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                //    LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                //}
                 //或者不符合合并条件中盒号+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)
+                    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;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        outboxcode2 = outboxcode2 + 1;
                     }
                 }
                 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)
+                    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;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        outboxcode2 = outboxcode2 + 1;
                     }
                 }
                 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)
+                    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;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        outboxcode2 = outboxcode2 + 1;
                     }
                 }
                 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)
+                    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;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        outboxcode2 = outboxcode2 + 1;
                     }
                 }
                 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)
+                    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;
+                        //LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
+                        //LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
+                        outboxcode2 = outboxcode2 + 1;
                     }
                 }
-                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;
+                //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;
+                //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;
@@ -2604,7 +2606,6 @@ namespace UAS_LabelMachine
                         SingleDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
                 }
             }
-            Console.WriteLine("8" + System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff"));
             SingleDoc.PrintDocument();
             LogicHandler.UpdateRowPrinted(pib_id);
         }

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