瀏覽代碼

加快加载速度

章政 6 年之前
父節點
當前提交
48ff634a75

+ 29 - 26
UAS-出货标签管理(贸易版)/PublicMethod/SqliteDBHelper.cs

@@ -172,21 +172,6 @@ namespace UAS_LabelMachine
         public void SaveDataTable(DataTable dt, string TableName)
         {
             StringBuilder sb = new StringBuilder();
-            //预防插入的DataTable中存在不属于该表的列,在进行下一步操作之前全部剔除
-            //DataTable data = (DataTable)ExecuteSql("select top 1 * from " + TableName, "select");
-            ////将所有的字段拼接起来
-            //for (int i = 0; i < data.Columns.Count; i++)
-            //{
-            //    sb.Append("#" + data.Columns[i].ColumnName.ToString().ToUpper());
-            //}
-            ////移除掉所有不属于该表的列
-            //for (int i = dt.Columns.Count - 1; i >= 0; i--)
-            //{
-            //    if (!sb.ToString().Contains(dt.Columns[i].ColumnName.ToUpper()))
-            //    {
-            //        dt.Columns.RemoveAt(i);
-            //    }
-            //}
             sb.Clear();
             sb.Append("insert into " + TableName + " (");
             string field = "";
@@ -240,21 +225,39 @@ namespace UAS_LabelMachine
 
         public void BatchInsert(string tableName, DataTable dt)
         {
-            List<string> columnList = new List<string>();
-            foreach (DataColumn one in dt.Columns)
-            {
-                columnList.Add(one.ColumnName);
-            }
-            SQLiteDataAdapter adapter = new SQLiteDataAdapter();
-            adapter.SelectCommand = new SQLiteCommand("select pib_id from " + tableName, this._odcConnection);
-            using (SQLiteCommandBuilder builder = new SQLiteCommandBuilder(adapter))
+            StringBuilder sb = new StringBuilder();
+            sb.Clear();
+            sb.Append("update  " + tableName + " set pib_outboxcode2=? where pib_id=?");
+            SQLiteTransaction tx = this._odcConnection.BeginTransaction();
+            command = new SQLiteCommand();
+            command.Connection = this._odcConnection;
+            command.Transaction = tx;
+            string sql = sb.ToString();
+            try
             {
-                adapter.InsertCommand = builder.GetInsertCommand();
-                foreach (string one in columnList)
+                for (int i = 0; i < dt.Rows.Count; i++)
                 {
-                    adapter.InsertCommand.Parameters.Add(new SQLiteParameter(one.ToLower(), "Test"));
+                    command.CommandText = sql;
+                    command.Parameters.AddWithValue("pib_outboxcode2", dt.Rows[i]["pib_outboxcode2"]);
+                    command.Parameters.AddWithValue("pib_id", dt.Rows[i]["pib_id"]);
+                    try
+                    {
+                        command.ExecuteNonQuery();
+                        command.Parameters.Clear();
+                    }
+                    catch (Exception e)
+                    {
+                        MessageBox.Show(e.Message.ToString());
+                    }
                 }
+                tx.Commit();
             }
+            catch (Exception E)
+            {
+                tx.Rollback();
+                throw new Exception(E.Message);
+            }
+
         }
 
         /// <summary>

+ 16 - 16
UAS-出货标签管理(贸易版)/UAS_出货标签管理.Designer.cs

@@ -1133,8 +1133,8 @@
             // LabelInf
             // 
             this.LabelInf.AllowUserToAddRows = false;
-            this.LabelInf.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
-            this.LabelInf.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
+            this.LabelInf.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.DisplayedCells;
+            this.LabelInf.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.DisplayedCells;
             this.LabelInf.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.LabelInf.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.Choose,
@@ -1202,7 +1202,7 @@
             this.pib_id1.HeaderText = "pib_id";
             this.pib_id1.Name = "pib_id1";
             this.pib_id1.Visible = false;
-            this.pib_id1.Width = 66;
+            this.pib_id1.Width = 5;
             // 
             // pib_pdno
             // 
@@ -1219,7 +1219,7 @@
             this.pib_prodcode.HeaderText = "物料编号";
             this.pib_prodcode.Name = "pib_prodcode";
             this.pib_prodcode.ReadOnly = true;
-            this.pib_prodcode.Width = 78;
+            this.pib_prodcode.Width = 51;
             // 
             // pr_vendprodcode
             // 
@@ -1235,14 +1235,14 @@
             this.pib_brand.HeaderText = "品牌";
             this.pib_brand.Name = "pib_brand";
             this.pib_brand.ReadOnly = true;
-            this.pib_brand.Width = 54;
+            this.pib_brand.Width = 51;
             // 
             // pib_madein
             // 
             this.pib_madein.DataPropertyName = "pib_madein";
             this.pib_madein.HeaderText = "产地";
             this.pib_madein.Name = "pib_madein";
-            this.pib_madein.Width = 54;
+            this.pib_madein.Width = 51;
             // 
             // pr_zxbzs
             // 
@@ -1250,7 +1250,7 @@
             this.pr_zxbzs.HeaderText = "最小包装数";
             this.pr_zxbzs.Name = "pr_zxbzs";
             this.pr_zxbzs.Visible = false;
-            this.pr_zxbzs.Width = 90;
+            this.pr_zxbzs.Width = 5;
             // 
             // pr_unit
             // 
@@ -1258,7 +1258,7 @@
             this.pr_unit.HeaderText = "单位";
             this.pr_unit.Name = "pr_unit";
             this.pr_unit.Visible = false;
-            this.pr_unit.Width = 54;
+            this.pr_unit.Width = 5;
             // 
             // pib_lotno
             // 
@@ -1280,7 +1280,7 @@
             this.pib_datecode1.HeaderText = "DateCode1";
             this.pib_datecode1.Name = "pib_datecode1";
             this.pib_datecode1.Visible = false;
-            this.pib_datecode1.Width = 84;
+            this.pib_datecode1.Width = 5;
             // 
             // pib_qty
             // 
@@ -1288,7 +1288,7 @@
             this.pib_qty.HeaderText = "数量";
             this.pib_qty.Name = "pib_qty";
             this.pib_qty.ReadOnly = true;
-            this.pib_qty.Width = 54;
+            this.pib_qty.Width = 51;
             // 
             // pib_barcode
             // 
@@ -1296,7 +1296,7 @@
             this.pib_barcode.HeaderText = "唯一条码";
             this.pib_barcode.Name = "pib_barcode";
             this.pib_barcode.ReadOnly = true;
-            this.pib_barcode.Width = 78;
+            this.pib_barcode.Width = 51;
             // 
             // pib_custbarcode
             // 
@@ -1304,7 +1304,7 @@
             this.pib_custbarcode.HeaderText = "客户条码";
             this.pib_custbarcode.Name = "pib_custbarcode";
             this.pib_custbarcode.ReadOnly = true;
-            this.pib_custbarcode.Width = 78;
+            this.pib_custbarcode.Width = 51;
             // 
             // pd_pocode
             // 
@@ -1312,7 +1312,7 @@
             this.pd_pocode.HeaderText = "客户PO";
             this.pd_pocode.Name = "pd_pocode";
             this.pd_pocode.ReadOnly = true;
-            this.pd_pocode.Width = 66;
+            this.pd_pocode.Width = 51;
             // 
             // pd_custprodcode
             // 
@@ -1320,7 +1320,7 @@
             this.pd_custprodcode.HeaderText = "客户料号";
             this.pd_custprodcode.Name = "pd_custprodcode";
             this.pd_custprodcode.ReadOnly = true;
-            this.pd_custprodcode.Width = 78;
+            this.pd_custprodcode.Width = 51;
             // 
             // pd_custprodspec
             // 
@@ -1328,7 +1328,7 @@
             this.pd_custprodspec.HeaderText = "客户型号";
             this.pd_custprodspec.Name = "pd_custprodspec";
             this.pd_custprodspec.ReadOnly = true;
-            this.pd_custprodspec.Width = 78;
+            this.pd_custprodspec.Width = 51;
             // 
             // pr_spec
             // 
@@ -1336,7 +1336,7 @@
             this.pr_spec.HeaderText = "规格";
             this.pr_spec.Name = "pr_spec";
             this.pr_spec.Visible = false;
-            this.pr_spec.Width = 54;
+            this.pr_spec.Width = 5;
             // 
             // pib_outboxcode1
             // 

+ 1 - 1
UAS-出货标签管理(贸易版)/UAS_出货标签管理.cs

@@ -1836,8 +1836,8 @@ namespace UAS_LabelMachine
                             BoxCode = BoxCode + 1;
                         }
                     }
