public static void DangXuat() { trangChu dx = new trangChu(); if (dx.ShowDialog() == DialogResult.OK) { dx.Close(); Application.Run(new dangNhap()); } }
public static void DangNhap() { dangNhap dn = new dangNhap(); if (dn.ShowDialog() == DialogResult.OK) { trangChu tc = new trangChu(); Application.Run(tc); } }
private void btn_dangNhap_Click(object sender, EventArgs e) { if (txt_matKhau.Text == "" || txt_tenDN.Text == "") { label4.Visible = true; label4.Text = "Vui lòng nhập đầy đủ thông tin!!"; } else { string user = (txt_tenDN.Text); user = user.Trim(); string pass = txt_matKhau.Text; pass = pass.Trim(); SqlConnection conn = new SqlConnection(con); conn.Open(); String query = String.Format("Select * from TaiKhoan where taiKhoan ='{0}' and matKhau = '{1}'", user, pass); SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read() == true) { trangChu tc = new trangChu(); this.Hide(); tc.ShowDialog(); this.Show(); // DialogResult = DialogResult.OK; } else { label4.Visible = true; label4.Text = "Tên đăng nhập hoặc mật khẩu không đúng!!"; txt_matKhau.Text = ""; } } }