Ver código fonte

优化逻辑

callm 23 horas atrás
pai
commit
3984101ea5

+ 9 - 0
FileWatcher/.workbuddy/memory/2026-10-30.md

@@ -0,0 +1,9 @@
+# 2026-10-30
+
+## AutoSMTRXY 报警弹窗去重改造
+- 需求:「缺料预警」「超出工单数量」两个弹窗在没点掉之前只弹一次。
+- 实现(AutoSMTRXY.cs):
+  - 新增 `AlarmBoxShowing`(Interlocked 互锁)+ `ShowAlarm(string)` 统一弹窗入口,同一时刻只允许存在一个 MessageBox,点掉后释放;串口 DataReceived 在后台线程与 Timer 主线程并存,必须互锁防并发弹窗。
+  - 「缺料预警」新增 `MaterialAlarmShowed` 标记:已提示过则不再弹,缺料记录清空(dt.Rows.Count==0)或点“开始监控”时复位。
+  - 「超出工单数量」复用已有 `StopData`:两处触发点(串口 DataReceived、Timer_Tick)均加 `Stop != "" && StopData` 判断,弹后置 false,点“启动”写 Stop=0 或“开始监控”时复位 true。
+- 注意:报警仍会每周期重复向 Stop 地址写 1(保持原有行为未改),如需改为只写一次可直接把写指令也放进同一判断内。

+ 52 - 15
FileWatcher/AutoSMTRXY.cs

@@ -127,15 +127,15 @@ namespace FileWatcher
                 {
                     string ma_inqty = dh.getFieldDataByCondition("make", "nvl(ma_inqty,0)", "ma_code='" + ma_code.Text + "'").ToString();
                     dh.ExecuteSql("update make set ma_inqty=nvl(ma_inqty,0)+'" + (qty - lastqty) + "' where ma_code='" + ma_code.Text + "' ", "update");
-                    dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount)" +
-                        "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "')", "insert");
+                    dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount,mhc_nowqty)" +
+                           "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "','" + qty + "')", "insert");
                 }
                 else
                 {
                     string ma_endqty = dh.getFieldDataByCondition("make", "nvl(ma_endqty,0)", "ma_code='" + ma_code.Text + "'").ToString();
                     dh.ExecuteSql("update make set ma_endqty=nvl(ma_endqty,0)+'" + (qty - lastqty) + "' where ma_code='" + ma_code.Text + "' ", "update");
-                    dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount)" +
-                             "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "')", "insert");
+                    dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount,mhc_nowqty)" +
+                             "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "','" + qty + "')", "insert");
                 }
                 dt = (DataTable)dh.ExecuteSql("select nvl(sum(MHC_QTY* MHC_PCBCOUNT),0)MHC_QTY,max(nvl(ma_qty,0)+nvl(ma_boutqty,0))ma_qty from makehourcount left join make on ma_code=mhc_macode where mhc_macode='" + ma_code.Text + "' and mhc_qty<10", "select");
                 if (dt.Rows.Count > 0)
@@ -144,7 +144,7 @@ namespace FileWatcher
                     int ma_qty = int.Parse(dt.Rows[0]["ma_qty"].ToString());
                     if (MHC_QTY >= ma_qty)
                     {
-                        if (Stop != "")
+                        if (Stop != "" && StopData)
                         {
                             OperateResult write = plc.Write(Stop, 1);
                             if (write.IsSuccess)
@@ -152,7 +152,7 @@ namespace FileWatcher
                                 OperateResult.AppendText("超出工单数量,发送指令" + Stop + "写入1\n");
                                 OperateResult.ScrollToCaret();
                                 StopData = false;
-                                MessageBox.Show("超出工单数量");
+                                ShowAlarm("超出工单数量");
                             }
                             else
                             {
@@ -234,7 +234,7 @@ namespace FileWatcher
                     " from devsmtlocation left  join    (select DSL_LINECODE alllincode,Dsl_Location allLocation, " +
                     " sum(dsl_madeqty)allmadeqty from devsmtlocation    group by  DSL_LINECODE,Dsl_Location)A on  " +
                     " alllincode=devsmtlocation.dsl_linecode and allLocation=dsl_location left join barcode  " +
-                    " on dsl_barcode = bar_code where  dsl_status=0 and dsl_usable=1)  ");
+                    " on dsl_barcode = bar_code where  dsl_status=0 and dsl_usable=1 and dsl_linecode='" + li_code.Text + "')  ");
                 System.Data.DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
@@ -252,8 +252,12 @@ namespace FileWatcher
                         {
                             OperateResult.AppendText("缺料预警,发送指令" + Stop + "写入1\n");
                             OperateResult.ScrollToCaret();
-                            MessageBox.Show("缺料预警");
                             StopData = false;
+                            if (!MaterialAlarmShowed)
+                            {
+                                MaterialAlarmShowed = true;
+                                ShowAlarm("缺料预警");
+                            }
                         }
                         else
                         {
@@ -263,6 +267,11 @@ namespace FileWatcher
 
                     }
                 }
+                else
+                {
+                    //缺料记录已清空,复位预警提示
+                    MaterialAlarmShowed = false;
+                }
             }
         }
 
@@ -447,6 +456,9 @@ namespace FileWatcher
                     serialPort1.BaudRate = int.Parse(BaudRate);
                     serialPort1.Open();
                 }
+                //开始新一轮监控,复位停机/预警标记,保证异常消除后能再次提示
+                StopData = true;
+                MaterialAlarmShowed = false;
                 Timer.Start();
             }
             catch (Exception mes)
@@ -468,8 +480,34 @@ namespace FileWatcher
             OperateResult.AppendText("停止执行监控\n");
         }
 
