From 852cd93a3e65988a2354a0b96b79d5e2d05bf646 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期五, 14 四月 2023 09:23:25 +0800
Subject: [PATCH] 工序流转卡  工艺参数 应该 可编辑; 1.生产资源 有异常; 删除有问题,删除后出来 异常数据(  );    其他信息 里的  几个字段 输入 字符时 报错,应提示; 2.工序 :  9999的 转工序 , 有个 转工序 字段,是否没显示出来; 其他信息 里的  几个字段 输入 字符时 报错,应提示; 3.工作中心:  其他信息 里的  几个字段 输入 字符时 报错,应提示; 4.生产班组: 刷新出来 异常数据;    其他信息 里的  几个字段 输入 字符时 报错,应提示; 5.基础资料的  一些 复选框 标题不对; 6. ADMIN 的账号 工艺路线 的模块 无法进行 新增 编辑; 7.工艺路线查询;工序号,工序代码,工序,工艺参数,表体备注, 其他的放后面  子表 的 委外标记 放到最后面去; 并且 把  供应商代码和供应商 放出来(也放在最后几个); 8.部门有 很多异常数据;   选择的时候 出来了; 9.流转卡维护, 表头 很多没有用的列,单据号 日期 都没有显示;     转工序 是否要打印(跟客户确认); 10. 流转卡拆分时,一些 列的 排序;

---
 Pub_Class/CustomerCls/ClsSqlHelper.cs |   72 +++++++++++++++++++++++++----------
 1 files changed, 51 insertions(+), 21 deletions(-)

