private void button1_Click(object sender, EventArgs e) { if (txtTenLogin.Text.Trim() == "" || txtPass.Text.Trim() == "") { MessageBox.Show("Bạn chưa nhập đủ thông tin", "Lỗi", MessageBoxButtons.OK); return; } thongTinLogin = new ThongTinLogin { Role = cbNhom.SelectedItem.ToString(), LoginName = txtTenLogin.Text.Trim(), Pass = txtPass.Text.Trim() }; this.Hide(); //an form tao login }
public static bool taoLogin(ThongTinLogin thongTinLogin) { try { using (SqlConnection conn = new SqlConnection(Program.connstr)) using (SqlCommand cmd = new SqlCommand("sp_TaoTaiKhoan", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@LGNAME", thongTinLogin.LoginName)); cmd.Parameters.Add(new SqlParameter("@PASS", thongTinLogin.Pass)); cmd.Parameters.Add(new SqlParameter("@USERNAME", thongTinLogin.UserName)); cmd.Parameters.Add(new SqlParameter("@ROLE", thongTinLogin.Role)); conn.Open(); cmd.ExecuteNonQuery(); return(true); } } catch (Exception ex) { MessageBox.Show("Tạo login không thành công", "Lỗi", MessageBoxButtons.OK); return(false); } }
private void button2_Click(object sender, EventArgs e) { thongTinLogin = null; this.Close(); }