From 580cf2962ea9befde5a9cc1e10999978e71ae348 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期六, 04 三月 2023 14:37:13 +0800
Subject: [PATCH] 工单派发写入节拍工价复制表
---
VueWebApi/Tools/DapperHelper.cs | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 101 insertions(+), 2 deletions(-)
diff --git a/VueWebApi/Tools/DapperHelper.cs b/VueWebApi/Tools/DapperHelper.cs
index fced6ea..a0762d0 100644
--- a/VueWebApi/Tools/DapperHelper.cs
+++ b/VueWebApi/Tools/DapperHelper.cs
@@ -211,6 +211,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>
@@ -292,6 +324,40 @@
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)
@@ -448,13 +514,13 @@
/// <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;
@@ -482,5 +548,38 @@
}
return result;
}
+
+ /// <summary>
+ /// Dapper鎻掑叆 杩斿洖鑷涓婚敭Id
+ /// </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;
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.3