private void btnDel_Click(object sender, EventArgs e) { DataGridViewSelectedRowCollection r = dgvListAcc.SelectedRows; if (r.Count == 1) { int key = Convert.ToInt32(r[0].Cells["Column1"].Value.ToString()); try { BUS_Account.Delete(key); Alert("Đã xóa thành công ^^", frmAlert.Type.Success); dgvListAcc.DataSource = BUS_Account.GetAllAccount(); } catch (Exception) { Alert("Đã xảy ra lỗi !!", frmAlert.Type.Error); } } else { Alert("Vui lòng chọn dòng cần xóa !", frmAlert.Type.Info); } }
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 txtTenDangNhap_OnValueChanged(object sender, EventArgs e) { if (key == 0) { errorProvider1.SetError(txtTenDangNhap, ""); if (BUS_Account.GetAllAccount().SingleOrDefault(p => p.TenDangNhap == txtTenDangNhap.Text) != null) { errorProvider1.SetError(txtTenDangNhap, "Tên đăng nhập đã tồn tại, xin nhập lại !"); } } }
private void btnAdd_Click(object sender, EventArgs e) { var frm = new frmAddAcc(0); this.ParentForm.Opacity = .55; frm.ShowDialog(); this.ParentForm.Opacity = 1; dgvListAcc.DataSource = BUS_Account.GetAllAccount(); }
private void timer1_Tick(object sender, EventArgs e) { if (circleSLTaiKhoan.Value == 20) { timer1.Interval = 5000; } if (circleSLTaiKhoan.Value == 100) { circleSLTaiKhoan.Value = 0; } circleSLTaiKhoan.Value += 20; txtSLNhanVien.Text = BUS_User.GetAllUser().Count().ToString(); txtSLAdmin.Text = BUS_Account.GetAllAccount().Where(p => p.ChucVu == "Admin").ToList().Count().ToString(); txtSLLeTan.Text = BUS_Account.GetAllAccount().Where(p => p.ChucVu == "Lễ Tân").ToList().Count().ToString(); txtSLKinhDoanh.Text = BUS_Account.GetAllAccount().Where(p => p.ChucVu == "Kinh Doanh").ToList().Count().ToString(); txtSLTK.Text = BUS_Account.GetAllAccount().Count().ToString(); }
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); } }
private void btnEdit_Click(object sender, EventArgs e) { DataGridViewSelectedRowCollection r = dgvListAcc.SelectedRows; if (r.Count == 1) { int key = Convert.ToInt32(r[0].Cells["Column1"].Value.ToString()); var frm = new frmAddAcc(key); this.ParentForm.Opacity = .55; frm.ShowDialog(); this.ParentForm.Opacity = 1; dgvListAcc.DataSource = BUS_Account.GetAllAccount(); } else { Alert("Hãy chọn dòng cần sửa", frmAlert.Type.Info); } }
private void UCListAcc_Load(object sender, EventArgs e) { dgvListAcc.DataSource = BUS_Account.GetAllAccount(); }
private void frmLogin_Load(object sender, EventArgs e) { this.Hide(); lst = BUS_Account.GetAllAccount(); }