callm 4 лет назад
Родитель
Сommit
d0e95922eb

+ 2 - 7
UAS_MES_PW/App.config

@@ -39,7 +39,7 @@
         <value />
       </setting>
       <setting name="FTPAddress" serializeAs="String">
-        <value>\\172.16.66.51\lable</value>
+        <value>ftp://10.8.0.82|vsftpd|vsftpd</value>
       </setting>
     </UAS_MES_NEW.Properties.Settings>
     <UAS_MES.Properties.Settings>
@@ -72,13 +72,8 @@
   <applicationSettings>
     <UAS_MES_NEW.Properties.Settings>
       <setting name="MES" serializeAs="String">
-        <value>Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.23)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</value>
+        <value>Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.5)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</value>
       </setting>
     </UAS_MES_NEW.Properties.Settings>
-    <UAS_MES.Properties.Settings>
-      <setting name="MES" serializeAs="String">
-        <value>Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=UAS_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=218.17.158.219)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</value>
-      </setting>
-    </UAS_MES.Properties.Settings>
   </applicationSettings>
 </configuration>

+ 51 - 23
UAS_MES_PW/DataOperate/DataHelper.cs

@@ -44,7 +44,7 @@ namespace UAS_MES_NEW.DataOperate
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
-            command.Dispose();
+            
             return dt;
         }
 
@@ -74,7 +74,7 @@ namespace UAS_MES_NEW.DataOperate
                 ad.Fill(dt);
             }
             ad.Dispose();
-            command.Dispose();
+            
             if (dt.Rows.Count > 0)
             {
                 return dt.Rows[0][0];
@@ -114,7 +114,7 @@ namespace UAS_MES_NEW.DataOperate
                 DataTable dt = new DataTable();
                 ad.Fill(dt);
                 ad.Dispose();
-                command.Dispose();
+                
                 return dt;
             }
             return "参数错误,请检查SQL语句";
@@ -133,7 +133,7 @@ namespace UAS_MES_NEW.DataOperate
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
-            command.Dispose();
+            
             return int.Parse(dt.Rows[0][0].ToString());
         }
 
@@ -152,7 +152,7 @@ namespace UAS_MES_NEW.DataOperate
 
             ad.Fill(dt);
             ad.Dispose();
-            command.Dispose();
+            
             return int.Parse(dt.Rows[0][0].ToString());
         }
 
@@ -182,7 +182,7 @@ namespace UAS_MES_NEW.DataOperate
                 ad.Fill(dt);
             }
             ad.Dispose();
-            command.Dispose();
+            
             return dt;
         }
 
@@ -235,7 +235,7 @@ namespace UAS_MES_NEW.DataOperate
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
-            command.Dispose();
+            
             dt.Columns.RemoveAt(0);
             foreach (DataColumn dc in dt.Columns)
             {
@@ -254,7 +254,7 @@ namespace UAS_MES_NEW.DataOperate
             string sql = "select ";
             sql += AddField(Fields);
             sql += " from " + TableName + " where " + Condition;
-            
+
             command = new OracleCommand(sql, connection);
             Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
@@ -272,7 +272,7 @@ namespace UAS_MES_NEW.DataOperate
                 ad.Fill(dt);
             }
             ad.Dispose();
-            command.Dispose();
+            
             return dt;
         }
 
@@ -303,7 +303,7 @@ namespace UAS_MES_NEW.DataOperate
                 ad.Fill(dt);
             }
             ad.Dispose();
-            command.Dispose();
+            
             return dt;
         }
 
@@ -425,7 +425,7 @@ namespace UAS_MES_NEW.DataOperate
             ad.UpdateCommand = command;
             ad.Update(DataTable);
             ad.Dispose();
-            command.Dispose();
+            
         }
 
         /// <summary>
@@ -495,7 +495,7 @@ namespace UAS_MES_NEW.DataOperate
                 ad.Fill(dt);
             }
             ad.Dispose();
-            command.Dispose();
+            
             Console.WriteLine(dt.Rows[0][0].ToString());
             Console.WriteLine(int.Parse(dt.Rows[0][0].ToString()) > 0);
             return int.Parse(dt.Rows[0][0].ToString()) > 0;
@@ -595,7 +595,7 @@ namespace UAS_MES_NEW.DataOperate
                     }
                     break;
             }
