private void btnLogin_Click(object sender, EventArgs e)
{
string strName = txtName.Text;
string strPasw = txtPassword.Text;
string strPwMd5 = Library.Util.MD5(strPasw);
string sql = "select permission " +
"from manager " +
"where [name] = @strName and " +
" password = @strPasw";
SqlCommand cmd = new SqlCommand(sql, Library.Connection.Instance());
cmd.Parameters.AddWithValue("@strName", strName);
cmd.Parameters.AddWithValue("@strPasw", strPwMd5);
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
int id = reader.GetInt32(0);
reader.Close();
if ((id & BACK_TERMINAL_PERMISSION) != 0)
{
this.Hide();
new frmBookMan().ShowDialog();
this.Close();
}
else
{
MessageBox.Show("抱歉,您的权限不够。", "无法登录",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
reader.Close();
MessageBox.Show("你的账号或密码错误。", "无法登录",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}