+        /// <summary>停机指令是否已下发(写入Stop后置false,点“启动”后复位,避免重复写、重复弹窗)</summary>
         bool StopData = true;
 
+        /// <summary>缺料预警是否已提示过(缺料记录消失后自动复位)</summary>
+        bool MaterialAlarmShowed = false;
+
+        /// <summary>弹窗显示锁,保证同一时刻只存在一个提示框</summary>
+        int AlarmBoxShowing = 0;
+
+        /// <summary>
+        /// 弹出提示框,同一时刻只弹一个:未点掉之前不会重复弹出(串口事件在后台线程,需防并发)
+        /// </summary>
+        private void ShowAlarm(string message)
+        {
+            if (System.Threading.Interlocked.CompareExchange(ref AlarmBoxShowing, 1, 0) != 0)
+            {
+                return;
+            }
+            try
+            {
+                MessageBox.Show(message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+            }
+            finally
+            {
+                System.Threading.Interlocked.Exchange(ref AlarmBoxShowing, 0);
+            }
+        }
+
         private void Timer_Tick(object sender, EventArgs e)
         {
             if (CountType == "PLC")
@@ -506,15 +544,15 @@ namespace FileWatcher
                         {
                             string ma_inqty = dh.getFieldDataByCondition("make", "nvl(ma_inqty,0)", "ma_code='" + ma_code.Text + "'").ToString();
                             dh.ExecuteSql("update make set ma_inqty=nvl(ma_inqty,0)+'" + (qty - lastqty) + "' where ma_code='" + ma_code.Text + "' ", "update");
-                            dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount)" +
-                                "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "')", "insert");
+                            dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount,mhc_nowqty)" +
+                              "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "','" + qty + "')", "insert");
                         }
                         else
                         {
                             string ma_endqty = dh.getFieldDataByCondition("make", "nvl(ma_endqty,0)", "ma_code='" + ma_code.Text + "'").ToString();
                             dh.ExecuteSql("update make set ma_endqty=nvl(ma_endqty,0)+'" + (qty - lastqty) + "' where ma_code='" + ma_code.Text + "' ", "update");
-                            dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount)" +
-                                     "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "')", "insert");
+                            dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount,mhc_nowqty)" +
+                                                "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "','" + qty + "')", "insert");
                         }
                         if (Counter.Checked)
                         {
@@ -536,8 +574,7 @@ namespace FileWatcher
                                         OperateResult.AppendText("超出工单数量,发送指令" + Stop + "写入1\n");
                                         OperateResult.ScrollToCaret();
                                         StopData = false;
-                                        MessageBox.Show("超出工单数量");
-
+                                        ShowAlarm("超出工单数量");
                                     }
                                     else
                                     {
@@ -551,7 +588,7 @@ namespace FileWatcher
                                 }
                             }
                         }
-                       
+
                     }
                 }
                 else

+ 40 - 177
FileWatcher/SOP.Designer.cs

@@ -34,6 +34,7 @@
             this.FilePath = new System.Windows.Forms.TextBox();
             this.ChooseFile = new System.Windows.Forms.Button();
             this.UploadSOP = new System.Windows.Forms.Button();
+            this.pr_code = new System.Windows.Forms.TextBox();
             this.label2 = new System.Windows.Forms.Label();
             this.OperatResult = new System.Windows.Forms.RichTextBox();
             this.SendSop = new System.Windows.Forms.Button();
@@ -41,19 +42,8 @@
             this.label4 = new System.Windows.Forms.Label();
             this.pr_detail = new System.Windows.Forms.Label();
             this.JPG = new System.Windows.Forms.RadioButton();
+            this.PDF = new System.Windows.Forms.RadioButton();
             this.pr_spec = new System.Windows.Forms.RichTextBox();
-            this.label5 = new System.Windows.Forms.Label();
-            this.SendDGV = new System.Windows.Forms.DataGridView();
-            this.ChooseALL = new System.Windows.Forms.Button();
-            this.ps_prodcode = new FileWatcher.SearchTextBox();
-            this.li_code = new FileWatcher.SearchTextBox();
-            this.GetSOP = new System.Windows.Forms.Button();
-            this.CheckColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.fp_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.fp_path = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.psd_iskey = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.issend = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            ((System.ComponentModel.ISupportInitialize)(this.SendDGV)).BeginInit();
             this.SuspendLayout();
             // 
             // richTextBox1
@@ -88,7 +78,7 @@
             // 
             // ChooseFile
             // 
-            this.ChooseFile.Location = new System.Drawing.Point(218, 666);
+            this.ChooseFile.Location = new System.Drawing.Point(218, 611);
             this.ChooseFile.Name = "ChooseFile";
             this.ChooseFile.Size = new System.Drawing.Size(160, 42);
             this.ChooseFile.TabIndex = 8;
@@ -98,7 +88,7 @@
             // 
             // UploadSOP
             // 
-            this.UploadSOP.Location = new System.Drawing.Point(424, 666);
+            this.UploadSOP.Location = new System.Drawing.Point(424, 611);
             this.UploadSOP.Name = "UploadSOP";
             this.UploadSOP.Size = new System.Drawing.Size(160, 42);
             this.UploadSOP.TabIndex = 9;
@@ -106,30 +96,37 @@
             this.UploadSOP.UseVisualStyleBackColor = true;
             this.UploadSOP.Click += new System.EventHandler(this.UploadSOP_Click);
             // 
