private void Save_Data(bool msg) { try { _KTCTLUONGRepo = new KTCTLUONGRepo(); int i = 0; foreach (int pos in _listUpdate) { int id = Utils.CIntDef(gridView1.GetRowCellValue(pos, "ID"), 0); KT_CTLUONG obj = _KTCTLUONGRepo.GetById(id); if (obj != null) { Get_Data(obj, pos); _KTCTLUONGRepo.Update(obj); i++; } } _listUpdate = new List<int>(); //if (i > 0 && msg) //{ // MessageBox.Show("Lưu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); //} } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public virtual bool InsertDuplicate(List<KT_NHANVIEN> cus, string nam, string thang, string loaibangluong) { try { KTCTLUONGRepo _KTCTLUONGRepo = new KTCTLUONGRepo(); for (int i = 0; i < cus.Count; i++) { db.KT_UNG_LUONGs.InsertOnSubmit( new KT_UNG_LUONG { STT = cus[i].STT, TEN_NV = cus[i].TEN_NV_VIET, NAM = nam, THANG = thang, LOAI_BL = loaibangluong, MA_NV = cus[i].MA_NV, PHONG_BAN = cus[i].PHONG_BAN, TEN_PHONG_BAN = cus[i].TEN_PHONG_BAN, LUONG_CB = cus[i].LUONG_CB, TAM_UNG = _KTCTLUONGRepo.CongThucTinhLuong("KT_NHANVIEN", "TAM_UNG", cus[i].ID) }); db.SubmitChanges(); } return true; } catch { return false; } }
private void Load_Data() { try { _KTCTLUONGRepo = new KTCTLUONGRepo(); gridData.DataSource = _KTCTLUONGRepo.GetAll(); } catch (Exception) { } }
public virtual bool InsertDuplicate(List<KT_NHANVIEN> cus, string nam, string thang, string loaibangluong) { try { //Khai báo Class KTCTLUONGRepo _KTCTLUONGRepo = new KTCTLUONGRepo(); KTUNGLUONGRepo _KTUNGLUONGRepo = new KTUNGLUONGRepo(); KTCHAMCONGRepo _KTCHAMCONGRepo = new KTCHAMCONGRepo(); for (int i = 0; i < cus.Count; i++) { //Công thức tính double _tongLuong = _KTCTLUONGRepo.CongThucTinhLuong("KT_NHANVIEN", "TONG_LUONG", cus[i].ID); double _bhxhNLD = _KTCTLUONGRepo.CongThucTinhLuong("KT_NHANVIEN", "BHXH_NLD", cus[i].ID); double _bhxhCty = _KTCTLUONGRepo.CongThucTinhLuong("KT_NHANVIEN", "BHXH_CTY", cus[i].ID); double _bhytNLD = _KTCTLUONGRepo.CongThucTinhLuong("KT_NHANVIEN", "BHYT_NLD", cus[i].ID); double _bhytCty = _KTCTLUONGRepo.CongThucTinhLuong("KT_NHANVIEN", "BHYT_CTY", cus[i].ID); double _bhtnNLD = _KTCTLUONGRepo.CongThucTinhLuong("KT_NHANVIEN", "BHTN_NLD", cus[i].ID); double _bhtnCty = _KTCTLUONGRepo.CongThucTinhLuong("KT_NHANVIEN", "BHTN_CTY", cus[i].ID); double _kpCD = _KTCTLUONGRepo.CongThucTinhLuong("KT_NHANVIEN", "KP_CD", cus[i].ID); double _luongTN = _KTCTLUONGRepo.CongThucTinhLuongTN("KT_NHANVIEN", "LUONG_TN", cus[i].ID , Utils.CIntDef(thang, 0), Utils.CIntDef(nam, 0), _tongLuong, _bhxhNLD, _bhytNLD, _bhtnNLD); //===========================// db.KT_BANG_LUONGs.InsertOnSubmit( new KT_BANG_LUONG { STT = cus[i].STT, TEN_NV_VIET = cus[i].TEN_NV_VIET, NAM = nam, THANG = thang, LOAI_BL = loaibangluong, MA_NV = cus[i].MA_NV, HSO_LUONG = cus[i].HSO_LUONG, TK_LUONG = cus[i].TK_LUONG, TK_CP_LUONG = cus[i].TK_CP_LUONG, TK_KPCD = cus[i].TK_KPCD, TK_BHXH = cus[i].TK_BHXH, TK_BHYT = cus[i].TK_BHYT, TK_BHTN = cus[i].TK_BHTN, TK_TNCN = cus[i].TK_TNCN, NGAY_CONG = _KTCHAMCONGRepo.getNgayCongByMaNV(nam, thang, cus[i].MA_NV).Count > 0 ? _KTCHAMCONGRepo.getNgayCongByMaNV(nam, thang, cus[i].MA_NV)[0] : 0, NGAY_NGHI = _KTCHAMCONGRepo.getNgayCongByMaNV(nam, thang, cus[i].MA_NV).Count > 0 ? _KTCHAMCONGRepo.getNgayCongByMaNV(nam, thang, cus[i].MA_NV)[1] : 0, LUONG_CB = cus[i].LUONG_CB, PC_CHUCVU = cus[i].PC_CHUCVU, PC_TRACH_NHIEM = cus[i].PC_TRACH_NHIEM, PC_AN = cus[i].PC_AN, PC_THAM_NIEN = cus[i].PC_THAM_NIEN, TONG_LUONG = _tongLuong, BHXH_NLD = _bhxhNLD, BHXH_CTY = _bhxhCty, BHYT_NLD = _bhytNLD, BHYT_CTY = _bhytCty, BHTN_NLD = _bhtnNLD, BHTN_CTY = _bhtnCty, KP_CD = _kpCD, LUONG_TN = _unit.Round(_luongTN, -3), TEN_NV_ANH = cus[i].TEN_NV_ANH, TEN_NV_HOA = cus[i].TEN_NV_HOA, NGAY_SINH = cus[i].NGAY_SINH, GIOI_TINH = cus[i].GIOI_TINH, NOI_SINH = cus[i].NOI_SINH, QUOC_GIA = cus[i].QUOC_GIA, TINH_TP = cus[i].TINH_TP, QUAN_HUYEN = cus[i].QUAN_HUYEN, CMND = cus[i].CMND, NGAY_CAP = cus[i].NGAY_CAP, NOI_CAP = cus[i].NOI_CAP, QUE_QUAN = cus[i].QUE_QUAN, THUONG_TRU = cus[i].THUONG_TRU, TAM_TRU = cus[i].TAM_TRU, DIEN_THOAI1 = cus[i].DIEN_THOAI1, DIEN_THOAI2 = cus[i].DIEN_THOAI2, EMAIL = cus[i].EMAIL, DAN_TOC = cus[i].DAN_TOC, TON_GIAO = cus[i].TON_GIAO, QUOC_TICH = cus[i].QUOC_TICH, VAN_HOA = cus[i].VAN_HOA, CHUYEN_NGANH = cus[i].CHUYEN_NGANH, CHUC_VU = cus[i].CHUC_VU, CHUC_DANH = cus[i].CHUC_DANH, CHUC_VU_DN = cus[i].CHUC_VU_DN, PHONG_BAN = cus[i].PHONG_BAN, THUOC_TO = cus[i].THUOC_TO, NGAY_LUU = cus[i].NGAY_LUU, GHI_CHU = cus[i].GHI_CHU, TEN_PHONG_BAN = cus[i].TEN_PHONG_BAN, TAM_UNG = _KTUNGLUONGRepo.TongTienUngByMaNV(nam,thang,cus[i].MA_NV) }); db.SubmitChanges(); } return true; } catch { return false; } }
private void Save_Tick() { try { _KTCTLUONGRepo = new KTCTLUONGRepo(); int _id = Utils.CIntDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID").ToString(), 0); KT_CTLUONG obj = _KTCTLUONGRepo.GetById(_id); if (obj != null) { obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DANH_DAU"), "").Trim() == "T" ? "" : "T"; _KTCTLUONGRepo.Update(obj); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { try { GridView view = sender as GridView; _KTCTLUONGRepo = new KTCTLUONGRepo(); //Kiểm tra đây là dòng dữ liệu mới hay cũ, nếu là mới thì mình insert if (view.IsNewItemRow(e.RowHandle)) { //e.RowHandle trả về giá trị int là thứ tự của dòng hiện tại KT_CTLUONG obj = new KT_CTLUONG(); Get_Data(obj, e.RowHandle); _KTCTLUONGRepo.Create(obj); } //Cũ thì update else { int id = Utils.CIntDef(gridView1.GetRowCellValue(e.RowHandle, "ID").ToString(), 0); KT_CTLUONG obj = _KTCTLUONGRepo.GetById(id); if (obj != null) { Get_Data(obj, e.RowHandle); _KTCTLUONGRepo.Update(obj); } } Load_Data(); } catch (Exception ex) { e.Valid = false; MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Remove_Data() { try { //if (_listUpdate.Count > 0) //{ // MessageBox.Show("Hãy thực hiện lưu trước khi xóa!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} Save_Data(false); _KTCTLUONGRepo = new KTCTLUONGRepo(); int Id = Utils.CIntDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID").ToString(), 0); _KTCTLUONGRepo.Remove(Id); //MessageBox.Show("Xóa dòng ID:" + Id + " thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Load_Data(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Save_Duplicate() { try { if (MessageBox.Show("Bạn có muốn copy dòng này thành dòng mới?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _KTCTLUONGRepo = new KTCTLUONGRepo(); KT_CTLUONG obj = new KT_CTLUONG(); Get_Data(obj, gridView1.FocusedRowHandle); _KTCTLUONGRepo.Create(obj); MessageBox.Show("Đã copy dòng này vào cuối bảng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }