Browse Source

优化AOI上传界面

callm 4 weeks ago
parent
commit
c6723379fa

+ 55 - 54
UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.Designer.cs

@@ -47,6 +47,11 @@ namespace UAS_MES_NEW.Query
             this.ChoosePrint = new System.Windows.Forms.Button();
             this.PrintPath = new System.Windows.Forms.TextBox();
             this.label3 = new System.Windows.Forms.Label();
+            this.label4 = new System.Windows.Forms.Label();
+            this.label6 = new System.Windows.Forms.Label();
+            this.label7 = new System.Windows.Forms.Label();
+            this.X = new System.Windows.Forms.NumericUpDown();
+            this.Y = new System.Windows.Forms.NumericUpDown();
             this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -59,11 +64,6 @@ namespace UAS_MES_NEW.Query
             this.fp_path = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.psd_iskey = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.issend = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.label4 = new System.Windows.Forms.Label();
-            this.label6 = new System.Windows.Forms.Label();
-            this.label7 = new System.Windows.Forms.Label();
-            this.X = new System.Windows.Forms.NumericUpDown();
-            this.Y = new System.Windows.Forms.NumericUpDown();
             ((System.ComponentModel.ISupportInitialize)(this.SendDGV)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.X)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.Y)).BeginInit();
@@ -190,6 +190,7 @@ namespace UAS_MES_NEW.Query
             this.SendDGV.RowTemplate.Height = 37;
             this.SendDGV.Size = new System.Drawing.Size(1068, 759);
             this.SendDGV.TabIndex = 22;
+            this.SendDGV.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.SendDGV_CellPainting);
             // 
             // ChooseALL
             // 
@@ -239,6 +240,55 @@ namespace UAS_MES_NEW.Query
             this.label3.TabIndex = 29;
             this.label3.Text = "添加电子章";
             // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label4.Location = new System.Drawing.Point(12, 860);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(178, 41);
+            this.label4.TabIndex = 30;
+            this.label4.Text = "电子章坐标";
+            // 
+            // label6
+            // 
+            this.label6.AutoSize = true;
+            this.label6.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label6.Location = new System.Drawing.Point(211, 860);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(39, 41);
+            this.label6.TabIndex = 31;
+            this.label6.Text = "X";
+            // 
+            // label7
+            // 
+            this.label7.AutoSize = true;
+            this.label7.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label7.Location = new System.Drawing.Point(405, 860);
+            this.label7.Name = "label7";
+            this.label7.Size = new System.Drawing.Size(37, 41);
+            this.label7.TabIndex = 32;
+            this.label7.Text = "Y";
+            // 
+            // X
+            // 
+            this.X.Location = new System.Drawing.Point(258, 866);
+            this.X.Name = "X";
+            this.X.Size = new System.Drawing.Size(120, 35);
+            this.X.TabIndex = 33;
+            this.X.Value = new decimal(new int[] {
+            20,
+            0,
+            0,
+            0});
+            // 
+            // Y
+            // 
+            this.Y.Location = new System.Drawing.Point(464, 866);
+            this.Y.Name = "Y";
+            this.Y.Size = new System.Drawing.Size(120, 35);
+            this.Y.TabIndex = 34;
+            // 
             // dataGridViewCheckBoxColumn1
             // 
             this.dataGridViewCheckBoxColumn1.DataPropertyName = "CheckColumn";
@@ -358,55 +408,6 @@ namespace UAS_MES_NEW.Query
             this.issend.Visible = false;
             this.issend.Width = 200;
             // 
