Prechádzať zdrojové kódy

添加计数器计数功能

callm 2 týždňov pred
rodič
commit
af051613f3

+ 19 - 49
UAS_MES_YTDZ/FunctionCode/Make/Make_SplitBoard.Designer.cs

@@ -37,7 +37,6 @@
             this.label3 = new System.Windows.Forms.Label();
             this.label2 = new System.Windows.Forms.Label();
             this.AutoStart = new System.Windows.Forms.CheckBox();
-            this.Type = new System.Windows.Forms.ComboBox();
             this.ATEFile = new System.IO.FileSystemWatcher();
             this.Timer = new System.Windows.Forms.Timer(this.components);
             this.MakeCode_lable = new System.Windows.Forms.Label();
@@ -46,10 +45,9 @@
             this.StopWatch = new System.Windows.Forms.Button();
             this.StartWatch = new System.Windows.Forms.Button();
             this.XmlFolder = new System.Windows.Forms.FolderBrowserDialog();
-            this.label1 = new System.Windows.Forms.Label();
             this.XmlWatcher = new System.IO.FileSystemWatcher();
-            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox();
             this.ComPort = new UAS_MES_NEW.CustomControl.ComBoxWithFocus.SerialPortCombox();
+            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
             ((System.ComponentModel.ISupportInitialize)(this.pr_pcbacount)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.ATEFile)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.XmlWatcher)).BeginInit();
@@ -57,7 +55,7 @@
             // 
             // pr_pcbacount
             // 
-            this.pr_pcbacount.Location = new System.Drawing.Point(480, 601);
+            this.pr_pcbacount.Location = new System.Drawing.Point(480, 528);
             this.pr_pcbacount.Name = "pr_pcbacount";
             this.pr_pcbacount.Size = new System.Drawing.Size(120, 35);
             this.pr_pcbacount.TabIndex = 48;
@@ -71,7 +69,7 @@
             // 
             this.label6.AutoSize = true;
             this.label6.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label6.Location = new System.Drawing.Point(310, 598);
+            this.label6.Location = new System.Drawing.Point(310, 525);
             this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label6.Name = "label6";
             this.label6.Size = new System.Drawing.Size(104, 38);
@@ -80,7 +78,7 @@
             // 
             // NowQTY
             // 
-            this.NowQTY.Location = new System.Drawing.Point(480, 681);
+            this.NowQTY.Location = new System.Drawing.Point(480, 608);
             this.NowQTY.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.NowQTY.Name = "NowQTY";
             this.NowQTY.Size = new System.Drawing.Size(146, 35);
@@ -90,7 +88,7 @@
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label4.Location = new System.Drawing.Point(310, 678);
+            this.label4.Location = new System.Drawing.Point(310, 605);
             this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(133, 38);
@@ -139,18 +137,6 @@
             this.AutoStart.Text = "开机自动启动";
             this.AutoStart.UseVisualStyleBackColor = true;
             // 
-            // Type
-            // 
-            this.Type.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-            this.Type.FormattingEnabled = true;
-            this.Type.Items.AddRange(new object[] {
-            "投入",
-            "产出"});
-            this.Type.Location = new System.Drawing.Point(480, 528);
-            this.Type.Name = "Type";
-            this.Type.Size = new System.Drawing.Size(436, 32);
-            this.Type.TabIndex = 38;
-            // 
             // ATEFile
             // 
             this.ATEFile.EnableRaisingEvents = true;
@@ -218,23 +204,20 @@
             this.StartWatch.UseVisualStyleBackColor = true;
             this.StartWatch.Click += new System.EventHandler(this.StartWatch_Click);
             // 
-            // label1
-            // 
-            this.label1.AutoSize = true;
-            this.label1.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label1.Location = new System.Drawing.Point(310, 522);
-            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(75, 38);
-            this.label1.TabIndex = 39;
-            this.label1.Text = "类型";
-            // 
             // XmlWatcher
             // 
             this.XmlWatcher.EnableRaisingEvents = true;
             this.XmlWatcher.Filter = "*.log";
             this.XmlWatcher.SynchronizingObject = this;
             // 
