Browse Source

修改数据上传模块BUG

章政 6 years ago
parent
commit
6389a25919

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

@@ -999,7 +999,7 @@ namespace UAS_LabelMachine
             }
             catch (Exception)
             {
-                connection= new OracleConnection(DBConnectionString);
+                connection = new OracleConnection(DBConnectionString);
                 connection.Open();
                 command.Connection = connection;
                 command.ExecuteNonQuery();
@@ -1109,6 +1109,49 @@ namespace UAS_LabelMachine
             command.Dispose();
         }
 
+        /// <summary>
+        /// 调用存储过程
+        /// </summary>
+        /// <param name="ProcedureName"></param>
+        /// <param name="param"></param>
+        public void CallProcedure(string ProcedureName, DataTable upload, out string pibid)
+        {
+            StringBuilder sql = new StringBuilder();
+            pibid = "";
+            sql.Append("declare barcode BarCodeUpload_arr;begin barcode:=BarCodeUpload_arr(");
+            for (int i = 0; i < upload.Rows.Count; i++)
+            {
+                //特殊语句,传递回拼接的ID给到跟新本地数据
+                pibid += upload.Rows[i]["pib_id"].ToString() + ",";
+                sql.Append("BarCodeUpload(");
+                for (int j = 0; j < upload.Columns.Count; j++)
+                {
+                    sql.Append("'" + upload.Rows[i][j].ToString() + "',");
+                }
+                sql.Remove(sql.Length - 1, 1);
+                sql.Append("),");
+            }
+            pibid += 0;
+            sql.Remove(sql.Length - 1, 1);
+            sql.Append(");sp_uploadbarcode(barcode);END;");
+            command = new OracleCommand();
+            command.Connection = connection;
+            command.CommandText = sql.ToString();
+            try
+            {
+                command.ExecuteNonQuery();
+            }
+            catch (Exception)
+            {
+                connection = new OracleConnection(DBConnectionString);
+                connection.Open();
+                command.Connection = connection;
+                command.ExecuteNonQuery();
+            }
+            command.Dispose();
+        }
+
+
         /// <summary>
         /// 调用存储过程
         /// </summary>
@@ -1120,6 +1163,7 @@ namespace UAS_LabelMachine
             sql.Append("declare barcode BarCodeUpload_arr;begin barcode:=BarCodeUpload_arr(");
             for (int i = 0; i < upload.Rows.Count; i++)
             {
+                //特殊语句,传递回拼接的ID给到跟新本地数据
                 sql.Append("BarCodeUpload(");
                 for (int j = 0; j < upload.Columns.Count; j++)
                 {
@@ -1195,7 +1239,7 @@ namespace UAS_LabelMachine
             }
             catch (Exception)
             {
-                 connection = new OracleConnection(DBConnectionString);
+                connection = new OracleConnection(DBConnectionString);
                 connection.Open();
                 command.Connection = connection;
                 command.ExecuteNonQuery();

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

@@ -63,7 +63,7 @@ namespace UAS_LabelMachine.PublicMethod
             oBarCode = param[9];
         }
 
-        public static void GetTimeFromDatecode(DataHelper dh,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";
@@ -121,17 +121,30 @@ namespace UAS_LabelMachine.PublicMethod
         /// <param name="iInoutno"></param>
         public static bool CheckUploadData(string iInoutno)
         {
-            DataTable dt = (DataTable)adh.ExecuteSql("select pib_id,pib_outboxcode1,pib_outboxcode2,pib_custmidboxcode,pib_custoutboxcode,pib_lotno,pib_datecode,pib_ifmodify,-1 as pib_ifupload,pib_ifpick,pib_ifprint,pib_ifrecheck,pib_year,pib_month,pib_day from prodiobarcode where pib_inoutno='" + iInoutno + "' and pib_ifupload=0 and pib_ifrecheck=-1  ", "select");
-            if (dt.Rows.Count > 0)
+            DataTable dt = (DataTable)adh.ExecuteSql("select count(1) from prodiobarcode where pib_inoutno='" + iInoutno + "' and pib_ifupload=0 and pib_ifrecheck=-1  ", "select");
+            if (dt.Rows[0][0].ToString() != "")
             {
-                dh.CallProcedure("sp_uploadbarcode", dt);
-                //更新本地数据为已上传
-                if (adh.UpdateByCondition("prodiobarcode", "pib_ifupload=-1", "pib_inoutno='" + iInoutno + "' and pib_ifrecheck=-1 and pib_ifupload<>-1") > 0)
+                int rowcount = int.Parse(dt.Rows[0][0].ToString());
+                for (int i = 0; i < rowcount; i++)
                 {
-                    return true;
+                    if (i % 100 == 0 || i == rowcount - 1)
+                    {
+
+                        dt = (DataTable)adh.ExecuteSql("select pib_id,pib_outboxcode1,pib_outboxcode2,pib_custmidboxcode,pib_custoutboxcode,pib_lotno,pib_datecode,pib_ifmodify,-1 as pib_ifupload,pib_ifpick,pib_ifprint,pib_ifrecheck,pib_year,pib_month,pib_day from prodiobarcode where pib_inoutno='" + iInoutno + "' and pib_ifupload=0 and pib_ifrecheck=-1 limit " + 150, "select");
+                        string pibid = "";
+                        if (dt.Rows.Count > 0)
+                        {
+                            dh.CallProcedure("sp_uploadbarcode", dt, out pibid);
+                            //更新本地数据为已上传
+                            if (adh.UpdateByCondition("prodiobarcode", "pib_ifupload=-1", "pib_id in (" + pibid + ")") > 0)
+                            {
+                                //return true;
+                            }
+                        }
+                    }
                 }
             }
-            return false;
+            return true;
         }
     }
 }

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


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

@@ -1578,7 +1578,7 @@ namespace UAS_LabelMachine
             LoadGridData(new object(), new EventArgs());
         }
         int CurrentPage = 1;
-        int PageSize = 5000;
+        int PageSize = 10000;
         int DataSize = 0;
         int MaxPageSize = 0;
         DataTable LabelInfDataTable;
@@ -2268,7 +2268,7 @@ namespace UAS_LabelMachine
             string day = "0";
             string date = "";
             LogicHandler.GetTimeFromDatecode(dh1, datecode, pi_cardcode.Text, out year, out month, out day, out date);
-            adh.ExecuteSql("update prodiobarcode set pib_autoset=-1,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");
+            adh.ExecuteSql("update prodiobarcode set pib_autoset=-1,pib_ifrecheck=-1,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();
         }
@@ -2284,7 +2284,7 @@ namespace UAS_LabelMachine
             string day = "0";
             string date = "";
             LogicHandler.GetTimeFromDatecode(dh1, datecode, pi_cardcode.Text, out year, out month, out day, out date);
-            adh.ExecuteSql("update prodiobarcode set pib_autoset=-1,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");
+            adh.ExecuteSql("update prodiobarcode set pib_autoset=-1,pib_ifrecheck,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");
             for (int i = 0; i < pibid_dt.Rows.Count; i++)

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