From 9c634fd767aec36ef97c3a814bf7a29c67d20ee1 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期五, 29 三月 2024 10:57:35 +0800
Subject: [PATCH] 修改单据重复显示问题,增加工单源单id关联

---
 VueWebApi/Tools/DapperHelper.cs |  238 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 235 insertions(+), 3 deletions(-)

diff --git a/VueWebApi/Tools/DapperHelper.cs b/VueWebApi/Tools/DapperHelper.cs
index 132be16..8554721 100644
--- a/VueWebApi/Tools/DapperHelper.cs
+++ b/VueWebApi/Tools/DapperHelper.cs
@@ -29,8 +29,9 @@
             return connection;
         }
 
+
         /// <summary>
-        /// Dapper鏌ヨ杩斿洖List<T>
+        /// Dapper鏌ヨ杩斿洖List
         /// </summary>
         /// <typeparam name="T">闇�瑕佽繑鍥炵殑瀵硅薄绫诲瀷</typeparam>
         /// <param name="sql">Sql璇彞</param>
@@ -44,6 +45,8 @@
             {
                 try
                 {
+                    //鐢ㄦ埛鎿嶄綔璁板綍鍐欏叆鏁版嵁琛�
+                    //Log4net.LogUtil.SaveMessage("PC", "鎿嶄綔浜唜xxxx", "api/Login/LoginSave", ConfigurationManager.AppSettings["FileIP"], "9999", 1);
                     list = conn.Query<T>(sql, parm).ToList<T>();
                 }
                 catch (Exception ex)
@@ -210,6 +213,38 @@
         }
 
         /// <summary>
+        /// Dapper鏌ヨ杩斿洖datatable鏁版嵁(甯﹀弬鏁�)
+        /// </summary>
+        /// <param name="sql"></param>
+        /// <param name="parm"></param>
+        /// <returns></returns>
+        public static DataTable selectlist(string sql, Object parm)
+        {
+            //sql璇彞
+            using (IDbConnection conn = sqlConnection())
+            {
+                try
+                {
+                    DataTable table = new DataTable();
+                    var data = conn.ExecuteReader(sql, parm);
+                    table.Load(data);
+                    return table;
+                }
+                catch (Exception ex)
+                {
+                    //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+                    LogHelper.WriteLog(ex);
+                    throw ex;
+                }
+                finally
+                {
+                    conn.Dispose();
+                    conn.Close();
+                }
+            }
+        }
+
+        /// <summary>
         /// Dapper鏌ヨ杩斿洖datatable鏁版嵁(涓嶅甫鍙傛暟)
         /// </summary>
         /// <param name="sql"></param>
@@ -272,6 +307,75 @@
                 }
             }
 
+        }
+
+        /// <summary>
+        /// Dapper鎵ц瀛樺偍杩囩▼杩斿洖datatable鏁版嵁(甯﹀弬鏁�)
+        /// </summary>
+        /// <param name="sql">瀛樺偍杩囩▼鍚�</param>
+        /// <param name="parm">鍙傛暟</param>
+        /// <returns></returns>
+        public static bool IsProcedure(string sql, Object parm)
+        {
+            bool result;
+            //sql璇彞
+            using (IDbConnection conn = sqlConnection())
+            {
+                try
+                {
+                    DataTable table = new DataTable();
+                    //var data = conn.ExecuteReader(sql, parm);
+                    var res = conn.ExecuteReader(sql, parm, commandType: CommandType.StoredProcedure);//sql 瀛樺偍杩囩▼ 
+                    result = true;
+                }
+                catch (Exception ex)
+                {
+                    //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+                    LogHelper.WriteLog(ex);
+                    result = false;
+                    throw ex;
+                }
+                finally
+                {
+                    conn.Dispose();
+                    conn.Close();
+                }
+                return result;
+            }
+        }
+
+        /// <summary>
+        /// Dapper鎵ц瀛樺偍杩囩▼杩斿洖datatable鏁版嵁(涓嶅甫鍙傛暟)
+        /// </summary>
+        /// <param name="sql">瀛樺偍杩囩▼鍚�</param>
+        /// <returns></returns>
+        public static bool IsProcedureNo(string sql)
+        {
+            bool result;
+            //sql璇彞
+            using (IDbConnection conn = sqlConnection())
+            {
+                try
+                {
+                    DataTable table = new DataTable();
+                    //var data = conn.ExecuteReader(sql, parm);
+                    var res = conn.ExecuteReader(sql);//sql 瀛樺偍杩囩▼ 
+                    result = true;
+                }
+                catch (Exception ex)
+                {
+                    //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+                    LogHelper.WriteLog(ex);
+                    result = false;
+                    throw ex;
+                }
+                finally
+                {
+                    conn.Dispose();
+                    conn.Close();
+                }
+                return result;
+            }
         }
 
         /// <summary>
