public static string login(Stuff stf)//判断员工用户名密码是否一致 { string str=""; SqlDataReader sqlrd; DataBase db = new DataBase(); string sql = "select tKey from tb_Stuff where Name='" + stf.Name + "'"; sqlrd=db.GetDataReader(sql); while(sqlrd.Read ()) { str = (string)(sqlrd["tKey"]); } return str; }
private void but_login_Click(object sender, EventArgs e) { manager_window maw = new manager_window(); if (this.text_name.Text != "" && this.text_psw.Text != ""&&(this.check_manger .Checked ||this.check_stf .Checked )) { if (this.check_stf .Checked ) { Model.Stuff stf = new Stuff(); stf.Name = this.text_name.Text.Trim(); if (this.text_psw.Text == stfmanager.login_(stf))//验证员工用户名和密码是否一致 { maw.Show(); } else { MessageBox.Show("用户名或密码不正确!"); } } if (this.check_manger .Checked ) { Model.Manager mag = new Manager(); mag.Name = this.text_name.Text.Trim(); if (this.text_psw.Text ==managet_ .login_ (mag))//验证员工用户名和密码是否一致 { maw.Show(); } else { MessageBox.Show("用户名或密码不正确!"); } } } else { MessageBox.Show("请填写完整信息!"); } }
public static string login_(Stuff stf) { string str=Stuffs.login(stf); return str; }