133 lines
3.1 KiB
Plaintext
133 lines
3.1 KiB
Plaintext
|
using System;
|
||
|
using DeiNiu.wms.Data.Model;
|
||
|
using System.Data;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
namespace DeiNiu.wms.Logical
|
||
|
{
|
||
|
[Serializable]
|
||
|
public class LAuthority
|
||
|
{
|
||
|
Authority _obj;
|
||
|
|
||
|
|
||
|
public LAuthority()
|
||
|
{
|
||
|
|
||
|
Initialize();
|
||
|
}
|
||
|
|
||
|
public Authority GetAuthority
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return _obj;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// get all data
|
||
|
/// </summary>
|
||
|
public DataSet GetAllData()
|
||
|
{
|
||
|
return _obj.Query();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// get all data
|
||
|
/// </summary>
|
||
|
public DataSet getAllActiveData()
|
||
|
{
|
||
|
return _obj.QueryActived();
|
||
|
}
|
||
|
|
||
|
|
||
|
/*
|
||
|
private void leavetypeDsConstruct()
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
*/
|
||
|
|
||
|
/// <summary>
|
||
|
/// get a record by id
|
||
|
/// </summary>
|
||
|
public void Initialize(int id)
|
||
|
{
|
||
|
_obj = id != 0 ? new Authority(id) : new Authority();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// get a record by id 0
|
||
|
/// </summary>
|
||
|
public void Initialize()
|
||
|
{
|
||
|
Initialize(0);
|
||
|
}
|
||
|
public List<Authority> getAuthorities()
|
||
|
{
|
||
|
List<Authority> auths = new List<Authority>();
|
||
|
DataTable dt = getAllActiveData().Tables[0];
|
||
|
|
||
|
foreach (DataRow row in dt.Rows)
|
||
|
{
|
||
|
|
||
|
int id = Convert.ToInt32(row["id"].ToString());
|
||
|
Authority ath = new Authority(id);
|
||
|
auths.Add(ath);
|
||
|
}
|
||
|
return auths;
|
||
|
}
|
||
|
|
||
|
public List<Authority> getAuthorities(int empId,int warehouse)
|
||
|
{
|
||
|
|
||
|
List<Authority> auths = new List<Authority>();
|
||
|
LRoleAuthority ll = new LRoleAuthority();
|
||
|
DataTable dt = ll.GetAuthByEm(empId , warehouse);
|
||
|
|
||
|
foreach (DataRow row in dt.Rows)
|
||
|
{
|
||
|
Authority ath = new Authority(row);
|
||
|
auths.Add(ath);
|
||
|
}
|
||
|
return auths;
|
||
|
}
|
||
|
|
||
|
|
||
|
public Dictionary<String, List<Authority>> getCatedAuthorities(int empId,int warehouse=-1)
|
||
|
{
|
||
|
Dictionary<String, List<Authority>> auths = new Dictionary<String, List<Authority>>();
|
||
|
|
||
|
DataView dv = new DataView(getAllActiveData().Tables[0]);
|
||
|
dv.Sort = "[auth_order]";
|
||
|
|
||
|
List<Authority> subAuths = getAuthorities(empId, warehouse);
|
||
|
|
||
|
foreach (Authority a in subAuths)
|
||
|
{
|
||
|
dv.RowFilter = "id =" + a.auth_uplevel;
|
||
|
string key;
|
||
|
foreach (DataRowView dr in dv)
|
||
|
{
|
||
|
key = dr["auth_name"].ToString();
|
||
|
if (auths.ContainsKey(key))
|
||
|
{
|
||
|
auths[key].Add(a);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
List<Authority> sa = new List<Authority>();
|
||
|
sa.Add(a);
|
||
|
auths.Add(key, sa);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return auths;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|