Просмотр исходного кода

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

caosy 6 лет назад
Родитель
Сommit
05af035413

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

@@ -3,6 +3,8 @@
     class SystemInf
     {
         public static DataHelper dh;
+        //备用数据库链接,防止主链接被释放
+        public static DataHelper dh1;
 
         public static AccessDBHelper adh;
 

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

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

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

@@ -63,7 +63,7 @@ namespace UAS_LabelMachine.PublicMethod
             oBarCode = param[9];
         }
 
-        public static void GetTimeFromDatecode(string iDatecode, string iCustcode, out string oYear, out string oMonth, out string oDay, out string oDate)
+        public static void GetTimeFromDatecode(DataHelper dh,string iDatecode, string iCustcode, out string oYear, out string oMonth, out string oDay, out string oDate)
         {
             oYear = "0";
             oMonth = "0";

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

@@ -24,6 +24,8 @@ namespace UAS_LabelMachine
 
         DataHelper dh;
 
+        DataHelper dh1;
+
         AccessDBHelper adh;
 
         AccessDBHelper back_adh;
@@ -136,6 +138,7 @@ namespace UAS_LabelMachine
             //用计时器重置数据库链接
             LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
             dh = SystemInf.dh;
+            dh1 = SystemInf.dh1;
             adh = SystemInf.adh;
             back_adh = SystemInf.back_adh;
             CheckForIllegalCrossThreadCalls = false;
@@ -360,7 +363,6 @@ namespace UAS_LabelMachine
                         }
                         break;
                     case "BackendCheck":