+            // pr_code
+            // 
+            this.pr_code.Location = new System.Drawing.Point(218, 152);
+            this.pr_code.Name = "pr_code";
+            this.pr_code.Size = new System.Drawing.Size(582, 35);
+            this.pr_code.TabIndex = 11;
+            this.pr_code.KeyDown += new System.Windows.Forms.KeyEventHandler(this.pr_code_KeyDown);
+            this.pr_code.Leave += new System.EventHandler(this.pr_code_Leave);
+            // 
             // label2
             // 
             this.label2.AutoSize = true;
             this.label2.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label2.Location = new System.Drawing.Point(19, 311);
+            this.label2.Location = new System.Drawing.Point(19, 147);
             this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(82, 41);
+            this.label2.Size = new System.Drawing.Size(146, 41);
             this.label2.TabIndex = 10;
-            this.label2.Text = "机型";
+            this.label2.Text = "产品编号";
             // 
             // OperatResult
             // 
-            this.OperatResult.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
-            | System.Windows.Forms.AnchorStyles.Right)));
-            this.OperatResult.Location = new System.Drawing.Point(865, 841);
+            this.OperatResult.Location = new System.Drawing.Point(823, 32);
             this.OperatResult.Name = "OperatResult";
-            this.OperatResult.Size = new System.Drawing.Size(1068, 381);
+            this.OperatResult.Size = new System.Drawing.Size(1110, 874);
             this.OperatResult.TabIndex = 12;
             this.OperatResult.Text = "";
             this.OperatResult.TextChanged += new System.EventHandler(this.OperatResult_TextChanged);
             // 
             // SendSop
             // 
-            this.SendSop.Location = new System.Drawing.Point(640, 666);
+            this.SendSop.Location = new System.Drawing.Point(640, 611);
             this.SendSop.Name = "SendSop";
             this.SendSop.Size = new System.Drawing.Size(160, 42);
             this.SendSop.TabIndex = 13;
@@ -141,33 +138,30 @@
             // 
             this.label3.AutoSize = true;
             this.label3.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label3.Location = new System.Drawing.Point(19, 22);
+            this.label3.Location = new System.Drawing.Point(19, 240);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(146, 41);
             this.label3.TabIndex = 14;
             this.label3.Text = "产品名称";
-            this.label3.Visible = false;
             // 
             // label4
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label4.Location = new System.Drawing.Point(19, 115);
+            this.label4.Location = new System.Drawing.Point(19, 333);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(146, 41);
             this.label4.TabIndex = 15;
             this.label4.Text = "产品规格";
-            this.label4.Visible = false;
             // 
             // pr_detail
             // 
             this.pr_detail.AutoSize = true;
             this.pr_detail.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.pr_detail.Location = new System.Drawing.Point(211, 22);
+            this.pr_detail.Location = new System.Drawing.Point(211, 240);
             this.pr_detail.Name = "pr_detail";
             this.pr_detail.Size = new System.Drawing.Size(0, 41);
             this.pr_detail.TabIndex = 16;
-            this.pr_detail.Visible = false;
             // 
             // JPG
             // 
@@ -181,174 +175,52 @@
             this.JPG.Text = "图片";
             this.JPG.UseVisualStyleBackColor = true;
             // 
+            // PDF
+            // 
+            this.PDF.AutoSize = true;
+            this.PDF.Location = new System.Drawing.Point(382, 534);
+            this.PDF.Name = "PDF";
+            this.PDF.Size = new System.Drawing.Size(77, 28);
+            this.PDF.TabIndex = 18;
+            this.PDF.TabStop = true;
+            this.PDF.Text = "PDF";
+            this.PDF.UseVisualStyleBackColor = true;
+            // 
             // pr_spec
             // 
             this.pr_spec.Enabled = false;
-            this.pr_spec.Location = new System.Drawing.Point(218, 123);
+            this.pr_spec.Location = new System.Drawing.Point(218, 341);
             this.pr_spec.Name = "pr_spec";
             this.pr_spec.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
             this.pr_spec.Size = new System.Drawing.Size(580, 94);
             this.pr_spec.TabIndex = 19;
             this.pr_spec.Text = "";
