|
发表于 2013-7-29 22:42:48
|
显示全部楼层
public static int IsLogin(user u)
{
int result = 0;
SqlConnection cn = null;
try
{
string sql = string.Format("select count(*) from admin where id='{0}' and password = '{1}'", u.UName, u.UPass);
cn = new SqlConnection("Data Source=.;Initial Catalog=HRMS;Integrated Security=True");
cn.Open();
SqlCommand cmd = new SqlCommand(sql, cn);
result = (int)cmd.ExecuteScalar();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
cn.Close();
}
return result;
}
public static DataSet GetAll()
{
DataSet ds = new DataSet();
SqlConnection cn = null;
try
{
string sql = string.Format("SELECT [employee_id] as 'ID',[employee_password] as '密码',[employee_name] as '姓名',[employee_age] as '年龄' ,[employee_sex] as '性别' ,[employee_birthday] as '生日',[employee_phone] as '电话' ,[emplayee_department] as '部门' ,[emplayee_position] as '职位' ,[emplayee_salary] as '基本工资',employee.emplayee_salary + salary.salary_overtime_pay as '所有工资' FROM employee ,salary");
cn = new SqlConnection("Data Source=.;Initial Catalog=HRMS;Integrated Security=True");
cn.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
da.Fill(ds);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
cn.Close();
}
return ds;
}
|
|