Bladeren bron

允许更新非本表的字段

章政 6 jaren geleden
bovenliggende
commit
81b168e093

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

@@ -196,20 +196,20 @@ namespace UAS_LabelMachine
         {
             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);
-                }
-            }
+            //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 = "";

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

@@ -152,8 +152,8 @@
             this.pib_id1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_ifmodify = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_ifupload = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_ifmodify = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.pib_ifupload = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.pr_vendprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_madein = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -1502,6 +1502,8 @@
             this.pib_ifmodify.DataPropertyName = "pib_ifmodify";
             this.pib_ifmodify.HeaderText = "已修改";
             this.pib_ifmodify.Name = "pib_ifmodify";
+            this.pib_ifmodify.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+            this.pib_ifmodify.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
             this.pib_ifmodify.Width = 66;
             // 
             // pib_ifupload
@@ -1509,6 +1511,8 @@
             this.pib_ifupload.DataPropertyName = "pib_ifupload";
             this.pib_ifupload.HeaderText = "已上传";
             this.pib_ifupload.Name = "pib_ifupload";
+            this.pib_ifupload.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+            this.pib_ifupload.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
             this.pib_ifupload.Width = 66;
             // 
             // pr_vendprodcode
@@ -1867,8 +1871,8 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_id1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_pdno;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_prodcode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pib_ifmodify;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pib_ifupload;
+        private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifmodify;
+        private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifupload;
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_vendprodcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_brand;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_madein;

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

@@ -505,6 +505,7 @@ namespace UAS_LabelMachine
                                 PaintCell.Add(LabelInf.Rows[i].Cells["pib_qty"], true);
                                 LabelInf.Refresh();
                                 LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
+                                adh.UpdateByCondition("prodiobarcode", "pib_ifpick=-1", "pib_id='" + LabelInf.Rows[i].Cells["pib_id"].Value + "'");
                                 LabelInf.Rows[i].Cells["Choose"].Value = true;
                                 //当前行的索引随循环增长
                                 CurrentRowIndex = i;
@@ -1578,13 +1579,18 @@ namespace UAS_LabelMachine
         private void LoadGridData(object sender, EventArgs e)
         {
             AllCollect = false;
-            sql.Clear();
-            sql.Append("select pd_custprodcode,pd_custprodspec,pib_ifrecheck,pib_ifupload,pib_ifmodify,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,pib_id,pib_datecode1,pib_pdid,pib_piid,pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,");
-            sql.Append("pib_lotno,pib_datecode,pib_qty,pr_spec,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint");
-            sql.Append(" from prodiobarcode 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 ");
-            sql.Append("where pib_piid='" + PI_ID + "' order by to_number(pib_outboxcode1),pib_id,pd_prodcode");
-            dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+            dt = (DataTable)adh.ExecuteSql("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "'", "select");
+            if (dt.Rows.Count == 0)
+            {
+                sql.Clear();
+                sql.Append("select pd_custprodcode,pib_inoutno,pd_custprodspec,pib_ifrecheck,pib_ifupload,pib_ifmodify,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,pib_id,pib_pdid,pib_piid,pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,");
+                sql.Append("pib_lotno,pib_datecode,pib_qty,pr_spec,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint");
+                sql.Append(" from prodiobarcode 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 ");
+                sql.Append("where pib_piid='" + PI_ID + "' order by to_number(pib_outboxcode1),pib_id,pd_prodcode");
+                dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+                adh.SaveDataTable(dt, "prodiobarcode");
+            }
             //获取系统设置的上传数量,如参数异常则默认为100
             if (!int.TryParse(adh.getFieldDataByCondition("dataextra", "uploadnum", "id=1").ToString(), out UploadNum))
             {
@@ -1625,7 +1631,7 @@ namespace UAS_LabelMachine
             bool mouseOver = e.CellBounds.Contains(this.PointToClient(Cursor.Position));
             if (e.ColumnIndex > 0)
             {
-                if (LabelInf.Columns[e.ColumnIndex].Name == "pib_madein" || LabelInf.Columns[e.ColumnIndex].Name == "pib_lotno" || LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode" || LabelInf.Columns[e.ColumnIndex].Name == "pib_outboxcode1" || LabelInf.Columns[e.ColumnIndex].Name == "pib_outboxcode2" || LabelInf.Columns[e.ColumnIndex].Name == "pib_brand")
+                if (LabelInf.Columns[e.ColumnIndex].Name == "pib_lotno" || LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode")
                 {
                     SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
                     e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.LightSeaGreen, e.CellBounds);