/*----------------------------------------------------------------/
Copyright (C)
文件名:
文件功能描述:
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
创建标识:
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
修改标识:
修改描述:
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
/----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data;
using XEP.Model;
namespace XEP.DataAccess
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
public
class EmployeeDAL
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
/// <summary>
/// 验证用户登陆信息
/// </summary>
/// <param name="empid">员工号</param>
/// <param name="pwd">密码(MD5加密后)</param>
/// <returns></returns>
public
static
bool CheckPassword(
string empid,
string pwd)
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
string sql =
string.Format(
"select EmpID from employee where empid = '{0}' and password = '{1}'",empid,pwd);
if (DBAccess.getExecuteCount(sql) > 0)
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
return
true;
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
else
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
return
false;
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
///<summary>
///通过工号获取员工姓名
///</summary>
///<param name="empID" >员工号</parm>
///<returns>employeeName</returns>
public
static
string FindEmployeeByID(
int empID)
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
string employeeName =
null;
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
SqlDataReader reader = DBAccess.getDataReader(
"SELECT EmpName FROM employee WHERE empID='" +empID+
"' ");
if (reader.Read())
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
employeeName =reader.GetString(0);
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
DBAccess.close();
return employeeName;
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
public
static
bool IsHasRight(
short empLevel,
string empID)
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
string selectSql =
string.Format(
"SELECT * FROM Discount,Employee WHERE EmpID='{0}' AND Employee.Emplevel >= {1}", empID, empLevel);
if (DBAccess.getExecuteCount(selectSql)> 0)
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
return
true;
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
else
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
return
false;
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
public
static
short GetEmpLevel(
string empID)
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
string sql =
string.Format(
"select EmpLevel from employee where empid = '{0}' ", empID);
return Convert.ToInt16(DBAccess.selectFirstRecord(sql));
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
public
static
double GetEmpDiscount(
string empID)
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
string sql =
string.Format(
"select EmpDiscount from employee where empid = '{0}' ", empID);
return Convert.ToDouble(DBAccess.selectFirstRecord(sql));
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
public
static
string GetRightCode(
string empID)
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
string sql =
string.Format(
"select UserRightCode from employee where empid = '{0}' ", empID);
return Convert.ToString(DBAccess.selectFirstRecord(sql));
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
//tfq-7-3
public
static
string GetEmpNameByEmpID(
string empid)
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
string select =
"select EmpName from Employee where EmpID='" +
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
empid +
"'";
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
DataTable dt = DBAccess.getDataTable(select);
if (dt.Rows.Count > 0)
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
string result = dt.Rows[0][0].ToString();
return result;
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
else
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
return "";
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
/// <summary>
/// 获得所有员工的基本信息(工号、姓名)
/// </summary>
/// <returns>所有员工的信息(工号、姓名)</returns>
public
static List<Employee> GetEmployee()
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
List<Employee> listEmployee =
new List<Employee>();
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
Employee emp =
null;
string selectSql =
"SELECT EmpID,EmpName FROM Employee";
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
SqlDataReader reader = DBAccess.getDataReader(selectSql);
while (reader.Read())
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
{
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
emp =
new Employee();
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
emp.EmpID = reader.GetString(0);
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
emp.EmpName = reader.GetString(1);
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
listEmployee.Add(emp);
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
reader.Close();
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
DBAccess.close();
return listEmployee;
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}
![InBlock.gif](http://gaochaojs.blog.51cto.com/images/editer/InBlock.gif)
}