Explorar o código

对所有的操作数据库方法添加重新连接的方式

章政 %!s(int64=8) %!d(string=hai) anos
pai
achega
bc917e7750

+ 18 - 3
UAS-MES/CustomControl/CustomCheckBox/LockCheckBox.cs

@@ -17,6 +17,21 @@ namespace UAS_MES.CustomControl.CustomCheckBox
         /// </summary>
         Control MaCtl;
 
+        bool LeaveEvent1;
+
+        public bool LeaveEvent
+        {
+            get
+            {
+                return LeaveEvent1;
+            }
+
+            set
+            {
+                LeaveEvent1 = value;
+            }
+        }
+
         public LockCheckBox()
         {
             InitializeComponent();
@@ -29,7 +44,6 @@ namespace UAS_MES.CustomControl.CustomCheckBox
 
         public void LockCheckBox_CheckedChanged(object sender, EventArgs e)
         {
-            Console.WriteLine(Checked);
             if (Checked)
             {
                 if (MaCtl.Text != "")
@@ -49,9 +63,10 @@ namespace UAS_MES.CustomControl.CustomCheckBox
                     BaseUtil.ShowError("工单号不能为空");
                 }
             }
-            else {
+            else if(!Checked&& !LeaveEvent1)
+            {
                 MaCtl.Enabled = true;
-                MaCtl.Focus();
+                //MaCtl.Focus();
             }
         }
     }

+ 4 - 14
UAS-MES/CustomControl/TextBoxWithIcon/MaCodeSearchTextBox.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Data;
 using System.Windows.Forms;
+using UAS_MES.CustomControl.CustomCheckBox;
 using UAS_MES.DataOperate;
 using UAS_MES.PublicMethod;
 
@@ -60,7 +61,7 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         /// <summary>
         /// 设置绑定的CheckBox
         /// </summary>
-        CheckBox LockCheckBox;
+        LockCheckBox LockCheckBox;
 
         DbFind db;
 
@@ -239,12 +240,10 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         private void TextBox_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode == Keys.Enter)
-            {
                 GetData();
-            }
         }
 
-        public void SetLockCheckBox(CheckBox ctl)
+        public void SetLockCheckBox(LockCheckBox ctl)
         {
             LockCheckBox = ctl;
         }
@@ -314,19 +313,10 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
             TextBox.BackColor = System.Drawing.Color.GreenYellow;
         }
 
-        /// <summary>
-        /// 重新刷新数据
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        public void RefreshDB(object sender, EventArgs e)
-        {
-            TextBox_Leave(sender, e);
-        }
-
         public void TextBox_Leave(object sender, EventArgs e)
         {
             TextBox.BackColor = System.Drawing.Color.White;
+            LockCheckBox.LeaveEvent = false;
             GetData();
         }
 

+ 11 - 1
UAS-MES/DataOperate/DataHelper.cs

@@ -121,6 +121,7 @@ namespace UAS_MES.DataOperate
             string sql = "select count(1) from " + TableName + " where " + Condition;
             Console.WriteLine(sql);
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
@@ -138,6 +139,7 @@ namespace UAS_MES.DataOperate
             DataTable dt = new DataTable();
             string sql = "select count(1) from " + TableName;
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             Console.WriteLine(sql);
             ad.Fill(dt);
@@ -211,6 +213,7 @@ namespace UAS_MES.DataOperate
             }
             Console.WriteLine(sql.ToString());
             command = new OracleCommand(sql.ToString(), connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
@@ -662,6 +665,7 @@ namespace UAS_MES.DataOperate
             string sql = "select distinct count('" + Field + "') from " + TableName;
             Console.WriteLine(sql);
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
@@ -692,6 +696,7 @@ namespace UAS_MES.DataOperate
             string sql = "delete from " + TableName + " where " + ID + " =:DeleteID";
             Console.WriteLine(sql);
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             command.ArrayBindCount = DeleteID.Length;
             command.Parameters.Add(new OracleParameter("DeleteID", OracleDbType.Long, DeleteID, ParameterDirection.Input));
             command.ExecuteNonQuery();
@@ -817,6 +822,7 @@ namespace UAS_MES.DataOperate
         public void BatchInsert(string sql, params object[][] names)
         {
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             command.ArrayBindCount = names[1].Length;
             Console.WriteLine(sql);
             //因为第一个数组保存的是参数的名称,所以循环从1而不是0开始
@@ -832,6 +838,7 @@ namespace UAS_MES.DataOperate
         public void BatchInsertDataTable(string sql, string[] param, params object[][] param1)
         {
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             command.ArrayBindCount = param1[0].Length;
             //因为第一个数组保存的是参数的名称,所以循环从1而不是0开始
             //将第一个数组的下标固定为0作为循环添加的参数的名称
@@ -855,6 +862,7 @@ namespace UAS_MES.DataOperate
             DataTable dt = new DataTable();
             string SQL = " select listagg(dld_field,',') within group (order by dld_id)  from datalistdetail where dld_caller='" + Caller + "'";
             command = new OracleCommand(SQL, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
@@ -929,6 +937,7 @@ namespace UAS_MES.DataOperate
             string sql = "update " + TableName + " set " + update + " where " + condition;
             Console.WriteLine(sql);
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             command.ExecuteNonQuery();
             command.Dispose();
             return sql;
@@ -943,7 +952,7 @@ namespace UAS_MES.DataOperate
         {
             command = new OracleCommand(ProcedureName);
             command.Connection = connection;
-            //Reconnect(command);
+            Reconnect(command);
             command.CommandText = ProcedureName;
             command.CommandType = CommandType.StoredProcedure;
             for (int i = 0; i < param.Length; i++)
@@ -1033,6 +1042,7 @@ namespace UAS_MES.DataOperate
         {
             DataTable dt = new DataTable();
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter();
             ad.SelectCommand = command;
             ad.Fill(dt);

+ 1 - 2
UAS-MES/FunctionCode/Make/Make_TestCollection.cs

@@ -191,10 +191,9 @@ namespace UAS_MES.Make
                         {
                             dt = (DataTable)dh.ExecuteSql("select ms_nextstepcode,ms_stepcode,ms_status,nvl(st_ifrepair,0) st_ifrepair from makeserial left join step on ms_stepcode=st_code where ms_id='" + oMSID + "'", "select");
                             string status = dt.Rows[0]["ms_status"].ToString();
-                            string nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
                             string stepcode = dt.Rows[0]["ms_stepcode"].ToString();
                             string ifrepair = dt.Rows[0]["st_ifrepair"].ToString();
-                            if (nextstepcode == User.CurrentStepCode && (status == "1" || status == "2") && ifrepair == "0")
+                            if (stepcode == User.CurrentStepCode && (status == "1" || status == "2") && ifrepair == "0")
                             {
                                 OperateResult.AppendText(">>" + ms_sncode.Text + " 序列号已执行过" + User.CurrentStepCode + "工序,采集结果为良品\n", Color.Red, ms_sncode);
                                 return;

+ 1 - 1
UAS-MES/UAS-MES.csproj

@@ -41,7 +41,7 @@
     <MinimumRequiredVersion>1.0.0.201</MinimumRequiredVersion>
     <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
     <WebPage>publish.htm</WebPage>
-    <ApplicationRevision>224</ApplicationRevision>
+    <ApplicationRevision>226</ApplicationRevision>
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
     <UseApplicationTrust>true</UseApplicationTrust>
     <CreateDesktopShortcut>true</CreateDesktopShortcut>