-            command.Dispose();
+            
             return result;
         }
 
@@ -608,7 +608,7 @@ namespace UAS_MES_NEW.DataOperate
             SQL = SQL.Replace("?", ":Param");
             command = new OracleCommand(SQL, connection);
             command.ExecuteNonQuery();
-            command.Dispose();
+            
         }
 
         public int GetDistinctRowCount(string TableName, string Field)
@@ -632,7 +632,7 @@ namespace UAS_MES_NEW.DataOperate
                 ad.Fill(dt);
             }
             ad.Dispose();
-            command.Dispose();
+            
             return int.Parse(dt.Rows[0][0].ToString());
         }
 
@@ -672,7 +672,7 @@ namespace UAS_MES_NEW.DataOperate
                 command.Connection.Open();
                 command.ExecuteNonQuery();
             }
-            command.Dispose();
+            
         }
 
         /// <summary>
@@ -830,7 +830,7 @@ namespace UAS_MES_NEW.DataOperate
                 command.Connection.Open();
                 command.ExecuteNonQuery();
             }
-            command.Dispose();
+            
         }
 
         public void BatchInsertDataTable(string sql, string[] param, params object[][] param1)
@@ -854,7 +854,7 @@ namespace UAS_MES_NEW.DataOperate
                 command.Connection.Open();
                 command.ExecuteNonQuery();
             }
-            command.Dispose();
+            
         }
 
         /// <summary>
@@ -935,7 +935,7 @@ namespace UAS_MES_NEW.DataOperate
                 command.Connection.Open();
                 command.ExecuteNonQuery();
             }
-            command.Dispose();
+            
             return sql;
         }
 
@@ -965,7 +965,35 @@ namespace UAS_MES_NEW.DataOperate
             }
             for (int i = 0; i < command.Parameters.Count; i++)
                 param[i] = command.Parameters[i].Value.ToString();
-            command.Dispose();
+            
+        }
+
+
+        public void CallProcedure(string ProcedureName, string[] ParamName, ref string[] param)
+        {
+            command = new OracleCommand(ProcedureName);
+            command.Connection = connection;
+            Reconnect(command);
+            command.CommandText = ProcedureName;
+            command.CommandType = CommandType.StoredProcedure;
+            for (int i = 0; i < param.Length; i++)
+            {
+                command.Parameters.Add(new OracleParameter(ParamName[i], OracleDbType.Varchar2, 200, param[i], ParameterDirection.InputOutput));
+                //command.Parameters.Add(new OracleParameter(ParamName[i], OracleType.VarChar, 200, ParameterDirection.InputOutput, "", DataRowVersion.Default, true, param[i]));
+            }
+            try
+            {
+                command.ExecuteNonQuery();
+            }
+            catch (Exception)
+            {
+                command.Connection = new OracleConnection(ConnectionStrings);
+                command.Connection.Open();
+                command.ExecuteNonQuery();
+            }
+            for (int i = 0; i < command.Parameters.Count; i++)
+                param[i] = command.Parameters[i].Value.ToString();
+            
         }
 
         /// <summary>
@@ -1006,7 +1034,7 @@ namespace UAS_MES_NEW.DataOperate
                 tx.Rollback();
                 throw new Exception(E.Message);
             }
-            command.Dispose();
+            
         }
 
         /// <summary>
@@ -1076,12 +1104,12 @@ namespace UAS_MES_NEW.DataOperate
             if (dt.Rows.Count > 0)
             {
                 ad.Dispose();
-                command.Dispose();
+                
                 return dt.Rows[0][0];
             }
             else
             {
-                command.Dispose();
+                
                 return "";
             }
         }

+ 6 - 4
UAS_MES_PW/Entity/SystemInf.cs

@@ -36,11 +36,11 @@ namespace UAS_MES_NEW.Entity
         /// <summary>
         /// 打开的串口的名称
         /// </summary>
-        public static List<string> OpenPort=new List<string>();
+        public static List<string> OpenPort = new List<string>();
         /// <summary>
         /// 检测音频是否可用
         /// </summary>
-        public static bool CheckAudioEnable=true;
+        public static bool CheckAudioEnable = true;
         /// <summary>
         /// 导航宽度
         /// </summary>