+            // ComPort
+            // 
+            this.ComPort.Location = new System.Drawing.Point(480, 376);
+            this.ComPort.Margin = new System.Windows.Forms.Padding(4);
+            this.ComPort.Name = "ComPort";
+            this.ComPort.Size = new System.Drawing.Size(192, 40);
+            this.ComPort.TabIndex = 69;
+            // 
             // ma_code
             // 
             this.ma_code.AllPower = null;
@@ -242,34 +225,25 @@
             this.ma_code.Condition = null;
             this.ma_code.DBTitle = null;
             this.ma_code.FormName = null;
-            this.ma_code.Location = new System.Drawing.Point(480, 453);
-            this.ma_code.Margin = new System.Windows.Forms.Padding(5);
+            this.ma_code.Location = new System.Drawing.Point(480, 451);
+            this.ma_code.Margin = new System.Windows.Forms.Padding(4);
             this.ma_code.Name = "ma_code";
             this.ma_code.Power = null;
             this.ma_code.ReturnData = null;
             this.ma_code.SelectField = null;
             this.ma_code.SetValueField = null;
-            this.ma_code.Size = new System.Drawing.Size(436, 43);
-            this.ma_code.TabIndex = 68;
+            this.ma_code.Size = new System.Drawing.Size(409, 40);
+            this.ma_code.TabIndex = 213;
             this.ma_code.TableName = null;
-            this.ma_code.Tag = "ma_code";
             this.ma_code.TextBoxEnable = true;
             // 
-            // ComPort
-            // 
-            this.ComPort.Location = new System.Drawing.Point(480, 376);
-            this.ComPort.Margin = new System.Windows.Forms.Padding(4);
-            this.ComPort.Name = "ComPort";
-            this.ComPort.Size = new System.Drawing.Size(192, 40);
-            this.ComPort.TabIndex = 69;
-            // 
             // Make_SplitBoard
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1994, 1163);
-            this.Controls.Add(this.ComPort);
             this.Controls.Add(this.ma_code);
+            this.Controls.Add(this.ComPort);
             this.Controls.Add(this.pr_pcbacount);
             this.Controls.Add(this.label6);
             this.Controls.Add(this.NowQTY);
@@ -278,13 +252,11 @@
             this.Controls.Add(this.label3);
             this.Controls.Add(this.label2);
             this.Controls.Add(this.AutoStart);
-            this.Controls.Add(this.Type);
             this.Controls.Add(this.MakeCode_lable);
             this.Controls.Add(this.Clean);
             this.Controls.Add(this.OperateResult);
             this.Controls.Add(this.StopWatch);
             this.Controls.Add(this.StartWatch);
-            this.Controls.Add(this.label1);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
             this.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
             this.Name = "Make_SplitBoard";
@@ -309,18 +281,16 @@
         private System.Windows.Forms.Label label3;
         private System.Windows.Forms.Label label2;
         private System.Windows.Forms.CheckBox AutoStart;
-        private System.Windows.Forms.ComboBox Type;
         private System.IO.FileSystemWatcher ATEFile;
         private System.Windows.Forms.Label MakeCode_lable;
         private System.Windows.Forms.Button Clean;
         private System.Windows.Forms.RichTextBox OperateResult;
         private System.Windows.Forms.Button StopWatch;
         private System.Windows.Forms.Button StartWatch;
-        private System.Windows.Forms.Label label1;
         private System.Windows.Forms.Timer Timer;
         private System.Windows.Forms.FolderBrowserDialog XmlFolder;
         private System.IO.FileSystemWatcher XmlWatcher;
-        private CustomControl.TextBoxWithIcon.MaCodeSearchTextBox ma_code;
         private CustomControl.ComBoxWithFocus.SerialPortCombox ComPort;
+        private CustomControl.TextBoxWithIcon.SearchTextBox ma_code;
     }
 }

+ 46 - 40
UAS_MES_YTDZ/FunctionCode/Make/Make_SplitBoard.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Data;
 using System.IO.Ports;
 using System.Windows.Forms;
 using UAS_MES_NEW.DataOperate;
@@ -14,6 +15,8 @@ namespace UAS_MES_NEW.Make
 
         SerialPort serialPort1 = new SerialPort();
 
