public frmTonghopDiemdanh(DTO_NguoiDung nguoidung) { InitializeComponent(); this.NguoiDung = nguoidung; layGiangVienByTenDangNhap(); loadCboLopByMagv(GiangVien.MAGV); }
public void ProcessLogin() { int result; result = Cauhinh.Check_User(txtDangNhap.Text, txtMatKhau.Text); if (result == 0) { MessageBox.Show("Sai" + lblUser.Text + " hoặc " + lblPass.Text); return; } else if (result == 1) { MessageBox.Show("Tài khoản bị khóa"); return; } DataTable table = nguoidungBLL.getNguoiDungByTen(txtDangNhap.Text.Trim()); foreach (DataRow item in table.Rows) { nguoiDung = new DTO_NguoiDung(); nguoiDung.TenDangNhap = item.ItemArray[0].ToString(); nguoiDung.MatKhau = item.ItemArray[1].ToString(); nguoiDung.HoatDong = Convert.ToInt32(item.ItemArray[2]); } this.Hide(); frmMain frmMnger = new frmMain(NguoiDung); frmMnger.ShowDialog(); this.Show(); }
private void btnDangNhap_Click(object sender, EventArgs e) { DTO_NguoiDung user = new DTO_NguoiDung(); user.TenDangNhap = txtTaiKhoan.Text; user.MatKhau = busNguoiDung.encryption(txtMatKhau.Text); if (busNguoiDung.NguoiDungDangNhap(user)) { DataTable dt = busNguoiDung.EmailNguoiDung(user.TenDangNhap); email = dt.Rows[0][0].ToString(); FrmMain.mail = email; MessageBox.Show("Đăng nhập thành công"); FrmMain main = new FrmMain(); main.Show(); this.Hide(); } else { MessageBox.Show("Đăng nhập không thành công, kiểm tra lại tên đăng nhập hoặc mật khẩu"); txtMatKhau.Text = null; txtTaiKhoan.Focus(); } }
public bool DangKy(DTO_NguoiDung user) { try { _conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = _conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "DangKy"; cmd.Parameters.AddWithValue("tenngdung", user.TenNgDung); cmd.Parameters.AddWithValue("tendangnhap", user.TenDangNhap); cmd.Parameters.AddWithValue("email", user.Email); cmd.Parameters.AddWithValue("matkhau", user.MatKhau); cmd.Parameters.AddWithValue("gioitinh", user.GioiTinh); if (cmd.ExecuteNonQuery() > 0) { return(true); } } finally { _conn.Close(); } return(false); }
public bool NguoiDungDangNhap(DTO_NguoiDung user) { try { _conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = _conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "DangNhap"; cmd.Parameters.AddWithValue("tendangnhap", user.TenDangNhap); cmd.Parameters.AddWithValue("matKhau", user.MatKhau); if (Convert.ToInt16(cmd.ExecuteScalar()) > 0) { return(true); } } catch (Exception e) { } finally { _conn.Close(); } return(false); }
public bool UpdateNguoiDung(DTO_NguoiDung a) { try { QL_NguoiDung update = db.QL_NguoiDungs.Where(p => p.TenDangNhap.Trim().Equals(a.TenDangNhap)).SingleOrDefault(); update.MatKhau = a.MatKhau; update.TinhTrang = a.TinhTrang; db.SubmitChanges(); return(true); } catch { return(false); } }
public bool InsertNguoiDung(DTO_NguoiDung a) { try { QL_NguoiDung insert = new QL_NguoiDung(); insert.TenDangNhap = a.TenDangNhap; insert.MatKhau = a.MatKhau; insert.TinhTrang = a.TinhTrang; db.QL_NguoiDungs.InsertOnSubmit(insert); db.SubmitChanges(); return(true); } catch { return(false); } }
List <DTO_NguoiDung> listNguoidung() { List <DTO_NguoiDung> listNguoidung = new List <DTO_NguoiDung>(); DataTable table = nguoidungBll.loadNguoidung(); foreach (DataRow item in table.Rows) { DTO_NguoiDung nguoidung = new DTO_NguoiDung(); if (item.ItemArray[2].ToString() == "0") { nguoidung.TenDangNhap = item.ItemArray[0].ToString(); nguoidung.MatKhau = item.ItemArray[1].ToString(); nguoidung.HoatDong = 0; } else { nguoidung.TenDangNhap = item.ItemArray[0].ToString(); nguoidung.MatKhau = item.ItemArray[1].ToString(); nguoidung.HoatDong = 1; } listNguoidung.Add(nguoidung); } return(listNguoidung); }
public frmMain(DTO_NguoiDung nguoiDung) { InitializeComponent(); this.NguoiDung = nguoiDung; }
public frmMain(DTO_NguoiDung nguoiDung) { InitializeComponent(); this.NguoiDung = nguoiDung; LqnguoiDung = linqnguoiDung.getNguoiDung(NguoiDung.TenDangNhap); }
public bool InsertNguoiDung(DTO_NguoiDung a) { return(dalNguoiDung.InsertNguoiDung(a)); }
public bool UpdateNguoiDung(DTO_NguoiDung a) { return(dalNguoiDung.UpdateNguoiDung(a)); }
private void btnDangKy_Click(object sender, EventArgs e) { string sex; if (rdbtnNam.Checked) { sex = "Nam"; } else { sex = "Nữ"; } //Kiểm tra tên đăng nhập if (txtTenDN.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập tên đăng nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtTenDN.Focus(); return; } //Kiểm tra họ tên else if (txtHoTen.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập tên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtHoTen.Focus(); return; } //Kiểm tra email else if (txtEmail.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập email", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtEmail.Focus(); return; } //Kiểm tra email có tồn tại else if (!IsValid(txtEmail.Text.Trim())) { MessageBox.Show("Bạn phải nhập đúng địa chỉ email", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtEmail.Focus(); return; } //Kiểm tra mật khẩu else if (txtMatKhau.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mật khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMatKhau.Focus(); return; } else if (txtMKNhapLai.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mật khẩu nhập lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMKNhapLai.Focus(); return; } else if (txtMKNhapLai.Text.Trim() != txtMatKhau.Text.Trim()) { MessageBox.Show("Mật khẩu và mật khẩu nhập lại phải giống nhau", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMKNhapLai.Focus(); return; } //Kiểm tra giới tính else if (rdbtnNam.Checked == false && rdbtnNu.Checked == false) { MessageBox.Show("Bạn phải chọn giới tính", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //Thêm người dùng else { DTO_NguoiDung user = new DTO_NguoiDung(txtHoTen.Text, txtTenDN.Text, txtEmail.Text, busNguoiDung.encryption(txtMatKhau.Text), sex); if (busNguoiDung.DangKy(user)) { MessageBox.Show("Đăng ký thành công"); busNguoiDung.SendMail(txtEmail.Text); } else { MessageBox.Show("Đăng thất bại"); } } }