浏览代码

根据文件名称搜索

callm 2 年之前
父节点
当前提交
256d3ba5a3
共有 2 个文件被更改,包括 72 次插入38 次删除
  1. 23 22
      FileWatcher/SOP.Designer.cs
  2. 49 16
      FileWatcher/SOP.cs

+ 23 - 22
FileWatcher/SOP.Designer.cs

@@ -41,9 +41,9 @@
             this.label3 = new System.Windows.Forms.Label();
             this.label4 = new System.Windows.Forms.Label();
             this.pr_detail = new System.Windows.Forms.Label();
-            this.pr_spec = 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.SuspendLayout();
             // 
             // richTextBox1
@@ -62,7 +62,7 @@
             // 
             this.label1.AutoSize = true;
             this.label1.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label1.Location = new System.Drawing.Point(19, 430);
+            this.label1.Location = new System.Drawing.Point(19, 448);
             this.label1.Name = "label1";
             this.label1.Size = new System.Drawing.Size(146, 41);
             this.label1.TabIndex = 6;
@@ -70,14 +70,15 @@
             // 
             // FilePath
             // 
-            this.FilePath.Location = new System.Drawing.Point(218, 435);
+            this.FilePath.Enabled = false;
+            this.FilePath.Location = new System.Drawing.Point(218, 453);
             this.FilePath.Name = "FilePath";
             this.FilePath.Size = new System.Drawing.Size(582, 35);
             this.FilePath.TabIndex = 7;
             // 
             // ChooseFile
             // 
-            this.ChooseFile.Location = new System.Drawing.Point(218, 593);
+            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;
@@ -87,7 +88,7 @@
             // 
             // UploadSOP
             // 
-            this.UploadSOP.Location = new System.Drawing.Point(424, 593);
+            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;
@@ -101,7 +102,6 @@
             this.pr_code.Name = "pr_code";
             this.pr_code.Size = new System.Drawing.Size(582, 35);
             this.pr_code.TabIndex = 11;
-            this.pr_code.Text = "TEST";
             this.pr_code.KeyDown += new System.Windows.Forms.KeyEventHandler(this.pr_code_KeyDown);
             this.pr_code.Leave += new System.EventHandler(this.pr_code_Leave);
             // 
@@ -117,16 +117,16 @@
             // 
             // OperatResult
             // 
-            this.OperatResult.Location = new System.Drawing.Point(823, 80);
+            this.OperatResult.Location = new System.Drawing.Point(823, 32);
             this.OperatResult.Name = "OperatResult";
-            this.OperatResult.Size = new System.Drawing.Size(591, 758);
+            this.OperatResult.Size = new System.Drawing.Size(591, 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, 593);
+            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;
@@ -163,20 +163,11 @@
             this.pr_detail.Size = new System.Drawing.Size(0, 41);
             this.pr_detail.TabIndex = 16;
             // 
-            // pr_spec
-            // 
-            this.pr_spec.AutoSize = true;
-            this.pr_spec.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.pr_spec.Location = new System.Drawing.Point(211, 333);
-            this.pr_spec.Name = "pr_spec";
-            this.pr_spec.Size = new System.Drawing.Size(0, 41);
-            this.pr_spec.TabIndex = 17;
-            // 
             // JPG
             // 
             this.JPG.AutoSize = true;
             this.JPG.Checked = true;
-            this.JPG.Location = new System.Drawing.Point(251, 516);
+            this.JPG.Location = new System.Drawing.Point(251, 534);
             this.JPG.Name = "JPG";
             this.JPG.Size = new System.Drawing.Size(89, 28);
             this.JPG.TabIndex = 18;
@@ -187,7 +178,7 @@
             // PDF
             // 
             this.PDF.AutoSize = true;
-            this.PDF.Location = new System.Drawing.Point(382, 516);
+            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;
@@ -195,14 +186,24 @@
             this.PDF.Text = "PDF";
             this.PDF.UseVisualStyleBackColor = true;
             // 
+            // pr_spec
+            // 
+            this.pr_spec.Enabled = false;
+            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 = "";
+            // 
             // SOP
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1442, 934);
+            this.Controls.Add(this.pr_spec);
             this.Controls.Add(this.PDF);
             this.Controls.Add(this.JPG);
-            this.Controls.Add(this.pr_spec);
             this.Controls.Add(this.pr_detail);
             this.Controls.Add(this.label4);
             this.Controls.Add(this.label3);