-            // label4
-            // 
-            this.label4.AutoSize = true;
-            this.label4.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label4.Location = new System.Drawing.Point(12, 860);
-            this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(178, 41);
-            this.label4.TabIndex = 30;
-            this.label4.Text = "电子章坐标";
-            // 
-            // label6
-            // 
-            this.label6.AutoSize = true;
-            this.label6.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label6.Location = new System.Drawing.Point(211, 860);
-            this.label6.Name = "label6";
-            this.label6.Size = new System.Drawing.Size(39, 41);
-            this.label6.TabIndex = 31;
-            this.label6.Text = "X";
-            // 
-            // label7
-            // 
-            this.label7.AutoSize = true;
-            this.label7.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label7.Location = new System.Drawing.Point(405, 860);
-            this.label7.Name = "label7";
-            this.label7.Size = new System.Drawing.Size(37, 41);
-            this.label7.TabIndex = 32;
-            this.label7.Text = "Y";
-            // 
-            // X
-            // 
-            this.X.Location = new System.Drawing.Point(258, 866);
-            this.X.Name = "X";
-            this.X.Size = new System.Drawing.Size(120, 35);
-            this.X.TabIndex = 33;
-            // 
-            // Y
-            // 
-            this.Y.Location = new System.Drawing.Point(464, 866);
-            this.Y.Name = "Y";
-            this.Y.Size = new System.Drawing.Size(120, 35);
-            this.Y.TabIndex = 34;
-            this.Y.Value = new decimal(new int[] {
-            18,
-            0,
-            0,
-            0});
-            // 
             // Query_SOP
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);

+ 32 - 5
UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.cs

@@ -130,9 +130,8 @@ namespace UAS_MES_NEW.Query
                                 if (File.Exists(PrintPath.Text))
                                 {
                                     //she.Pictures.Add(int.Parse(X.Value.ToString()), int.Parse(Y.Value.ToString()), PrintPath.Text);
-                                    she.Pictures.Add(startRow+ int.Parse(X.Value.ToString()), int.Parse(Y.Value.ToString()), PrintPath.Text);
+                                    she.Pictures.Add(startRow + int.Parse(Y.Value.ToString()), int.Parse(X.Value.ToString()), PrintPath.Text);
                                 }
-
                                 // 创建SheetRender对象
                                 SheetRender sr = new SheetRender(she, options);
 
@@ -392,20 +391,43 @@ namespace UAS_MES_NEW.Query
             }
         }
 
+        private BindingSource bs = new BindingSource(); // 类成员变量
+
         private void LoadPrCode()
         {
             DataTable dt = (DataTable)dh.ExecuteSql("select * from productsop where ps_prodcode='" + ps_prodcode.Text + "'", "select");
             if (dt.Rows.Count > 0)
             {
                 string ps_id = dt.Rows[0]["ps_id"].ToString();
-                dt = (DataTable)dh.ExecuteSql("select fp_name,fp_path,'' issend,psd_iskey from ProductSOPdetail left join " +
-                    "filepath on FP_ID=substr(PSD_ATTACH,instr(PSD_ATTACH,';')+1)  where psd_psid=" + ps_id, "select");
+                dt = (DataTable)dh.ExecuteSql(@"select fp_name,fp_path,'' issend,psd_iskey 
+                                        from ProductSOPdetail 
+                                        left join filepath on FP_ID=substr(PSD_ATTACH,instr(PSD_ATTACH,';')+1)  
+                                        where psd_psid=" + ps_id, "select");
                 if (dt.Rows.Count > 0)
                 {
-                    SendDGV.DataSource = dt;
+                    // 在 UI 线程安全执行(如果已经在 UI 线程则直接调用)
+                    if (SendDGV.InvokeRequired)
+                        SendDGV.Invoke(new Action(() => BindData(dt)));
+                    else
+                        BindData(dt);
                 }
             }
         }
+        private void BindData(DataTable dt)
+        {
+            // 使用 BindingSource 避免直接置 null
+            if (SendDGV.DataSource == null)
+            {
+                bs.DataSource = dt;
+                SendDGV.DataSource = bs;
+            }
+            else
+            {
+                bs.DataSource = dt; // 直接替换内部数据,控件不会经历“无数据”状态
+            }
+            // 可选:刷新显示
+            SendDGV.Refresh();
+        }
 
         private void pr_code_Leave(object sender, EventArgs e)
         {
@@ -447,5 +469,10 @@ namespace UAS_MES_NEW.Query
                 PrintPath.Text = ChoosePath.FileName;
             }
         }
+
+        private void SendDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
+        {
+            if (e.RowIndex < 0 || e.ColumnIndex < 0) return;
+        }
     }
 }

+ 0 - 15
UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.resx

@@ -135,19 +135,4 @@
   <metadata name="issend.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="CheckColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="fp_name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="fp_path.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="psd_iskey.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="issend.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
 </root>