c302bb9dd6
SVN-Revision: r1247
1316 lines
65 KiB
C#
1316 lines
65 KiB
C#
/******************************
|
|
* 说明:主程序相关方法实现
|
|
* 创建人:龚宇超
|
|
* 创建日期:2017-09-01
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本:1.0.0.0
|
|
******************************/
|
|
using System;
|
|
using System.Data;
|
|
using Lskj.Core;
|
|
using Lskj.Util;
|
|
using System.Data.SqlClient;
|
|
using Lskj.Model;
|
|
using System.Net;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Kdbndp;
|
|
using KdbndpTypes;
|
|
|
|
namespace Lskj.Business.Impl
|
|
{
|
|
/// <summary>
|
|
/// 主程序相关方法实现
|
|
/// </summary>
|
|
public class MainImpl : BaseImpl
|
|
{
|
|
/// <summary>
|
|
/// <para>说明:解析配置的域名dns</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static void DnsHostEntry()
|
|
{
|
|
try
|
|
{
|
|
// 创建DNS字段
|
|
string sqlValue = "alter table p_systemtab add DnsHostEntry varchar(50)";
|
|
int result = SqlHelper.ExecuteNonQuery(sqlValue);
|
|
|
|
sqlValue = "update p_systemtab set DnsHostEntry = InternetIP";
|
|
result = SqlHelper.ExecuteNonQuery(sqlValue);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
|
|
try
|
|
{
|
|
// 修改dns值
|
|
string sqlValue = "select DnsHostEntry from p_systemtab";
|
|
DataRow rowItem = GetDataRowResult(sqlValue);
|
|
if (rowItem != null)
|
|
{
|
|
string dnsHostEntry = rowItem["DnsHostEntry"] + "";
|
|
string startHost = dnsHostEntry.Substring(0, dnsHostEntry.IndexOf("."));
|
|
int startNumber = 0;
|
|
if (!string.IsNullOrWhiteSpace(dnsHostEntry) && !Int32.TryParse(startHost, out startNumber))
|
|
{
|
|
string ipAddress = Dns.GetHostEntry(dnsHostEntry).AddressList[0] + "";
|
|
sqlValue = string.Format("update p_systemtab set InternetIP = '{0}'", ipAddress);
|
|
SqlHelper.ExecuteNonQuery(sqlValue);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:登录</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="userId">用户名Id</param>
|
|
/// <param name="password">密码</param>
|
|
/// <param name="isConstraint">是否强制登录</param>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int Login(string userId, string password, bool isConstraint)
|
|
{
|
|
password = SHAHelper.EncryptPassword(password);//密码加密
|
|
//强制登陆
|
|
if (isConstraint)
|
|
{
|
|
string tmpsql = string.Format("delete from p_LoginHostInfotab where OperatorId='{0}' and Tagid=1", userId);
|
|
SqlHelper.ExecuteNonQuery(CommandType.Text, tmpsql);
|
|
}
|
|
List<SqlParameter> list = new List<SqlParameter>
|
|
{
|
|
new SqlParameter("@ReturnValue",SqlDbType.NVarChar),
|
|
new SqlParameter("@operatorid",SqlDbType.VarChar),
|
|
new SqlParameter("@pwd",SqlDbType.VarChar,100),
|
|
};
|
|
if (SystemInfo.Instance.IsEncrypt)
|
|
{
|
|
list.Add(new SqlParameter("@IsEncrypt", SqlDbType.VarChar, 100));
|
|
}
|
|
SqlParameter[] cmdParams = list.ToArray();
|
|
cmdParams[0].Direction = ParameterDirection.ReturnValue;
|
|
cmdParams[1].Value = userId;
|
|
cmdParams[2].Value = password;
|
|
if (cmdParams.Length > 7)
|
|
{
|
|
cmdParams[7].Value = 1;
|
|
}
|
|
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "P_Login_pr", cmdParams);
|
|
return Convert.ToInt32(cmdParams[0].Value);
|
|
}
|
|
public static int MesLogin(string userCode, string password, bool isConstraint)
|
|
{
|
|
password = SHAHelper.EncryptPassword(password);
|
|
|
|
//强制登陆
|
|
//if (isConstraint)
|
|
//{
|
|
try
|
|
{
|
|
DataRow UserTable = MainImpl.MesGetUserID(userCode);
|
|
if (UserTable != null)
|
|
{
|
|
string tmpsql = string.Format("delete from p_LoginHostInfotab where OperatorId='{0}' and Tagid=4", UserTable["employeeid"] + "");
|
|
SqlHelper.ExecuteNonQuery(CommandType.Text, tmpsql);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
//}
|
|
SqlParameter[] cmdParams = new SqlParameter[]
|
|
{
|
|
new SqlParameter("@ReturnValue",SqlDbType.Int),
|
|
new SqlParameter("@operatorid",SqlDbType.VarChar),
|
|
new SqlParameter("@pwd",SqlDbType.VarChar,100),
|
|
new SqlParameter("@LoginAccount",SqlDbType.VarChar,100),
|
|
new SqlParameter("@ClientIP",SqlDbType.VarChar,100),
|
|
new SqlParameter("@LoginType",SqlDbType.Int),
|
|
};
|
|
cmdParams[0].Direction = ParameterDirection.ReturnValue;
|
|
cmdParams[1].Value = userCode;
|
|
cmdParams[2].Value = password;
|
|
cmdParams[3].Value = "";
|
|
cmdParams[4].Value = "";
|
|
cmdParams[5].Value = 4;
|
|
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "P_Login_pr", cmdParams);
|
|
return Convert.ToInt32(cmdParams[0].Value);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:强制修改密码</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="pass_before">The pass_before.</param>
|
|
/// <param name="pass_after">The pass_after.</param>
|
|
/// <returns>1.修改成功;0.修改失败,用户不存在</returns>
|
|
public static int ForceUpdatePassword(string userId, string password)
|
|
{
|
|
DataTable dtTable = GetEmployeeList(userId);
|
|
if (dtTable.Rows.Count == 0) return 0;
|
|
|
|
//md5加密密码
|
|
string mdpassword = SHAHelper.GetMd5Hash(password);
|
|
|
|
password = SHAHelper.EncryptPassword(password);
|
|
|
|
string sqlValue = string.Format("update P_EmployeeTab set password='{0}' where employeeId='{1}'", password, userId);
|
|
|
|
if (BaseImpl.HasExistsColumn("P_EmployeeTab", "p_emp_password"))
|
|
{
|
|
sqlValue = string.Format("update P_EmployeeTab set password='{0}',p_emp_password='{1}' where EmployeeId='{2}' select @@ROWCOUNT", password, mdpassword, userId);
|
|
}
|
|
int result = SqlHelper.ExecuteNonQuery(sqlValue);
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:修改密码</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-15 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>0.用户不存在.1.修改成功.2.旧密码错误.</returns>
|
|
public static int UpdatePassword(string userId, string beforePass, string afterPass)
|
|
{
|
|
// 检查用户是否存在
|
|
//string sqlValue = string.Format("select password from P_EmployeeTab WHERE sign=0 and UseFlag=1 and EmployeeId='{0}' order by loginaccount", userId);
|
|
//string password = SqlHelper.ExecuteString("password", sqlValue);
|
|
//if (string.IsNullOrWhiteSpace(password)) return 0;
|
|
DataTable dtTable = GetEmployeeList(userId);
|
|
if (dtTable.Rows.Count == 0) return 0;
|
|
string sqlValue = string.Format("select password from P_EmployeeTab WHERE sign=0 and UseFlag=1 and EmployeeId='{0}' order by loginaccount", userId);
|
|
string password = SqlHelper.ExecuteString("password", sqlValue);
|
|
|
|
//md5加密密码
|
|
string mdpassword = SHAHelper.GetMd5Hash(afterPass);
|
|
|
|
beforePass = SHAHelper.EncryptPassword(beforePass);
|
|
afterPass = SHAHelper.EncryptPassword(afterPass);
|
|
|
|
|
|
// 检查旧密码是否一致
|
|
if (!password.Equals(beforePass)&&!string.IsNullOrWhiteSpace(password)) return 2;
|
|
|
|
sqlValue = string.Format("update P_EmployeeTab set password='{0}' where EmployeeId='{1}' select @@ROWCOUNT", afterPass, userId);
|
|
|
|
if (BaseImpl.HasExistsColumn("P_EmployeeTab", "p_emp_password"))
|
|
{
|
|
sqlValue = string.Format("update P_EmployeeTab set password='{0}',p_emp_password='{1}' where EmployeeId='{2}' select @@ROWCOUNT", afterPass, mdpassword, userId);
|
|
}
|
|
|
|
|
|
DataTable dt = SqlHelper.ExecuteDataTable(sqlValue);
|
|
int numberOfAffectedRows = dt != null && dt.Rows.Count > 0 ? int.Parse(dt.Rows[0][0] + "") : 0;
|
|
return numberOfAffectedRows;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改密码,传入到存储过程中处理
|
|
/// </summary>
|
|
/// <param name="personid"></param>
|
|
/// <param name="newpsw"></param>
|
|
/// <param name="tipMsg"></param>
|
|
/// <returns></returns>
|
|
public static int ChangePassword(string personid, string newpsw, out string tipMsg)
|
|
{
|
|
try
|
|
{
|
|
//md5加密密码
|
|
//string mdpassword = SHAHelper.GetMd5Hash(newpsw);
|
|
newpsw = SHAHelper.EncryptPassword(newpsw);
|
|
|
|
SqlParameter pMsg = ERPInfo.Instance.ChangeParameterType ? new SqlParameter("@msg", SqlDbType.NVarChar, 4000) : 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("@personid",SqlDbType.Int),
|
|
new SqlParameter("@newpsw",SqlDbType.VarChar),
|
|
pMsg,
|
|
returnValue
|
|
};
|
|
param[0].Value = personid;
|
|
param[1].Value = newpsw;
|
|
param[2].Value = "";
|
|
|
|
int result = MainImpl.ExecProcedure("pr_sytemchangepsw", param);
|
|
tipMsg = pMsg.Value.ToString();
|
|
int rValue = Convert.ToInt32(returnValue.Value);
|
|
return rValue;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
tipMsg = ex.Message;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 记录修改后的密码
|
|
/// </summary>
|
|
/// <param name="userId"></param>
|
|
/// <param name="afterPass"></param>
|
|
/// <returns></returns>
|
|
public static bool RecordPassword(string afterPass)
|
|
{
|
|
try
|
|
{
|
|
//加密密码
|
|
afterPass = AESUtil.Encrypt(afterPass);
|
|
LogUtil.WriteDebug("", "修改密码", afterPass, "");
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:跨数据库修改密码</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2023-05-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static bool UpdatePasswordAllSubsystem(string userId, string afterPass)
|
|
{
|
|
try
|
|
{
|
|
string condition = string.Format("where ShowName !='{0}'", ERPInfo.Instance.AccountBook);
|
|
//获取套账表格
|
|
DataTable subsystemDt = MainImpl.GetLedgerList(condition);
|
|
//让数据库可以跨数据库操作
|
|
BaseImpl.ExecSqlValue("exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure");
|
|
string Connection1 = "QkYyNjE3QTcxQjc4RDFFMDlERjlFMDc1QkIyMDVGRjdDRUIyMEVEOUM5NjBCQjc5NTA5NzdEQTk0MkNEQTE1RTFGMEIwMThFNUJDQTE0RjE1NjQwM0U5QTYxMThCMDY2MTA4NkE2OTIxNTNBQjQ0MjRDMDIwM0Q5OEVDQjkwQTVCN0RENjJBODkxNUNGOUM5OEI5RTEzN0E3ODBERjg2OURCNEQ5QTlCMzhCQUZGQ0FBNUREMjY4M0FCODg2RTkxMDRERTQ3MjRGQTE1MERDOTJGRDFDRjY2REQ1ODYyREUzN0RGM0ZBQzc4NzJENjIwNDg4RUUyNkI3ODE1RjlDM0I0MjNCQzcyOENDN0VDMTg0QUU0MjgwMDVDMENBOUZF";
|
|
int numberOfAffectedRows = 0;
|
|
afterPass = SHAHelper.EncryptPassword(afterPass);
|
|
foreach (DataRow dr in subsystemDt.Rows)
|
|
{
|
|
try
|
|
{
|
|
string Ip = dr["IP"] + "";
|
|
string DBname = dr["DBname"] + "";
|
|
string link = string.Format(AESUtil.Decrypt(Connection1), Ip, DBname);
|
|
//跨库修改
|
|
string sqlValue = string.Format("update OPENDATASOURCE( 'SQLOLEDB ', '{0}').{1}.dbo.P_EmployeeTab set password='{2}' where EmployeeId='{3}' select @@ROWCOUNT", link, DBname, afterPass, userId);
|
|
DataTable dt = SqlHelper.ExecuteDataTable(sqlValue);
|
|
numberOfAffectedRows += dt != null && dt.Rows.Count > 0 ? int.Parse(dt.Rows[0][0] + "") : 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorMessage.PromptErrorMessage(ex);
|
|
}
|
|
}
|
|
//关闭跨数据库权限
|
|
BaseImpl.ExecSqlValue("exec sp_configure 'Ad Hoc Distributed Queries',0 reconfigure exec sp_configure 'show advanced options',0 reconfigure");
|
|
return subsystemDt.Rows.Count == numberOfAffectedRows;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
ErrorMessage.PromptErrorMessage(e);
|
|
BaseImpl.ExecSqlValue("exec sp_configure 'Ad Hoc Distributed Queries',0 reconfigure exec sp_configure 'show advanced options',0 reconfigure");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:保存用户皮肤</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-26 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="skinName">Name of the skin.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static int SaveUserSkin(string skinName)
|
|
{
|
|
string sqlValue = string.Format("update p_EmployeeTab set {0}='{1}' where employeeId='{2}'", ERPInfo.Instance.SkinFieldName, skinName, ERPInfo.Instance.UserId);
|
|
return SqlHelper.ExecuteNonQuery(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:检查Mac地址过滤</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="macAddress">The mac address.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int CheckMacAddress(string macAddress, string username)
|
|
{
|
|
// 不存在表
|
|
if (!HasExistsTable("P_SystemMacTab")) return -1;
|
|
|
|
string sqlValue = string.Format("select * from P_SystemMacTab where MacAddress='{0}' and UserName ='{1}' and isnull(Enabled,0)=0", macAddress, username);
|
|
|
|
return GetDataRowResult(sqlValue) != null ? 1 : 0;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:记录登陆者的mac地址</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-10-30 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="macAddress">The mac address.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
public static void LoginAfterRegister(string macAddress, string username)
|
|
{
|
|
// 不存在表
|
|
if (!HasExistsTable("HR_MacAddresstab")) return;
|
|
string sqlValue = string.Format("insert into HR_MacAddresstab (UserName,MacAddress,Operatedate) values('{0}','{1}','{2}')", username, macAddress, DateTime.Now + "");
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取用户皮肤</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-26 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
public static string GetUserSkin(string userId)
|
|
{
|
|
if (!HasExistsColumn("P_employeeTab", "SkinName"))
|
|
{
|
|
SqlHelper.ExecuteNonQuery("alter table P_employeeTab add SkinName varchar(50)");
|
|
}
|
|
|
|
string sqlValue = string.Format("select SkinName from P_employeeTab where employeeId='{0}'", userId);
|
|
|
|
return GetResult(sqlValue) + "";
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取可用的子系统数量</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.Int32.</returns>
|
|
public static DataTable EnableSubSystem(string where = "")
|
|
{
|
|
string sqlValue = string.Format("select SubSysId,SubSysName from P_SubSystemTab where UseEd=1 {0} order by orderid", where);
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取单个模块信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
/// <returns>DataRow.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static DataRow GetSystemdllTab(string menuCode)
|
|
{
|
|
string sqlValue = $"select * from P_systemdlltab where DllCoid = '{menuCode}'";
|
|
DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue);//执行sql返回DataTable
|
|
return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取员工信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="userId">The user identifier.</param>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetEmployeeList(string userId = null)
|
|
{
|
|
string sqlWhere = string.Empty;
|
|
string fields = string.Empty;
|
|
if (!string.IsNullOrWhiteSpace(userId))
|
|
sqlWhere = string.Format(" and EmployeeId='{0}'", userId);
|
|
|
|
DataTable dataTable = GetTableColumns("P_EmployeeTab");
|
|
if (dataTable.Columns.Contains("SignBmp"))
|
|
fields = ",SignBmp";
|
|
if (dataTable.Columns.Contains("Password"))
|
|
fields += ",Password";
|
|
if (dataTable.Columns.Contains("AD_Id"))
|
|
fields += ",AD_Id";
|
|
if (dataTable.Columns.Contains("useLanguage"))
|
|
fields += ",useLanguage";
|
|
if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.LoginUsername) && dataTable.Columns.Contains(SystemInfo.Instance.LoginUsername))
|
|
{
|
|
fields += " ," + SystemInfo.Instance.LoginUsername;
|
|
}
|
|
//if (HasExistsColumn("P_EmployeeTab", "DefaultLedger"))
|
|
// fields += ",DefaultLedger";
|
|
string sqlValue = string.Format("select EmployeeId UserId,LoginAccount UserCode,EmployeeName UserName {1} from P_EmployeeTab WHERE sign=0 and UseFlag=1 {0} order by loginaccount", sqlWhere, fields);
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取mes系统员工信息</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2023-12-05 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetMesEmployeeList()
|
|
{
|
|
|
|
string conditions = string.Empty;
|
|
string fields = string.Empty;
|
|
DataTable dataTable = GetTableColumns("P_EmployeeTab");
|
|
|
|
if (dataTable.Columns.Contains("SignBmp"))
|
|
fields = ",SignBmp";
|
|
if (dataTable.Columns.Contains("Password"))
|
|
fields += ",Password";
|
|
if (dataTable.Columns.Contains("AD_Id"))
|
|
fields += ",AD_Id";
|
|
if (dataTable.Columns.Contains("useLanguage"))
|
|
fields += ",useLanguage";
|
|
if (dataTable.Columns.Contains("mestig"))
|
|
{
|
|
conditions = "and mestig=1";
|
|
}
|
|
|
|
|
|
string sqlValue = string.Format("select EmployeeId UserId,LoginAccount UserCode,EmployeeName UserName {1} from P_EmployeeTab WHERE sign=0 and UseFlag=1 {0} order by loginaccount", conditions, fields);
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取员工信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="userId">The user identifier.</param>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetEmployeeListNew(string userId = null)
|
|
{
|
|
string sqlWhere = string.Empty;
|
|
string fields = string.Empty;
|
|
if (!string.IsNullOrWhiteSpace(userId))
|
|
sqlWhere = string.Format(" and EmployeeId='{0}'", userId);
|
|
|
|
DataTable dataTable = GetTableColumns("P_EmployeeTab");
|
|
|
|
if (dataTable.Columns.Contains("SignBmp"))
|
|
fields = ",SignBmp";
|
|
if (dataTable.Columns.Contains("Password"))
|
|
fields += ",Password";
|
|
if (dataTable.Columns.Contains("AD_Id"))
|
|
fields += ",AD_Id";
|
|
if (dataTable.Columns.Contains("useLanguage"))
|
|
fields += ",useLanguage";
|
|
if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.LoginUsername)&& dataTable.Columns.Contains(SystemInfo.Instance.LoginUsername))
|
|
{
|
|
fields += " ," + SystemInfo.Instance.LoginUsername;
|
|
}
|
|
|
|
//if (HasExistsColumn("P_EmployeeTab", "DefaultLedger"))
|
|
// fields += ",DefaultLedger";
|
|
|
|
string sqlValue = string.Format("select EmployeeId UserId,LoginAccount UserCode,EmployeeName UserName,LoginAccount 工号 {1} from P_EmployeeTab WHERE sign=0 and UseFlag=1 {0} order by loginaccount", sqlWhere, fields);
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取帐套信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetLedgerList(string where = null)
|
|
{
|
|
string sqlValue = string.Format("select * from p_sydbGroupTab " + where + " order by orderid ");
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取方案信息</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-11-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetProgramme(string where = null)
|
|
{
|
|
string sqlValue = string.Format("select id,SeriesName,SeriesScript remark from p_systemproductseriestab");
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取全部子系统信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetSubSystems(string where = "")
|
|
{
|
|
try
|
|
{
|
|
string sqlValue = string.Format("select * from P_SubSystemTab where ISNULL(visible,0)=0 and SubSysId<>0 {0} order by UseEd desc,orderid,right('000'+cast(showid as varchar),3)+right('0000'+cast(SubSysId as varchar),4)", where);
|
|
if (!ERPInfo.Instance.IsUserManager && SystemInfo.Instance.MainMenuType > 2)//是超级管理员,并且主要菜单类型>2
|
|
{
|
|
sqlValue = string.Format(@"select * from P_SubSystemTab
|
|
where ISNULL(visible,0)=0 and SubSysId in (
|
|
select SubSysId from P_FormMenuConfigTab
|
|
where 1=1 and useed=1 and isnull(dllfilename,'')<>'' " + GetPurviewCond() + @" ) {0}
|
|
order by UseEd desc,orderid,right('000'+cast(showid as varchar),3)+right('0000'+cast(SubSysId as varchar),4)", where);
|
|
}
|
|
return SqlHelper.ExecuteDataSet(sqlValue).Tables[0];
|
|
}
|
|
catch (Exception)
|
|
{
|
|
string sqlValue = "select * from P_SubSystemTab where SubSysId<>0 order by UseEd desc,right('000'+cast(showid as varchar),3)+right('0000'+cast(SubSysId as varchar),4)";
|
|
if (!ERPInfo.Instance.IsUserManager && SystemInfo.Instance.MainMenuType > 2)
|
|
{
|
|
sqlValue = @"select * from P_SubSystemTab
|
|
where SubSysId in (
|
|
select SubSysId from P_FormMenuConfigTab
|
|
where 1=1 and useed=1 and isnull(dllfilename,'')<>'' " + GetPurviewCond() + @" )
|
|
order by UseEd desc,right('000'+cast(showid as varchar),3)+right('0000'+cast(SubSysId as varchar),4)";
|
|
}
|
|
return SqlHelper.ExecuteDataSet(sqlValue).Tables[0];
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:根据配置MenuType加载菜单</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetMenusByMenuType(out string menuSql)
|
|
{
|
|
// MainMenuType:1: 加载子系统菜单数据,2.加载所有菜单,3.加载子系统权限菜单,4.加载所有权限菜单
|
|
int menutype = SystemInfo.Instance.MainMenuType;
|
|
string condWhere = string.Empty;
|
|
string sqlValue = string.Empty;
|
|
if (menutype > 2)
|
|
{
|
|
// 获取权限
|
|
condWhere = GetPurviewCond();
|
|
}
|
|
DataTable dataTable = GetTableColumns("P_FormMenuConfigTab");
|
|
if (dataTable.Columns.Contains("useFlag"))
|
|
{
|
|
// 获取可用菜单标识
|
|
condWhere += " and isnull(useFlag,0)=1";
|
|
}
|
|
if (dataTable.Columns.Contains("TargetMode"))
|
|
{
|
|
// 获取CS端显示标识(0 全部、1cs、 2 手机、3、bs)
|
|
condWhere += " and isnull(TargetMode,0) in (0,1)";
|
|
}
|
|
string fields = string.Empty, field = string.Empty;
|
|
if (dataTable.Columns.Contains("menuRow"))
|
|
{
|
|
fields += ",menuRow";
|
|
field += "a.menuRow,";
|
|
}
|
|
if (dataTable.Columns.Contains("menuposition"))
|
|
{
|
|
fields += ",isnull(menuposition,0)";
|
|
field += "isnull(a.menuposition,0) as menuposition,";
|
|
}
|
|
if (dataTable.Columns.Contains("GroupCaption"))
|
|
{
|
|
fields += ",GroupCaption";
|
|
field += "a.GroupCaption,";
|
|
}
|
|
string SeriesConds = string.Empty; string SeriesCond = string.Empty;
|
|
if (dataTable.Columns.Contains("SeriesId") && !string.IsNullOrEmpty(ERPInfo.Instance.SeriesId))
|
|
{
|
|
SeriesConds = ",SeriesId";
|
|
SeriesCond = "a.SeriesId,";
|
|
}
|
|
|
|
string countSqlconditions = string.Empty;
|
|
string countSql = string.Empty;
|
|
if (SystemInfo.Instance.BillCornerMark && HasExistsColumn("P_systemdlltab", "countSql") && HasExistsColumn("p_systembilltype", "countSql"))
|
|
{
|
|
|
|
countSqlconditions = string.Format(@"left join P_systemdlltab e on a.PurviewId=e.DllCoid
|
|
left join (
|
|
select a.menuid as mkid , e.typecode ,countSql
|
|
from p_formmenuconfigtab a
|
|
left join p_systembilltype e on a.PurviewId=e.typecode
|
|
where 1=1 {0}
|
|
)x on a.menuid=x.mkid ", string.IsNullOrWhiteSpace(SystemInfo.Instance.DocumentQuantityLimit) ? "and DllFileName in ('Lskj.PubBill.dll')" : SystemInfo.Instance.DocumentQuantityLimit);
|
|
countSql = "(select (CASE isnull(e.countSql,'') WHEN '' THEN (x.countSql) ELSE(e.countSql)END )) as'countSql',";//如果e.countSql为空,就用x.countSql,否则还是e.countSql
|
|
}
|
|
else if (HasExistsColumn("P_systemdlltab", "countSql"))
|
|
{
|
|
countSqlconditions = " left join P_systemdlltab e on a.PurviewId=e.DllCoid ";
|
|
countSql = "e.countSql as countSql,";
|
|
}
|
|
else if (SystemInfo.Instance.BillCornerMark && HasExistsColumn("p_systembilltype", "countSql"))
|
|
{
|
|
//countSqlconditions = "left join p_systembilltype x on a.PurviewId=x.typecode ";
|
|
//countSql = " x.countSql as countSqlBill,";
|
|
countSqlconditions = string.Format(@"
|
|
left join (
|
|
select a.menuid as mkid , e.typecode ,countSql
|
|
from p_formmenuconfigtab a
|
|
left join p_systembilltype e on a.PurviewId=e.typecode
|
|
where 1=1 {0}
|
|
)x on a.menuid=x.mkid ", string.IsNullOrWhiteSpace(SystemInfo.Instance.DocumentQuantityLimit) ? "and DllFileName in ('Lskj.PubBill.dll')" : SystemInfo.Instance.DocumentQuantityLimit);
|
|
countSql = " x.countSql as countSql,";
|
|
}
|
|
|
|
|
|
|
|
|
|
if (SystemInfo.Instance.DefaultMainTag == 2)
|
|
{
|
|
sqlValue = string.Format(@"select * from (select MenuId,MouseOutImg,MouseOverImg1,MenuCaption,DllFileName,MenuStruct,PurviewId,UrlParams,SubSysId {2} {3}
|
|
FROM p_formmenuconfigtab
|
|
WHERE SubSysId={0} {1}) x
|
|
inner join (select left(MenuStruct,2) as MenuStruct,count(1) as menucount
|
|
FROM p_formmenuconfigtab
|
|
WHERE SubSysId={0} and LEN(MenuStruct)=4 and isnull(dllfilename,'')<>'' {1}
|
|
group by left(MenuStruct,2) ) y on left(x.menustruct,2)=y.menustruct
|
|
where LEN(x.MenuStruct)=2
|
|
ORDER BY x.menustruct", ERPInfo.Instance.SubSysId, condWhere, fields, SeriesConds);
|
|
}
|
|
else
|
|
{
|
|
if (menutype == 1 || menutype == 3)
|
|
{
|
|
// 加载子系统下的菜单数据
|
|
sqlValue = string.Format(@"select * from (
|
|
select a.MenuId,a.MouseOutImg,a.MouseOverImg1,a.MenuCaption,a.DllFileName,a.MenuStruct,a.PurviewId,a.UrlParams,a.subsysid,{1} {2} {3}
|
|
z.SubSysName,MenuCaption+'-'+z.SubSysName SearchMenuCaption
|
|
FROM p_formmenuconfigtab a
|
|
{4}
|
|
left join P_SubSystemTab z on a.SubSysId=z.SubSysId
|
|
WHERE z.SubSysId={0} " + condWhere + @") x
|
|
inner join (select left(MenuStruct,2) as MenuStruct,count(1) as menucount
|
|
FROM p_formmenuconfigtab
|
|
WHERE SubSysId={0} and isnull(dllfilename,'')<>'' " + condWhere + @"
|
|
group by left(MenuStruct,2) ) y on left(x.menustruct,2)=y.menustruct
|
|
ORDER BY x.menustruct", ERPInfo.Instance.SubSysId, field, SeriesCond, countSql, countSqlconditions);
|
|
}
|
|
else
|
|
{
|
|
// 加载所有菜单下的数据
|
|
sqlValue = string.Format(@"select * from (
|
|
select a.MenuId,a.MouseOutImg,a.MouseOverImg1,a.MenuCaption,a.DllFileName,a.MenuStruct,a.PurviewId,a.UrlParams,a.subsysid,{0} {1} {2}
|
|
z.SubSysName,MenuCaption+'-'+z.SubSysName SearchMenuCaption
|
|
FROM p_formmenuconfigtab a
|
|
{3}
|
|
left join P_SubSystemTab z on a.SubSysId=z.SubSysId
|
|
WHERE 1=1 " + condWhere + @") x
|
|
inner join (select left(MenuStruct,2) as MenuStruct,count(1) as menucount
|
|
FROM p_formmenuconfigtab
|
|
WHERE isnull(dllfilename,'')<>'' " + condWhere + @"
|
|
group by left(MenuStruct,2) ) y on left(x.menustruct,2)=y.menustruct
|
|
ORDER BY x.menustruct", field, SeriesCond, countSql, countSqlconditions);
|
|
}
|
|
}
|
|
// and LEN(MenuStruct)>0
|
|
menuSql = string.Format(@"select * from (
|
|
select a.MenuId,a.MouseOutImg,a.MouseOverImg1,a.MenuCaption,a.DllFileName,a.MenuStruct,a.PurviewId,a.UrlParams,a.subsysid,{0} {1}
|
|
z.SubSysName,MenuCaption+'-'+z.SubSysName SearchMenuCaption
|
|
FROM p_formmenuconfigtab a
|
|
left join P_SubSystemTab z on a.SubSysId=z.SubSysId
|
|
WHERE 1=1 " + condWhere + @") x
|
|
where LEN(x.MenuStruct)=4", field, SeriesCond);
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:根据用户ID获取快捷通道数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetGallerysByUserId(string userId = null)
|
|
{
|
|
|
|
//string sql = string.Format(@"select a.*,b.PurviewId from
|
|
// (select * from P_RoleShortcut where EmployeeID in ( select roleId from p_systemRoleOperSetTab where roleOperatorId='{0}') and grouptagid in ('1','2'))
|
|
// a join p_formmenuconfigtab b on a.LMenuId=b.MenuId where LinkModeTag=1 order by grouptagid,ItemTagId", ERPInfo.Instance.UserId);
|
|
|
|
//P_MessageToolLinkDllTab表中cardId=-99为通用模块(右侧快捷通道通用模块) 2023-12-4 徐成说的cardId=-99的配置
|
|
if (!BaseImpl.HasExistsColumn("P_MessageToolLinkDllTab", "cardId"))
|
|
{
|
|
SqlHelper.ExecuteNonQuery("alter table P_MessageToolLinkDllTab add cardId int");
|
|
}
|
|
string sqlValue = string.Format("select a.*,b.PurviewId,b.MouseOutImg,b.MouseOverImg1,b.DllFileName,z.SubSysName,b.menucaption from(select * from P_MessageToolLinkDllTab where employeeid={0} and ( grouptagid=2 or grouptagid=1) and isnull(cardId,0) !=-99 "
|
|
+ " union "
|
|
+ " select * from P_MessageToolLinkDllTab where cardId=-99 and ( grouptagid=2 or grouptagid=1) "
|
|
+ ")a join p_formmenuconfigtab b on a.LMenuId=b.MenuId" +
|
|
" left join P_SubSystemTab z on a.LSubSysId=z.SubSysId where LinkModeTag=1 order by grouptagid,ItemTagId", ERPInfo.Instance.UserId);
|
|
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:根据用户ID获取快捷通道数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable newGetGallerysByUserId(string userId)
|
|
{
|
|
//P_MessageToolLinkDllTab表中cardId=-99为通用模块(右侧快捷通道通用模块) 2023-12-4 徐成说的cardId=-99的配置
|
|
string sqlValue = string.Format("select a.*,b.PurviewId,b.MouseOutImg,b.MouseOverImg1 from(select * from P_MessageToolLinkDllTab where employeeid='{0}' and ( grouptagid=2 or grouptagid=1) and isnull(cardId,0) !=-99 "
|
|
+ " union "
|
|
+ " 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 order by grouptagid,ItemTagId", userId);
|
|
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:根据用户ID获取快捷通道数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetPrivatesByUserId()
|
|
{
|
|
string sqlValue = string.Format("select * from P_PrivateDllTab where privateTag = 1");
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:根据用户ID获取快捷通道数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetGallerysByRoleId(string userId)
|
|
{
|
|
string sqlValue = string.Format("select a.*,b.PurviewId from(select * from P_RoleShortcut where employeeid='{0}' and grouptagid=1 "
|
|
+ " union "
|
|
+ " select * from P_RoleShortcut where employeeid='{0}' and grouptagid=2 "
|
|
+ ")a join p_formmenuconfigtab b on a.LMenuId=b.MenuId where LinkModeTag=1 order by grouptagid,ItemTagId", userId);
|
|
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取当前登录用户对应子系统的通知数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-17 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="subsysId">The subsys identifier.</param>
|
|
/// <param name="userId">The user identifier.</param>
|
|
/// <returns>DataTable.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static DataTable GetNotifys(string subsysId, string userId)
|
|
{
|
|
if (string.IsNullOrEmpty(subsysId) || string.IsNullOrEmpty(userId))
|
|
return new DataTable();
|
|
|
|
string sqlValue = string.Empty;
|
|
string billCond = string.Empty;
|
|
|
|
if (HasExistsColumn("p_systemNotification", "billdocument_id"))
|
|
billCond = " and isnull(a.billdocument_id,'')='' ";
|
|
|
|
if (HasExistsColumn("p_systemNotification", "msgid"))
|
|
{
|
|
sqlValue = string.Format(@"select distinct a.DLLCoid moduleid,sum(Cnt1) num,a.DllFileName dllname,b.MenuCaption modulename,ISNULL(MenuMode_Mobile,0) menumode,b.menuid from p_systemNotification a WITH (NOLOCK)
|
|
inner join P_FormMenuConfigTab b WITH (NOLOCK) ON ISNULL(a.menuid,0)=b.MenuId where isnull(a.status,0)=0 and isnull(a.Cnt1,0)<>0 and msgid='1' and a.UserId={0} and b.SubSysId={1} group by a.DLLCoid,TypeId,a.DllFileName,isnull(MenuMode_Mobile,0),b.MenuId,b.MenuCaption", userId, subsysId);
|
|
}
|
|
else
|
|
if (HasExistsColumn("p_systemNotification", "menuid"))
|
|
{
|
|
sqlValue = string.Format(@"select distinct a.DLLCoid moduleid,Cnt1 num,a.DllFileName dllname,b.MenuCaption modulename,ISNULL(MenuMode_Mobile,0) menumode,b.menuid from p_systemNotification a WITH (NOLOCK)
|
|
inner join P_FormMenuConfigTab b WITH (NOLOCK) ON ISNULL(a.menuid,0)=b.MenuId where isnull(a.status,0)=0 and isnull(a.Cnt1,0)<>0 {2} and a.UserId={0} and b.SubSysId={1}", userId, subsysId, billCond);
|
|
}
|
|
else
|
|
{
|
|
sqlValue = string.Format(@"select distinct a.DLLCoid moduleid,Cnt1 num,a.DllFileName dllname,b.MenuCaption modulename,ISNULL(MenuMode_Mobile,0) menumode,b.menuid from p_systemNotification a WITH (NOLOCK)
|
|
inner join P_FormMenuConfigTab b WITH (NOLOCK) ON a.DLLCoid=UrlParams and a.DllFileName=b.DllFileName where isnull(a.status,0)=0 and isnull(a.Cnt1,0)<>0 {2} and a.UserId={0} and b.SubSysId={1}", userId, subsysId, billCond);
|
|
}
|
|
return GetDataTableResult(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取子菜单集</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="subSysId">子模块Id</param>
|
|
/// <param name="menuStruct">菜单编号.</param>
|
|
/// <param name="purviewCond">权限设置</param>
|
|
/// <param name="configMenuVisible">菜单的显隐配置</param>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetChildsMenu(string subSysId, string menuStruct, string purviewCond)
|
|
{
|
|
|
|
string sqlValue = string.Format("select * from P_FormMenuConfigTab where subsysid='{0}' and LEN(MenuStruct)=4 and SUBSTRING(MenuStruct,1,2)='{1}' and isnull(useflag,0)=1 {2} and isnull(useFlag,0)=1 order by MenuStruct", subSysId, menuStruct, purviewCond);
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取左部分菜单树</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetLeftTreeView()
|
|
{
|
|
string sqlValue = string.Format(@"select distinct * from (
|
|
select a.* from Hr_PeraonnelSpecTab a
|
|
inner join(
|
|
select SpeciesNo,speciesname from Hr_PeraonnelSpecTab
|
|
where CHARINDEX(',{0},',','+purview+',')>0 and LEN(SpeciesNo)=6
|
|
) b on LEFT(a.SpeciesNo,4)=LEFT(b.SpeciesNo,4) or LEFT(a.SpeciesNo,2)=LEFT(b.SpeciesNo,2)
|
|
where len(a.SpeciesNo)<>6
|
|
union all
|
|
select * from Hr_PeraonnelSpecTab
|
|
where CHARINDEX(',{0},',','+purview+',')>0 and LEN(SpeciesNo)=6
|
|
)a
|
|
order by speciesno desc", ERPInfo.Instance.UserName);
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-07-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable MesGetCJ()
|
|
{
|
|
|
|
|
|
string conditions = string.Empty;
|
|
|
|
if (HasExistsColumn("mes_ws_list", "mes_ws_ban"))
|
|
{
|
|
conditions = " and isnull(mes_ws_ban,0)=0";
|
|
}
|
|
string sqlValue = string.Format("select mes_ws_id dm,mes_ws_name mc,dllcoid,mes_ws_no no from mes_ws_list where 1=1 {0}", conditions);
|
|
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:Mes获取班组信息</para>
|
|
/// <para>创建日期:2020-11-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataRow MesGetTeam()
|
|
{
|
|
if (!HasExistsTable("MES_SystemNoticeTab"))
|
|
{
|
|
return null;
|
|
}
|
|
string sqlValue = string.Format("select noticeContent from MES_SystemNoticeTab where (classname ='{0}' or ISNULL(classname,'')='') and (ISNULL(noticeoperator,'') ='' or CHARINDEX(',{1},',','+noticeoperator+',')>0) and noticedate<=GETDATE() and expirydate>=GETDATE()", ERPInfo.Instance.WorkBZ, ERPInfo.Instance.UserName);
|
|
DataTable mesTeam = SqlHelper.ExecuteDataTable(sqlValue);
|
|
return (mesTeam != null && mesTeam.Rows.Count > 0) ? mesTeam.Rows[0] : null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-07-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable MesGetJT(string cjid)
|
|
{
|
|
string Str = "";
|
|
if (HasExistsColumn("Mps_MachineSetTab", "JzName"))
|
|
{
|
|
Str = ",JzName";
|
|
}
|
|
if (HasExistsColumn("Mps_MachineSetTab", "modid"))
|
|
{
|
|
Str += ",modid";
|
|
}
|
|
string sqlValue = string.Format("select id dm,jtname mc{1} from Mps_MachineSetTab where workshopid='{0}' ", cjid, Str);
|
|
if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.MachineConditions)) sqlValue = sqlValue + SystemInfo.Instance.MachineConditions;
|
|
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:通过机台选中值改变登录人员</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-05-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataRow JTGetStaff(string jtname)
|
|
{
|
|
string Str = "";
|
|
if (HasExistsColumn("Mps_MachineSetTab", "JzName"))
|
|
{
|
|
Str = ",JzName";
|
|
}
|
|
string sqlValue = string.Format("select id dm,jtname mc{1} from Mps_MachineSetTab WHERE jtname='{0}'", jtname, Str);
|
|
DataTable mesTeam = SqlHelper.ExecuteDataTable(sqlValue);
|
|
return (mesTeam != null && mesTeam.Rows.Count > 0) ? mesTeam.Rows[0] : null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-07-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable MesGetBZ()
|
|
{
|
|
string sqlValue = string.Format("select id dm,className mc from mps_ClassTimeSetTab");
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:通过工号获取用户信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-07-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="account">The account.</param>
|
|
/// <returns>DataRow.</returns>
|
|
public static DataRow MesGetUserID(string account)
|
|
{
|
|
string sqlValue = string.Format("select * from p_employeetab where LoginAccount='{0}' or employeename='{0}'", account);
|
|
DataTable table = SqlHelper.ExecuteDataTable(sqlValue);
|
|
return table != null && table.Rows.Count > 0 ? table.Rows[0] : null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:根据用户ID获取快捷通道数据和待审核的数量</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetGallerysByUserIdAndReviewAmount(string userId = null)
|
|
{
|
|
try
|
|
{
|
|
string sqlValue = string.Format("select a.*,b.PurviewId,ss.amount from ( select * from P_MessageToolLinkDllTab where employeeid={0} and grouptagid=1 "
|
|
+ " union "
|
|
+ " select * from P_MessageToolLinkDllTab where employeeid={0} and grouptagid=2 "
|
|
+ ")a join p_formmenuconfigtab b on a.LMenuId=b.MenuId left join (select aa.UserId,aa.DLLCoid,count(1) amount from p_systemNotification aa group by aa.UserId,aa.DLLCoid) ss on ss.UserId=a.EmployeeID and ss.DLLCoid =case when len(b.PurviewId)>15 then b.PurviewId_DLLCoid else b.PurviewId end where LinkModeTag=1 order by grouptagid,ItemTagId", ERPInfo.Instance.UserId);
|
|
|
|
if (HasExistsColumn("p_systemDlltab", "countsql") && HasExistsColumn("p_systembilltype", "countSql"))
|
|
{
|
|
sqlValue = string.Format(@"select a.*,b.PurviewId,ss.amount,countsql from (
|
|
select * from P_MessageToolLinkDllTab where employeeid={0} and grouptagid=1
|
|
union
|
|
select * from P_MessageToolLinkDllTab where employeeid={0} and grouptagid=2
|
|
)a join p_formmenuconfigtab b on a.LMenuId=b.MenuId
|
|
left join (
|
|
select aa.UserId,aa.DLLCoid,count(1) amount from p_systemNotification aa group by aa.UserId,aa.DLLCoid
|
|
) ss on ss.UserId=a.EmployeeID and ss.DLLCoid =case when len(b.PurviewId)>15 then b.PurviewId_DLLCoid else b.PurviewId end
|
|
left join (
|
|
SELECT dllcoid,countsql,1 lx from p_systemDlltab where isnull(countsql,'')<>''
|
|
union all
|
|
select typecode,countsql,2 lx from p_systembilltype where isnull(countsql,'')<>''
|
|
)mk on b.PurviewId=mk.dllcoid
|
|
where LinkModeTag=1
|
|
order by grouptagid,ItemTagId ", ERPInfo.Instance.UserId);
|
|
}
|
|
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
return null;
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:通过基础模块配置的待审数量sql获得当前数量</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2022-08-2 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="account">The account.</param>
|
|
/// <returns>DataRow.</returns>
|
|
public static DataRow GetModuleDisplayQuantity(string sqlValue)
|
|
{
|
|
DataTable table = SqlHelper.ExecuteDataTable(sqlValue);
|
|
return table != null && table.Rows.Count > 0 ? table.Rows[0] : null;
|
|
}
|
|
|
|
|
|
//默认获得指定模块的待审数量
|
|
public static string GetModuleDisplayQuantityDefault(string DllId, string userId)
|
|
{
|
|
if (string.IsNullOrEmpty(DllId) || string.IsNullOrEmpty(userId))
|
|
return "0";
|
|
|
|
string sqlValue = string.Empty;
|
|
string billCond = string.Empty;
|
|
|
|
if (HasExistsColumn("p_systemNotification", "billdocument_id"))
|
|
billCond = " and isnull(a.billdocument_id,'')='' ";
|
|
|
|
if (HasExistsColumn("p_systemNotification", "msgid"))
|
|
{
|
|
sqlValue = string.Format(@"select distinct a.DLLCoid moduleid,sum(Cnt1) num,a.DllFileName dllname,b.MenuCaption modulename,ISNULL(MenuMode_Mobile,0) menumode,b.menuid from p_systemNotification a WITH (NOLOCK)
|
|
inner join P_FormMenuConfigTab b WITH (NOLOCK) ON ISNULL(a.menuid,0)=b.MenuId where isnull(a.status,0)=0 and isnull(a.Cnt1,0)<>0 and msgid='1' and a.UserId={0} and b.menuId='{1}' group by a.DLLCoid,TypeId,a.DllFileName,isnull(MenuMode_Mobile,0),b.MenuId,b.MenuCaption", userId, DllId);
|
|
}
|
|
else
|
|
if (HasExistsColumn("p_systemNotification", "menuid"))
|
|
{
|
|
sqlValue = string.Format(@"select distinct a.DLLCoid moduleid,Cnt1 num,a.DllFileName dllname,b.MenuCaption modulename,ISNULL(MenuMode_Mobile,0) menumode,b.menuid from p_systemNotification a WITH (NOLOCK)
|
|
inner join P_FormMenuConfigTab b WITH (NOLOCK) ON ISNULL(a.menuid,0)=b.MenuId where isnull(a.status,0)=0 and isnull(a.Cnt1,0)<>0 {2} and a.UserId={0} and b.menuId='{1}'", userId, DllId, billCond);
|
|
}
|
|
else
|
|
{
|
|
sqlValue = string.Format(@"select distinct a.DLLCoid moduleid,Cnt1 num,a.DllFileName dllname,b.MenuCaption modulename,ISNULL(MenuMode_Mobile,0) menumode,b.menuid from p_systemNotification a WITH (NOLOCK)
|
|
inner join P_FormMenuConfigTab b WITH (NOLOCK) ON a.DLLCoid=UrlParams and a.DllFileName=b.DllFileName where isnull(a.status,0)=0 and isnull(a.Cnt1,0)<>0 {2} and a.UserId={0} and b.menuId='{1}'", userId, DllId, billCond);
|
|
}
|
|
DataTable table = SqlHelper.ExecuteDataTable(sqlValue);
|
|
return table != null && table.Rows.Count > 0 ? table.Rows[0]["num"] + "" : "";
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取用户电话</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2022-12-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
public static string GetUserPhone(string userId)
|
|
{
|
|
if (HasExistsColumn("P_employeeTab", "p_emp_linkphone"))
|
|
{
|
|
string sqlValue = string.Format("select p_emp_linkphone from P_employeeTab where employeeId='{0}'", userId);
|
|
return GetResult(sqlValue) + "";
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:切换人员时判断条件</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2023-10-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
public static bool SwitchPermissions(string userId, string userName)
|
|
{
|
|
try
|
|
{
|
|
string sqlValue = string.Format(@"select * from P_SubSystemTab
|
|
where ISNULL(visible,0)=0 and SubSysId in (
|
|
select SubSysId from P_FormMenuConfigTab
|
|
where 1=1 and useed=1 and isnull(dllfilename,'')<>'' and (CHARINDEX(','+CAST(menuid as varchar)+',',(select top 1
|
|
','+isnull(wmsPurview,'')+','','+isnull(KcPurview,'')+','','+isnull(crmPurview,'')+','','+isnull(bomPurview,'')+','','+isnull(mpsPurview,'')+','','+isnull(mrpPurview,'')+','','+isnull(scmPurview,'')+','','+isnull(sellPurview,'')+','','+isnull(RdmPurview,'')+','','+isnull(hrPurview,'')+','','+isnull(costPurview,'')+','','+isnull(eamPurview,'')+','','+isnull(accPurview,'')+','','+isnull(oaPurview,'')+','','+isnull(BiPurview,'')+','','+isnull(QmsPurview,'')+','','+isnull(FmPurview,'')+','','+isnull(Ppurview,'')+','','+isnull(EMApurview,'')+','','+isnull(GYSpurview,'')+','','+isnull(scmtestPurview,'')+','','+isnull(CBpurview,'')+','','+isnull(PMPurview,'')+','','+isnull(SMSPurview,'')+','','+isnull(AMSPurview,'')+','','+isnull(cmspurview,'')+','','+isnull(MEspurview,'')+','','+isnull(APSPurview,'')+','','+isnull(qmcPurview,'')+','
|
|
from [p_SubsysPurviewTab]
|
|
where employeeid={0}))>0
|
|
or CHARINDEX(','+CAST(menuid as varchar)+'|,',(select top 1
|
|
','+isnull(wmsPurview,'')+'|,'','+isnull(KcPurview,'')+'|,'','+isnull(crmPurview,'')+'|,'','+isnull(bomPurview,'')+'|,'','+isnull(mpsPurview,'')+'|,'','+isnull(mrpPurview,'')+'|,'','+isnull(scmPurview,'')+'|,'','+isnull(sellPurview,'')+'|,'','+isnull(RdmPurview,'')+'|,'','+isnull(hrPurview,'')+'|,'','+isnull(costPurview,'')+'|,'','+isnull(eamPurview,'')+'|,'','+isnull(accPurview,'')+'|,'','+isnull(oaPurview,'')+'|,'','+isnull(BiPurview,'')+'|,'','+isnull(QmsPurview,'')+'|,'','+isnull(FmPurview,'')+'|,'','+isnull(Ppurview,'')+'|,'','+isnull(EMApurview,'')+'|,'','+isnull(GYSpurview,'')+'|,'','+isnull(scmtestPurview,'')+'|,'','+isnull(CBpurview,'')+'|,'','+isnull(PMPurview,'')+'|,'','+isnull(SMSPurview,'')+'|,'','+isnull(AMSPurview,'')+'|,'','+isnull(cmspurview,'')+'|,'','+isnull(MEspurview,'')+'|,'','+isnull(APSPurview,'')+'|,'','+isnull(qmcPurview,'')+'|,'
|
|
from [p_SubsysPurviewTab]
|
|
where employeeid={0}))>0 or len(menustruct)=2 or {0}=1 or '{1}'='管理员') )
|
|
order by UseEd desc,orderid,right('000'+cast(showid as varchar),3)+right('0000'+cast(SubSysId as varchar),4)", userId, userName);
|
|
DataTable table = SqlHelper.ExecuteDataTable(sqlValue);
|
|
return table != null && table.Rows.Count > 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:登录时判断mac地址</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2023-10-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
public static bool CheckingMacAddress(string userId)
|
|
{
|
|
try
|
|
{
|
|
if (SystemInfo.Instance.MacMandatoryJudgment)
|
|
{
|
|
if (HasExistsTable("P_MacAddressTable"))
|
|
{
|
|
DataTable table = SqlHelper.ExecuteDataTable(string.Format("select MacAddress from P_MacAddressTable where userid='{0}'", userId));
|
|
DataRow dataRow = table != null && table.Rows.Count > 0 ? table.Rows[0] : null;
|
|
//if (dataRow == null) return false; 没有配置就默认成功
|
|
if (dataRow != null && !string.IsNullOrWhiteSpace(dataRow["MacAddress"] + ""))
|
|
{
|
|
List<string> MacAddress = ((dataRow["MacAddress"] + "").Split(',')).ToList();
|
|
return MacAddress.Contains(ERPInfo.Instance.MacAddress);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取模块信息</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2025-03-03 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public static DataRow GetModuleInformation(string menuCode)
|
|
{
|
|
string sqlValue = string.Format("select * from p_formmenuconfigtab where PurviewId='{0}'", menuCode);
|
|
|
|
DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue);
|
|
|
|
return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取自增长列名
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string GetAutogrowcolumn(string tableName)
|
|
{
|
|
string sqlvalue = $@"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns
|
|
WHERE TABLE_NAME = '{tableName}' AND COLUMNPROPERTY(OBJECT_ID('{tableName}'),COLUMN_NAME,'IsIdentity')= 1;";
|
|
if (SqlHelper.ConnectionType == ConnectionType.DmServer)
|
|
|