diff --git a/Pub_Class/CustomerCls/ClsSqlHelper.cs b/Pub_Class/CustomerCls/ClsSqlHelper.cs
index 2420e00..1e8b508 100644
--- a/Pub_Class/CustomerCls/ClsSqlHelper.cs
+++ b/Pub_Class/CustomerCls/ClsSqlHelper.cs
@@ -7,23 +7,23 @@
 
 namespace Pub_Class
 {
-    public class ClsSqlHelper:IDisposable
+    public class ClsSqlHelper : IDisposable
     {
         private SqlConnection MainCn;//鍒涘缓杩炴帴瀵硅薄
         public string strCon;
         SqlTransaction MainTran;
         public string sServer;
-        public string sDataBase ;
+        public string sDataBase;
         public string sUser;
         public string sPassword;
         //public string sTextBox = "HXErp_Test.ini";
         public string sTextBox = "HXErp.ini";
         //寮�濮嬩簨鍔�
-        public void  BeginTran()
+        public void BeginTran()
         {
             if (!this.CnOpen())
                 return;
-            MainTran=MainCn.BeginTransaction();
+            MainTran = MainCn.BeginTransaction();
         }
         //缁撴潫浜嬪姟
         public void Commit()
@@ -45,7 +45,7 @@
                 ClsPub.AppPath = System.Environment.CurrentDirectory;
                 //ClsPub.AppPath = @"C:\Windows\System32";
             }
-            sServer = ClsIni.ReadIni("Erp", "Server", ClsPub.AppPath + @"\"+sTextBox);
+            sServer = ClsIni.ReadIni("Erp", "Server", ClsPub.AppPath + @"\" + sTextBox);
             sDataBase = ClsIni.ReadIni("Erp", "DataBase", ClsPub.AppPath + @"\" + sTextBox);
             sUser = ClsIni.ReadIni("Erp", "UserName", ClsPub.AppPath + @"\" + sTextBox);
             sPassword = ClsIni.ReadIni("Erp", "PassWord", ClsPub.AppPath + @"\" + sTextBox);
@@ -54,13 +54,13 @@
 
         public bool CheckOpen()
         {
-            if (sServer == "" || sServer == "娌℃湁鎵惧埌锛�" )
+            if (sServer == "" || sServer == "娌℃湁鎵惧埌锛�")
             {
                 throw new Exception("閿欒鐨勬湇鍔″櫒鍚�!!" + System.Environment.CurrentDirectory);
             }
             if (sDataBase == "" || sDataBase == "娌℃湁鎵惧埌锛�")
             {
-                throw new Exception("閿欒鐨勬暟鎹簱鍚�!!"  +System.Environment.CurrentDirectory);
+                throw new Exception("閿欒鐨勬暟鎹簱鍚�!!" + System.Environment.CurrentDirectory);
             }
             SqlConnection oCn = new SqlConnection("Data Source=" + sServer + ";DataBase=master;User ID=" + sUser + ";PWD=" + sPassword + ";max pool size=32767");
             try
@@ -78,7 +78,7 @@
             }
         }
 
-        private bool  CnOpen()//OPEN鏁版嵁搴撹繛鎺�
+        private bool CnOpen()//OPEN鏁版嵁搴撹繛鎺�
         {
             if (sServer == "" || sServer == "娌℃湁鎵惧埌锛�")
             {
@@ -88,7 +88,7 @@
             {
                 throw new Exception("閿欒鐨勬暟鎹簱鍚�!");
             }
-            if (MainCn==null)
+            if (MainCn == null)
             {
                 MainCn = new SqlConnection("Data Source=" + sServer + ";DataBase=" + sDataBase + ";User ID=" + sUser + ";PWD=" + sPassword + ";max pool size=32767");
             }
@@ -117,10 +117,10 @@
 
         public void CnDispose()//閲婃斁璧勬簮
         {
-            if(MainCn!=null)
-            { 
+            if (MainCn != null)
+            {
                 MainCn.Dispose();
-                MainCn=null;
+                MainCn = null;
             }
         }
         /// <summary>
@@ -133,7 +133,7 @@
         /// <returns>鏂扮殑 parameter 瀵硅薄</returns>
         public SqlParameter MakeInParam(string ParamName, SqlDbType DbType, int Size, object Value)
         {
-            return MakeParam(ParamName, DbType, Size, ParameterDirection.Input, Value); 
+            return MakeParam(ParamName, DbType, Size, ParameterDirection.Input, Value);
         }
         /// <summary>
         /// 鍒濆鍖栧弬鏁板��
@@ -192,13 +192,13 @@
         /// <param name="procName"></param>
         /// <param name="sErrMessage"></param>
         /// <returns></returns>
-        public void RunProc(string procName,ref string sErr)
+        public void RunProc(string procName, ref string sErr)
         {
             if (!this.CnOpen())
             {
                 sErr = "杩炴帴鏁版嵁搴撳け璐ワ紒";
                 return;
-                
+
             }
             try
             {
@@ -211,7 +211,7 @@
             }
             catch (Exception e)
             {
-                sErr =e.Message;
+                sErr = e.Message;
                 ClsPub.sErrInfo = e.Message;
                 throw (e);
                 //return;
@@ -226,7 +226,7 @@
         /// <param name="tbName">琛ㄥ悕</param>
         /// <param name="sErrMessage">寮傚父淇℃伅</param>
         /// <returns></returns>
-        public DataSet RunProcReturn(string procName, SqlParameter[] prams, string tbName )
+        public DataSet RunProcReturn(string procName, SqlParameter[] prams, string tbName)
         {
             SqlDataAdapter dap = CreateDataAdaper(procName, prams);
             if (dap == null)
@@ -252,7 +252,7 @@
         /// <param name="tbName">琛ㄥ悕</param>
         /// <param name="sErrMessage">寮傚父淇℃伅</param>
         /// <returns></returns>
-        public DataSet RunProcReturn(string procName, string tbName )
+        public DataSet RunProcReturn(string procName, string tbName)
         {
             SqlDataAdapter dap = CreateDataAdaper(procName, null);
             DataSet ds = new DataSet();
@@ -276,7 +276,7 @@
         /// <param name="tbName">琛ㄥ悕</param>
         /// <param name="sErrMessage">寮傚父淇℃伅</param>
         /// <returns></returns>
-        public DataSet RunProcReturn(string procName, string tbName,ref string sErr)   
+        public DataSet RunProcReturn(string procName, string tbName, ref string sErr)
         {
             SqlDataAdapter dap = CreateDataAdaper(procName, null);
             DataSet ds = new DataSet();
@@ -366,7 +366,7 @@
 
         }
 
-        public SqlDataReader RunReader(string sSQL,string tbName,ref string sErr)
+        public SqlDataReader RunReader(string sSQL, string tbName, ref string sErr)
         {
             if (!this.CnOpen())
             {
@@ -384,12 +384,42 @@
             catch (Exception e)
             {
                 ClsPub.sErrInfo = e.Message;
-                sErr = e.Message; 
+                sErr = e.Message;
                 return null;
             }
         }
 
 
+        /// <summary>
+        /// 鎵归噺鎻掑叆鏁版嵁搴�
+        /// </summary>
+        /// <param name="TableName">鐩爣琛�</param>
+        /// <param name="dt">婧愭暟鎹�</param>
+        public bool SqlBulkCopyByDatatable(string TableName, DataTable dt)
+        {
+            string connectionString = $"Data Source={sServer};DataBase={sDataBase};User ID={sUser};PWD={sPassword}";
+            using (SqlConnection conn = new SqlConnection(connectionString))
+            {
+                using (SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(connectionString, SqlBulkCopyOptions.UseInternalTransaction))
+                {
+                    try
+                    {
+                        sqlbulkcopy.DestinationTableName = TableName;
+                        for (int i = 0; i < dt.Columns.Count; i++)
+                        {
+                            sqlbulkcopy.ColumnMappings.Add(dt.Columns[i].ColumnName, dt.Columns[i].ColumnName);
+                        }
+                        sqlbulkcopy.WriteToServer(dt);
+                        return true;
+                    }
+                    catch (System.Exception ex)
+                    {
+                        //ex.Message;
+                        return false;
+                    }
+                }
+            }
+        }
         #region IDisposable 鎴愬憳
 
         public void Dispose()

--
Gitblit v1.9.1