ldj/Logical/lEmployee.cs

316 lines
7.9 KiB
C#
Raw Normal View History

2023-05-23 16:13:17 +08:00
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); //Ȩ<>޼<EFBFBD>ʱ<EFBFBD><CAB1>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
return new ArrayList();
}
}
public DataTable AuthTable
{
get
{
if (_obj != null) return new LRoleAuthority().GetAuthByEm(_obj.ID); //Ȩ<>޼<EFBFBD>ʱ<EFBFBD><CAB1>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
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>
/// ȡ<><C8A1><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
/// </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.<EFBFBD><EFBFBD>Ŀά<EFBFBD><EFBFBD>);
if (GetCanApproveDeptList().Count > 0) //ֻ<>в<EFBFBD><D0B2>Ÿ<EFBFBD><C5B8><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
{
_canShenHe = al.Contains(ApproveRoles.ShenHe);
_canYuShen = al.Contains(ApproveRoles.YuShen);
}
}
/// <summary>
/// <20><>ǰ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ĿȨ<C4BF><C8A8>authType<70>б<EFBFBD>,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>
/// <20><>ǰ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>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>
/// <20><>ǰ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>ҳ<EFBFBD><D2B3>, 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>
/// <20><>ǰ<EFBFBD>û<EFBFBD><C3BB>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>б<EFBFBD>
/// </summary>
/// <returns></returns>
public ArrayList GetCanApproveDeptList()
{
return new Department().QueryDepts(GetEmployee.ID);
}
/// <summary>
/// ȡ<>õ<EFBFBD>ǰԱ<C7B0><D4B1><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>б<EFBFBD>
/// </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>
/// ȡ<><C8A1>Ա<EFBFBD><D4B1><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>б<EFBFBD>
/// </summary>
/// <param name="empId"></param>
/// <returns></returns>
public DataTable GetDepartments(int empId)
{
return _obj.GetDepartments(empId);
}
/// <summary>
/// ȡ<>ò<EFBFBD><C3B2>ŵ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>б<EFBFBD>
/// </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);
}
}
}
}