639 lines
25 KiB
C#
639 lines
25 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Data;
|
||
using WMS.IData.IBase;
|
||
using WMS.DBUtility;
|
||
|
||
using WMS.IData;
|
||
using Oracle.ManagedDataAccess.Client;
|
||
using WMS.Model.Base;
|
||
using WMS.Common;
|
||
using WMS.Model.SystemManage;
|
||
|
||
namespace WMS.SqlServerData.BaseData
|
||
{
|
||
public class SystemUserData : ISystemUser
|
||
{
|
||
/// <summary>
|
||
/// 获取新的用户内部员工编号
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public string GetUserNumber()
|
||
{
|
||
string strSQL = "select NEXT VALUE FOR SEQ_USER_NUMBER";
|
||
DataTable dt = null;
|
||
dt = SystemDataObject.Instance.GetDataTable(strSQL);
|
||
string strUserNumber = string.Empty;
|
||
if (dt != null)
|
||
{
|
||
if (dt.Rows.Count > 0)
|
||
{
|
||
strUserNumber = dt.Rows[0][0].ToString();
|
||
}
|
||
}
|
||
return strUserNumber;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据用户名返回所有用户信息
|
||
///
|
||
/// </summary>
|
||
/// <param name="strUserName">用户登录编号</param>
|
||
/// <returns></returns>
|
||
public DataTable GetUserData(string strUserName)
|
||
{
|
||
///查询视图
|
||
string sqlStr = "select t_base_UserInfo.User_Id,"
|
||
+ " t_base_UserInfo.Name,"
|
||
+ " t_base_UserInfo.Phone,"
|
||
+ " t_base_UserInfo.Password,"
|
||
+ " t_base_UserInfo.Qq,"
|
||
+ " t_base_UserInfo.Email,"
|
||
+ " t_base_UserInfo.Ip,"
|
||
+ " t_base_UserInfo.USER_NUMBER,"
|
||
+ " t_base_UserInfo.USER_STATUS,"
|
||
+ " t_base_UserInfo.USRINFO_STATUS,"
|
||
+ " t_base_UserInfo.USER_ENTRY,"
|
||
+ " t_base_UserInfo.USER_DRIVING,"
|
||
+ " t_base_UserInfo.Nameshort,"
|
||
+ " t_base_UserInfo.Group_Id,"
|
||
+ " t_base_UserInfo.Role_Id,"
|
||
+ " t_base_UserInfo.Storage_Id,"
|
||
+ " t_Base_Storageinfo.Storage_name,"
|
||
+ " t_base_UserInfo.isdriver,"
|
||
+ " t_base_UserInfo.sex,"
|
||
+ " t_base_UserInfo.IMG,"
|
||
//+ " t_base_DepartmentInfo.Dep_Id, "
|
||
//+ " t_base_DepartmentInfo.Dep_Name, "
|
||
//+ " t_base_Company.Com_ID,"
|
||
//+ " t_base_Company.Com_Name,"
|
||
+ " t_base_roledictionary.role_name from t_base_UserInfo"
|
||
//+ " left join t_base_DepartmentInfo on t_base_DepartmentInfo.Dep_Id =t_base_UserInfo.Dep_Id"
|
||
+ " left join t_Base_Storageinfo on t_Base_Storageinfo.storage_ID = t_base_UserInfo.Storage_Id"
|
||
//+ " left join t_base_Company on t_base_Company.Com_Id = t_base_UserInfo.Com_Id"
|
||
+ " left join t_base_roledictionary on t_base_UserInfo.Role_Id = t_base_roledictionary.role_id where t_base_UserInfo.user_id =:user_id";
|
||
|
||
|
||
OracleParameter[] parmeter = new OracleParameter[] {
|
||
new OracleParameter(":user_id",OracleDbType.Varchar2, ParameterDirection.Input)
|
||
};
|
||
parmeter[0].Value = strUserName;
|
||
DataTable dt = new DataTable();
|
||
dt = SystemDataObject.Instance.GetDataTable(sqlStr, parmeter);
|
||
return dt;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据用户返回所有公司的信息,包括签名认证
|
||
/// </summary>
|
||
/// <param name="strUserName">当erp用户直接登录时,第三方需要传入申请的web的账户</param>
|
||
/// <returns></returns>
|
||
public DataTable GetCompanyData(string strUserName)
|
||
{
|
||
throw new Exception();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 第三方访问webservice 时,根据登录的编号返回appkey
|
||
/// </summary>
|
||
/// <param name="strUserName">输入的申请的用户编号</param>
|
||
/// <returns></returns>
|
||
public string GetCyAppkey(string strUserName)
|
||
{
|
||
throw new Exception();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 第三方访问webservice 时,根据登录的编号返回appkey
|
||
/// </summary>
|
||
/// <param name="strUserName">登录的用户编号</param>
|
||
/// <param name="appKey">appkey</param>
|
||
/// <returns></returns>
|
||
public string GetCyLinSes(string strUserName, string appKey)
|
||
{
|
||
throw new Exception();
|
||
}
|
||
|
||
#region 获取用户权限
|
||
/// <summary>
|
||
/// 获取用户权限
|
||
/// </summary>
|
||
/// <param name="UserId">用户编号</param>
|
||
/// <returns></returns>
|
||
public DataSet GetUserRole(string UserId)
|
||
{
|
||
DataSet ds = new DataSet();
|
||
//菜单权限sql
|
||
string strUserRoleMenu = GetUserRoleMenu(UserId);
|
||
//功能操作权限sql
|
||
string strUserRoleButton = GetUserRoleButton(UserId);
|
||
|
||
//List<string> list = new List<string>();
|
||
//list.Add(strUserRoleMenu);
|
||
//list.Add(strUserRoleButton);
|
||
DataTable mentable = SystemDataObject.Instance.GetDataTable(strUserRoleMenu);
|
||
DataTable roltable = SystemDataObject.Instance.GetDataTable(strUserRoleButton);
|
||
|
||
ds.Tables.Add(mentable);
|
||
ds.Tables.Add(roltable);
|
||
return ds;
|
||
|
||
}
|
||
/// <summary>
|
||
///根据用户编号返回当前的机构信息
|
||
/// </summary>
|
||
/// <param name="userId"></param>
|
||
/// <returns></returns>
|
||
public DataTable GetUserComanpy(string userId)
|
||
{
|
||
|
||
//string sqlStr = " select b.com_id,b.com_name,group_id,1 SELECTED from t_base_company b where b.com_id "
|
||
// + " in (select t.com_id from T_COMUSER t where t.userid='" + userId + "')"
|
||
// + " union "
|
||
// + " select b.com_id,b.com_name,group_id ,0 SELECTED from t_base_company b where b.com_id "
|
||
// + " not in (select t.com_id from T_COMUSER t where t.userid='" + userId + "') ";
|
||
|
||
//string sqlStr = " select b.com_id, b.com_name, group_id, 1 SELECTED"
|
||
// + " from t_base_company b "
|
||
// + " where b.com_id in "
|
||
// + " (select t.dep_id from t_Base_Userdepart t where t.user_id = '" + userId + "' )"
|
||
// + " or b.com_id in (select group_id from T_BASE_COmpany )"
|
||
// + " union "
|
||
// + " select b.com_id, b.com_name, group_id, 0 SELECTED "
|
||
// + " from t_base_company b "
|
||
// + " where b.com_id not in "
|
||
// + " (select t.dep_id from t_Base_Userdepart t where t.user_id = '" + userId + "' )"
|
||
// + " and b.com_id not in (select group_id from T_BASE_COmpany )";
|
||
|
||
|
||
string sqlStr = " select b.com_id, b.com_name, group_id,b.com_type,b.com_dpc, 1 SELECTED"
|
||
+ " from t_base_company b "
|
||
+ " where b.com_id in "
|
||
+ " (select t.dep_id from t_Base_Userdepart t where t.user_id = '" + userId + "') "
|
||
+ " union "
|
||
+ " select b.com_id, b.com_name, group_id,b.com_type,b.com_dpc, 0 SELECTED "
|
||
+ " from t_base_company b "
|
||
+ " where b.com_id not in "
|
||
+ " (select t.dep_id from t_Base_Userdepart t where t.user_id = '" + userId + "') ";
|
||
|
||
|
||
// string sqlStr = "select b.com_id,b.com_name,b.com_type,b.com_dpc, group_id,e.vc_dictionary_name as COM_TYPE_NAME,f.vc_dictionary_name as COM_DPC_NAME,1 SELECTED"
|
||
//+ " from t_base_company b "
|
||
//+ " left join T_SYS_DICTIONARY_TAB e "
|
||
//+ " on b.com_type = e.vc_char_value "
|
||
//+ " left join T_SYS_DICTIONARY_TAB f "
|
||
//+ " on b.Com_Dpc = f.vc_char_value "
|
||
//+ " where e.vc_dictionary_type = 'com_nature' "
|
||
//+ " and f.vc_dictionary_type = 'com_dep' "
|
||
//+ " and b.com_id in "
|
||
//+ " (select t.dep_id from t_Base_Userdepart t where t.user_id = '" + userId + "') "
|
||
//+ " union "
|
||
//+ " select b.com_id,b.com_name,b.com_type,b.com_dpc,group_id,e.vc_dictionary_name as COM_TYPE_NAME,f.vc_dictionary_name as COM_DPC_NAME,0 SELECTED "
|
||
//+ " from t_base_company b "
|
||
//+ " left join T_SYS_DICTIONARY_TAB e "
|
||
//+ " on b.com_type = e.vc_char_value "
|
||
//+ " left join T_SYS_DICTIONARY_TAB f "
|
||
//+ " on b.Com_Dpc = f.vc_char_value "
|
||
//+ " where e.vc_dictionary_type = 'com_nature' "
|
||
//+ " and f.vc_dictionary_type = 'com_dep' "
|
||
//+ " and b.com_id not in "
|
||
//+ " (select t.dep_id from t_Base_Userdepart t where t.user_id = '" + userId + "') ";
|
||
|
||
|
||
return SystemDataObject.Instance.GetDataTable(sqlStr);
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取用户菜单权限SQL
|
||
/// </summary>
|
||
/// <param name="UserId">用户编号</param>
|
||
/// <returns></returns>
|
||
private string GetUserRoleMenu(string UserId)
|
||
{
|
||
string sql = @" select distinct t.Menu_Id, --菜单编号
|
||
t.P_Menu_Id, --菜单父编号
|
||
t.Menu_Name, --菜单名称
|
||
t.Menu_Level, --菜单级别
|
||
t.Menu_Form, --窗体名称
|
||
t.Menu_Tag, --窗体类库名
|
||
t.Menu_Image, --菜单图片地址
|
||
t.Menu_Sort, --排序 from T_Base_Menu t
|
||
t.STATUS, t.MENU_VAL
|
||
from T_Base_Menu t
|
||
left join T_Base_MenuRole a
|
||
on t.MENU_ID = a.menu_id and a.ROLE_ID in
|
||
(select ROLE_ID FROM T_BASE_ROLE where USER_ID = '"+UserId+"') where t.status='1' order by Menu_Sort ";
|
||
|
||
|
||
|
||
return sql;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取用户功能操作权限SQL
|
||
/// </summary>
|
||
/// <param name="UserId">用户编号</param>
|
||
/// <returns></returns>
|
||
private string GetUserRoleButton(string UserId)
|
||
{
|
||
string sql =@"select distinct
|
||
t_base_FunctionInfo.Fun_Id,--功能编号
|
||
t_base_FunctionInfo.Fun_Name,--功能名称
|
||
t_base_FunctionInfo.Fun_Dictory,
|
||
t_base_FunctionInfo.FUN_METHOD,
|
||
t_base_FunctionInfo.Fun_Tag,-- 功能tag
|
||
t_base_FunctionInfo.Fun_Image,--图片地址
|
||
t_base_FunctionInfo.Fun_Sort, -- 排序
|
||
t_base_FunctionRole.Menu_Id
|
||
from
|
||
t_base_functionrole
|
||
join
|
||
t_base_FunctionInfo
|
||
on t_base_functionrole.Fun_Id = t_base_FunctionInfo.Fun_Id and t_base_functionrole.menu_id = t_base_FunctionInfo.Menu_Id
|
||
and FUN_VISIBLE='1'
|
||
|
||
where ROLE_ID in (select ROLE_ID FROM T_BASE_ROLE where USER_ID = '" + UserId + "') order by t_base_FunctionInfo.Fun_Sort";
|
||
|
||
return sql;
|
||
}
|
||
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 获取所有用户
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public DataSet GetAllUsers()
|
||
{
|
||
DataSet ds = null;
|
||
string sqlStr = "select USER_ID,COM_ID,NAME from t_base_userinfo order by USER_ID ";
|
||
|
||
//select name,user_id from t_base_userinfo
|
||
ds = SystemDataObject.Instance.GetDataSet(sqlStr);
|
||
|
||
return ds;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询所有用户
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public List<UserDataModel> GetUserInfo()
|
||
{
|
||
// string sqlStr = "select t.*,t_base_departmentinfo.Dep_Name from t_base_UserInfo t left join t_base_departmentinfo on t.dep_id = t_base_departmentinfo.dep_id";
|
||
string sqlStr = "select t.* from t_base_UserInfo t order by t.USER_ID ";
|
||
// string sqlStr =@"select t.*, c.com_name
|
||
// from t_base_UserInfo t
|
||
// left join t_Base_Userdepart u
|
||
// on u.user_id = t.user_id
|
||
// left join t_base_company c
|
||
// on u.dep_id = c.com_id";
|
||
|
||
DataTable table = SystemDataObject.Instance.GetDataTable(sqlStr);
|
||
if (table != null)
|
||
{
|
||
List<UserDataModel> userModel = ConvertHelper<UserDataModel>.ConvertToList(table);
|
||
return userModel;
|
||
}
|
||
|
||
else
|
||
{
|
||
return null;
|
||
}
|
||
}
|
||
|
||
|
||
#region 重置用户的密码
|
||
/// <summary>
|
||
/// 重置用户的密码
|
||
/// </summary>
|
||
/// <param name="userModel"></param>
|
||
public void resetPwd(string newPwd, string userID)
|
||
{
|
||
string sqlPwdSet = string.Format(@"update t_base_userinfo set PASSWORD={0}
|
||
where USER_ID={1}", newPwd, userID);
|
||
|
||
SystemDataObject.Instance.ExecuteSql(sqlPwdSet);
|
||
}
|
||
#endregion
|
||
|
||
#region 操作用户数据(新增 更新)
|
||
|
||
public void DeleteUserCompany(string userId)
|
||
{
|
||
|
||
string sqlStr = "delete T_COMUSER where userid='" + userId + "'";
|
||
SystemDataObject.Instance.ExecuteSql(sqlStr);
|
||
}
|
||
public void UpdateUserCompany(string userId, string comId, string sysUser)
|
||
{
|
||
string sqlStr = "insert into T_COMUSER (USERID,COM_ID,MODIFYDATA,MODIFYUSER)"
|
||
+ " values('" + userId + "','" + comId + "',getdate(),'" + sysUser + "')";
|
||
SystemDataObject.Instance.ExecuteSql(sqlStr);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 操作用户
|
||
/// </summary>
|
||
/// <param name="userModel">用户信息</param>
|
||
/// <param name="listComId">组织结构编号</param>
|
||
/// <param name="listRoleId">Role Name</param>
|
||
public void OperateUser(UserDataModel userModel, List<string> listRoleId)
|
||
{
|
||
|
||
string strSQL = string.Empty;
|
||
//删除用户 促织机构 角色 信息
|
||
strSQL = " delete from t_base_userinfo where User_ID = '" + userModel.USER_ID + "';";
|
||
|
||
strSQL = strSQL + " delete from t_Base_Userdepart where User_ID = '" + userModel.USER_ID + "';";
|
||
//strSQL = "delete from t_comuser where UserID = '" + userModel.USER_ID + "'";
|
||
|
||
strSQL = strSQL + " delete from t_base_role where User_ID = '" + userModel.USER_ID + "';";
|
||
|
||
|
||
//用户表操作
|
||
|
||
//strSQL = strSQL + "insert into T_BASE_USERINFO(USERNAME,PASSWORD,DEP_ID,COM_ID,NAME," +
|
||
// "PHONE,QQ,EMAIL,USER_ID,IP,NAMESHORT,ROLE_ID,USER_STATUS,USRINFO_STATUS," +
|
||
// "USER_NUMBER,INFO_USER)values ('" + userModel.USERNAME + "','" + userModel.PASSWORD + "',"
|
||
// + "'ASRS','ASRS','" + userModel.NAME + "','" + userModel.PHONE + "','" + userModel.QQ + "',"
|
||
|
||
// + "'" + userModel.EMAIL + "','" + userModel.USER_ID + "','" + userModel.IP + "',"
|
||
|
||
// + "'" + userModel.NAMESHORT + "','" + userModel.ROLE_ID + "','" + userModel.USER_STATUS + "',"
|
||
|
||
// + "'" + userModel.USRINFO_STATUS + "','" + userModel.USER_NUMBER + "','" + userModel.INFO_USER + "');";
|
||
|
||
string sqlInsert = string.Format(@"INSERT INTO [dbo].[T_BASE_USERINFO]
|
||
([PASSWORD]
|
||
,[COM_ID]
|
||
,[NAME]
|
||
,[PHONE]
|
||
,[QQ]
|
||
,[EMAIL]
|
||
,[USER_ID]
|
||
,[IP]
|
||
,[NAMESHORT]
|
||
,[GROUP_ID]
|
||
,[ROLE_ID]
|
||
,[USER_DESC]
|
||
,[USER_STATUS]
|
||
,[USRINFO_STATUS]
|
||
,[USER_NUMBER]
|
||
,[USER_ENTRY]
|
||
,[USER_DRIVING]
|
||
,[INFO_USER]
|
||
,[INFO_DATE]
|
||
,[IMG]
|
||
,[STORAGE_ID]
|
||
,[DRIVE_ID]
|
||
,[DRIVE_STATUS]
|
||
,[SEX]
|
||
,[DRIVE_ACTIVE_TIME]
|
||
,[DRIVE_LEVEL]
|
||
,[ISDRIVER]
|
||
,[USERNAME]
|
||
,[DEP_ID])
|
||
VALUES
|
||
('{0}'
|
||
,'{1}'
|
||
,'{2}'
|
||
,'{3}'
|
||
,'{4}'
|
||
,'{5}'
|
||
,'{6}'
|
||
,'{7}'
|
||
,'{8}'
|
||
,'{9}'
|
||
,'{10}'
|
||
,'{11}'
|
||
,'{12}'
|
||
,'{13}'
|
||
,'{14}'
|
||
,'{15}'
|
||
,'{16}'
|
||
,'{17}'
|
||
,'{18}'
|
||
,'{19}'
|
||
,'{20}'
|
||
,'{21}'
|
||
,'{22}'
|
||
,{23}
|
||
,'{24}'
|
||
,'{25}'
|
||
,'{26}'
|
||
,'{27}');", userModel.PASSWORD, userModel.COM_ID, userModel.NAME, userModel.PHONE, userModel.QQ, userModel.EMAIL,
|
||
userModel.USER_ID, userModel.IP, userModel.NAMESHORT, "",
|
||
userModel.ROLE_ID, "", userModel.USER_STATUS, userModel.USRINFO_STATUS,
|
||
userModel.USER_NUMBER, userModel.USER_ENTRY, userModel.USER_DRIVING, userModel.INFO_USER,
|
||
userModel.INFO_DATE, userModel.IMG, userModel.STORAGE_ID, userModel.DRIVE_ID,
|
||
userModel.DRIVE_STATUS, userModel.SEX, userModel.DRIVE_ACTIVE_TIME, userModel.DRIVE_LEVEL,
|
||
userModel.ISDRIVER, userModel.USERNAME, userModel.DEP_ID);
|
||
strSQL = strSQL + sqlInsert;
|
||
|
||
//用户角色关联表操作
|
||
foreach (string roleid in listRoleId)
|
||
{
|
||
|
||
strSQL = strSQL + "insert into t_base_role(user_id,role_id) values ('" + userModel.USER_ID + "','" + roleid + "');";
|
||
}
|
||
|
||
SystemDataObject.Instance.ExecuteSql(strSQL);
|
||
}
|
||
|
||
|
||
#endregion
|
||
|
||
#region 用户增加 修改 操作
|
||
/// <summary>
|
||
/// 操作用户
|
||
/// </summary>
|
||
/// <param name="userModel">用户信息</param>
|
||
/// <param name="listComId">组织结构编号</param>
|
||
/// <param name="listRoleId">Role Name</param>
|
||
public void OperateUser(UserDataModel userModel, List<string> listComId, List<string> listRoleId, List<UserAreaModel> listArea)
|
||
{
|
||
List<string> listSQL = new List<string>();
|
||
StringBuilder strSQL = new StringBuilder();
|
||
List<OracleParameter[]> listparam = new List<OracleParameter[]>();
|
||
//删除用户 促织机构 角色 信息
|
||
//用户表
|
||
string sqlUserDel = string.Format("delete from t_base_userinfo where User_ID ='{0}'", userModel.USER_ID);
|
||
listSQL.Add(sqlUserDel);
|
||
//用户部门
|
||
string sqlDeptDel = string.Format("delete from T_BASE_USERDEPART where User_ID ='{0}'", userModel.USER_ID);
|
||
listSQL.Add(sqlDeptDel);
|
||
//用户角色
|
||
string sqlRoleDel = string.Format("delete from t_base_role where User_ID ='{0}'", userModel.USER_ID);
|
||
listSQL.Add(sqlRoleDel);
|
||
//用户库区
|
||
string sqlAreaDel = string.Format("delete from T_BASE_userArea where User_ID ='{0}'", userModel.USER_ID);
|
||
listSQL.Add(sqlAreaDel);
|
||
|
||
//用户表操作
|
||
|
||
string sqlUserAdd = string.Format(@"insert into T_BASE_USERINFO(PASSWORD, COM_ID, NAME, PHONE, QQ, EMAIL, USER_ID, IP,
|
||
NAMESHORT, ROLE_ID, USER_STATUS, USRINFO_STATUS, USER_NUMBER,
|
||
INFO_USER, STORAGE_ID, DRIVE_ID, DRIVE_STATUS, SEX, DRIVE_ACTIVE_TIME, DRIVE_LEVEL, ISDRIVER)
|
||
values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}',
|
||
'{10}', '{11}', '{12}', '{13}',
|
||
'{14}', '{15}', '{16}', '{17}', '{18}',
|
||
'{19}', '{20}'
|
||
)", userModel.PASSWORD,
|
||
userModel.COM_ID,
|
||
userModel.NAME,
|
||
userModel.PHONE,
|
||
userModel.QQ,
|
||
userModel.EMAIL,
|
||
userModel.USER_ID,
|
||
userModel.IP,
|
||
userModel.NAMESHORT,
|
||
userModel.ROLE_ID,
|
||
userModel.USER_STATUS,
|
||
userModel.USRINFO_STATUS,
|
||
userModel.USER_NUMBER,
|
||
|
||
// userModel.USER_DRIVING = userModel.USER_DRIVING.,
|
||
userModel.INFO_USER,
|
||
|
||
// userModel.IMG == null ? new byte[10] : userModel.IMG,
|
||
userModel.STORAGE_ID,
|
||
userModel.DRIVE_ID,
|
||
userModel.DRIVE_STATUS == null ? "" : userModel.DRIVE_STATUS,
|
||
userModel.SEX,
|
||
userModel.DRIVE_ACTIVE_TIME,
|
||
userModel.DRIVE_LEVEL == null ? "" : userModel.DRIVE_LEVEL,
|
||
userModel.ISDRIVER);
|
||
listSQL.Add(sqlUserAdd);
|
||
|
||
|
||
//用户部门关联表操作
|
||
//foreach (string comid in listComId)
|
||
//{
|
||
// strSQL = new StringBuilder();
|
||
// string sqlDeptUerInsert = string.Format(@"insert into t_Base_Userdepart(user_id,dep_id) values('{0}','{1}')", userModel.USER_ID, comid);
|
||
// listSQL.Add(sqlDeptUerInsert);
|
||
|
||
//}
|
||
|
||
//用户角色关联表操作
|
||
foreach (string roleid in listRoleId)
|
||
{
|
||
strSQL = new StringBuilder();
|
||
|
||
// string strSqlSeq = "";
|
||
// strSqlSeq = "select NEXT VALUE FOR SEQ_ROLE_USER_ID";
|
||
// DataTable dt = SystemDataObject.Instance.GetDataTable(strSqlSeq);
|
||
// string strSEQ = dt.Rows[0][0].ToString();
|
||
string sqlUerRoleInsert = string.Format(@"insert into t_base_role(user_id, role_id) values('{0}','{1}')", userModel.USER_ID, roleid);
|
||
listSQL.Add(sqlUerRoleInsert);
|
||
}
|
||
|
||
//用户仓库关联表操作
|
||
//foreach (UserAreaModel area in listArea)
|
||
//{
|
||
// string sqlUserAreaInsert = string.Format(@"insert into T_BASE_USERAREA(USER_ID,AREA_ID,WORKKIND_ID,WORKLOAD,STORAGE_ID)
|
||
// values ('{0}','{1}','{2}','{3}','{4}')", userModel.USER_ID, area.AREA_ID, area.WORKKIND_ID, area.WORKLOAD, area.STORAGE_ID);
|
||
// listSQL.Add(sqlUserAreaInsert);
|
||
|
||
//}
|
||
SystemDataObject.Instance.ExecuteList(listSQL);
|
||
if (userModel.IMG != null)
|
||
{
|
||
//图片处理
|
||
if (userModel.IMG.Length > 10)
|
||
{
|
||
string sqlUpdateImg = string.Format("update T_BASE_USERINFO set IMG=:IMG where USER_ID= '{0}'", userModel.USER_ID);
|
||
OracleParameter[] parameter = new OracleParameter[]{
|
||
new OracleParameter(":IMG",OracleDbType.Blob),
|
||
};
|
||
parameter[0].Value = userModel.IMG;
|
||
try
|
||
{
|
||
SystemDataObject.Instance.ExecuteSql(sqlUpdateImg, parameter);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
string errMsg = ex.Message;
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
#endregion
|
||
|
||
#region 删除用户记录
|
||
/// <summary>
|
||
/// 删除用户记录
|
||
/// </summary>
|
||
/// <param name="userModel">用户Model</param>
|
||
public void UserDel(string strUserID)
|
||
{
|
||
|
||
//删除用户 促织机构 角色 信息
|
||
string strSQL = "delete from t_base_userinfo where User_ID = '" + strUserID + "'";
|
||
|
||
SystemDataObject.Instance.ExecuteSqlCommit(strSQL);
|
||
//strSQL = "delete from t_comuser where UserID = '" + strUserID + "'";
|
||
|
||
strSQL = "delete from t_base_role where User_ID = '" + strUserID + "'";
|
||
SystemDataObject.Instance.ExecuteSqlCommit(strSQL);
|
||
strSQL = "delete from T_BASE_USERAREA where User_ID ='" + strUserID + "'";
|
||
|
||
SystemDataObject.Instance.ExecuteSqlCommit(strSQL);
|
||
|
||
}
|
||
public void UserDepartData(string userID)
|
||
{
|
||
string strSQL = "delete from t_Base_Userdepart where User_ID = '" + userID + "'";
|
||
}
|
||
public void UserRoleData(string userID)
|
||
{
|
||
string strSQL = "delete from t_Base_Userdepart where User_ID = '" + userID + "'";
|
||
}
|
||
public void UserDEluserAre(string userID)
|
||
{
|
||
string strSQL = "delete from T_BASE_USERAREA where User_ID = '" + userID + "'";
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 验证人员编码是否存在
|
||
/// </summary>
|
||
/// <param name="strUserID">用户编号</param>
|
||
/// <returns>false不存在 true存在</returns>
|
||
public bool IsCheckUser(string strUserID)
|
||
{
|
||
string strSQL = "select * from t_base_userinfo where User_ID = '" + strUserID + "'";
|
||
DataTable dt = SystemDataObject.Instance.GetDataTable(strSQL);
|
||
bool b = false;
|
||
if (dt != null && dt.Rows.Count > 0)
|
||
{
|
||
b = true;
|
||
}
|
||
return b;
|
||
}
|
||
|
||
/// <summary>
|
||
#region 通过用户ID得到同部门的所有用户
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public DataTable GetSameDepUserInfo(string userID)
|
||
{
|
||
string sqlStr = "select USER_ID,NAME from t_base_UserInfo where com_id = (select com_id from t_base_UserInfo where USER_ID =:USER_ID)";
|
||
OracleParameter[] parameter = new OracleParameter[]{
|
||
new OracleParameter(":USER_ID",OracleDbType.Varchar2),
|
||
};
|
||
parameter[0].Value = userID;
|
||
return SystemDataObject.Instance.GetDataTable(sqlStr.ToString(), parameter);
|
||
}
|
||
#endregion
|
||
}
|
||
}
|