@@ -60,7 +60,7 @@ namespace UAS_MES_NEW.Entity
         /// <summary>
         /// 缓存数据的文件夹
         /// </summary>
-        public static string CacheFolder= Environment.GetEnvironmentVariable("windir").Substring(0, 1)+@":\UAS_MES\CacheFile\";
+        public static string CacheFolder = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\UAS_MES\CacheFile\";
         /// <summary>
         /// 日志文件的缓存路径
         /// </summary>
@@ -68,10 +68,12 @@ namespace UAS_MES_NEW.Entity
         /// <summary>
         /// 缓存的XML文件的路径和名称
         /// </summary>
-        public static string CacheFilePath= Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\UAS_MES\CacheFile\CacheInfo.xml";
+        public static string CacheFilePath = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\UAS_MES\CacheFile\CacheInfo.xml";
 
         public static bool UpperCollection = true;
 
         public static DataOperate.DataHelper dh;
+
+        public static Boolean OpenByNet = false;
     }
 }

+ 57 - 13
UAS_MES_PW/FunctionCode/Make/Make_ColorBoxWeigh.cs

@@ -13,6 +13,7 @@ using UAS_MES_NEW.PublicMethod;
 using System.Drawing;
 using LabelManager2;
 using UAS_MES_NEW.PublicForm;
+using System.Net.Sockets;
 
 namespace UAS_MES_NEW.Make
 {
@@ -74,7 +75,7 @@ namespace UAS_MES_NEW.Make
             ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_spec" };
             ma_code.Condition = "ma_statuscode='STARTED'";
             ma_code.DbChange += Ma_code_DbChange;
-            StartWeight.PerformClick();
+            //StartWeight.PerformClick();
             dh = SystemInf.dh;
             StepCount.StepCode = User.CurrentStepCode;
             StepCount.Source = User.UserSourceCode;
@@ -316,26 +317,69 @@ namespace UAS_MES_NEW.Make
             }
         }
 
+        TcpClient client;
+        NetworkStream ns;
+        Thread receiveThread;
+
         private void StartWeight_Click(object sender, EventArgs e)
         {
-            thread = new Thread(getSerialData);
-            try
+            if (!SystemInf.OpenByNet)
             {
-                serialPort1.PortName = ComList.Text;
-                serialPort1.BaudRate = int.Parse(BaudRate.Text);
-                serialPort1.Open();
-                GetData = true;
-                thread.Start();
+                thread = new Thread(getSerialData);
+                try
+                {
+                    serialPort1.PortName = ComList.Text;
+                    serialPort1.BaudRate = int.Parse(BaudRate.Text);
+                    serialPort1.Open();
+                    GetData = true;
+                    thread.Start();
+                }
+                catch (Exception mes)
+                {
+                    if (BaudRate.Text == "" || ComList.Text == "")
+                        OperateResult.AppendText(">>请先在电子秤调试界面维护波特率和串口\n", Color.Red);
+                    else
+                        OperateResult.AppendText(">>" + mes.Message + "\n", Color.Red);
+                }
             }
-            catch (Exception mes)
+            else
             {
-                if (BaudRate.Text == "" || ComList.Text == "")
-                    OperateResult.AppendText(">>请先在电子秤调试界面维护波特率和串口\n", Color.Red);
-                else
-                    OperateResult.AppendText(">>" + mes.Message + "\n", Color.Red);
+                client = new TcpClient();
+                client.Connect("192.168.56.1", 8001);
+                if (client != null)
+                {
+                    ns = client.GetStream();
+                    Control.CheckForIllegalCrossThreadCalls = false;
+                    //实例化并启动接受消息线程  
+                    receiveThread = new Thread(receive_message);
+                    receiveThread.Start();
+                }
             }
         }
 