@@ -239,8 +240,8 @@
         private System.Windows.Forms.Label label3;
         private System.Windows.Forms.Label label4;
         private System.Windows.Forms.Label pr_detail;
-        private System.Windows.Forms.Label pr_spec;
         private System.Windows.Forms.RadioButton JPG;
         private System.Windows.Forms.RadioButton PDF;
+        private System.Windows.Forms.RichTextBox pr_spec;
     }
 }

+ 49 - 16
FileWatcher/SOP.cs

@@ -32,19 +32,32 @@ namespace FileWatcher
         private void Form3_Load(object sender, EventArgs e)
         {
             CheckForIllegalCrossThreadCalls = false;
-            IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
-            string IPAddress = "";
-            for (int i = 0; i < IpEntry.AddressList.Length; i++)
-            {
-                if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
-                {
-                    IPAddress = IpEntry.AddressList[i].ToString();
-                }
-            }
         }
 
         void uploadfile()
         {
+            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 instr('" + pr_code.Text + "',ps_prodcode)>0 ", "select");
+            if (dt.Rows.Count == 0)
+            {
+                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
+            {
+                pr_code.Text = dt.Rows[0]["ps_prodcode"].ToString();
+            }
             Workbook workbook = new Workbook();
             workbook.LoadFromFile(FilePath.Text);
             workbook.ConverterSetting.JPEGQuality = 100;
@@ -87,8 +100,11 @@ namespace FileWatcher
             for (int i = 0; i < filename.ToArray().Length; i++)
             {
                 OperatResult.AppendText("上传文件【" + filename.ToArray()[i] + "】\n");
-                string fp_id = UploadFilesToRemoteUrl("http://10.1.81.208:11773/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + pr_code.Text + @"\" + filename.ToArray()[i], dic);
-                dh.ExecuteSql("update ProductSOP set ps_attachsop=ps_attachsop||" + fp_id + "||';' where ps_prodcode='" + pr_code.Text + "'", "update");
+                string fp_id = UploadFilesToRemoteUrl("http://192.168.101.253:11773/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + pr_code.Text + @"\" + filename.ToArray()[i], dic);
+                if (fp_id != "")
+                {
+                    dh.ExecuteSql("update ProductSOP set ps_attachsop=ps_attachsop||" + fp_id + "||';' where ps_prodcode='" + pr_code.Text + "'", "update");
+                }
             }
         }
 
@@ -227,7 +243,6 @@ namespace FileWatcher
 
         private void UploadSOP_Click(object sender, EventArgs e)
         {
-
             Thread thread = new Thread(uploadfile);
             SetLoadingWindow stw = new SetLoadingWindow(thread, "上传文件");
             stw.StartPosition = FormStartPosition.CenterScreen;
@@ -254,6 +269,16 @@ namespace FileWatcher
         {
             try
             {
+                IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
+                string IPAddress = "";
+                for (int i = 0; i < IpEntry.AddressList.Length; i++)
+                {
+                    if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
+                    {
+                        IPAddress = IpEntry.AddressList[i].ToString();
+                    }
+                }
+                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)
                 {
@@ -285,10 +310,12 @@ namespace FileWatcher
                     tcpserver.Send(jss.Serialize(map));
                     tcpserver.Stop();
                     LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "广播SOP", "广播成功", pr_code.Text, "");
+                    MessageBox.Show("产品编号" + pr_code.Text + "广播成功");
                 }
                 else
                 {
-                    MessageBox.Show("产品编号" + pr_code.Text + "不存在");
+                    MessageBox.Show("产品编号" + pr_code.Text + "未维护SOP文档");
+                    LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "广播SOP", "广播失败,未维护SOP文档", pr_code.Text, "");
                 }
             }
             catch (Exception ex)
@@ -327,14 +354,15 @@ namespace FileWatcher
             }
         }
 
-
         private void LoadPrCode()
         {
-            DataTable dt = (DataTable)dh.ExecuteSql("select pr_code,pr_spec,pr_detail from product where pr_code='" + pr_code.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)
             {
-                pr_spec.Text = dt.Rows[0]["pr_spec"].ToString();
+                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
             {
@@ -346,5 +374,10 @@ namespace FileWatcher
         {
             LoadPrCode();
         }
+
+        private void pr_spec_Click(object sender, EventArgs e)
+        {
+
+        }
     }
 }