private void btnEnableDisable_Click(object sender, EventArgs e) { tbl_NhanVien tbltaikhoan = new tbl_NhanVien(); if (dgvttNV.SelectedRows.Count > 0) { foreach (DataGridViewRow row in dgvttNV.SelectedRows) { string maNhanvien = row.Cells["clManv"].Value.ToString(); nhanvien tk = tbltaikhoan.getLstNhanVien().First(c => c.tennv == maNhanvien); if (tk.trangthai == 0) { tk.trangthai = 1; } else { tk.trangthai = 0; } if (tbltaikhoan.update() == true) { loadDgvHienthi(new tbl_NhanVien().getLstNhanVien()); } } } }
private void frmQlNhanvien_Load(object sender, EventArgs e) { cbxQuyenhan.SelectedIndex = 0; tblNhanVien = new tbl_NhanVien(); lstNhanvien = tblNhanVien.getLstNhanVien(); loadDgvHienthi(lstNhanvien); }
private void Init() { _tv = ThuViecBUS.Instance.GetOneData(_id); _hs = NhanVienBUS.Instance.GetOneData(_tv.ThuViecID); txtTen.Caption = _hs.HoTen; bbiGT.Caption = (_hs.GioiTinh ?? default(bool)) ? "Nam" : "Nữ"; }
public ActionResult InfoUpdate(tbl_NhanVien nhanVien) { bool result = false; using (HutechMartDbContext db = new HutechMartDbContext()) { using (var trans = db.Database.BeginTransaction()) { try { var _nhanVien = db.tbl_NhanVien.Find(nhanVien.id); _nhanVien.sodienthoai = nhanVien.sodienthoai; _nhanVien.facebook = nhanVien.facebook; _nhanVien.email = nhanVien.email; db.SaveChanges(); trans.Commit(); result = true; } catch { trans.Rollback(); } } } return(Json(result, JsonRequestBehavior.AllowGet)); }
private void btnDoimatkhau_Click(object sender, EventArgs e) { if (txtMatkhaucu.Text != "" && txtMatkhaumoi.Text != "" && txtMatkhaumoi2.Text != "") { tbl_NhanVien tblTaikhoan = new tbl_NhanVien(); string mkMD5 = tblTaikhoan.getMd5(txtMatkhaucu.Text); if (mkMD5 != ttTaiKhoan.get().passwword) { MessageBox.Show("Mật khẩu không chính xác"); } else { if (txtMatkhaumoi.Text.Trim() != txtMatkhaumoi2.Text.Trim()) { MessageBox.Show(" Mật khẩu mới nhập phải giống nhau "); } else { string mkmoiMD5 = tblTaikhoan.getMd5(txtMatkhaumoi.Text); nhanvien taikhoan = tblTaikhoan.getLstNhanVien().FirstOrDefault(); taikhoan.passwword = mkmoiMD5; if (tblTaikhoan.update() == true) { MessageBox.Show(" Đổi mật khẩu thành công"); txtMatkhaumoi.Text = ""; txtMatkhaumoi2.Text = ""; txtMatkhaucu.Text = ""; } } } } }
private void bbiSaveAndNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { SaveData(); ResetData(); _id = -1; _hoSo = new tbl_NhanVien(); }
private void btndangnhap_Click(object sender, EventArgs e) { if (txtten.Text == "" || txtmatkhau.Text == "") { MessageBox.Show("Cần nhập đủ thông tin."); } else { if (counts <= 3) { tbl_NhanVien tblnhanvien = new tbl_NhanVien(); string username = txtten.Text; string password = tblnhanvien.getMd5(txtmatkhau.Text); nhanvien nv = tblnhanvien.getLstNhanVien().FirstOrDefault(c => c.email == username && c.passwword == password); if (nv != null) { //trường hợp đăng nhập thành công if (nv.trangthai == 0) { //trường hợp tài khoản bị disable MessageBox.Show("Không thể đăng nhập vào tài khoản"); return; } ttTaiKhoan.set(nv); //if (nv.quyenhan == 1) //{ // //trường hợp tài khoản là admin form home admin // frmHomeAdmin frm = new frmHomeAdmin(); // frm.Show(); //} //else //{ // frmHomeUser frm = new frmHomeUser(); // frm.Show(); // //trường hợp tài khoản là user sẽ dẫn tời form home user //} //trường hợp tài khoản là admin form home admin frmQlNhanvien frm = new frmQlNhanvien(); frm.Show(); this.Hide(); } else { //trường hợp đăng nhập không thành công MessageBox.Show("Tài khoản hoặc mật khẩu không chính xác"); counts++; } } else { timer.Start(); label4.Text = (label4.Text == "") ? "30" : label4.Text; MessageBox.Show("Vui lòng đăng nhập lại sau " + label4.Text + " giây"); } } }
public JsonResult SaveData(string strEmployee) { JavaScriptSerializer serializer = new JavaScriptSerializer(); tbl_NhanVien employee = serializer.Deserialize <tbl_NhanVien>(strEmployee); bool status = false; string message = string.Empty; //add new employee if id = 0 if (employee.Id == 0) { db.tbl_NhanVien.Add(employee); try { db.SaveChanges(); status = true; } catch (Exception ex) { status = false; message = ex.Message; } } else { //update existing DB //save db var entity = db.tbl_NhanVien.Find(employee.Id); entity.tenNV = employee.tenNV; entity.NgaySinh = employee.NgaySinh; entity.Status = employee.Status; entity.gioitinh = employee.gioitinh; entity.ChucVu = employee.ChucVu; entity.Id_Quyen = employee.Id_Quyen; entity.UserName = employee.UserName; entity.Password = employee.Password; entity.Status = employee.Status; entity.Luong = employee.Luong; try { db.SaveChanges(); status = true; } catch (Exception ex) { status = false; message = ex.Message; } } return(Json(new { status = status, message = message })); }
public ActionResult Create(tbl_NhanVien nhanVien, HttpPostedFileBase hinhAnh) { bool result = false; if (hinhAnh == null) { nhanVien.hinhanh = "NguoiDung.jpg"; } else { nhanVien.hinhanh = GetImage(hinhAnh, nhanVien.tennhanvien); } nhanVien.tinhtrang = true; nhanVien.ngaytao = DatetimeLocation.GetDate(); using (HutechMartDbContext db = new HutechMartDbContext()) { using (var trans = db.Database.BeginTransaction()) { try { db.tbl_NhanVien.Add(nhanVien); db.SaveChanges(); var dangNhap = new tbl_DangNhap(); dangNhap.id_nhanvien = nhanVien.id; dangNhap.taikhoan = nhanVien.sodienthoai; dangNhap.matkhau = nhanVien.sodienthoai; if (nhanVien.id_chucvu != 1) { dangNhap.loaitaikhoan = true; } else { dangNhap.loaitaikhoan = false; } db.tbl_DangNhap.Add(dangNhap); db.SaveChanges(); trans.Commit(); result = true; } catch { trans.Rollback(); } } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult Update(string model) { JavaScriptSerializer serializer = new JavaScriptSerializer(); tbl_NhanVien nv = serializer.Deserialize <tbl_NhanVien>(model); //var entity = new NhanVienDao().GetById(nv.Id); var entity = db.tbl_NhanVien.Single(e => e.Id == nv.Id); entity.Luong = nv.Luong; db.SaveChanges(); return(Json(new { status = true })); }
public tbl_NhanVien GetOneData(int id) { try { tbl_NhanVien data = db.tbl_NhanVien.Find(id); return(data); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } }
public ActionResult Update(tbl_NhanVien nhanVien, HttpPostedFileBase hinhAnh) { bool result = false; using (HutechMartDbContext db = new HutechMartDbContext()) { var _nhanVien = db.tbl_NhanVien.FirstOrDefault(x => x.id == nhanVien.id); if (hinhAnh != null) { Random rd = new Random(); var thayAnh = nhanVien.tennhanvien + rd.Next(1, 10); nhanVien.hinhanh = GetImage(hinhAnh, thayAnh); } else { nhanVien.hinhanh = _nhanVien.hinhanh; } using (var trans = db.Database.BeginTransaction()) { try { _nhanVien.hinhanh = nhanVien.hinhanh; _nhanVien.id_cuahang = nhanVien.id_cuahang; _nhanVien.id_chucvu = nhanVien.id_chucvu; _nhanVien.tennhanvien = nhanVien.tennhanvien; _nhanVien.gioitinh = nhanVien.gioitinh; _nhanVien.ngaysinh = nhanVien.ngaysinh; _nhanVien.sochungminh = nhanVien.sochungminh; _nhanVien.sodienthoai = nhanVien.sodienthoai; _nhanVien.email = nhanVien.email; _nhanVien.facebook = nhanVien.facebook; _nhanVien.diachi_tentinh = nhanVien.diachi_tentinh; _nhanVien.diachi_tenquan = nhanVien.diachi_tenquan; _nhanVien.diachi_tenphuong = nhanVien.diachi_tenphuong; _nhanVien.diachi_sonha = nhanVien.diachi_sonha; _nhanVien.ghichu = nhanVien.ghichu; _nhanVien.id_nguoicapnhat = nhanVien.id_nguoicapnhat; _nhanVien.ngaycapnhat = DateTime.Now; db.SaveChanges(); trans.Commit(); result = true; } catch { trans.Rollback(); } } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public tbl_NhanVien AddData(tbl_NhanVien data) { try { tbl_NhanVien d = db.tbl_NhanVien.Add(data); db.SaveChanges(); return(d); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } }
public int UpdateData(tbl_NhanVien data) { try { var update = db.tbl_NhanVien.Find(data.NhanVienID); update.copy(data); db.SaveChanges(); return(1); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(0); } }
public int DeleteData(int id) { try { tbl_NhanVien tb = db.tbl_NhanVien.Find(id); db.tbl_NhanVien.Remove(tb); db.SaveChanges(); return(1); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(-1); } }
private void bbiChapNhan_ItemClick(object sender, ItemClickEventArgs e) { if (list[gridView1.GetSelectedRows()[0]].NgayKetThucThuViec <= DateTime.Now) { if (XtraMessageBox.Show("Bạn có chắc chắn nhận không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { tbl_NhanVien _hs = NhanVienBUS.Instance.GetOneData(list[gridView1.GetSelectedRows()[0]].NhanVienID ?? default(int)); _hs.TrangThai = 5; NhanVienBUS.Instance.UpdateData(_hs); LoadData(); } } else { XtraMessageBox.Show("Thử việc vẫn chưa kết thúc", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnsuaNV_Click(object sender, EventArgs e) { if (Manv == "") { return; } if (txtdiachi.Text != "" && txtTennv.Text != "" && txtsoCMNN.Text != "" && txtemail.Text != "") { tbl_NhanVien tblNhanvien = new tbl_NhanVien(); nhanvien Nhanvien = tblNhanvien.getLstNhanVien().FirstOrDefault(); ttTaiKhoan tbl = new ttTaiKhoan(); if (cbxquyenhan.SelectedIndex == 2) { Nhanvien.quyenhan = 1; } else if (cbxquyenhan.SelectedIndex == 1) { Nhanvien.quyenhan = 2; } Nhanvien.diachi = txtdiachi.Text; Nhanvien.email = txtemail.Text; Nhanvien.sdt = txtsdt.Text; Nhanvien.cmnd = txtsoCMNN.Text; Nhanvien.tennv = txtTennv.Text; // Nhanvien.giottinh = (rdbNvnam.Checked == "") ? true : false; if (Nhanvien.giottinh != " ") { rdbNvnam.Checked = true; } else { rdbNvnu.Checked = true; } if (tblNhanvien.update() == true) { MessageBox.Show(" Thay đổi thông tin thành công "); } else { MessageBox.Show(" Thay đổi thông tin không thành công "); } } }
private void LoadData(int id) { _id = id; _tv = ThuViecBUS.Instance.GetOneData(id); _hoSo = NhanVienBUS.Instance.GetOneData(_tv.NhanVienID ?? default(int)); txtHoTen.Text = _hoSo.HoTen; dNgaySinh.EditValue = _hoSo.NgaySinh; txtBacLuong.Text = _hoSo.LuongYeuCau; txtDanToc.Text = _hoSo.DanToc; txtDiaChi.Text = _hoSo.DanToc; txtEmail.Text = _hoSo.Email; txtMoTa.Text = _hoSo.Mota; txtSDT.Text = _hoSo.SDT; radioGroup1.SelectedIndex = _hoSo.GioiTinh ?? default(bool) ? 0 : 1; for (int i = 0; i < listChuyenMon.Count; ++i) { if (listChuyenMon[i].ChuyenMonID == _hoSo.ChuyenMonID) { cbbCM.SelectedIndex = i; } } for (int i = 0; i < listPhongBan.Count; ++i) { if (listPhongBan[i].PhongBanID == _hoSo.PhongBanID) { cbbPhongBan.SelectedIndex = i; } } for (int i = 0; i < listChucVu.Count; ++i) { if (listChucVu[i].ChucVuID == _hoSo.ChucVuID) { cbbViTri.SelectedIndex = i; } } for (int i = 0; i < listTrinhDoHocVan.Count; ++i) { if (listTrinhDoHocVan[i].TrinhDoHocVanID == _hoSo.TDHVID) { cbbTDHV.SelectedIndex = i; } } }
private void frmttNhanvien_Load(object sender, EventArgs e) { cbxquyenhan.SelectedIndex = 0; if (ttTaiKhoan.get().quyenhan == 1) { cbxquyenhan.Items.RemoveAt(1); } else if (ttTaiKhoan.get().quyenhan == 2) { cbxquyenhan.Items.RemoveAt(2); } if (this.Tag != null) { Manv = this.Tag.ToString(); nhanvien Nhanvien = new tbl_NhanVien().getLstNhanVien().FirstOrDefault(); string maNhanvien = Convert.ToString(Nhanvien.manv); txtdiachi.Text = Nhanvien.diachi; txtemail.Text = Nhanvien.email; txtTennv.Text = Nhanvien.tennv; txtmanv.Text = maNhanvien; txtsdt.Text = Nhanvien.sdt; txtsoCMNN.Text = Nhanvien.cmnd; if (Nhanvien.giottinh == " ") { rdbNvnam.Checked = true; } else { rdbNvnu.Checked = true; } if (Nhanvien.quyenhan == 1) { cbxquyenhan.Text = "Admin"; } else if (Nhanvien.quyenhan == 2) { cbxquyenhan.Text = "Nhân Viên "; } txtmanv.ReadOnly = true; } }
private void btnXoa_Click(object sender, EventArgs e) { if (dgvNhanVien.SelectedRows.Count > 0) { if (XtraMessageBox.Show("Bạn có muốn xóa không ? ", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { string manv = txtMaNV.Text; tbl_NhanVien nv = db.tbl_NhanVien.Find(manv); db.tbl_NhanVien.Remove(nv); db.SaveChanges(); HienThiDSNhanVien(); setNull(); } } else { XtraMessageBox.Show("Vui lòng chọn dòng cần xóa"); } }
private void dgvttNV_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { string maNhanvien = dgvttNV.Rows[e.RowIndex].Cells["clManv"].Value.ToString(); frmttNhanvien frm = new frmttNhanvien(); frm.Tag = maNhanvien; frm.ShowDialog(); nhanvien nv = new tbl_NhanVien().getLstNhanVien().FirstOrDefault(); if (nv != null) { if (nv.quyenhan == 1) { dgvttNV.Rows[e.RowIndex].Cells["clQuyenhan"].Value = "Admin"; } else if (nv.quyenhan == 2) { dgvttNV.Rows[e.RowIndex].Cells["clQuyenhan"].Value = "Nhân viên"; } if (nv.trangthai == 0) { dgvttNV.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red; dgvttNV.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Gold; } dgvttNV.Rows[e.RowIndex].Cells["clTennv"].Value = nv.tennv; dgvttNV.Rows[e.RowIndex].Cells["clGioitinh"].Value = (nv.giottinh == null) ? "Nam" : "Nữ"; dgvttNV.Rows[e.RowIndex].Cells["clSdt"].Value = nv.sdt; dgvttNV.Rows[e.RowIndex].Cells["clDiachi"].Value = nv.diachi; dgvttNV.Rows[e.RowIndex].Cells["clSocmnd"].Value = nv.cmnd; dgvttNV.Rows[e.RowIndex].Cells["clEmail"].Value = nv.email; // dgvttNV.Rows[e.RowIndex].Cells["clMatkhau"].Value = nv.passwword; // dgvttNV.Rows[e.RowIndex].Cells["clTrangthai"].Value = nv.trangthai; } else { dgvttNV.Rows.Remove(dgvttNV.Rows[e.RowIndex]); } } }
public bool Update(tbl_NhanVien entity) { try { var nv = db.tbl_NhanVien.Find(entity.Id); nv.ChucVu = entity.ChucVu; nv.gioitinh = entity.gioitinh; nv.Id_Quyen = entity.Id_Quyen; nv.NgaySinh = entity.NgaySinh; if (!string.IsNullOrEmpty(entity.Password)) { nv.Password = entity.Password; } nv.Status = entity.Status; nv.tenNV = entity.tenNV; db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public long Insert(tbl_NhanVien entity) { db.tbl_NhanVien.Add(entity); db.SaveChanges(); return(entity.Id); }
private void SaveData() { if (cbbCM.Text == "" || cbbPhongBan.Text == "" || cbbTDHV.Text == "" || cbbViTri.Text == "" || txtBacLuong.Text == "" || txtDanToc.Text == "" || txtDiaChi.Text == "" || txtEmail.Text == "" || txtHoTen.Text == "" || txtMoTa.Text == "" || txtSDT.Text == "") { XtraMessageBox.Show("Không được bỏ trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (_id == -1) { int phongBanID = listPhongBan[cbbPhongBan.SelectedIndex].PhongBanID; int chucVuID = listChucVu[cbbViTri.SelectedIndex].ChucVuID; int trinhdoID = listTrinhDoHocVan[cbbTDHV.SelectedIndex].TrinhDoHocVanID; int chuyenMonID = listChuyenMon[cbbCM.SelectedIndex].ChuyenMonID; tbl_NhanVien t = new tbl_NhanVien(); t.HoTen = txtHoTen.Text; t.NgaySinh = Convert.ToDateTime(dNgaySinh.Text); t.QueQuan = txtDiaChi.Text; t.GioiTinh = (radioGroup1.SelectedIndex == 0); t.DanToc = txtDanToc.Text; t.SDT = txtSDT.Text; t.Email = txtEmail.Text; t.PhongBanID = phongBanID; t.ChucVuID = chucVuID; t.TDHVID = trinhdoID; t.LuongYeuCau = txtBacLuong.Text; t.TrangThai = 1; t.ChuyenMonID = chuyenMonID; _hoSo = NhanVienBUS.Instance.AddData(t); tbl_HoSoPV h = new tbl_HoSoPV(); h.NhanVienID = _hoSo.NhanVienID; h = HoSoPVBUS.Instance.AddData(h); _hoSo.HoSoPVID = h.HoSoPVID; NhanVienBUS.Instance.UpdateData(_hoSo); } else { int phongBanID = listPhongBan[cbbPhongBan.SelectedIndex].PhongBanID; int chucVuID = listChucVu[cbbViTri.SelectedIndex].ChucVuID; int trinhdoID = listTrinhDoHocVan[cbbTDHV.SelectedIndex].TrinhDoHocVanID; int chuyenMonID = listChuyenMon[cbbCM.SelectedIndex].ChuyenMonID; tbl_NhanVien t = new tbl_NhanVien(); t.NhanVienID = _hoSo.NhanVienID; t.HoTen = txtHoTen.Text; t.NgaySinh = Convert.ToDateTime(dNgaySinh.Text); t.QueQuan = txtDiaChi.Text; t.GioiTinh = (radioGroup1.SelectedIndex == 0); t.DanToc = txtDanToc.Text; t.SDT = txtSDT.Text; t.Email = txtEmail.Text; t.PhongBanID = phongBanID; t.ChucVuID = chucVuID; t.TDHVID = trinhdoID; t.LuongYeuCau = txtBacLuong.Text; t.TrangThai = 1; t.ChuyenMonID = chuyenMonID; t.HoSoPVID = _hoSo.HoSoPVID; NhanVienBUS.Instance.UpdateData(t); _hoSo = t; } XtraMessageBox.Show("Lưu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnLuu_Click(object sender, EventArgs e) { try { string manv = txtMaNV.Text; string tennv = txtTenNV.Text; DateTime ngaysinh = DateTime.Parse(dtpNgaySinh.Value.ToString("dd/MM/yyyy")); float luong = float.Parse(txtLuong.Text); string diachi = txtDiaChi.Text; string gioitinh; if (rdbNam.Checked == true) { gioitinh = "Nam"; } else { gioitinh = "Nữ"; } string sdt = txtSDT.Text; string email = txtEmail.Text; string chucvu = cboChucVu.SelectedValue.ToString(); if (Flag == true) { if (db.tbl_NhanVien.SqlQuery("select * from tbl_NhanVien").Where(m => m.MaNhanVien.Contains(txtMaNV.Text)).Count() > 0) { XtraMessageBox.Show("Mã nhân viên nhập sai hoặc bị trùng", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (txtTenNV.Text == "" || txtLuong.Text == "" || txtDiaChi.Text == "" || txtSDT.Text == "" || txtEmail.Text == "") { XtraMessageBox.Show("Vui lòng nhập đầy đủ thông tin!"); } else { tbl_NhanVien nv = new tbl_NhanVien(); nv.MaNhanVien = manv; nv.HoTen = tennv; nv.NgaySinh = ngaysinh; nv.Luong = luong; nv.DiaChi = diachi; nv.GioiTinh = gioitinh; nv.SDT = sdt; nv.Email = email; nv.MaChucVu = chucvu; db.tbl_NhanVien.Add(nv); db.SaveChanges(); HienThiDSNhanVien(); XtraMessageBox.Show("Thêm nhân viên thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); setNull(); setButton(true); setKhoa(true); } } } else { tbl_NhanVien nv = db.tbl_NhanVien.Where(m => m.MaNhanVien == manv).FirstOrDefault(); nv.HoTen = tennv; nv.NgaySinh = ngaysinh; nv.Luong = luong; nv.DiaChi = diachi; nv.GioiTinh = gioitinh; nv.SDT = sdt; nv.Email = email; nv.MaChucVu = chucvu; if (nv == null) { XtraMessageBox.Show("Nhân viên không tồn tại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { db.Entry(nv).State = EntityState.Modified; db.SaveChanges(); HienThiDSNhanVien(); XtraMessageBox.Show("Cập nhật thành công!", "Thông Báo"); setNull(); setButton(true); setKhoa(true); } } } catch { } }
public int UpdateData(tbl_NhanVien data) { return(NhanVienDAO.Instance.UpdateData(data)); }
private void btnthemNV_Click(object sender, EventArgs e) { if (Manv != "") { txtmanv.ReadOnly = false; cbxquyenhan.Enabled = true; txtmanv.Text = ""; txtdiachi.Text = ""; txtTennv.Text = ""; txtsoCMNN.Text = ""; txtsdt.Text = ""; // txtmatkhau.Text = ""; Manv = ""; return; } if (txtdiachi.Text != "" && txtTennv.Text != "" && txtsoCMNN.Text != "" && txtemail.Text != "") { if (cbxquyenhan.SelectedIndex < 0) { MessageBox.Show("Chọn quyền hạn không hợp lệ "); } tbl_NhanVien tblTaikhoan = new tbl_NhanVien(); nhanvien taikhoan = tblTaikhoan.getLstNhanVien().FirstOrDefault(); string mkMD5 = tblTaikhoan.getMd5(txtmanv.Text); taikhoan.passwword = mkMD5; taikhoan.trangthai = 1; int Quyenhan = 2;//Nhân viên if (cbxquyenhan.SelectedIndex == 2) { Quyenhan = 1;//Admin } else if (cbxquyenhan.SelectedIndex == 1) { Quyenhan = 2;// Nhân viên } taikhoan.quyenhan = Quyenhan; if (tblTaikhoan.add(taikhoan) == true) { nhanvien Tnhanvien = new nhanvien(); tbl_NhanVien tblNhavien = new tbl_NhanVien(); Tnhanvien.diachi = txtdiachi.Text; Tnhanvien.email = txtemail.Text; Tnhanvien.sdt = txtsdt.Text; Tnhanvien.tennv = txtTennv.Text; Tnhanvien.cmnd = txtsoCMNN.Text; Tnhanvien.manv = Convert.ToInt32(txtmanv.Text); if (tblNhavien.add(Tnhanvien) == true) { MessageBox.Show("Thêm tài khoản thành công"); } else { MessageBox.Show(" Thêm tài khoản không thành công"); } } else { MessageBox.Show(" Thêm tài khoản không thành công"); } } else { MessageBox.Show("Bạn cần nhập đủ thông tin"); } }
private void Init() { listPhongBan = PhongBanBUS.Instance.GetAllData(); foreach (var t in listPhongBan) { cbbPhongBan.Properties.Items.Add(t.TenPhongBan); } listChucVu = ChucVuBUS.Instance.GetAllData(); foreach (var t in listChucVu) { cbbViTri.Properties.Items.Add(t.TenChucVu); } listTrinhDoHocVan = TrinhDoHocVanBUS.Instance.GetAllData(); foreach (var t in listTrinhDoHocVan) { cbbTDHV.Properties.Items.Add(t.TenTrinhDoHocVan); } listChuyenMon = ChuyenMonBUS.Instance.GetAllData(); foreach (var t in listChuyenMon) { cbbCM.Properties.Items.Add(t.TenChuyenMon); } _tv = ThuViecBUS.Instance.GetOneData(_id); _hoSo = NhanVienBUS.Instance.GetOneData(_tv.NhanVienID ?? default(int)); txtHoTen.Text = _hoSo.HoTen; dNgaySinh.EditValue = _hoSo.NgaySinh; txtBacLuong.Text = _hoSo.LuongYeuCau; txtDanToc.Text = _hoSo.DanToc; txtDiaChi.Text = _hoSo.DanToc; txtEmail.Text = _hoSo.Email; txtSDT.Text = _hoSo.SDT; radioGroup1.SelectedIndex = _hoSo.GioiTinh ?? default(bool) ? 0 : 1; for (int i = 0; i < listChuyenMon.Count; ++i) { if (listChuyenMon[i].ChuyenMonID == _hoSo.ChuyenMonID) { cbbCM.SelectedIndex = i; } } for (int i = 0; i < listPhongBan.Count; ++i) { if (listPhongBan[i].PhongBanID == _hoSo.PhongBanID) { cbbPhongBan.SelectedIndex = i; } } for (int i = 0; i < listChucVu.Count; ++i) { if (listChucVu[i].ChucVuID == _hoSo.ChucVuID) { cbbViTri.SelectedIndex = i; } } for (int i = 0; i < listTrinhDoHocVan.Count; ++i) { if (listTrinhDoHocVan[i].TrinhDoHocVanID == _hoSo.TDHVID) { cbbTDHV.SelectedIndex = i; } } }
public tbl_NhanVien AddData(tbl_NhanVien data) { return(NhanVienDAO.Instance.AddData(data)); }