+        private void receive_message()
+        {
+            while (IsOnline(client))
+            {
+                //try
+                //{
+                //创建接收数据的字节流  
+                byte[] getData = new byte[1024];
+                //从网络流中读取数据  
+                ns.Read(getData, 0, getData.Length);
+                //将字节数组转换成文本形式  
+                string getMsg = Encoding.Default.GetString(getData);
+                weight.Text = getMsg;
+            }
+        }
+
+        public bool IsOnline(TcpClient c)
+        {
+            return !((c.Client.Poll(1000, SelectMode.SelectRead) && (c.Client.Available == 0)) || !c.Client.Connected);
+        }
+
+
+
         private void StopWeight_Click(object sender, EventArgs e)
         {
             if (serialPort1.IsOpen)

+ 1 - 1
UAS_MES_PW/FunctionCode/Make/Make_CustomLabelPrint.cs

@@ -229,7 +229,7 @@ namespace UAS_MES_NEW.Make
             {
                 return;
             }
-            paramsInfo = (DataTable)dh.ExecuteSql("select lp_detno, lp_name, lp_valuetype,lp_sql from label left join labelparameter on lp_laid=la_id where la_code='" + listA.Rows[PrintLabel.SelectedIndex]["la_code"].ToString() + "'and LA_TEMPLATETYPE = '自定义' order by lp_detno asc", "select");
+            paramsInfo = (DataTable)dh.ExecuteSql("select lp_detno, lp_name, lp_valuetype,lp_sql from label left join labelparameter on lp_laid=la_id where la_code='" + listA.Rows[PrintLabel.SelectedIndex]["la_code"].ToString() + "'and LA_TEMPLATETYPE = '自定义' order by to_number(lp_detno) asc", "select");
             if (paramsInfo.Rows.Count > 0)
             {
                 //根据查询出来的参数,一次提示用户, “<<SN001 “, 

+ 2 - 2
UAS_MES_PW/FunctionCode/Make/Make_TestCollection.Designer.cs

@@ -934,10 +934,10 @@ namespace UAS_MES_NEW.Make
             this.Load += new System.EventHandler(this.TestCollection_Load);
             this.SizeChanged += new System.EventHandler(this.测试采集_SizeChanged);
             this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Make_TestCollection_KeyDown);
-            this.panel1.ResumeLayout(false);
+            this.panel1.ResumeLayout(true);
             this.panel1.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.BadInfSource)).EndInit();
-            this.ResumeLayout(false);
+            this.ResumeLayout(true);
             this.PerformLayout();
 
         }

+ 5 - 0
UAS_MES_PW/FunctionCode/Make/Make_TestCollection.cs

@@ -360,6 +360,11 @@ namespace UAS_MES_NEW.Make
                         //良品信息采集
                         if (LogicHandler.SetStepResult(ma_code.Text, User.UserSourceCode, ms_sncode.Text, "良品采集", "检测合格", User.UserCode, out ErrorMessage))
                         {
+                            if (WriteSoftWare.Checked)
+                            {
+                                string Message = BaseUtil.GetDataFromDevice("INSTALL", SoftWarePath.Text);
+                                OperateResult.AppendText(">>" + Message + "\n");
+                            }
                             //提示正确返回时传递的信息
                             if (ErrorMessage.Contains("AFTERSUCCESS"))
                                 OperateResult.AppendText(">>" + ErrorMessage + "\n");

+ 1 - 2
UAS_MES_PW/FunctionCode/Query/Query_SN.Designer.cs

@@ -294,7 +294,7 @@
             this.seriallength.Str1 = null;
             this.seriallength.Str2 = null;
             this.seriallength.TabIndex = 14;
-            this.seriallength.Text = "7";
+            this.seriallength.Text = "4";
             // 
             // pr_code
             // 
@@ -310,7 +310,6 @@
             this.pr_code.Str1 = null;
             this.pr_code.Str2 = null;
             this.pr_code.TabIndex = 12;
-            this.pr_code.Text = "95023";
             // 
             // color
             // 

+ 127 - 76
UAS_MES_PW/FunctionCode/Query/Query_SpecialReport.Designer.cs

@@ -31,12 +31,16 @@
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Query_SpecialReport));
             this.Export = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
+            this.Prefix = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.label5 = new System.Windows.Forms.Label();
+            this.Date = new System.Windows.Forms.DateTimePicker();
+            this.Num = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.label1 = new System.Windows.Forms.Label();
             this.label2 = new System.Windows.Forms.Label();
-            this.Num = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.BeginMac = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.label5 = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.Rn = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.label4 = new System.Windows.Forms.Label();
+            this.Printer = new UAS_MES_NEW.CustomControl.ComBoxWithFocus.PrinterCombox();
             this.SuspendLayout();
             // 
             // Export
