private void btnLogin_Click(object sender, EventArgs e) { if (txtPass.Text == "") { Alert("Bạn Chưa Nhập Pass", frmAlert.Type.Warning); } else { bool check = false; for (int i = 0; i < lst.Count(); i++) { if (txtTen.Text == lst[i].TenDangNhap.ToString()) { check = true; if (lst[i].MatKhau.ToString() == BUS_Account.MaHoa(txtPass.Text)) { Alert("Đăng nhập thành công !", frmAlert.Type.Success); if (lst[i].ChucVu == "Admin") { this.Hide(); var frm = new frmAdmin(lst[i].STT); frm.ShowDialog(); Alert("Đã đăng xuất!", frmAlert.Type.Info); this.Show(); lst = BUS_Account.GetAllAccount(); txtPass.Text = null; } if (lst[i].ChucVu == "Lễ Tân") { this.Hide(); var frm = new frmLeTan(lst[i].STT); frm.ShowDialog(); Alert("Đã đăng xuất!", frmAlert.Type.Info); this.Show(); txtPass.Text = null; } break; } else { Alert("Nhập Sai Pass Rồi !", frmAlert.Type.Error); break; } } else { check = false; } } if (!check) { Alert("Sai tên đăng nhập !", frmAlert.Type.Error); } } }
private void btnAccept_Click(object sender, EventArgs e) { try { if (txtCMND.Text == "" || txtPass.Text == "" || txtTenDangNhap.Text == "") { Alert("Vui lòng điền đầy đủ", frmAlert.Type.Info); } if (txtPass.Text.Equals(txtPassRepeat.Text) && txtPassRepeat.Text != "") { DTO_Account acc = new DTO_Account(); int stt = BUS_Account.GetAllAccount().Count(); if (key != 0) { acc.STT = stt; } else { acc.STT = stt + 1; } acc.CMND = Convert.ToInt32(txtCMND.Text); acc.TenDangNhap = txtTenDangNhap.Text; acc.MatKhau = BUS_Account.MaHoa(txtPassRepeat.Text); acc.ChucVu = cbbChucVu.selectedValue.ToString(); if (key != 0) { acc.TenDangNhap = txtTenDangNhap.Text; acc.MatKhau = BUS_Account.MaHoa(txtPassRepeat.Text); acc.ChucVu = cbbChucVu.selectedValue.ToString(); BUS_Account.InsertUpdate(acc); Alert(msg, frmAlert.Type.Success); } else { BUS_Account.InsertUpdate(acc); msg = "Đã thêm thành công ^^"; Alert(msg, frmAlert.Type.Success); } } } catch (Exception) { Alert("Hãy thêm hồ sơ người này trước!", frmAlert.Type.Error); } }