316 lines
7.9 KiB
C#
316 lines
7.9 KiB
C#
using System;
|
|
using System.Collections;
|
|
using DeiNiu.Utils;
|
|
using DeiNiu.wms.Data.Model;
|
|
using System.Data;
|
|
using System.Threading;
|
|
namespace DeiNiu.wms.Logical
|
|
{
|
|
[Serializable]
|
|
public class LEmployee
|
|
{
|
|
Employee _obj;
|
|
private DeptEmp _deptEmpObj = new DeptEmp();
|
|
|
|
// ArrayList _authList = new ArrayList();
|
|
private bool _canYuShen;
|
|
private bool _canShenHe;
|
|
private bool _canKaoHe;
|
|
private bool _canManageProject;
|
|
|
|
public LEmployee()
|
|
{
|
|
Initialize();
|
|
|
|
}
|
|
public DeptEmp GetDeptEmp
|
|
{
|
|
get
|
|
{
|
|
return _deptEmpObj;
|
|
}
|
|
}
|
|
public Employee GetEmployee
|
|
{
|
|
get
|
|
{
|
|
return _obj;
|
|
}
|
|
}
|
|
|
|
public ArrayList AuthList
|
|
{
|
|
get
|
|
{
|
|
// return _authList;
|
|
if (_obj != null) return new LRoleAuthority().GetAuthorityList(_obj.ID); //权限即时有效,不需登录
|
|
return new ArrayList();
|
|
}
|
|
}
|
|
|
|
public DataTable AuthTable
|
|
{
|
|
get
|
|
{
|
|
if (_obj != null) return new LRoleAuthority().GetAuthByEm(_obj.ID); //权限即时有效,不需登录
|
|
return new DataTable();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// get all data
|
|
/// </summary>
|
|
public DataSet GetAllData()
|
|
{
|
|
return _obj.Query();
|
|
}
|
|
|
|
/// <summary>
|
|
/// get all data
|
|
/// </summary>
|
|
public DataSet GetAllActiveData()
|
|
{
|
|
return _obj.QueryActived();
|
|
}
|
|
/// <summary>
|
|
/// 取得用户部门信息
|
|
/// </summary>
|
|
public DataTable GetActivedEmpDept()
|
|
{
|
|
return _deptEmpObj.GetActivedEmpDept();
|
|
}
|
|
|
|
/// <summary>
|
|
/// get a record by id
|
|
/// </summary>
|
|
public void Initialize(int id)
|
|
{
|
|
_obj = id != 0 ? new Employee(id) : new Employee();
|
|
setApproveProperty(_obj.ID);
|
|
}
|
|
|
|
/// <summary>
|
|
/// get a record by id 0
|
|
/// </summary>
|
|
public void Initialize()
|
|
{
|
|
Initialize(0);
|
|
}
|
|
public DataTable GetDepartments()
|
|
{
|
|
return new Department().QueryActived().Tables[0];
|
|
}
|
|
|
|
/// <summary>
|
|
/// login, success then load authoritylist
|
|
/// </summary>
|
|
/// <param name="userAccount"></param>
|
|
/// <param name="passwd"></param>
|
|
/// <returns></returns>
|
|
public bool Login(string userAccount, string passwd)
|
|
{
|
|
int id = _obj.ValidUser(userAccount,Util.Encrypt(passwd) );
|
|
if ( id >0)
|
|
{
|
|
// _authList = new LRoleAuthority().GetAuthorityList(_obj.ID);
|
|
// setApproveProperty(_obj.ID);
|
|
Initialize(id);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
protected void setApproveProperty(int empId)
|
|
{
|
|
|
|
LRoleAuthority ra = new LRoleAuthority();
|
|
ArrayList al = ra.GetApproveRoleList(empId);
|
|
|
|
_canKaoHe = al.Contains(ApproveRoles.KaoHe);
|
|
_canManageProject = al.Contains(ApproveRoles.项目维护);
|
|
if (GetCanApproveDeptList().Count > 0) //只有部门负责人才有预审、审核的权利。
|
|
{
|
|
_canShenHe = al.Contains(ApproveRoles.ShenHe);
|
|
_canYuShen = al.Contains(ApproveRoles.YuShen);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 当前用户项目权限authType列表,0,100,200..
|
|
/// </summary>
|
|
public ArrayList ProjectAuthlist
|
|
{
|
|
get
|
|
{
|
|
const string prjlink = "~/Project/ProjectMain.aspx?authType=";
|
|
ArrayList al = AuthList;
|
|
ArrayList prjAuthlist = new ArrayList();
|
|
for (int i = 0; i < al.Count; i++)
|
|
{
|
|
|
|
if (al[i].ToString().Contains(prjlink.ToUpper()))
|
|
{
|
|
prjAuthlist.Add(al[i].ToString().Substring(prjlink.Length));
|
|
}
|
|
}
|
|
|
|
return prjAuthlist;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 当前用户项目最大权限authType, Example 200..
|
|
/// </summary>
|
|
public int ProjectMaxAuth
|
|
{
|
|
get
|
|
{
|
|
int authType = 0;
|
|
int index = -1;
|
|
ArrayList al = ProjectAuthlist;
|
|
|
|
for (int i = 0; i < al.Count; i++)
|
|
{
|
|
if (Convert.ToInt32(al[i].ToString() ) > authType)
|
|
{
|
|
authType = Convert.ToInt32(al[i].ToString() );
|
|
index = i;
|
|
|
|
}
|
|
}
|
|
return index>-1 ?Convert.ToInt32(al[index].ToString()):index ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 当前用户项目最大权限页面, Example 200..
|
|
/// </summary>
|
|
public string ProjectMaxAuthPage
|
|
{
|
|
get
|
|
{
|
|
const string prjlink = "~/Project/ProjectMain.aspx?authType=";
|
|
return ProjectMaxAuth>-1?prjlink +ProjectMaxAuth : string.Empty;
|
|
}
|
|
}
|
|
|
|
public bool CanShenHe
|
|
{
|
|
get { return _canShenHe; }
|
|
}
|
|
|
|
public bool CanYuShen
|
|
{
|
|
get { return _canYuShen; }
|
|
set { _canYuShen = value; }
|
|
}
|
|
|
|
public bool CanKaoHe
|
|
{
|
|
get { return _canKaoHe; }
|
|
}
|
|
public bool CanManageProjects
|
|
{
|
|
get { return _canManageProject; }
|
|
}
|
|
|
|
public DataTable GetLessons(int empId)
|
|
{
|
|
return _obj.GetLessons(empId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 当前用户可进行项目审批的部门列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ArrayList GetCanApproveDeptList()
|
|
{
|
|
|
|
return new Department().QueryDepts(GetEmployee.ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 取得当前员工的部门列表
|
|
/// </summary>
|
|
/// <param name="empId"></param>
|
|
/// <returns></returns>
|
|
public Array GetEmDepartments()
|
|
{
|
|
|
|
DataTable dt= _obj.GetDepartments( );
|
|
string[] al = new string[1] ;
|
|
if(dt !=null)
|
|
{
|
|
al = new string[dt.Rows.Count];
|
|
int i = 0;
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
al[i] = dr["DE_DEPT"].ToString();
|
|
i++;
|
|
}
|
|
}
|
|
return al;
|
|
}
|
|
/// <summary>
|
|
/// 取得员工的部门列表
|
|
/// </summary>
|
|
/// <param name="empId"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetDepartments(int empId)
|
|
{
|
|
return _obj.GetDepartments(empId);
|
|
}
|
|
/// <summary>
|
|
/// 取得部门的员工列表
|
|
/// </summary>
|
|
/// <param name="deptId"></param>
|
|
/// <returns></returns>
|
|
|
|
public DataTable GetActiveEmpByDept(int deptId)
|
|
{
|
|
return _obj.GetActivedEmplyeesByDept(deptId);
|
|
}
|
|
|
|
public bool AddEmployee()
|
|
{
|
|
if(!_obj.ValidUser(_obj.em_account))
|
|
{
|
|
_obj.Add();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public ArrayList OnLineUsers
|
|
{
|
|
get
|
|
{
|
|
return _obj.GetUsersOnLine();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void test()
|
|
{
|
|
int i = 0;
|
|
|
|
while (i < 1000000)
|
|
{
|
|
|
|
i++;
|
|
Console.WriteLine(string.Format("current user id is {0}", LoginInfo.UserId));
|
|
Thread.Sleep(1000);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|