@@ -46,110 +50,153 @@
             this.Export.DownImage = ((System.Drawing.Image)(resources.GetObject("Export.DownImage")));
             this.Export.Image = null;
             this.Export.IsShowBorder = true;
-            this.Export.Location = new System.Drawing.Point(305, 371);
-            this.Export.Margin = new System.Windows.Forms.Padding(6);
+            this.Export.Location = new System.Drawing.Point(362, 506);
+            this.Export.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
             this.Export.MoveImage = ((System.Drawing.Image)(resources.GetObject("Export.MoveImage")));
             this.Export.Name = "Export";
             this.Export.NormalImage = ((System.Drawing.Image)(resources.GetObject("Export.NormalImage")));
             this.Export.Power = null;
             this.Export.Size = new System.Drawing.Size(150, 56);
             this.Export.TabIndex = 0;
-            this.Export.Text = "导出";
+            this.Export.Text = "打印";
             this.Export.UseVisualStyleBackColor = false;
             this.Export.Click += new System.EventHandler(this.Export_Click);
             // 
-            // label1
+            // Prefix
+            // 
+            this.Prefix.AllPower = null;
+            this.Prefix.BackColor = System.Drawing.Color.White;
+            this.Prefix.ID = null;
+            this.Prefix.Location = new System.Drawing.Point(362, 85);
+            this.Prefix.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+            this.Prefix.Name = "Prefix";
+            this.Prefix.Power = null;
+            this.Prefix.Size = new System.Drawing.Size(278, 35);
+            this.Prefix.Str = null;
+            this.Prefix.Str1 = null;
+            this.Prefix.Str2 = null;
+            this.Prefix.TabIndex = 12;
+            this.Prefix.TextChanged += new System.EventHandler(this.inoutno_TextChanged);
             // 
-            this.label1.AutoSize = true;
-            this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label1.Location = new System.Drawing.Point(106, 160);
-            this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(82, 41);
-            this.label1.TabIndex = 1;
-            this.label1.Text = "数量";
+            // label5
             // 
-            // label2
+            this.label5.AutoSize = true;
+            this.label5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label5.Location = new System.Drawing.Point(217, 79);
+            this.label5.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(82, 41);
+            this.label5.TabIndex = 11;
+            this.label5.Text = "前缀";
             // 
-            this.label2.AutoSize = true;
-            this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label2.Location = new System.Drawing.Point(106, 240);
-            this.label2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(157, 41);
-            this.label2.TabIndex = 2;
-            this.label2.Text = "起始MAC";
+            // Date
+            // 
+            this.Date.Location = new System.Drawing.Point(362, 190);
+            this.Date.Name = "Date";
+            this.Date.Size = new System.Drawing.Size(278, 35);
+            this.Date.TabIndex = 13;
             // 
             // Num
             // 
             this.Num.AllPower = null;
             this.Num.BackColor = System.Drawing.Color.White;
             this.Num.ID = null;
-            this.Num.Location = new System.Drawing.Point(305, 161);
+            this.Num.Location = new System.Drawing.Point(362, 310);
             this.Num.Margin = new System.Windows.Forms.Padding(6);
             this.Num.Name = "Num";
             this.Num.Power = null;
-            this.Num.Size = new System.Drawing.Size(388, 35);
+            this.Num.Size = new System.Drawing.Size(278, 35);
             this.Num.Str = null;
             this.Num.Str1 = null;
             this.Num.Str2 = null;
-            this.Num.TabIndex = 5;
-            // 
-            // BeginMac
-            // 
-            this.BeginMac.AllPower = null;
-            this.BeginMac.BackColor = System.Drawing.Color.White;
-            this.BeginMac.ID = null;
-            this.BeginMac.Location = new System.Drawing.Point(305, 242);
-            this.BeginMac.Margin = new System.Windows.Forms.Padding(6);
-            this.BeginMac.Name = "BeginMac";
-            this.BeginMac.Power = null;
-            this.BeginMac.Size = new System.Drawing.Size(388, 35);
-            this.BeginMac.Str = null;
-            this.BeginMac.Str1 = null;
-            this.BeginMac.Str2 = null;
-            this.BeginMac.TabIndex = 6;
-            // 
-            // ma_code
-            // 
-            this.ma_code.AllPower = null;
-            this.ma_code.BackColor = System.Drawing.Color.White;
-            this.ma_code.ID = null;
-            this.ma_code.Location = new System.Drawing.Point(305, 88);
-            this.ma_code.Margin = new System.Windows.Forms.Padding(6);
-            this.ma_code.Name = "ma_code";
-            this.ma_code.Power = null;
-            this.ma_code.Size = new System.Drawing.Size(388, 35);
-            this.ma_code.Str = null;
-            this.ma_code.Str1 = null;
-            this.ma_code.Str2 = null;
-            this.ma_code.TabIndex = 12;
+            this.Num.TabIndex = 14;
             // 