-            this.pr_spec.Visible = false;
-            // 
-            // label5
-            // 
-            this.label5.AutoSize = true;
-            this.label5.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label5.Location = new System.Drawing.Point(19, 580);
-            this.label5.Name = "label5";
-            this.label5.Size = new System.Drawing.Size(82, 41);
-            this.label5.TabIndex = 20;
-            this.label5.Text = "线别";
-            // 
-            // SendDGV
-            // 
-            this.SendDGV.AllowUserToAddRows = false;
-            this.SendDGV.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
-            | System.Windows.Forms.AnchorStyles.Right)));
-            this.SendDGV.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
-            this.SendDGV.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
-            this.CheckColumn,
-            this.fp_name,
-            this.fp_path,
-            this.psd_iskey,
-            this.issend});
-            this.SendDGV.Location = new System.Drawing.Point(865, 61);
-            this.SendDGV.Name = "SendDGV";
-            this.SendDGV.RowHeadersWidth = 82;
-            this.SendDGV.RowTemplate.Height = 37;
-            this.SendDGV.Size = new System.Drawing.Size(1068, 759);
-            this.SendDGV.TabIndex = 22;
-            // 
-            // ChooseALL
-            // 
-            this.ChooseALL.Location = new System.Drawing.Point(865, 61);
-            this.ChooseALL.Name = "ChooseALL";
-            this.ChooseALL.Size = new System.Drawing.Size(80, 42);
-            this.ChooseALL.TabIndex = 23;
-            this.ChooseALL.Text = "全选";
-            this.ChooseALL.UseVisualStyleBackColor = true;
-            this.ChooseALL.Click += new System.EventHandler(this.ChooseALL_Click);
-            // 
-            // ps_prodcode
-            // 
-            this.ps_prodcode.AllPower = null;
-            this.ps_prodcode.Caller = null;
-            this.ps_prodcode.Condition = null;
-            this.ps_prodcode.DBTitle = null;
-            this.ps_prodcode.FormName = null;
-            this.ps_prodcode.Location = new System.Drawing.Point(216, 311);
-            this.ps_prodcode.Name = "ps_prodcode";
-            this.ps_prodcode.Power = null;
-            this.ps_prodcode.ReturnData = null;
-            this.ps_prodcode.SelectField = null;
-            this.ps_prodcode.SetValueField = null;
-            this.ps_prodcode.Size = new System.Drawing.Size(582, 41);
-            this.ps_prodcode.TabIndex = 24;
-            this.ps_prodcode.TableName = null;
-            this.ps_prodcode.TextBoxEnable = false;
-            this.ps_prodcode.UserControlTextChanged += new FileWatcher.SearchTextBox.OnTextChange(this.ps_prodcode_UserControlTextChanged);
-            // 
-            // li_code
-            // 
-            this.li_code.AllPower = null;
-            this.li_code.Caller = null;
-            this.li_code.Condition = null;
-            this.li_code.DBTitle = null;
-            this.li_code.FormName = null;
-            this.li_code.Location = new System.Drawing.Point(218, 580);
-            this.li_code.Name = "li_code";
-            this.li_code.Power = null;
-            this.li_code.ReturnData = null;
-            this.li_code.SelectField = null;
-            this.li_code.SetValueField = null;
-            this.li_code.Size = new System.Drawing.Size(582, 41);
-            this.li_code.TabIndex = 25;
-            this.li_code.TableName = null;
-            this.li_code.TextBoxEnable = false;
-            // 
-            // GetSOP
-            // 
-            this.GetSOP.Location = new System.Drawing.Point(638, 379);
-            this.GetSOP.Name = "GetSOP";
-            this.GetSOP.Size = new System.Drawing.Size(160, 42);
-            this.GetSOP.TabIndex = 26;
-            this.GetSOP.Text = "获取SOP";
-            this.GetSOP.UseVisualStyleBackColor = true;
-            this.GetSOP.Click += new System.EventHandler(this.GetSOP_Click);
-            // 
-            // CheckColumn
-            // 
-            this.CheckColumn.DataPropertyName = "CheckColumn";
-            this.CheckColumn.HeaderText = "勾选";
-            this.CheckColumn.MinimumWidth = 100;
-            this.CheckColumn.Name = "CheckColumn";
-            this.CheckColumn.Width = 200;
-            // 
-            // fp_name
-            // 
-            this.fp_name.DataPropertyName = "fp_name";
-            this.fp_name.HeaderText = "文件名";
-            this.fp_name.MinimumWidth = 10;
-            this.fp_name.Name = "fp_name";
-            this.fp_name.Width = 200;
-            // 
-            // fp_path
-            // 
-            this.fp_path.DataPropertyName = "fp_path";
-            this.fp_path.HeaderText = "路径";
-            this.fp_path.MinimumWidth = 10;
-            this.fp_path.Name = "fp_path";
-            this.fp_path.Width = 200;
-            // 
-            // psd_iskey
-            // 
-            this.psd_iskey.DataPropertyName = "psd_iskey";
-            this.psd_iskey.HeaderText = "是否关键工序";
-            this.psd_iskey.MinimumWidth = 10;
-            this.psd_iskey.Name = "psd_iskey";
-            this.psd_iskey.Width = 200;
-            // 
-            // issend
-            // 
-            this.issend.DataPropertyName = "issend";
-            this.issend.HeaderText = "是否成功发送";
-            this.issend.MinimumWidth = 10;
-            this.issend.Name = "issend";
-            this.issend.Visible = false;
-            this.issend.Width = 200;
             // 
             // SOP
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(1945, 1234);
-            this.Controls.Add(this.GetSOP);
-            this.Controls.Add(this.li_code);
-            this.Controls.Add(this.ps_prodcode);
-            this.Controls.Add(this.ChooseALL);
-            this.Controls.Add(this.SendDGV);
-            this.Controls.Add(this.label5);
+            this.ClientSize = new System.Drawing.Size(1945, 934);
             this.Controls.Add(this.pr_spec);
+            this.Controls.Add(this.PDF);
             this.Controls.Add(this.JPG);
             this.Controls.Add(this.pr_detail);
             this.Controls.Add(this.label4);
             this.Controls.Add(this.label3);
             this.Controls.Add(this.SendSop);
             this.Controls.Add(this.OperatResult);
+            this.Controls.Add(this.pr_code);
             this.Controls.Add(this.label2);
             this.Controls.Add(this.UploadSOP);
             this.Controls.Add(this.ChooseFile);
             this.Controls.Add(this.FilePath);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.richTextBox1);
+            this.MaximizeBox = false;
             this.Name = "SOP";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Text = "SOP管理";
-            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
             this.Load += new System.EventHandler(this.Form3_Load);
-            ((System.ComponentModel.ISupportInitialize)(this.SendDGV)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -361,6 +233,7 @@
         private System.Windows.Forms.TextBox FilePath;
         private System.Windows.Forms.Button ChooseFile;
         private System.Windows.Forms.Button UploadSOP;
+        private System.Windows.Forms.TextBox pr_code;
         private System.Windows.Forms.Label label2;
         private System.Windows.Forms.RichTextBox OperatResult;
         private System.Windows.Forms.Button SendSop;
@@ -368,17 +241,7 @@
         private System.Windows.Forms.Label label4;
         private System.Windows.Forms.Label pr_detail;
         private System.Windows.Forms.RadioButton JPG;
+        private System.Windows.Forms.RadioButton PDF;
         private System.Windows.Forms.RichTextBox pr_spec;
-        private System.Windows.Forms.Label label5;
-        private System.Windows.Forms.DataGridView SendDGV;
-        private System.Windows.Forms.Button ChooseALL;
-        private SearchTextBox ps_prodcode;
-        private SearchTextBox li_code;
-        private System.Windows.Forms.Button GetSOP;
-        private System.Windows.Forms.DataGridViewCheckBoxColumn CheckColumn;
-        private System.Windows.Forms.DataGridViewTextBoxColumn fp_name;
-        private System.Windows.Forms.DataGridViewTextBoxColumn fp_path;
-        private System.Windows.Forms.DataGridViewTextBoxColumn psd_iskey;
-        private System.Windows.Forms.DataGridViewTextBoxColumn issend;
     }
 }

