private void UserInformation_Load(object sender, EventArgs e) { taikhoan tk = new taikhoan(); nhanvien nv = new nhanvien(); AccountDAO1 accountDAO = new AccountDAO1(); StaffDAO1 staffDAO = new StaffDAO1(); tk = accountDAO.getAccountLogedin(); nv = staffDAO.getStaffLogedin(); txtName.Text = nv.hoten; txtCMND.Text = nv.cnmd; txtPhoneNumber.Text = nv.sdt; txtPermission.Text = nv.chucvu; current_gender = (int)nv.gioitinh; if (nv.gioitinh == 1) { cbFemale.Checked = true; } else { cbMale.Checked = true; } txtUsername.Text = tk.tentaikhoan; txtBirth.Text = nv.ngaysinh.ToString(); }
private void iconButton1_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có chắc muốn đổi mật khẩu?", "Thông báo", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { AccountDAO1 accountDAO1 = new AccountDAO1(); try { StaffDAO1 staff = new StaffDAO1(); taikhoan tk = new taikhoan(); tk.manv = staff.getIDbyUsername(Program.idLoged); tk.tentaikhoan = Program.idLoged; tk.matkhau = Script.MD5Hash(txtPass.Text); if (accountDAO1.Edit(tk) == 1) { MessageBox.Show("Cập nhập mật khẩu thành công"); LoadData(); } else { MessageBox.Show("Đổi mật khẩu thất bại"); } } catch { MessageBox.Show("Có lỗi xảy ra!!!"); } } }
public void phanquyen() { StaffDAO1 staff = new StaffDAO1(); if (staff.getStaffLogedin().chucvu == "quản lý") { iconTaiKhoan.Visible = false; iconbtnadmin.Visible = false; iconNCC.Visible = false; } else if (staff.getStaffLogedin().chucvu == "nhân viên") { iconTaiKhoan.Visible = false; iconbtnadmin.Visible = false; iconKho.Visible = false; iconbtnImportGoods.Visible = false; iconNCC.Visible = false; } else if (staff.getStaffLogedin().chucvu == "thủ kho") { iconTaiKhoan.Visible = false; iconbtnadmin.Visible = false; iconKho.Visible = false; iconbtnImportGoods.Visible = false; iconNCC.Visible = false; iconbtnSelling.Visible = false; iconbtnMenuProducts.Visible = false; } }
private void ProceedPayment() { if (txtTotalMoney.Text != "0") { StaffDAO1 staff = new StaffDAO1(); BillDAO1 bill = new BillDAO1(); hoadon h = new hoadon(); h.mahd = bill.getnewID(); h.hoten = txtCustomerName.Text; h.sdt = txtCustomerPhoneNumber.Text; h.ngaylap = DateTime.Now; h.macn = Program.station; h.tong = TotalValue; h.manv = staff.getIDbyUsername(Program.idLoged); if (bill.create(h) == 1) { //MessageBox.Show("Thêm thành công"); ProceedPayment_Detail(h.mahd); } else { MessageBox.Show("Thêm thất bại"); } //int totalValue = TotalValue; //int DiscountMoney = totalValue - Pay; //string CustomerName = txtCustomerName.Text; //string CustomerPhone = txtCustomerPhoneNumber.Text; //int IDCustomer = BillDAO.Instance.AddCustomerInfor(CustomerName, CustomerPhone); //int IDBill = BillDAO.Instance.AddBillInfor(IDCustomer, StaffID, totalValue, DiscountMoney,Pay); } }
private void iconbtnUpdate_Click(object sender, EventArgs e) { if (CheckValid()) { nhanvien nv = new nhanvien(); nv.hoten = txtStaffName.Text; nv.ngaysinh = dtpBirth.Value; if (cbFemale.Checked) { nv.gioitinh = 0; } else { nv.gioitinh = 1; }; nv.cnmd = txtCMND.Text; nv.sdt = txtPhoneNumber.Text; nv.ngaylamviec = dtpDateStart.Value; nv.chucvu = cbbPosition.Text; string chinhanh = cbStation.Text; if (chinhanh == "Chi Nhánh 1") { nv.macn = "CN01"; } else { nv.macn = "CN02"; } //try //{ StaffDAO1 staff = new StaffDAO1(); nv.manv = IDstaff; if (staff.Edit(nv) == 1) { MessageBox.Show("Cập nhập thành công"); Clear(); LoadListStaff(); } else { MessageBox.Show("Cập nhập thất bại"); } //} //catch (Exception ex) //{ // MessageBox.Show("Đã xảy ra lỗi: " + ex.ToString()); //} } else { MessageBox.Show("Chưa nhập đầy đủ hoặc thông tin không hợp lệ"); } }
private void iconbtnAccept_Click(object sender, EventArgs e) { if (txtOldPass.TextLength == 0 || txtConfirmPass.TextLength == 0 || txtNewpass.TextLength == 0) { MessageBox.Show("Vẫn còn thông tin bị bỏ sót"); } else if (txtNewpass.Text != txtConfirmPass.Text) { MessageBox.Show("Mật khẩu không khớp với nhau"); } else if (txtNewpass.TextLength < 6) { MessageBox.Show("Mật khẩu quá ngắn"); } else { if (MessageBox.Show("Bạn có chắc muốn đổi mật khẩu?", "Thông báo", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { AccountDAO1 accountDAO1 = new AccountDAO1(); if (accountDAO1.getAccountLogedin().matkhau != Script.MD5Hash(txtOldPass.Text)) { MessageBox.Show("mật khẩu cũ không đúng"); } else { try { StaffDAO1 staff = new StaffDAO1(); taikhoan tk = new taikhoan(); tk.manv = staff.getIDbyUsername(Program.idLoged); tk.tentaikhoan = Program.idLoged; tk.matkhau = Script.MD5Hash(txtNewpass.Text); if (accountDAO1.Edit(tk) == 1) { MessageBox.Show("Thêm thành công"); } else { MessageBox.Show("Đổi mật khẩu thất bại"); } } catch { MessageBox.Show("Có lỗi xảy ra!!!"); } } } } }
private void iconbtnDelete_Click(object sender, EventArgs e) { StaffDAO1 staff = new StaffDAO1(); if (staff.Delete(IDstaff) == 1) { MessageBox.Show("Xóa nhân viên thành công"); Clear(); LoadListStaff(); } else { MessageBox.Show("Xóa nhân viên thất bại"); } }