-
                         BackCheck.Text = msg;
                         if (BackendCheckFunction(msg, "Auto", out ErrorMsg))
                         {
@@ -460,7 +462,7 @@ namespace UAS_LabelMachine
                                         string month = "";
                                         string day = "";
                                         string date = "";
-                                        LogicHandler.GetTimeFromDatecode(DateCode, pi_cardcode.Text, out year, out month, out day, out date);
+                                        LogicHandler.GetTimeFromDatecode(dh,DateCode, pi_cardcode.Text, out year, out month, out day, out date);
                                         System.DateTime dtime;
                                         //有效期比对
                                         if (System.DateTime.TryParseExact(date, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dtime))
@@ -700,7 +702,7 @@ namespace UAS_LabelMachine
                             dr[0]["pib_datecode"] = DateCode;
                             try
                             {
-                                LogicHandler.GetTimeFromDatecode(DateCode, pi_cardcode.Text, out year, out month, out day, out date);
+                                LogicHandler.GetTimeFromDatecode(dh1,DateCode, pi_cardcode.Text, out year, out month, out day, out date);
                                 dr[0]["pib_year"] = year;
                                 dr[0]["pib_month"] = month;
                                 dr[0]["pib_day"] = day;
@@ -776,7 +778,7 @@ namespace UAS_LabelMachine
                     //解析DateCode,将值设置到年月日
                     try
                     {
-                        LogicHandler.GetTimeFromDatecode(DateCode, pi_cardcode.Text, out year, out month, out day, out date);
+                        LogicHandler.GetTimeFromDatecode(dh1,DateCode, pi_cardcode.Text, out year, out month, out day, out date);
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_year"].Value = year;
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_month"].Value = month;
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_day"].Value = day;
@@ -1368,6 +1370,8 @@ namespace UAS_LabelMachine
             for (int j = 0; j < MidDoc.Variables.FormVariables.Count; j++)
             {
                 DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name + "'");
+                if (dr1.Length == 0)
+                    dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name.Replace("_1", "") + "'");
                 if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                 {
                     MidDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
@@ -1380,12 +1384,12 @@ namespace UAS_LabelMachine
                     {
                         for (int k = 0; k < MidDoc.Variables.FormVariables.Count; k++)
                         {
-                            if (i == 0 & MidDoc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == dr1[0]["lp_name"].ToString().ToUpper())
+                            if (i == 0 & MidDoc.Variables.FormVariables.Item(k + 1).Name == dr1[0]["lp_name"].ToString())
                             {
                                 MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[0][0].ToString();
                             }
                             //使用SN开头的参数赋值SN1,SN2,SN3等参数
-                            if (MidDoc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == (dr1[0]["lp_name"].ToString() + (i + 1)).ToUpper())
+                            if (MidDoc.Variables.FormVariables.Item(k + 1).Name == (dr1[0]["lp_name"].ToString() + "_" + (i + 1)))
                             {
                                 MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
                             }
@@ -1455,6 +1459,9 @@ namespace UAS_LabelMachine
                 for (int j = 0; j < OutBoxDoc.Variables.FormVariables.Count; j++)
                 {
                     DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name + "'");
+                    //多参数命名
+                    if (dr1.Length == 0)
+                        dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name.Replace("_1", "") + "'");
                     if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                     {
                         OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
@@ -1467,12 +1474,12 @@ namespace UAS_LabelMachine
                         {
                             for (int k = 0; k < OutBoxDoc.Variables.FormVariables.Count; k++)
                             {
-                                if (i == 0 & OutBoxDoc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == dr1[0]["lp_name"].ToString().ToUpper())
+                                if (i == 0 & OutBoxDoc.Variables.FormVariables.Item(k + 1).Name == dr1[0]["lp_name"].ToString())
                                 {
                                     OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[0][0].ToString();
                                 }
                                 //使用SN开头的参数赋值SN1,SN2,SN3等参数
-                                if (OutBoxDoc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == (dr1[0]["lp_name"].ToString() + (i + 1)).ToUpper())
+                                if (OutBoxDoc.Variables.FormVariables.Item(k + 1).Name == (dr1[0]["lp_name"].ToString() + "_" + (i + 1)))
                                 {
                                     OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
                                 }
@@ -1900,7 +1907,7 @@ namespace UAS_LabelMachine
 
         private void RefreshDBConnect_Tick(object sender, EventArgs e)
         {
-          
+
         }
 
         private void ButtonSetting_Click(object sender, EventArgs e)
@@ -2315,7 +2322,7 @@ namespace UAS_LabelMachine
             string month = "0";
             string day = "0";
             string date = "";
-            LogicHandler.GetTimeFromDatecode(datecode, pi_cardcode.Text, out year, out month, out day, out date);
+            LogicHandler.GetTimeFromDatecode(dh1,datecode, pi_cardcode.Text, out year, out month, out day, out date);
             adh.ExecuteSql("update prodiobarcode set pib_ifpick=-1,pib_ifmodify=-1,pib_lotno='" + lotno + "',pib_datecode='" + datecode + "',pib_year='" + year + "',pib_month='" + month + "',pib_day='" + day + "' where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno=" + pdno, "update");
             LoadGridData();
             setvalue.FindForm().Close();
@@ -2331,7 +2338,7 @@ namespace UAS_LabelMachine
             string month = "0";
             string day = "0";
             string date = "";
-            LogicHandler.GetTimeFromDatecode(datecode, pi_cardcode.Text, out year, out month, out day, out date);
+            LogicHandler.GetTimeFromDatecode(dh1,datecode, pi_cardcode.Text, out year, out month, out day, out date);
             adh.ExecuteSql("update prodiobarcode set pib_ifpick=-1,pib_ifmodify=-1,pib_ifprint=-1,pib_lotno='" + lotno + "',pib_datecode='" + datecode + "',pib_year='" + year + "',pib_month='" + month + "',pib_day='" + day + "' where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno=" + pdno, "update");
             LoadGridData();
             DataTable pibid_dt = (DataTable)adh.ExecuteSql("select pib_id from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno=" + pdno, "select");
@@ -2361,7 +2368,7 @@ namespace UAS_LabelMachine
             //解析DateCode,将值设置到年月日
             try
             {
-                LogicHandler.GetTimeFromDatecode(DateCode, pi_cardcode.Text, out year, out month, out day, out date);
+                LogicHandler.GetTimeFromDatecode(dh,DateCode, pi_cardcode.Text, out year, out month, out day, out date);
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_year"].Value = year;
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_month"].Value = month;
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_day"].Value = day;
@@ -2370,8 +2377,6 @@ namespace UAS_LabelMachine
             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();
-            //获取上一行的数据
-            DataTable LastRowData = null;
             //如果满容量获取过箱号就不再重复获取了
             bool GetBarcode = false;
             //获取当前的行号
@@ -2387,7 +2392,8 @@ namespace UAS_LabelMachine
             }
             else 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");
+                //获取上一行的数据
+                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 == "")
                 {
@@ -2470,7 +2476,8 @@ namespace UAS_LabelMachine
             }
             else 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");
+                //获取上一行数据
+                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 == "")
                 {
@@ -2559,7 +2566,6 @@ namespace UAS_LabelMachine
             }
             sql.Append("1,");
             DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
-            Console.WriteLine("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id);
             for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
             {
                 DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name + "'");