private void Login_but_ok_Click(object sender, EventArgs e) { string user_name = Login_uname_box.Text; string pword = Login_pword_box.Text; QLKS formQLKS = new QLKS(); formQLKS.ShowDialog(); this.Close(); //kiem tra csdl xem co nguoi dung }
private void Login_but_ok_Click(object sender, EventArgs e) { SqlCommand command = new SqlCommand(); command.Connection = con; command.CommandType = CommandType.Text; command.CommandText = "Select username,pass from NHANVIEN where (username=@user) and (pass=@pass)"; command.Parameters.Add("@user", SqlDbType.NVarChar, 50).Value = Login_uname_box.Text; command.Parameters.Add("@pass", SqlDbType.NVarChar, 50).Value = Login_pword_box.Text; da.SelectCommand = command; da.Fill(dt); if (dt.Rows.Count > 0) { QLKS ql = new QLKS(); ql.Show(); Hide(); } else { MessageBox.Show("Đăng nhập thất bại. Sai mật khẩu hoặc tên tài khoản"); } //kiem tra csdl xem co nguoi dung }