1255 lines
54 KiB
C#
1255 lines
54 KiB
C#
/******************************
|
|
* 说明:业务基类
|
|
* 创建人:龚宇超
|
|
* 创建日期:2017-09-01
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本:1.0.0.0
|
|
******************************/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
using Lskj.Model;
|
|
using Lskj.Core;
|
|
using Lskj.Util;
|
|
using System.Data.SqlClient;
|
|
using System.Data.Common;
|
|
|
|
namespace Lskj.Business.Impl
|
|
{
|
|
/// <summary>
|
|
/// 业务基类
|
|
/// </summary>
|
|
public class BaseImpl
|
|
{
|
|
/// <summary>
|
|
/// 检查数据库某表的结构是否完整
|
|
/// </summary>
|
|
/// <param name="dataImpl"></param>
|
|
/// <returns></returns>
|
|
public static bool CheckTable(Dictionary<string, string> colDic, string tableName)
|
|
{
|
|
try
|
|
{
|
|
string isExitTab = $"select top 1 * from sysObjects where Id=OBJECT_ID(N'{tableName}') and xtype='U'";
|
|
DataTable apiTab = SqlHelper.ExecuteDataTable(isExitTab);
|
|
if (apiTab.Rows.Count > 0)//存在表
|
|
{
|
|
DataTable columnsTab = SqlHelper.ExecuteDataTable(string.Format($"select name from syscolumns where id=object_id('{tableName}')"));
|
|
foreach (KeyValuePair<string, string> colunmField in colDic)
|
|
{
|
|
DataRow[] dataRows = columnsTab.Select().Where(n => (n["name"] + "").Equals(colunmField.Key)).ToArray();
|
|
if (dataRows.Length == 0)
|
|
{
|
|
string addColSql = string.Format($"alter table {tableName} add {0} {1}", colunmField.Key, colunmField.Value);
|
|
SqlHelper.ExecuteNonQuery(addColSql);//添加列
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string createCol = string.Empty;
|
|
foreach (KeyValuePair<string, string> colunmField in colDic)
|
|
{
|
|
createCol += string.Format("{0} {1},", colunmField.Key, colunmField.Value);
|
|
}
|
|
string createTabSql = $"create table {tableName}(id int IDENTITY(1,1) NOT NULL,{createCol.TrimEnd(',')})";
|
|
SqlHelper.ExecuteNonQuery(createTabSql);//创建表
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:检查数据库表是否包含某列</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <param name="colName">Name of the col.</param>
|
|
/// <returns><c>true</c> if [has contain column]; otherwise, <c>false</c>.</returns>
|
|
public static bool HasExistsColumn(string tableName, string 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;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:检查数据库表是否包含某列,不存在则创建</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <param name="colName">Name of the col.</param>
|
|
/// <returns><c>true</c> if [has contain column]; otherwise, <c>false</c>.</returns>
|
|
public static bool HasExistsColumn(string tableName, string colName, string colType)
|
|
{
|
|
if (!HasExistsColumn(tableName, colName))
|
|
{
|
|
return ExecSqlValue(string.Format("ALTER TABLE {0} ADD {1} {2}", tableName, colName, colType)) > 0;
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:是否存在xxx表</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <returns><c>true</c> if [has exists table] [the specified table name]; otherwise, <c>false</c>.</returns>
|
|
public static bool HasExistsTable(string tableName)
|
|
{
|
|
try
|
|
{
|
|
string sqlValue = "select 1 from " + tableName + " where 1<>1";
|
|
return SqlHelper.ExecuteDataTable(sqlValue).Rows.Count >= 0;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 判断是否存在指定存储过程
|
|
/// </summary>
|
|
/// <param name="Name"></param>
|
|
/// <returns></returns>
|
|
public static bool HasExistsStoredProcedure(string Name)
|
|
{
|
|
try
|
|
{
|
|
string sqlValue = string.Format("select OBJECT_ID(N'{0}', N'P') ", Name);
|
|
return !string.IsNullOrWhiteSpace(SqlHelper.ExecuteScalar(sqlValue) + "");
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取树节点配置表</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-12-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <returns><c>true</c> if [has exists table] [the specified table name]; otherwise, <c>false</c>.</returns>
|
|
public static DataRow TreeNodeSetTab(string treeTable)
|
|
{
|
|
string sqlValue = string.Format("select * from p_systemTreeNodeSetTab" + " where treeTable='{0}'", treeTable);
|
|
DataTable dt = SqlHelper.ExecuteDataTable(sqlValue);
|
|
return dt != null ? dt.Rows.Count > 0 ? dt.Rows[0] : null : null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:是否包含某条数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <param name="key">The key.</param>
|
|
/// <param name="value">The value.</param>
|
|
/// <param name="row">The row.</param>
|
|
/// <returns><c>true</c> if [has exists data row] [the specified table name]; otherwise, <c>false</c>.</returns>
|
|
public static bool HasExistsDataRow(string tableName, string key, string value, out DataRow row)
|
|
{
|
|
return HasExistsDataRow(tableName, key, value, "", out row);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:是否包含某条数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-08-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <param name="key">The key.</param>
|
|
/// <param name="value">The value.</param>
|
|
/// <param name="whereCond">The where cond.</param>
|
|
/// <param name="row">The row.</param>
|
|
/// <returns><c>true</c> if [has exists data row] [the specified table name]; otherwise, <c>false</c>.</returns>
|
|
public static bool HasExistsDataRow(string tableName, string key, string value, string whereCond, out DataRow row)
|
|
{
|
|
try
|
|
{
|
|
string sqlValue = string.Format("select * from {0} where {1}='{2}' {3}", tableName, key, value, whereCond);
|
|
row = GetDataRowResult(sqlValue);
|
|
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
|
|
row = null;
|
|
return false;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:修改某个表字段</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <param name="fieldName">Name of the field.</param>
|
|
/// <param name="fieldType">Type of the field.</param>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
public static bool UpdateTableField(string tableName, string fieldName, string fieldType)
|
|
{
|
|
string sqlValue = string.Format("ALTER TABLE {0} ALTER COLUMN {1} {2}", tableName, fieldName, fieldType);
|
|
return ExecSqlValue(sqlValue) > 0;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:添加业务异常数据到lscrm系统</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="msg">The MSG.</param>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
public static bool AddExceptionToLsCrm(string msg)
|
|
{
|
|
try
|
|
{
|
|
using (SqlConnection conn = new SqlConnection(DBConfig.Instance.GetLsCrmConnection()))
|
|
{
|
|
conn.Open();
|
|
string commText = string.Format("insert into Crm_ProblemTab(OperatorName,ProDesc,CusName,CusConnection) values('{0}','{1}','{2}','{3}')",
|
|
ERPInfo.Instance.UserName, msg, SystemInfo.Instance.ClientName, DBConfig.Instance.GetConnection());
|
|
using (SqlCommand comm = new SqlCommand(commText, conn))
|
|
{
|
|
int result = comm.ExecuteNonQuery();
|
|
comm.Dispose();
|
|
|
|
return result > 0;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:通过模块ID获取用户模块权限</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-18 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="subId">The sub identifier.</param>
|
|
/// <param name="menuId">The menu identifier.</param>
|
|
/// <returns>1.有操作权限.0.无权限.2.只读权限</returns>
|
|
public static int GetUserPurviewsByMenuId(string menuId)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.HeadMenuId) && SystemInfo.Instance.HeadMenuId.Split(',').Contains(menuId))
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
//2026-08-08 pz说不要判断,工具统一处理
|
|
//P_MessageToolLinkDllTab表中cardId=-99为通用模块(右侧快捷通道通用模块),默认有权限 2023-12-4 徐成说的cardId=-99的配置
|
|
//string sql = string.Format("select a.*,b.PurviewId,b.MouseOutImg,b.MouseOverImg1 from("
|
|
// + " select * from P_MessageToolLinkDllTab where cardId=-99 and ( grouptagid=2 or grouptagid=1) "
|
|
// + ")a join p_formmenuconfigtab b on a.LMenuId=b.MenuId where LinkModeTag=1 and LMenuid='{1}' order by grouptagid,ItemTagId", ERPInfo.Instance.UserId, menuId);
|
|
//DataTable table = SqlHelper.ExecuteDataTable(sql);
|
|
//if (table.Rows.Count > 0)
|
|
//{
|
|
// return 1;
|
|
//}
|
|
|
|
if (ERPInfo.Instance.UserName == ERPInfo.Instance.UserManager)
|
|
return 1;
|
|
string readPurview = "," + menuId + "|,";
|
|
string editPurview = "," + menuId + ",";
|
|
|
|
string allPurview = ",";
|
|
|
|
string sqlValue = "select top 1 * from p_SubsysPurviewTab where employeeid=@employeeid";
|
|
DataTable tablePurviews = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@employeeid", ERPInfo.Instance.UserId) });
|
|
|
|
for (int i = 0; i < tablePurviews.Columns.Count; i++)
|
|
{
|
|
DataColumn col = tablePurviews.Columns[i];
|
|
if (col.ColumnName.ToLower().Contains("purview"))
|
|
{
|
|
DataRow item = tablePurviews.Rows[0];
|
|
allPurview += item[col.ColumnName] + ",";
|
|
}
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(allPurview)) return 0;
|
|
if (allPurview.Contains(editPurview)) return 1;
|
|
if (allPurview.Contains(readPurview)) return 2;
|
|
|
|
return 0;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:通过模块编号获取用户模块权限</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-14 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int GetUserPurviewsByMenuCode(string menuCode)
|
|
{
|
|
string where = string.IsNullOrEmpty(ERPInfo.Instance.SeriesId) ? "" : string.Format("and SeriesId={0}", ERPInfo.Instance.SeriesId);
|
|
string sqlValue = string.Format("select top 1 MenuId from P_FormMenuConfigTab where UrlParams='{0}' and lower(DllFileName) not like '%accraditation%' and subsysid in (select SubSysId from P_SubSystemTab where UseEd=1 {1}) {1}", menuCode, where);
|
|
string menuId = SqlHelper.ExecuteString("MenuId", sqlValue);
|
|
|
|
return GetUserPurviewsByMenuId(menuId);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取单据是否有多表头</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-07-31 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
/// <returns>0.普通表格、1.多表头、2.树结构表格</returns>
|
|
public static int GetBillDetailType(string menuCode)
|
|
{
|
|
if (HasExistsColumn("p_systembillDetail", "bandTitle") && HasExistsColumn("p_systembillDetail", "bandFields"))
|
|
{
|
|
string sqlValue = "select 1 from p_systembillDetail where typeCode=@tab and ISNULL(bandTitle,'')<>'' and ISNULL(bandFields,'')<>''";
|
|
bool isBanded = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@tab", menuCode) }).Rows.Count > 0;
|
|
return isBanded ? 1 : 0;
|
|
}
|
|
return 0;
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取基础档案、报表模版类型</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
/// <returns>0.普通表格、1.多表头、2.树结构表格</returns>
|
|
public static int GetBaseType(string menuCode)
|
|
{
|
|
// 是否为多表头
|
|
string sqlValue = "select 1 from p_systemwordbooktab where tab=@tab and ISNULL(bandTitle,'')<>'' and ISNULL(bandFields,'')<>''";
|
|
bool isBanded = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@tab", menuCode) }).Rows.Count > 0;
|
|
|
|
if (isBanded) return 1;
|
|
|
|
// 是否为树结构表格
|
|
sqlValue = "select 1 from P_FormMenuConfigTab where PurviewId=@tab and ISNULL(TRCReport,0)=1";
|
|
bool isTreeGrid = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@tab", menuCode) }).Rows.Count > 0;
|
|
|
|
return isTreeGrid ? 2 : 0;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取扫码控件表格</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
/// <returns>控件为扫码框且内容隐藏就为扫码控件</returns>
|
|
public static DataTable GetSweepCode(string menuCode)
|
|
{
|
|
// 是否为存在扫码控件
|
|
string sqlValue = "select * from p_systemwordbooktab where tab=@tab and vislble='1' and fieldsqlTag='98' ORDER BY orderid";
|
|
return SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@tab", menuCode) });
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取扫码控件表格</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
/// <returns>扫码控件的提醒</returns>
|
|
public static DataTable GetSweepCodeTips(string menuCode)
|
|
{
|
|
// 是否为多表头
|
|
string sqlValue = "select * from p_systemwordbooktab where tab=@tab and TM_tagID=-1 ORDER BY orderid";
|
|
return SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@tab", menuCode) });
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:验证是否允许删除记录</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
/// <param name="fieldKey">The key value.</param>
|
|
/// <param name="tipMsg">The tip MSG.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int VerifyCanDelete(string menuCode, string fieldKey, out string tipMsg)
|
|
{
|
|
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
|
pMsg.Direction = ParameterDirection.Output;
|
|
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
|
returnValue.Direction = ParameterDirection.ReturnValue;
|
|
SqlParameter[] param =
|
|
{
|
|
new SqlParameter("@modid",SqlDbType.VarChar,20),
|
|
new SqlParameter("@keyvalue",SqlDbType.VarChar,40),
|
|
pMsg,
|
|
returnValue
|
|
};
|
|
param[0].Value = menuCode;
|
|
param[1].Value = fieldKey;
|
|
|
|
SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_VerifyCanDelete", "baseSave", param);
|
|
tipMsg = pMsg.Value + "";
|
|
|
|
return Convert.ToInt32(returnValue.Value + "");
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:树结构自定义配置功能</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-12-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
/// <param name="fieldKey">The key value.</param>
|
|
/// <param name="tipMsg">The tip MSG.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int ReBuildTreeNode(string treeModid, int operType, out string tipMsg)
|
|
{
|
|
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
|
pMsg.Direction = ParameterDirection.Output;
|
|
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
|
returnValue.Direction = ParameterDirection.ReturnValue;
|
|
SqlParameter[] param =
|
|
{
|
|
new SqlParameter("@treeModid",SqlDbType.VarChar,20),
|
|
new SqlParameter("@operType",SqlDbType.Int),
|
|
new SqlParameter("@operatorid",SqlDbType.Int),
|
|
new SqlParameter("@operatorname",SqlDbType.VarChar,20),
|
|
pMsg,
|
|
returnValue
|
|
};
|
|
param[0].Value = treeModid;
|
|
param[1].Value = operType;
|
|
param[2].Value = ERPInfo.Instance.UserId;
|
|
param[3].Value = ERPInfo.Instance.UserName;
|
|
|
|
SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_system_ReBuildTreeNode", "treeDrop", param);
|
|
tipMsg = pMsg.Value + "";
|
|
return Convert.ToInt32(returnValue.Value + "");
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:执行SQL语句返回受影响行</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <param name="parameters">The parameters.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int ExecSqlValue(string sqlValue, params DbParameter[] parameters)
|
|
{
|
|
try
|
|
{
|
|
return SqlHelper.ExecuteNonQuery(CommandType.Text, sqlValue, parameters);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:执行SQL语句返回受影响行,mes使用,报错抛出</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <param name="parameters">The parameters.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int ExecSqlValueMes(string sqlValue, params DbParameter[] parameters)
|
|
{
|
|
try
|
|
{
|
|
return SqlHelper.ExecuteNonQuery(CommandType.Text, sqlValue, parameters);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:执行SQL语句返回受影响行,带事务</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <param name="parameters">The parameters.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int ExecSqlValue(string sqlValue, DbTransaction Trans, params DbParameter[] parameters)
|
|
{
|
|
try
|
|
{
|
|
return SqlHelper.ExecuteNonQuery(CommandType.Text, sqlValue, Trans, 1, parameters);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
public static int ExecSqlValue(string sqlValue, bool isTip, params SqlParameter[] parameters)
|
|
{
|
|
try
|
|
{
|
|
return SqlHelper.ExecuteNonQuery(CommandType.Text, sqlValue, parameters);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
if (isTip) throw;
|
|
}
|
|
return 0;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:执行存储过程</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-31 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <param name="parameters">The parameters.</param>
|
|
/// <returns>System.Object.</returns>
|
|
public static int ExecProcedure(string sqlValue, params DbParameter[] parameters)
|
|
{
|
|
|
|
return SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, sqlValue, parameters);
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:执行存储过程,带事务</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-31 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <param name="parameters">The parameters.</param>
|
|
/// <returns>System.Object.</returns>
|
|
public static int ExecProcedure(string sqlValue, DbTransaction Trans, params DbParameter[] parameters)
|
|
{
|
|
|
|
return SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, sqlValue, Trans, 1, parameters);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取列前缀</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <returns>System.String.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static string GetColumnPrefix(string tableName)
|
|
{
|
|
string sqlValue = "select column_prefix from p_systemtables where lower(table_name)=@tableName";
|
|
return SqlHelper.ExecuteString("column_prefix", sqlValue, new SqlParameter[] { new SqlParameter("@tableName", tableName) });
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取主键</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
/// <returns>System.String.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static string GetBasePrimaryKey(string menuCode)
|
|
{
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取当前登录用户权限</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-14 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
public static string GetPurviewCond()
|
|
{
|
|
string operColumn = string.Empty;
|
|
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)
|
|
{
|
|
operColumn = @"','+isnull([KcPurview],'')+','+isnull([crmPurview],'')+','+isnull([bomPurview],'')+','+
|
|
isnull([mrpPurview],'')+','+isnull([scmPurview],'')+','+isnull([sellPurview],'')+','+
|
|
isnull([RdmPurview],'')+','+isnull([hrPurview],'')+','+isnull([costPurview],'')+','+
|
|
isnull([eamPurview],'')+','+isnull([FmPurview],'')+','+isnull([oaPurview],'')+','+
|
|
isnull([BiPurview],'')+','+isnull([QmsPurview],'')+','";
|
|
viewColumn = @"','+isnull([KcPurview],'')+'|,'+isnull([crmPurview],'')+'|,'+isnull([bomPurview],'')+'|,'+
|
|
isnull([mrpPurview],'')+'|,'+isnull([scmPurview],'')+'|,'+isnull([sellPurview],'')+'|,'+
|
|
isnull([RdmPurview],'')+'|,'+isnull([hrPurview],'')+'|,'+isnull([costPurview],'')+'|,'+
|
|
isnull([eamPurview],'')+'|,'+isnull([FmPurview],'')+'|,'+isnull([oaPurview],'')+'|,'+
|
|
isnull([BiPurview],'')+'|,'+isnull([QmsPurview],'')+'|,'";
|
|
}
|
|
else
|
|
{
|
|
foreach (DataRow item in dtTable.Rows)
|
|
{
|
|
operColumn += "','+isnull(" + item["name"] + ",'')+','";
|
|
viewColumn += "','+isnull(" + item["name"] + ",'')+'|,'";
|
|
}
|
|
}
|
|
return @"and (CHARINDEX(','+CAST(menuid as varchar)+',',(select top 1
|
|
" + operColumn + @"
|
|
from [p_SubsysPurviewTab]
|
|
where employeeid=" + ERPInfo.Instance.UserId + "))>0 " +
|
|
@" or CHARINDEX(','+CAST(menuid as varchar)+'|,',(select top 1
|
|
" + viewColumn + @"
|
|
from [p_SubsysPurviewTab]
|
|
where employeeid=" + ERPInfo.Instance.UserId + "))>0 " +
|
|
"or len(menustruct)=2 or " + ERPInfo.Instance.UserId + "=1 or '" + ERPInfo.Instance.UserName + "'='管理员')";
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:替换默认值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="defaultValue">The default value.</param>
|
|
/// <returns>System.String.</returns>
|
|
public static string GetDefaultValue(string defaultValue, string parentValue = "", string[] otherParams = null)
|
|
{
|
|
if (string.IsNullOrEmpty(defaultValue)) return defaultValue;
|
|
|
|
defaultValue = defaultValue.TrimStart(new char[] { '\r', '\n' }); // 去除前后空格、制表符等
|
|
defaultValue = ReplaceHelper.ReplaceUserInfo(defaultValue);//
|
|
defaultValue = ReplaceHelper.ReplaceTreeViewParentKeyCond(defaultValue, parentValue);
|
|
|
|
if ("guid".Equals(defaultValue))
|
|
return Guid.NewGuid().ToString();
|
|
|
|
if (defaultValue.StartsWith("@"))
|
|
return GetResult(defaultValue.Replace("@", "")) + "";
|
|
|
|
if (defaultValue.StartsWith("!"))
|
|
{
|
|
defaultValue = "exec " + defaultValue.Replace("!", "").Replace("(", " ").Replace(")", "");
|
|
return GetResult(defaultValue) + "";
|
|
}
|
|
if (defaultValue.ToLower().Contains("{#p_"))
|
|
{
|
|
try
|
|
{
|
|
List<string> 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;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 替换特殊字符 {#p_
|
|
/// </summary>
|
|
/// <param name="defaultValue"></param>
|
|
/// <param name="parentValue"></param>
|
|
/// <param name="otherParams"></param>
|
|
/// <returns></returns>
|
|
public static string SpecialReplacement(string defaultValue, string[] otherParams = null)
|
|
{
|
|
if (string.IsNullOrEmpty(defaultValue)) return defaultValue;
|
|
|
|
if (defaultValue.ToLower().Contains("{#p_"))
|
|
{
|
|
try
|
|
{
|
|
List<string> 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;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取记录</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <param name="fieldName">Name of the field.</param>
|
|
/// <param name="condKey">The cond key.</param>
|
|
/// <param name="condValue">The cond value.</param>
|
|
/// <returns>System.Object.</returns>
|
|
public static object GetRecord(string tableName, string fieldName, string condKey, string condValue)
|
|
{
|
|
if (string.IsNullOrEmpty(tableName) ||
|
|
string.IsNullOrEmpty(fieldName) ||
|
|
string.IsNullOrEmpty(condKey) ||
|
|
string.IsNullOrEmpty(condValue))
|
|
return new object();
|
|
|
|
string sqlValue = string.Format("select top 1 {0} from {1} where {2}='{3}'", fieldName, tableName, condKey, condValue);
|
|
return GetResult(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:执行sql语句返回数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <returns>System.String.</returns>
|
|
public static object GetResult(string sqlValue)
|
|
{
|
|
return SqlHelper.ExecuteScalar(sqlValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:执行sql语句返回数据,带事务</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <returns>System.String.</returns>
|
|
public static object GetResult(string sqlValue, DbTransaction Trans)
|
|
{
|
|
return SqlHelper.ExecuteScalar(sqlValue, Trans);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:执行sql语句返回数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <param name="parameters">The parameters.</param>
|
|
/// <returns>System.Object.</returns>
|
|
public static object GetResult(string sqlValue, SqlParameter[] parameters)
|
|
{
|
|
return SqlHelper.ExecuteScalar(CommandType.Text, sqlValue, parameters);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取菜单其他配置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="moduleId">The module identifier.</param>
|
|
/// <returns>DataRow.</returns>
|
|
public static DataRow GetMenuConfigTab(int moduleId)
|
|
{
|
|
string sqlValue = "select * from P_FormMenuConfigTab where menuid=@menuid";
|
|
DataTable table = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@menuid", moduleId) });
|
|
|
|
return table != null && table.Rows.Count > 0 ? table.Rows[0] : null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取右键具体配置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="moduleId">The module identifier.</param>
|
|
/// <returns>DataRow.</returns>
|
|
public static DataRow GetPopMenu(string tab, string menuname)
|
|
{
|
|
string sqlValue = string.Format("select* from P_systempopupmenu where tab='{0}' and menuname = '{1}'", tab, menuname);
|
|
DataTable table = SqlHelper.ExecuteDataTable(sqlValue);
|
|
|
|
return table != null && table.Rows.Count > 0 ? table.Rows[0] : null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取系统配置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataRow.</returns>
|
|
public static DataRow GetSystemTab()
|
|
{
|
|
string sqlValue = "select * from p_systemtab";
|
|
return GetDataRowResult(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取验证系统配置</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-12-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataRow.</returns>
|
|
public static DataRow GetVeriSystemTab()
|
|
{
|
|
string sqlValue = "select isnull(clientcode,'') AS coid,ClientName,* from p_systemtab";
|
|
return GetDataRowResult(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:执行SQL语句返回第一行</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <returns>DataRow.</returns>
|
|
public static DataRow GetDataRowResult(string sqlValue)
|
|
{
|
|
DataTable table = GetDataTableResult(sqlValue);
|
|
return table.Rows.Count > 0 ? table.Rows[0] : null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取某个表的列</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetTableColumns(string tableName)
|
|
{
|
|
string sqlValue = string.Format("select * from {0} where 1<>1", tableName);
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:执行SQL语句返回结果集</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:2017-10-25</para>
|
|
/// <para>修改备注:1. 2017-10-25增加传入参数为空处理,返回空DataTable</para>
|
|
/// <para>版本:1.1</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetDataTableResult(string sqlValue)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrWhiteSpace(sqlValue)) return new DataTable();
|
|
sqlValue = GetDefaultValue(sqlValue);
|
|
sqlValue = ReplaceHelper.ReplaceParam(sqlValue);
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
return new DataTable();
|
|
}
|
|
|
|
public static DataTable GetDataTableResultGetTableStructure(string sqlValue)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrWhiteSpace(sqlValue)) return new DataTable();
|
|
sqlValue = GetDefaultValue(sqlValue);
|
|
sqlValue = ReplaceHelper.ReplaceParamGetTableStructure(sqlValue);
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
return new DataTable();
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:执行SQL语句返回结果集</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-10-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <returns>SqlDataAdapter.</returns>
|
|
public static DbDataAdapter GetAdapterResult(string sqlValue)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrWhiteSpace(sqlValue)) return null;
|
|
sqlValue = GetDefaultValue(sqlValue);
|
|
sqlValue = ReplaceHelper.ReplaceParam(sqlValue);
|
|
return SqlHelper.ExecuteAdapter(CommandType.Text, sqlValue);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
return null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取打印配置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-07-31 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="key">The key.</param>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetPrintTemp70(string key)
|
|
{
|
|
string sqlValue = string.Format(@"select * from p_systemPrintDesignTab where modid='{0}'", key);
|
|
return GetDataTableResult(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// 执行删除存储过程
|
|
/// </summary>
|
|
/// <param name="modid"></param>
|
|
/// <param name="tagid"></param>
|
|
/// <param name="mid"></param>
|
|
/// <returns></returns>
|
|
public static int deleteFlow(int tagid, string Dllcode, string stepCode, int typeID, out string tipMsg)
|
|
{
|
|
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
|
pMsg.Direction = ParameterDirection.Output;
|
|
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
|
returnValue.Direction = ParameterDirection.ReturnValue;
|
|
SqlParameter[] param =
|
|
{
|
|
new SqlParameter("@tagid",SqlDbType.Int),
|
|
new SqlParameter("@Dllcode",SqlDbType.VarChar,50),
|
|
new SqlParameter("@stepCode",SqlDbType.VarChar,50),
|
|
new SqlParameter("@typeID",SqlDbType.Int),
|
|
pMsg,
|
|
returnValue
|
|
};
|
|
param[0].Value = tagid;
|
|
param[1].Value = Dllcode;
|
|
param[2].Value = stepCode;
|
|
param[3].Value = typeID;
|
|
BaseImpl.ExecProcedure("[p_systemDeleteFlowInfo]", param);
|
|
tipMsg = pMsg.Value + "";
|
|
return Convert.ToInt32(returnValue.Value.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 执行删除存储过程,带事务
|
|
/// </summary>
|
|
/// <param name="modid"></param>
|
|
/// <param name="tagid"></param>
|
|
/// <param name="mid"></param>
|
|
/// <returns></returns>
|
|
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;
|
|
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
|
returnValue.Direction = ParameterDirection.ReturnValue;
|
|
SqlParameter[] param =
|
|
{
|
|
new SqlParameter("@tagid",SqlDbType.Int),
|
|
new SqlParameter("@Dllcode",SqlDbType.VarChar,50),
|
|
new SqlParameter("@stepCode",SqlDbType.VarChar,50),
|
|
new SqlParameter("@typeID",SqlDbType.Int),
|
|
pMsg,
|
|
returnValue
|
|
};
|
|
param[0].Value = tagid;
|
|
param[1].Value = Dllcode;
|
|
param[2].Value = stepCode;
|
|
param[3].Value = typeID;
|
|
BaseImpl.ExecProcedure("[p_systemDeleteFlowInfo]", Trans, param);
|
|
tipMsg = pMsg.Value + "";
|
|
return Convert.ToInt32(returnValue.Value.ToString());
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 执行通过人员id获取权限菜单存储过程
|
|
/// </summary>
|
|
/// <param name="modid"></param>
|
|
/// <param name="tagid"></param>
|
|
/// <param name="mid"></param>
|
|
/// <returns></returns>
|
|
public static DataSet getAuthorityByEmpid(int typeId, string empid, string operatorId, string operatorName, out string tipMsg)
|
|
{
|
|
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
|
pMsg.Direction = ParameterDirection.Output;
|
|
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
|
returnValue.Direction = ParameterDirection.ReturnValue;
|
|
SqlParameter[] param =
|
|
{
|
|
new SqlParameter("@typeId",SqlDbType.Int),
|
|
new SqlParameter("@empid",SqlDbType.VarChar,50),
|
|
new SqlParameter("@operatorId",SqlDbType.VarChar,50),
|
|
new SqlParameter("@operatorName",SqlDbType.VarChar,50),
|
|
pMsg,
|
|
returnValue
|
|
};
|
|
param[0].Value = typeId;
|
|
param[1].Value = empid;
|
|
param[2].Value = operatorId;
|
|
param[3].Value = operatorName;
|
|
tipMsg = pMsg.Value + "";
|
|
DataSet ds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_getAuthorityByEmpid", "#ba_firstpage", param);
|
|
return ds;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:拖拽后执行存储过程</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-12-12 </para>
|
|
/// <param name="operType"></param>
|
|
/// <param name="billno"></param>
|
|
/// <param name="tipMsg"></param>
|
|
/// <returns></returns>
|
|
public static int getMrpPlanAdd(string operType, string billno, out string tipMsg)
|
|
{
|
|
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
|
pMsg.Direction = ParameterDirection.Output;
|
|
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
|
returnValue.Direction = ParameterDirection.ReturnValue;
|
|
SqlParameter[] param =
|
|
{
|
|
new SqlParameter("@operType",SqlDbType.VarChar,50),
|
|
new SqlParameter("@billno",SqlDbType.VarChar,50),
|
|
new SqlParameter("@operatorid",SqlDbType.Int),
|
|
new SqlParameter("@operatorname",SqlDbType.VarChar,50),
|
|
pMsg,
|
|
returnValue
|
|
};
|
|
param[0].Value = operType;
|
|
param[1].Value = billno;
|
|
param[2].Value = ERPInfo.Instance.UserId;
|
|
param[3].Value = ERPInfo.Instance.UserName;
|
|
tipMsg = pMsg.Value + "";
|
|
BaseImpl.ExecProcedure("[pr_mrp_planadd]", param);
|
|
tipMsg = pMsg.Value + "";
|
|
return Convert.ToInt32(returnValue.Value.ToString());
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取表的主键值</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-05-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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 = MainImpl.GetDatabaseProperty(TableName);
|
|
//DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue);
|
|
return (dtTable.Rows.Count > 0) ? dtTable.Rows[0]["COLUMN_NAME"] + "" : string.Empty;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取表中是否包含其主键列</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-04-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static bool GetIsContainKey(string TableName, string ParmaryKey, string ids)
|
|
{
|
|
int idCount = ids.Split(',').Count();
|
|
string sqlValue = string.Format("SELECT * from {0} where {1} in({2})", TableName, ParmaryKey, ids);
|
|
DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue);
|
|
return dtTable != null ? dtTable.Rows.Count == idCount : false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:根据模块id判断是否设置不能同时打开多个相同模块</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2024-02-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static bool GetOpenRestrictions(string MenuId)
|
|
{
|
|
|
|
if (ERPInfo.Instance.SingleOpenMode)
|
|
{
|
|
string sqlValue = string.Format("SELECT SingleOpenMode from p_formmenuconfigtab where MenuId='{0}'", MenuId);
|
|
DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue);
|
|
if (dtTable.Rows.Count > 0)
|
|
{
|
|
return "1".Equals(dtTable.Rows[0]["SingleOpenMode"] + "");
|
|
}
|
|
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
} |