-            // label5
+            // label1
             // 
-            this.label5.AutoSize = true;
-            this.label5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label5.Location = new System.Drawing.Point(106, 85);
-            this.label5.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.label5.Name = "label5";
-            this.label5.Size = new System.Drawing.Size(114, 41);
-            this.label5.TabIndex = 11;
-            this.label5.Text = "工单号";
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(217, 304);
+            this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(82, 41);
+            this.label1.TabIndex = 15;
+            this.label1.Text = "数量";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label2.Location = new System.Drawing.Point(217, 190);
+            this.label2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(82, 41);
+            this.label2.TabIndex = 16;
+            this.label2.Text = "日期";
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label3.Location = new System.Drawing.Point(217, 411);
+            this.label3.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(82, 41);
+            this.label3.TabIndex = 18;
+            this.label3.Text = "流水";
+            // 
+            // Rn
+            // 
+            this.Rn.AllPower = null;
+            this.Rn.BackColor = System.Drawing.Color.White;
+            this.Rn.ID = null;
+            this.Rn.Location = new System.Drawing.Point(362, 417);
+            this.Rn.Margin = new System.Windows.Forms.Padding(6);
+            this.Rn.Name = "Rn";
+            this.Rn.Power = null;
+            this.Rn.Size = new System.Drawing.Size(278, 35);
+            this.Rn.Str = null;
+            this.Rn.Str1 = null;
+            this.Rn.Str2 = null;
+            this.Rn.TabIndex = 17;
+            this.Rn.Text = "1";
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label4.Location = new System.Drawing.Point(801, 85);
+            this.label4.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(114, 41);
+            this.label4.TabIndex = 186;
+            this.label4.Text = "打印机";
+            // 
+            // Printer
+            // 
+            this.Printer.Location = new System.Drawing.Point(960, 85);
+            this.Printer.Margin = new System.Windows.Forms.Padding(8);
+            this.Printer.Name = "Printer";
+            this.Printer.Size = new System.Drawing.Size(291, 50);
+            this.Printer.TabIndex = 185;
             // 
             // Query_SpecialReport
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1494, 1075);
-            this.Controls.Add(this.ma_code);
-            this.Controls.Add(this.label5);
-            this.Controls.Add(this.BeginMac);
-            this.Controls.Add(this.Num);
+            this.Controls.Add(this.label4);
+            this.Controls.Add(this.Printer);
+            this.Controls.Add(this.label3);
+            this.Controls.Add(this.Rn);
             this.Controls.Add(this.label2);
             this.Controls.Add(this.label1);
+            this.Controls.Add(this.Num);
+            this.Controls.Add(this.Date);
+            this.Controls.Add(this.Prefix);
+            this.Controls.Add(this.label5);
             this.Controls.Add(this.Export);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-            this.Margin = new System.Windows.Forms.Padding(6);
+            this.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
             this.Name = "Query_SpecialReport";
             this.Tag = "Query!SpecialReport";
             this.Text = "Query_SpecialReport";
@@ -163,11 +210,15 @@
 
         private CustomControl.ButtonUtil.NormalButton Export;
         private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
+        private CustomControl.TextBoxWithIcon.EnterTextBox Prefix;
+        private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.DateTimePicker Date;
+        private CustomControl.TextBoxWithIcon.EnterTextBox Num;
         private System.Windows.Forms.Label label1;
         private System.Windows.Forms.Label label2;