@@ -374,15 +478,50 @@
             }
         }
 
+        /// <summary>
+        /// 澧炲姞锛屽垹闄わ紝淇敼浣跨敤鐨� 浜嬪姟鏂规硶  Sqllist涓轰緷娆℃墽琛�
+        /// </summary>
+        /// <param name="sqlList"></param>
+        /// <returns></returns>
+        public static int DoTransactionCont(List<object> sqlList)
+        {
+            int result = 0;
+            IDbTransaction tranction = null;
+            using (IDbConnection conn = sqlConnection())
+            {
+                try
+                {
+                    tranction = conn.BeginTransaction();
+                    for (int i = 0; i < sqlList.Count; i++)
+                    {
+                        result += conn.Execute(sqlList[i].GetType().GetProperty("str").GetValue(sqlList[i], null).ToString(), sqlList[i].GetType().GetProperty("parm").GetValue(sqlList[i], null), tranction);
+                    }
+                    tranction.Commit();
+                }
+                catch (Exception ex)
+                {
+                    //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+                    LogHelper.WriteLog(ex);
+                    tranction.Rollback();
+                    throw ex;
+                }
+                finally
+                {
+                    conn.Dispose();
+                    conn.Close();
+                }
+                return result;
+            }
+        }
 
         /// <summary>
-        /// Dapper鎻掑叆 杩斿洖鑷涓婚敭Id
+        /// Dapper鎻掑叆 杩斿洖鑷涓婚敭Id锛堝浠斤級
         /// </summary>
         /// <param name="sql"></param>
         /// <param name="parameter"></param>
         /// <param name="tableName">寰呮彃鍏ユ暟鎹殑琛ㄥ悕</param>
         /// <returns></returns>
-        public static int insertReturnId(string sql, Object parameter, String tableName)
+        public static int insertReturnId0(string sql, Object parameter, String tableName)
         {
 
             int result = 0;
@@ -410,5 +549,98 @@
             }
             return result;
         }
+
+
+        /// <summary>
+        /// Dapper 杩斿洖鑷涓婚敭褰撳墠鏁版嵁琛ㄦ渶澶d
+        /// </summary>
+        /// <param name="tableName">寰呮彃鍏ユ暟鎹殑琛ㄥ悕</param>
+        /// <returns></returns>
+        public static int insertReturnId(String tableName)
+        {
+
+            int result = 0;
+            using (IDbConnection conn = sqlConnection())
+            {
+                try
+                {
+                    if (result == 0)
+                    {
+                        result = conn.Query<int>("select ident_current(@table)", new { table = tableName }).Single<int>();
+                    }
+                }
+                catch (Exception ex)
+                {
+                    //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+                    LogHelper.WriteLog(ex);
+                    throw ex;
+                }
+                finally
+                {
+                    conn.Dispose();
+                    conn.Close();
+                }
+            }
+            return result;
+        }
+        /// <summary>
+        /// 鎵цsql鎵ц璇彞,杩斿洖瀛楃涓�
+        /// </summary>
+        /// <param name="sql"></param>
+        /// <returns></returns>
+        public static string sqlstr(String sql)
+        {
+
+            string result = "";
+            using (IDbConnection conn = sqlConnection())
+            {
+                try
+                {
+                    if (result == "")
+                    {
+                        result = conn.Query<string>(sql).First();
+                    }
+                }
+                catch (Exception ex)
+                {
+                    //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+                    LogHelper.WriteLog(ex);
+                    throw ex;
+                }
+                finally
+                {
+                    conn.Dispose();
+                    conn.Close();
+                }
+            }
+            return result;
+        }
+
+        public static DataTable lissql(string sql)
+        {
+            //sql璇彞
+            using (IDbConnection conn = sqlConnection())
+            {
+                try
+                {
+                    DataTable table = new DataTable();
+                    //var data = conn.ExecuteReader(sql, parm);
+                    var res = conn.ExecuteReader(sql);//sql 瀛樺偍杩囩▼ 
+                    table.Load(res);
+                    return table;
+                }
+                catch (Exception ex)
+                {
+                    //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+                    LogHelper.WriteLog(ex);
+                    throw ex;
+                }
+                finally
+                {
+                    conn.Dispose();
+                    conn.Close();
+                }
+            }
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3