111,094
社区成员




private void button1_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection();
cn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["china"].ConnectionString;
cn.Open();
SqlCommand cmd = new SqlCommand();
if (comboBox1.Text == "读者")
{
string str=string.Format("select rno,rpwd from reader where rno='{0}'and rpwd='{1}'",textBox1.Text.Trim(),textBox2.Text.Trim());
cmd.CommandText=str;
cmd.Connection=cn;
SqlDataReader dr=cmd.ExecuteReader();
if(dr.Read()){
pwd = textBox2.Text.Trim();//密码
userid = textBox1.Text.Trim();
reader r=new reader();
r.Show();
this.Hide();
}
else
{ MessageBox.Show("用户名或密码错误");
textBox1.Text = null;
textBox2.Text = null;
}
}
else if (comboBox1.Text == "管理人员") {
string str = string.Format("select mno,mpwd from management where mno='{0}'and mpwd='{1}'", textBox1.Text.Trim(), textBox2.Text.Trim());
cmd.CommandText = str;
cmd.Connection = cn;
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
pwd = textBox2.Text.Trim();//密码
userid = textBox1.Text.Trim();
manager m = new manager();
m.Show();
this.Hide();
}
else
{ MessageBox.Show("用户名或密码错误");
textBox1.Text = null;
textBox2.Text = null;
}
}
else { MessageBox.Show("请选着职称");
textBox1.Text = null;
textBox2.Text = null;
}
}