-        private CustomControl.TextBoxWithIcon.EnterTextBox Num;
-        private CustomControl.TextBoxWithIcon.EnterTextBox BeginMac;
-        private CustomControl.TextBoxWithIcon.EnterTextBox ma_code;
-        private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.Label label3;
+        private CustomControl.TextBoxWithIcon.EnterTextBox Rn;
+        private System.Windows.Forms.Label label4;
+        private CustomControl.ComBoxWithFocus.PrinterCombox Printer;
     }
 }

+ 81 - 42
UAS_MES_PW/FunctionCode/Query/Query_SpecialReport.cs

@@ -1,13 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
+using LabelManager2;
+using System;
 using System.Linq;
-using System.Text;
+using System.Threading;
 using System.Windows.Forms;
 using UAS_MES_NEW.DataOperate;
 using UAS_MES_NEW.Entity;
+using UAS_MES_NEW.PublicForm;
 using UAS_MES_NEW.PublicMethod;
 
 namespace UAS_MES_NEW.Query
@@ -17,6 +15,12 @@ namespace UAS_MES_NEW.Query
 
         DataHelper dh = SystemInf.dh;
 
+        ApplicationClass lbl;
+
+        Document doc;
+
+        Thread InitPrint;
+
         public Query_SpecialReport()
         {
             InitializeComponent();
@@ -30,52 +34,87 @@ namespace UAS_MES_NEW.Query
         //选择导出Excel时是选择导出数据的还是模板
         private void ExcelExport(string DataOrTemplet)
         {
-            //Data表示导出数据
-            //Templet表示导出模板
-            if (ma_code.Text == "")
+            for (int i = int.Parse(Rn.Text); i < int.Parse(Num.Text); i = i + 8)
             {
-                MessageBox.Show("请输入工单号");
+                int temp = i;
+                for (int j = 0; j < doc.Variables.FormVariables.Count; j++)
+                {
+                    switch (doc.Variables.FormVariables.Item(j + 1).Name)
+                    {
+                        case "RN1":
+                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp).ToString()));
+                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
+                            break;
+                        case "RN2":
+                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 1).ToString()));
+                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
+                            break;
+                        case "RN3":
+                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 2).ToString()));
+                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
+                            break;
+                        case "RN4":
+                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 3).ToString()));
+                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
+                            break;
+                        case "RN5":
+                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 4).ToString()));
+                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
+                            break;
+                        case "RN6":
+                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 5).ToString()));
+                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
+                            break;
+                        case "RN7":
+                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 6).ToString()));
+                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
+                            break;
+                        case "RN8":
+                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 7).ToString()));
+                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                doc.Printer.SwitchTo(Printer.Text);
+                doc.PrintDocument(1);
             }
-            if (Num.Text == "")
+        }
+
+        private void Query_SpecialReport_Load(object sender, EventArgs e)
+        {
+            InitPrint = new Thread(InPrint);
+            SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
+            BaseUtil.SetFormCenter(stw);
+            stw.ShowDialog();
+            doc = lbl.Documents.Open(System.Windows.Forms.Application.StartupPath + @"\SN.lab");
+        }
+
+        private void InPrint()
+        {
+            try
             {
-                MessageBox.Show("请输入数量");
+                lbl = new ApplicationClass();
+                BaseUtil.WriteLbl();
             }
-            if (BeginMac.Text == "")
+            catch (Exception)
             {
-                MessageBox.Show("请输入起始地址号");
+                MessageBox.Show("未正确安装CodeSoft软件");
             }
-            folderBrowserDialog1.Description = "选择导出的路径";
-            DialogResult result = folderBrowserDialog1.ShowDialog();
-            if (result == DialogResult.OK)
+        }
+
+        private static string lpad(int length, string number)
+        {
+            while (number.Length < length)
             {
-                string FolderPath = folderBrowserDialog1.SelectedPath;
-                ExcelHandler eh = new ExcelHandler();
-                DataTable dt = new DataTable();
-                dt.Columns.Add("工单号");
-                dt.Columns.Add("MAC");
-                dt.Columns.Add("BT");
-                dt.Columns.Add("扩展栏位1");
-                dt.Columns.Add("扩展栏位2");
-                dt.Columns.Add("扩展栏位3");
-                dt.Columns.Add("备注");
-                string prefix = BeginMac.Text.Substring(0, 8);
-                string suffix = BeginMac.Text.Substring(8, 4);
-                int num = Int32.Parse(suffix, System.Globalization.NumberStyles.HexNumber);
-                for (int i = 0; i < int.Parse(Num.Text); i++)
-                {
-                    DataRow dr = dt.NewRow();
-                    dr["工单号"] = ma_code.Text;
-                    dr["MAC"] = prefix + num.ToString("X");
-                    num = num + 1;
-                    dr["BT"] = prefix + num.ToString("X");
-                    num = num + 1;
-                    dt.Rows.Add(dr);
-                }
-                eh.ExportExcel(dt, FolderPath);
+                number = "0" + number;
             }
+            number = number.Substring(number.Length - length, length);
+            return number;
         }
 