+        DataTable Dbfind;
+
         public Make_SplitBoard()
         {
             InitializeComponent();
@@ -22,12 +25,31 @@ namespace UAS_MES_NEW.Make
         private void 分板作业_Load(object sender, EventArgs e)
         {
             dh = SystemInf.dh;
+
+            ma_code.TableName = "make";
+            ma_code.SelectField = "ma_code # 工单号";
+            ma_code.FormName = Name;
+            ma_code.DBTitle = "工单查询";
+            ma_code.SetValueField = new string[] { "ma_code" };
+            ma_code.Condition = "";
+            ma_code.DbChange += nr_rule_DBChange;
             serialPort1.DataReceived += SerialPort1_DataReceived;
+
+            try
+            {
+                ComPort.Text = BaseUtil.GetCacheData("ComPort").ToString();
+                BaudRate.Text = BaseUtil.GetCacheData("BaudRate").ToString();
+            }
+            catch (Exception ex) { MessageBox.Show(ex.Message); }
+        }
+
+        private void nr_rule_DBChange(object sender, EventArgs e)
+        {
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
         }
 
         private void StartWatch_Click(object sender, EventArgs e)
         {
-            BaseUtil.SetCacheData("Type", Type.Text);
             BaseUtil.SetCacheData("ComPort", ComPort.Text);
             BaseUtil.SetCacheData("BaudRate", BaudRate.Text);
             if (!dh.CheckExist("Make", "ma_code='" + ma_code.Text + "'"))
@@ -35,35 +57,29 @@ namespace UAS_MES_NEW.Make
                 OperateResult.AppendText("工单号不能为空\n");
                 return;
             }
-            if (Type.Text == "印刷机")
+
+            string ExitConfirm = MessageBox.Show(this, "确认计数器是否置为0?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+            if (ExitConfirm != "Yes")
+            {
+                return;
+            }
+            //设置按钮不可点击
+            StartWatch.Enabled = false;
+            ma_code.Enabled = false;
+            StopWatch.Enabled = true;
+            try
             {
+                serialPort1.PortName = ComPort.Text;
+                serialPort1.BaudRate = int.Parse(BaudRate.Text);
+                serialPort1.Open();
                 Timer.Start();
             }
-            else
+            catch (Exception mes)
             {
-                string ExitConfirm = MessageBox.Show(this, "确认计数器是否置为0?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
-                if (ExitConfirm != "Yes")
-                {
-                    return;
-                }
-                //设置按钮不可点击
-                StartWatch.Enabled = false;
-                ma_code.Enabled = false;
-                StopWatch.Enabled = true;
-                try
-                {
-                    serialPort1.PortName = ComPort.Text;
-                    serialPort1.BaudRate = int.Parse(BaudRate.Text);
-                    serialPort1.Open();
-                    Timer.Start();
-                }
-                catch (Exception mes)
-                {
-                    if (BaudRate.Text == "" || BaudRate.Text == "")
-                        OperateResult.AppendText(">>请先维护波特率和串口\n");
-                    else
-                        OperateResult.AppendText(">>" + mes.Message + "\n");
-                }
+                if (BaudRate.Text == "" || BaudRate.Text == "")
+                    OperateResult.AppendText(">>请先维护波特率和串口\n");
+                else
+                    OperateResult.AppendText(">>" + mes.Message + "\n");
             }
             OperateResult.AppendText("开始执行监控\n");
         }
@@ -84,20 +100,10 @@ namespace UAS_MES_NEW.Make
                     lastqty = 0;
                 }
                 NowQTY.Text = qty.ToString();
-                if (Type.Text == "投入")
-                {
-                    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_sourcecode,mhc_stepcode,mhc_pcbcount)" +
-                        "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + User.UserSourceCode + "','" + User.CurrentStepCode + "','" + pr_pcbacount.Value + "')", "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_sourcecode,mhc_stepcode,mhc_pcbcount)" +
-                             "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + User.UserSourceCode + "','" + User.CurrentStepCode + "','" + pr_pcbacount.Value + "')", "insert");
-                }
+                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_qty,mhc_sourcecode,mhc_inman,mhc_linecode,mhc_stepcode,mhc_pcbcount)" +
+                         "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + (qty - lastqty) + "','" + User.UserSourceCode + "','" + User.UserCode + "','" + User.UserLineCode + "','" + User.CurrentStepCode + "','" + pr_pcbacount.Value + "')", "insert");
                 lastqty = qty;
             }
         }