/// <summary>
/// 获取员工列表
/// </summary>
/// <returns></returns>
public static DataTable GetAllEmployee()
{
string sql = "select EmpID,EmpName,EmpCertType,EmpCertNum,EmpPhone,"+
"EmpMobile,EmpAddress,EmpLevel,DepartmentID,Password,UserRightCode,RoleId,UserBirthDate,EmpDiscount from employee";
DataTable dt = DBAccess.getDataTable(sql);
return dt;
}
public static List<Employee> GetAllEmployeeList()
{
List<Employee> lst = new List<Employee>();
string sql = "select EmpID,EmpName,EmpCertType,EmpCertNum,EmpPhone," +
"EmpMobile,EmpAddress,EmpLevel,DepartmentID,Password,UserRightCode,RoleId,UserBirthDate,EmpDiscount from employee";
SqlDataReader reader = DBAccess.getDataReader(sql);
while (reader.Read())
{
Employee emp = new Employee();
emp.EmpID =reader.IsDBNull(0)?"": reader.GetString(0);
emp.EmpName = reader.IsDBNull(1) ? "" : reader.GetString(1);
emp.EmpCertType = reader.IsDBNull(2) ? "" : reader.GetString(2);
emp.EmpCertNum = reader.IsDBNull(3) ? "" : reader.GetString(3);
emp.EmpPhone = reader.IsDBNull(4) ? "" : reader.GetString(4);
emp.EmpMobile = reader.IsDBNull(5) ? "" : reader.GetString(5);
emp.EmpAddress = reader.IsDBNull(6) ? "" : reader.GetString(6);
emp.EmpLevel = reader.IsDBNull(7) ? ( short)0 : reader.GetInt16(7);
emp.DepartmentID = reader.IsDBNull(8) ? ( short)0 : reader.GetInt16(8);
emp.Password = reader.IsDBNull(9) ? "" : reader.GetString(9);
emp.UserRightCode = reader.IsDBNull(10) ? "" : reader.GetString(10);
emp.RoleID = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
emp.UserBirthDate = reader.GetDateTime(12);
emp.EmpDiscount = reader.IsDBNull(13) ? ( float)0 : ( float)reader.GetDouble(13);
lst.Add(emp);
}
//DataTable dt = DBAccess.getDataTable(sql);
return lst;
}
/// <summary>
/// 获取员工的详细信息
/// </summary>
/// <returns></returns>
public static List<EmployeeDetail> GetAllEmpDetailList()
{
List<EmployeeDetail> lst = new List<EmployeeDetail>();
string sql = "select EmpID,EmpName,EmpCertType,EmpCertNum,EmpPhone," +
"EmpMobile,EmpAddress,EmpLevel,employee.DepartmentID,Password,UserRightCode,employee.RoleId,UserBirthDate,EmpDiscount,checkdepartname,rolename from employee,role,checkDepart" +
" where employee.roleid = role.roleid and employee.departmentid = checkdepart.checkdepartid";
SqlDataReader reader = DBAccess.getDataReader(sql);
while (reader.Read())
{
EmployeeDetail emp = new EmployeeDetail();
emp.EmpID = reader.IsDBNull(0) ? "" : reader.GetString(0);
emp.EmpName = reader.IsDBNull(1) ? "" : reader.GetString(1);
emp.EmpCertType = reader.IsDBNull(2) ? "" : reader.GetString(2);
emp.EmpCertNum = reader.IsDBNull(3) ? "" : reader.GetString(3);
emp.EmpPhone = reader.IsDBNull(4) ? "" : reader.GetString(4);
emp.EmpMobile = reader.IsDBNull(5) ? "" : reader.GetString(5);
emp.EmpAddress = reader.IsDBNull(6) ? "" : reader.GetString(6);
emp.EmpLevel = reader.IsDBNull(7) ? ( short)0 : reader.GetInt16(7);
emp.DepartmentID = reader.IsDBNull(8) ? ( short)0 : reader.GetInt16(8);
emp.Password = reader.IsDBNull(9) ? "" : reader.GetString(9);
emp.UserRightCode = reader.IsDBNull(10) ? "" : reader.GetString(10);
emp.RoleID = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
emp.UserBirthDate = reader.GetDateTime(12);
emp.EmpDiscount = reader.IsDBNull(13) ? ( float)0 : ( float)reader.GetDouble(13);
emp.DepartName = reader.IsDBNull(14) ? "" : reader.GetString(14);
emp.RoleName = reader.IsDBNull(15) ? "" : reader.GetString(15);
lst.Add(emp);
}
//DataTable dt = DBAccess.getDataTable(sql);
return lst;
}