-                    sdh.ExecuteSql("update prodiobarcode set pib_outboxcode2=" + BoxCode + " where pib_id=" + LabelInf.Rows[i].Cells["pib_id1"].Value, "update");
                 }
+                sdh.BatchInsert("prodiobarcode", LabelInf.DataSource as DataTable);
             }
             SaveGrid_Click(sender, e);
         }

+ 3 - 3
UAS-出货标签管理(贸易版)/生成条码.cs

@@ -275,11 +275,11 @@ namespace UAS_LabelMachine
                     {
                         //插入条码
                         sql.Clear();
-                        sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,pib_brand,PIB_BARCODE,PIB_CUSTBARCODE,PIB_PDNO,");
+                        sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,pib_inman,PIB_INDATE,PIB_INOUTNO,PIB_PIID,pib_brand,PIB_BARCODE,PIB_CUSTBARCODE,PIB_PDNO,");
                         sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,PIB_PRODID,PIB_OUTBOXCODE1,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,PIB_CUSTPO,pib_orderdetno)");
-                        sql.Append(" values (prodiobarcode_seq.nextval,'" + pd_prodcode + "',sysdate,'" + pi_inoutno.Text + "'," + pi_id + ",'" + pr_brand + "',:barcode,:custbarcode,'" + pd_pdno + "','" + pd_id + "',");
+                        sql.Append(" values (prodiobarcode_seq.nextval,'" + pd_prodcode + "','" + User.UserName + "',sysdate,'" + pi_inoutno.Text + "'," + pi_id + ",'" + pr_brand + "',:barcode,:custbarcode,'" + pd_pdno + "','" + pd_id + "',");
                         sql.Append("'" + pi_class.Text + "',:pib_inqty,'" + pr_id + "',:midcode,0,0,'" + pd_ordercode + "','','" + pd_orderdetno + "')");
-                        dh.BatchInsert(sql.ToString(), new string[] { "barcode", "custbarcode", "pib_inqty" , "midcode" }, barcode.ToArray(), custbarcode.ToArray(), pib_inqty.ToArray(), midcode.ToArray());
+                        dh.BatchInsert(sql.ToString(), new string[] { "barcode", "custbarcode", "pib_inqty", "midcode" }, barcode.ToArray(), custbarcode.ToArray(), pib_inqty.ToArray(), midcode.ToArray());
                         //更新最大流水号
                         dh.UpdateByCondition("RuleMaxNum", "rmn_maxnumber='" + custserialnum + "'", "rmn_nrcode='" + NrCode + "' and rmn_prefix='" + Prefix + "'");
                     }