diff --git a/插件库/Lskj.Business/Impl/BaseImpl.cs b/插件库/Lskj.Business/Impl/BaseImpl.cs index cba9462..4333b0d 100644 --- a/插件库/Lskj.Business/Impl/BaseImpl.cs +++ b/插件库/Lskj.Business/Impl/BaseImpl.cs @@ -80,7 +80,11 @@ namespace Lskj.Business.Impl /// true if [has contain column]; otherwise, false. public static bool HasExistsColumn(string tableName, string colName) { - string sqlValue = string.Format("select 1 from sys.columns where object_id=object_id('{0}') and name='{1}'", tableName, colName); + string sqlValue = string.Format("select object_id from sys.columns where object_id = object_id('{0}') and name = '{1}'", tableName, colName); + if (SqlHelper.ConnectionType == ConnectionType.DmServer) + { + sqlValue = string.Format("select COLUMN_NAME from ALL_TAB_COLUMNS where TABLE_NAME = '{0}' and COLUMN_NAME = '{1}'", tableName, colName); + } return SqlHelper.ExecuteDataTable(sqlValue).Rows.Count > 0; } /// @@ -507,7 +511,7 @@ namespace Lskj.Business.Impl /// The SQL value. /// The parameters. /// System.Int32. - public static int ExecSqlValue(string sqlValue, params SqlParameter[] parameters) + public static int ExecSqlValue(string sqlValue, params DbParameter[] parameters) { try { @@ -531,7 +535,7 @@ namespace Lskj.Business.Impl /// The SQL value. /// The parameters. /// System.Int32. - public static int ExecSqlValueMes(string sqlValue, params SqlParameter[] parameters) + public static int ExecSqlValueMes(string sqlValue, params DbParameter[] parameters) { try { @@ -556,7 +560,7 @@ namespace Lskj.Business.Impl /// The SQL value. /// The parameters. /// System.Int32. - public static int ExecSqlValue(string sqlValue, DbTransaction Trans, params SqlParameter[] parameters) + public static int ExecSqlValue(string sqlValue, DbTransaction Trans, params DbParameter[] parameters) { try { @@ -594,8 +598,9 @@ namespace Lskj.Business.Impl /// The SQL value. /// The parameters. /// System.Object. - public static int ExecProcedure(string sqlValue, params DbParameter [] parameters) + public static int ExecProcedure(string sqlValue, params DbParameter[] parameters) { + return SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, sqlValue, parameters); } @@ -611,7 +616,7 @@ namespace Lskj.Business.Impl /// The SQL value. /// The parameters. /// System.Object. - public static int ExecProcedure(string sqlValue, DbTransaction Trans, params DbParameter[] parameters) + public static int ExecProcedure(string sqlValue, DbTransaction Trans, params DbParameter[] parameters) { return SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, sqlValue, Trans, 1, parameters); @@ -649,7 +654,7 @@ namespace Lskj.Business.Impl /// public static string GetBasePrimaryKey(string menuCode) { - string sqlValue = "select top 1 fieldname from P_systemwordbooktab where tab=@tab order by orderid"; + string sqlValue = "select top 1 fieldname from P_systemwordbooktab where tab = @tab order by orderid"; DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@tab", menuCode) }); return (dtTable.Rows.Count > 0) ? dtTable.Rows[0]["fieldname"] + "" : string.Empty; @@ -670,6 +675,10 @@ namespace Lskj.Business.Impl string viewColumn = string.Empty; string targetColumn = string.Empty; string sqlValue = "select name from sys.columns where object_id=object_id('p_SubsysPurviewTab') and name like '%purview'"; + if (SqlHelper.ConnectionType == ConnectionType.DmServer) + { + sqlValue = "select COLUMN_NAME name from ALL_TAB_COLUMNS where TABLE_NAME = 'p_SubsysPurviewTab' and COLUMN_NAME like '%purview%'"; + } DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue); if (dtTable.Rows.Count == 0) @@ -756,44 +765,6 @@ namespace Lskj.Business.Impl } return defaultValue; } - - - /// - /// 替换特殊字符 {#p_ - /// - /// - /// - /// - /// - public static string SpecialReplacement(string defaultValue,string[] otherParams = null) - { - if (string.IsNullOrEmpty(defaultValue)) return defaultValue; - - if (defaultValue.ToLower().Contains("{#p_")) - { - try - { - List paramList = ReplaceHelper.GetParamFields(defaultValue); - - foreach (var item in paramList) - { - string index = item.Replace("{#p_", "").Replace("}", ""); - int i = 0; - if (int.TryParse(index, out i)) - { - defaultValue = defaultValue.Replace(item, otherParams != null ? otherParams[i - 1] : ""); - } - } - } - catch (Exception) - { - - } - } - return defaultValue; - } - - /// /// 说明:获取记录 /// 创建人:龚宇超 @@ -846,7 +817,7 @@ namespace Lskj.Business.Impl /// /// The SQL value. /// System.String. - public static object GetResult(string sqlValue, DbTransaction Trans) + public static object GetResult(string sqlValue, DbTransaction Trans) { return SqlHelper.ExecuteScalar(sqlValue, Trans); } @@ -916,7 +887,7 @@ namespace Lskj.Business.Impl /// DataRow. public static DataRow GetSystemTab() { - string sqlValue = "select * from dbo.p_systemtab"; + string sqlValue = "select * from p_systemtab"; return GetDataRowResult(sqlValue); } /// @@ -1022,10 +993,9 @@ namespace Lskj.Business.Impl /// SqlDataAdapter. public static DbDataAdapter GetAdapterResult(string sqlValue) { - DbDataAdapter dbDataAdapter = SqlHelper.dbFactory.CreateDataAdapter(); try { - if (string.IsNullOrWhiteSpace(sqlValue)) return dbDataAdapter; + if (string.IsNullOrWhiteSpace(sqlValue)) return null; sqlValue = GetDefaultValue(sqlValue); sqlValue = ReplaceHelper.ReplaceParam(sqlValue); return SqlHelper.ExecuteAdapter(CommandType.Text, sqlValue); @@ -1033,7 +1003,7 @@ namespace Lskj.Business.Impl catch (Exception) { } - return dbDataAdapter; + return null; } /// /// 说明:获取打印配置 @@ -1089,7 +1059,7 @@ namespace Lskj.Business.Impl /// /// /// - public static int deleteFlow(int tagid, string Dllcode, string stepCode, int typeID, out string tipMsg, DbTransaction Trans) + public static int deleteFlow(int tagid, string Dllcode, string stepCode, int typeID, out string tipMsg, DbTransaction Trans) { SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000); pMsg.Direction = ParameterDirection.Output; @@ -1190,8 +1160,9 @@ namespace Lskj.Business.Impl /// public static string GetPrimaryKey(string TableName) { - string sqlValue = string.Format("SELECT TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME='{0}'", TableName); - DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue); + //string sqlValue = string.Format("SELECT TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME='{0}'", TableName); + DataTable dtTable = MainImpl.GetDatabaseProperty(TableName); + //DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue); return (dtTable.Rows.Count > 0) ? dtTable.Rows[0]["COLUMN_NAME"] + "" : string.Empty; } ///