private void button1_Click(object sender, EventArgs e) { string userName = textBox1.Text; string password = textBox2.Text; conn.Open();//打开数据库连接 string sql = string.Format("select * from 管理员信息 where 用户名 ='{0}' and 密码='{1}'", userName, password);//构造用户名密码查询字符串 SqlDataAdapter sda = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet();//构造返回结果集 sda.Fill(ds); conn.Close();//关闭数据库连接 if (((userName == "刘兴") && ( password== "1121011323")) || ((userName == "季洲晨") && ( password== "1121011328")) || ((userName == "张航") && ( password== "1121011339")) || ((userName == "肖仲垚") && ( password== "1121011523"))) { MessageBox.Show("管理员认证成功,"+"登录成功!"); textBox1.Clear(); textBox2.Clear(); Form myfrm = new 客房信息(); myfrm.Show(); } else { MessageBox.Show("非法用户,请重新输入!"); textBox1.Clear(); textBox2.Clear(); } }
private void button1_Click(object sender, EventArgs e) { string userName = textBox1.Text; string password = textBox2.Text; conn.Open(); //打开数据库连接 string sql = string.Format("select * from 管理员信息 where 用户名 ='{0}' and 密码='{1}'", userName, password); //构造用户名密码查询字符串 SqlDataAdapter sda = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet(); //构造返回结果集 sda.Fill(ds); conn.Close();//关闭数据库连接 if (((userName == "刘兴") && (password == "1121011323")) || ((userName == "季洲晨") && (password == "1121011328")) || ((userName == "张航") && (password == "1121011339")) || ((userName == "肖仲垚") && (password == "1121011523"))) { MessageBox.Show("管理员认证成功," + "登录成功!"); textBox1.Clear(); textBox2.Clear(); Form myfrm = new 客房信息(); myfrm.Show(); } else { MessageBox.Show("非法用户,请重新输入!"); textBox1.Clear(); textBox2.Clear(); } }
private void button2_Click(object sender, EventArgs e) { Form f = new 客房信息(); f.Show(); }