+ 135 - 161
FileWatcher/SOP.cs

@@ -2,14 +2,13 @@
 using System.IO;
 using System.Text;
 using System.Windows.Forms;
+using Spire.Xls;
 using System.Net;
 using System.Collections.Generic;
 using System.Threading;
+using System.Net.Sockets;
 using System.Data;
 using System.Web.Script.Serialization;
-using Aspose.Cells.Rendering;
-using Aspose.Cells;
-using System.Drawing.Imaging;
 
 namespace FileWatcher
 {
@@ -19,7 +18,6 @@ namespace FileWatcher
 
         string usercode;
         string sourcecode;
-        DataTable Dbfind;
 
         public SOP(string iUserCode, string iSource)
         {
@@ -31,72 +29,72 @@ namespace FileWatcher
         private void Form3_Load(object sender, EventArgs e)
         {
             CheckForIllegalCrossThreadCalls = false;
-
-            ps_prodcode.TableName = "productsop";
-            ps_prodcode.SelectField = "ps_prodcode # SOP编号";
-            ps_prodcode.FormName = Name;
-            ps_prodcode.DBTitle = "SOP查询";
-            ps_prodcode.SetValueField = new string[] { "ps_prodcode" };
-            ps_prodcode.Condition = "";
-            ps_prodcode.DbChange += nr_rule_DBChange;
-
-            li_code.TableName = "line";
-            li_code.SelectField = "li_code # 线别编号,li_name # 线别名称";
-            li_code.FormName = Name;
-            li_code.DBTitle = "线别查询";
-            li_code.SetValueField = new string[] { "li_code" };
-            li_code.Condition = "";
-            li_code.DbChange += nr_rule_DBChange;
-            SystemInf.dh = dh;
-        }
-
-        private void nr_rule_DBChange(object sender, EventArgs e)
-        {
-            Dbfind = ps_prodcode.ReturnData;
-            BaseUtil.SetFormValue(this.Controls, Dbfind);
         }
 
         void uploadfile()
         {
-            if (FilePath.Text == "")
-            {
-                MessageBox.Show("文件不能为空!");
-                return;
-            }
-            ps_prodcode.Text = FilePath.Text.Substring(FilePath.Text.LastIndexOf(@"\") + 1).Replace(".xls", "").Replace(".xlsx", "");
+            pr_code.Text = FilePath.Text.Substring(FilePath.Text.LastIndexOf(@"\") + 1).Replace(".xls", "").Replace(".xlsx", "");
             pr_code_Leave(new object(), new EventArgs());
-            DataTable dt = (DataTable)dh.ExecuteSql("select * from productsop where ps_prodcode='" + ps_prodcode.Text + "' ", "select");
+            DataTable dt = (DataTable)dh.ExecuteSql("select * from productsop where instr('" + pr_code.Text + "',ps_prodcode)>0 ", "select");
             if (dt.Rows.Count == 0)
             {
-                string code = LogicHandler.GetPiInoutCode("ProductSOP", "1");
-                dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman,ps_status,ps_statuscode)values(productsop_seq.nextval,'" + code + "','" + ps_prodcode.Text + "',sysdate,'" + usercode + "','在录入','ENTERING')", "insert");
+                DataTable dt1 = (DataTable)dh.ExecuteSql("select pr_code from product where instr('" + pr_code.Text + "',pr_code)>0", "select");
+                if (dt1.Rows.Count > 0)
+                {
+                    string code = LogicHandler.GetPiInoutCode("ProductSOP", "1");
+                    pr_code.Text = dt1.Rows[0]["pr_code"].ToString();
+                    dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman)values(productsop_seq.nextval,'" + code + "','" + pr_code.Text + "',sysdate,'" + usercode + "')", "insert");
+                }
+                else
+                {
+                    MessageBox.Show("产品编号" + pr_code.Text + "不存在");
+                    return;
+                }
             }
             else
             {
-                string ps_id = dt.Rows[0]["ps_id"].ToString();
-                dh.ExecuteSql("delete from ProductSOPdetail where psd_psid='" + ps_id + "'", "delete");
-                ps_prodcode.Text = dt.Rows[0]["ps_prodcode"].ToString();
+                pr_code.Text = dt.Rows[0]["ps_prodcode"].ToString();
             }
-
-            Workbook workbook = new Workbook(FilePath.Text);
+            Workbook workbook = new Workbook();
+            workbook.LoadFromFile(FilePath.Text);
+            workbook.ConverterSetting.JPEGQuality = 100;
+            workbook.ConverterSetting.XDpi = 600;
+            workbook.ConverterSetting.YDpi = 600;
             List<Worksheet> list = new List<Worksheet>();
             List<string> filename = new List<string>();
-            dh.ExecuteSql("update ProductSOP set ps_attachsop='' where ps_prodcode='" + ps_prodcode.Text + "'", "update");
+            dh.ExecuteSql("update ProductSOP set ps_attachsop='' where ps_prodcode='" + pr_code.Text + "'", "update");
             OperatResult.AppendText("一共Sheet: " + workbook.Worksheets.Count + "\n");
             try
             {
                 for (int i = 0; i < workbook.Worksheets.Count; i++)
                 {
-                    if (workbook.Worksheets[i].Name != "物料清单") {
-                        OperatResult.AppendText("正在解析Sheet" + workbook.Worksheets[i].Name + "\n");
-                        Worksheet she = workbook.Worksheets[i];
-                        if (JPG.Checked)
+                    for (int k = 0; k < workbook.Worksheets[i].TextBoxes.Count; k++)
+                    {
+                        if (workbook.Worksheets[i].TextBoxes[k].RichText.Text.Length > 1)
                         {
-                            var myThread = new Thread(() => SaveFileToJPG(she));
-                            myThread.Start();
-                            filename.Add(she.Name + ".jpg");
+                            //OperatResult.AppendText(workbook.Worksheets[i].TextBoxes[k].ID + " " + workbook.Worksheets[i].TextBoxes[k].Name + " " + workbook.Worksheets[i].TextBoxes[k].RichText.GetFont(0).FontName + " " + workbook.Worksheets[i].TextBoxes[k].RichText.GetFont(0).Size);
+                            workbook.Worksheets[i].TextBoxes[k].RichText.Text = workbook.Worksheets[i].TextBoxes[k].RichText.Text;
+                            workbook.Worksheets[i].TextBoxes[k].Width = workbook.Worksheets[i].TextBoxes[k].Width * 2;
+                            workbook.Worksheets[i].TextBoxes[k].Height = workbook.Worksheets[i].TextBoxes[k].Height * 2;
+                            workbook.Worksheets[i].TextBoxes[k].HAlignment = CommentHAlignType.Center;
                         }
                     }
+                    Workbook bw = new Workbook();
+                    Worksheet she = bw.CreateEmptySheet();
+                    she.Name = workbook.Worksheets[i].Name;
+                    she.CopyFrom(workbook.Worksheets[i]);
+                    if (JPG.Checked)
+                    {
+                        var myThread = new Thread(() => SaveFileToJPG(she));
+                        myThread.Start();
+                        filename.Add(she.Name + ".jpg");
+                    }
+                    else
+                    {
+                        var myThread = new Thread(() => SaveFileToPDF(she));
+                        myThread.Start();
+                        filename.Add(she.Name + ".pdf");
+                    }
                 }
             }
             catch (Exception ex)
@@ -105,74 +103,60 @@ namespace FileWatcher
             }
         }
 
+        private void SaveFileToPDF(Worksheet sheet)
+        {
+            if (!Directory.Exists(Application.StartupPath + @"\" + pr_code.Text))
+            {
+                Directory.CreateDirectory(Application.StartupPath + @"\" + pr_code.Text);
+            }
+            sheet.SaveToPdf(Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".pdf");
+            OperatResult.AppendText("解析PDF【" + sheet.Name + ".pdf】" + "\n");
+            Dictionary<string, object> dic = new Dictionary<string, object>();
+            dic.Add("em_name", "管理员");
+            dic.Add("em_code", "ADMIN");
+            dic.Add("caller", "ProductSOP");
+            OperatResult.AppendText("上传文件【" + sheet.Name + ".pdf" + "】\n");
+            string fp_id = UploadFilesToRemoteUrl("http://192.168.101.253:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".pdf", dic);
+            if (fp_id != "")
+            {
+                dh.ExecuteSql("update ProductSOP set ps_attachsop=ps_attachsop||" + fp_id + "||';' where ps_prodcode='" + pr_code.Text + "'", "update");
+            }
+        }
+
         private void SaveFileToJPG(Worksheet sheet)
         {
             try
             {
-                DataHelper dh = new DataHelper();
-                //OperatResult.AppendText("解析图片【" + sheet.Name + ".jpg】添加水印" + "\n");
-                if (!Directory.Exists(Application.StartupPath + @"\" + ps_prodcode.Text))
+                if (!Directory.Exists(Application.StartupPath + @"\" + pr_code.Text))
                 {
-                    Directory.CreateDirectory(Application.StartupPath + @"\" + ps_prodcode.Text);
+                    Directory.CreateDirectory(Application.StartupPath + @"\" + pr_code.Text);
                 }
-                string sheetname = sheet.Name;
-                sheetname = sheetname.Replace("01", "1");
-                sheetname = sheetname.Replace("02", "2");
-                sheetname = sheetname.Replace("03", "3");
-                sheetname = sheetname.Replace("04", "4");
-                sheetname = sheetname.Replace("05", "5");
-                sheetname = sheetname.Replace("06", "6");
-                sheetname = sheetname.Replace("07", "7");
-                sheetname = sheetname.Replace("08", "8");
-                sheetname = sheetname.Replace("09", "9");
-                //if (sheetname.Contains("-"))
-                //{
-                //    sheetname = sheetname.Split('-')[0];
-                //}
-                int width = 0;
-                int height = 0;
-                //Console.WriteLine(sheet.Name);
-                //for (int i = 0; i < sheet.Cells.Columns.Count; i++)
-                //{
-                //    width +=(int) sheet.Cells.Columns[i].Width;
-                //}
-                //for (int i = 0; i < sheet.Cells.Rows.Count; i++)
-                //{
-                //    height += (int)sheet.Cells.Rows[i].Height;
-                //}
-                //Console.WriteLine("width:"+width);
-                //Console.WriteLine("height:"+height);
-                //sheet.Pictures.Add(0, 18, @"图片\电子受控章.png");
-                //sheet.Pictures.Add(0, 15, @"图片\签名.png");
-                //sheet.PageSetup.LeftMargin = 0;
-                //sheet.PageSetup.RightMargin = 0;
-                //sheet.PageSetup.BottomMargin = 0;
-                //sheet.PageSetup.TopMargin = 0;
-                ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
-                imgOptions.ImageFormat = ImageFormat.Png;
-                imgOptions.OnePagePerSheet = true;
-                imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
-                imgOptions.SetDesiredSize(1565, 1043);
-                SheetRender sr = new SheetRender((Aspose.Cells.Worksheet)sheet, imgOptions);
-                sr.ToImage(0, Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + sheetname + ".jpg");
-                //// 创建一个图片
-                OperatResult.AppendText("解析图片【" + sheetname + ".jpg】" + "\n");
+                ExcelPicture picture = sheet.Pictures.Add(@"图片\电子受控章.png");
+                picture.Width = 113;
+                picture.Height = 38;
+                picture.LeftColumn = 20;
+                picture.TopRowOffset = 20;
+                ExcelPicture picture1 = sheet.Pictures.Add(@"图片\签名.png");
+                picture1.Width = 100;
+                picture1.Height = 38;
+                picture1.LeftColumn = 15;
+                picture1.TopRowOffset = 600;
+                sheet.SaveToImage(Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".jpg");
+                OperatResult.AppendText("解析图片【" + sheet.Name + ".jpg】" + "\n");
                 Dictionary<string, object> dic = new Dictionary<string, object>();
                 dic.Add("em_name", "管理员");
                 dic.Add("em_code", "ADMIN");
                 dic.Add("caller", "ProductSOP");
-                OperatResult.AppendText("上传文件【" + sheetname + ".jpg" + "】\n");
-                string fp_id = UploadFilesToRemoteUrl("http://192.168.0.85:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + sheetname + ".jpg", dic);
-                string ps_id = dh.getFieldDataByCondition("ProductSOP", "ps_id", "ps_prodcode='" + ps_prodcode.Text + "'").ToString();
-                dh.ExecuteSql("insert into ProductSOPdetail(psd_id,psd_psid,psd_attach) select ProductSOPdetail_seq.nextval,ps_id,'" + sheetname + ".jpg" + ";" + fp_id + "' from ProductSOP where ps_prodcode='" + ps_prodcode.Text + "'", "insert");
-                //if (fp_id != "")
-                //{
-                //    dh.ExecuteSql("update ProductSOP set ps_attachsop=ps_attachsop||" + fp_id + "||';' where ps_prodcode='" + pr_code.Text + "'", "update");
-                //}
+                OperatResult.AppendText("上传文件【" + sheet.Name + ".jpg" + "】\n");
+                string fp_id = UploadFilesToRemoteUrl("http://192.168.101.253:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".jpg", dic);
+                if (fp_id != "")
+                {
+                    dh.ExecuteSql("update ProductSOP set ps_attachsop=ps_attachsop||" + fp_id + "||';' where ps_prodcode='" + pr_code.Text + "'", "update");
+                }
             }
             catch (Exception ex)
             {
-                OperatResult.AppendText(ex.Message + ex.StackTrace);
+                Console.WriteLine(ex.Message);
             }
         }
 
@@ -266,7 +250,7 @@ namespace FileWatcher
             }
             catch (Exception e)
             {
-                LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "上传SOP", "上传失败", ps_prodcode.Text, "");
+                LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "上传SOP", "上传失败", pr_code.Text, "");
                 Console.WriteLine(e.Message + e.StackTrace);
             }
             return "";
@@ -290,11 +274,11 @@ namespace FileWatcher
             stw.ShowDialog();
             if (JPG.Checked)
             {
-                LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "上传SOP【图片格式】", "上传成功", ps_prodcode.Text, "");
+                LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "上传SOP【图片格式】", "上传成功", pr_code.Text, "");
             }
             else
             {
-                LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "上传SOP【PDF格式】", "上传成功", ps_prodcode.Text, "");
+                LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "上传SOP【PDF格式】", "上传成功", pr_code.Text, "");
             }
         }
 
@@ -304,59 +288,70 @@ namespace FileWatcher
             OperatResult.ScrollToCaret();
         }
 
-
+        TcpServer tcpserver = new TcpServer();
 
         private void SendSop_Click(object sender, EventArgs e)
         {
             try
             {
-                if (li_code.Text == "" || ps_prodcode.Text == "")
+                IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
+                string IPAddress = "";
+                for (int i = 0; i < IpEntry.AddressList.Length; i++)
                 {
-                    MessageBox.Show("线别和SOP文档不能为空");
-                    return;
+                    if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
+                    {
+                        IPAddress = IpEntry.AddressList[i].ToString();
+                    }
                 }
-                if (SendDGV.Rows.Count > 0)
+                dh.ExecuteSql("update SOPSOURCE set SS_BRDIP='" + IPAddress + "'", "update");
+                DataTable dt = (DataTable)dh.ExecuteSql("select * from productsop where ps_prodcode='" + pr_code.Text + "'", "select");
+                if (dt.Rows.Count > 0)
                 {
+                    tcpserver.Start();
+                    Thread.Sleep(5000);
                     List<Dictionary<string, string>> listr = new List<Dictionary<string, string>>();
+                    string PS_ATTACHSOP = dt.Rows[0]["PS_ATTACHSOP"].ToString();
+                    PS_ATTACHSOP = PS_ATTACHSOP.Substring(0, PS_ATTACHSOP.Length - 1).Replace(";", ",");
+                    dt = (DataTable)dh.ExecuteSql("select fp_path, fp_name from filepath where fp_id in (" + PS_ATTACHSOP + ") and nvl(fp_path, ' ') <> ' '", "select");
                     JavaScriptSerializer jss = new JavaScriptSerializer();
                     Dictionary<string, object> map1 = new Dictionary<string, object>();
                     Dictionary<string, object> map = new Dictionary<string, object>();
                     string path;
                     string pathroot = dh.GetConfig("filePathUrl", "sys").ToString();
-                    for (int i = 0; i < SendDGV.Rows.Count; i++)
+                    for (int i = 0; i < dt.Rows.Count; i++)
                     {
-                        if (SendDGV.Rows[i].Cells["CheckColumn"].FormattedValue.ToString().ToUpper() == "TRUE")
-                        {
-                            Dictionary<string, string> dic1 = new Dictionary<string, string>();
-                            path = SendDGV.Rows[i].Cells["fp_path"].Value.ToString();
-                            path = encryptBASE64(path.Replace("/app/uas/webapps/postattach", pathroot)).Replace("\\s*|\r|\n|\t", "");
-                            dic1.Add("path", path);
-                            dic1.Add("filename", SendDGV.Rows[i].Cells["fp_name"].Value.ToString().Replace(" ", "").Replace("(", "").Replace(")", ""));
-                            dic1.Add("ps_prodcode", ps_prodcode.Text);
-                            listr.Add(dic1);
-                            dh.ExecuteSql("insert into soprelease(SR_ID, SR_LINECODE, SR_PATH, SR_STATUS, SR_MACHINETYPE, SR_FILENAME,sr_ifkeyset)" +
-                          "values(soprelease_seq.nextval,'" + li_code.Text + "','" + path + "',0,'" + ps_prodcode.Text + "','" + SendDGV.Rows[i].Cells["fp_name"].Value.ToString().Replace(" ", "").Replace("(", "").Replace(")", "") + "','" + SendDGV.Rows[i].Cells["psd_iskey"].Value + "') ", "insert");
-                        }
+                        Dictionary<string, string> dic1 = new Dictionary<string, string>();
+                        path = dt.Rows[i]["fp_path"].ToString();
+                        path = encryptBASE64(path.Replace("/app/uas/webapps/postattach", pathroot)).Replace("\\s*|\r|\n|\t", "");
+                        dic1.Add("path", path);
+                        dic1.Add("filename", dt.Rows[i]["fp_name"].ToString().Replace(" ", "").Replace("(", "").Replace(")", ""));
+                        dic1.Add("ps_prodcode", pr_code.Text);
+                        listr.Add(dic1);
                     }
-                    LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "广播SOP", "广播成功", ps_prodcode.Text, "");
-                    MessageBox.Show("文档[" + ps_prodcode.Text + "]下放成功");
+                    map1.Add("ps_code", "");
+                    map1.Add("url", listr);
+                    map.Add("success", true);
+                    map.Add("data", map1);
+                    tcpserver.Send(jss.Serialize(map));
+                    tcpserver.Stop();
+                    LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "广播SOP", "广播成功", pr_code.Text, "");
+                    MessageBox.Show("产品编号" + pr_code.Text + "广播成功");
                 }
                 else
                 {
-                    MessageBox.Show("产品编号" + ps_prodcode.Text + "未维护SOP文档");
-                    LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "广播SOP", "广播失败,未维护SOP文档", ps_prodcode.Text, "");
+                    MessageBox.Show("产品编号" + pr_code.Text + "未维护SOP文档");
+                    LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "广播SOP", "广播失败,未维护SOP文档", pr_code.Text, "");
                 }
             }
             catch (Exception ex)
             {
-                LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "广播SOP", "广播失败", ps_prodcode.Text, "");
+                LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "广播SOP", "广播失败", pr_code.Text, "");
                 Console.WriteLine(ex.Message + ex.StackTrace);
             }
         }
 
         public string encryptBASE64(string key)
         {
-            Console.WriteLine(key);
             byte[] bytes = Encoding.Default.GetBytes(key);
             return Convert.ToBase64String(bytes);
         }
@@ -386,49 +381,28 @@ namespace FileWatcher
 
         private void LoadPrCode()
         {
-            DataTable dt = (DataTable)dh.ExecuteSql("select * from productsop where ps_prodcode='" + ps_prodcode.Text + "'", "select");
+            DataTable dt = (DataTable)dh.ExecuteSql("select pr_code,pr_spec,pr_detail from product where instr('" + pr_code.Text + "',pr_code)>0", "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");
-                if (dt.Rows.Count > 0)
-                {
-                    SendDGV.DataSource = dt;
-                }
-            }
-        }
-
-        private void pr_code_Leave(object sender, EventArgs e)
-        {
-            //LoadPrCode();
-        }
-
-        bool AllChecked = false;
-        private void ChooseALL_Click(object sender, EventArgs e)
-        {
-            if (AllChecked)
-            {
-                foreach (DataGridViewRow dr in SendDGV.Rows)
-                    dr.Cells[0].Value = false;
-                AllChecked = false;
+                pr_spec.Clear();
+                pr_spec.AppendText(dt.Rows[0]["pr_spec"].ToString());
+                pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
+                pr_code.Text = dt.Rows[0]["pr_code"].ToString();
             }
             else
             {
-                foreach (DataGridViewRow dr in SendDGV.Rows)
-                    dr.Cells[0].Value = true;
-                AllChecked = true;
+                MessageBox.Show("产品编号" + pr_code.Text + "不存在");
             }
         }
 
-        private void ps_prodcode_UserControlTextChanged(object sender, EventArgs e)
+        private void pr_code_Leave(object sender, EventArgs e)
         {
             LoadPrCode();
         }
 
-        private void GetSOP_Click(object sender, EventArgs e)
+        private void pr_spec_Click(object sender, EventArgs e)
         {
-            LoadPrCode();
+
         }
     }
 }