-        private void Query_SpecialReport_Load(object sender, EventArgs e)
+        private void inoutno_TextChanged(object sender, EventArgs e)
         {
 
         }

+ 2 - 0
UAS_MES_PW/Login.cs

@@ -50,6 +50,8 @@ namespace UAS_MES_NEW
             CheckForIllegalCrossThreadCalls = false;
             LoadMasterInf = new Thread(LoadMaster);
             LoadMasterInf.Start();
+
+            //SystemInf.OpenByNet = true;
             //显示上次用户登录的用户名,将输入框定位到密码
             UserName.Text = BaseUtil.GetCacheData("LastLoginUser").ToString();
             Source.Text = BaseUtil.GetCacheData("LastLoginResource").ToString();

+ 3 - 3
UAS_MES_PW/Properties/Settings.Designer.cs

@@ -109,7 +109,7 @@ namespace UAS_MES_NEW.Properties {
         
         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("\\\\172.16.66.51\\lable")]
+        [global::System.Configuration.DefaultSettingValueAttribute("ftp://10.8.0.82|vsftpd|vsftpd")]
         public string FTPAddress {
             get {
                 return ((string)(this["FTPAddress"]));
@@ -122,8 +122,8 @@ namespace UAS_MES_NEW.Properties {
         [global::System.Configuration.ApplicationScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
         [global::System.Configuration.DefaultSettingValueAttribute("Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false" +
-            ";Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.2" +
-            "3)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));")]
+            ";Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.5" +
+            ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));")]
         public string MES {
             get {
                 return ((string)(this["MES"]));

+ 2 - 2
UAS_MES_PW/Properties/Settings.settings

@@ -24,10 +24,10 @@
       <Value Profile="(Default)" />
     </Setting>
     <Setting Name="FTPAddress" Type="System.String" Scope="User">
-      <Value Profile="(Default)">\\172.16.66.51\lable</Value>
+      <Value Profile="(Default)">ftp://10.8.0.82|vsftpd|vsftpd</Value>
     </Setting>
     <Setting Name="MES" Type="System.String" Scope="Application">
-      <Value Profile="(Default)">Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.23)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</Value>
+      <Value Profile="(Default)">Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.5)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</Value>
     </Setting>
   </Settings>
 </SettingsFile>

+ 11 - 0
UAS_MES_PW/PublicMethod/BaseUtil.cs

@@ -28,6 +28,17 @@ namespace UAS_MES_NEW.PublicMethod
 {
     class BaseUtil
     {
+
+        /// <summary>
+        ///  检测TCP连接是否存在还是已经中断
+        /// </summary>
+        /// <param name="c"></param>
+        /// <returns></returns>
+        public static bool IsOnline(TcpClient c)
+        {
+            return !((c.Client.Poll(1000, SelectMode.SelectRead) && (c.Client.Available == 0)) || !c.Client.Connected);
+        }
+
         /// <summary>
         /// 通过DataTable的ColumnName和Caption来拼接一条语句
         /// </summary>

+ 1 - 1
UAS_MES_PW/PublicMethod/Print.cs

@@ -131,7 +131,7 @@ namespace UAS_MES_NEW.PublicMethod
             FileInfo PrintFile = new FileInfo(LabelName);
             //打开模板路径
             //查询模板对应的取值SQL和参数名称
-            dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id=lp_laid where la_id='" + LaID + "'", "select");
+            dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id=lp_laid where la_id='" + LaID + "' order by to_number(lp_detno)" , "select");
             StringBuilder sb = new StringBuilder();
             if (!PrintFile.Exists)
             {