//sự kiện nhấn nút lưu sửa public void btnSuaThongTin_Click(object sender, DirectEventArgs e) { NhanVien_BaoHiemController nvc = new NhanVien_BaoHiemController(); DAL.BHNHANVIEN_BAOHIEM nvbh = nvc.GetNhanVien_BaoHiemByMaNhanVien(hdfIDNhanVienBaoHiem.Text); if (txtHoTenMoi.Text != "") { nvbh.HoTen = txtHoTenMoi.Text; nvbh.Ten = new CommonUtil().GetFirstNamFromFullName(txtHoTenMoi.Text); } if (!string.IsNullOrEmpty(nfNgayMoi.Text) && !string.IsNullOrEmpty(nfThangMoi.Text) && !string.IsNullOrEmpty(nfNamMoi.Text)) { nvbh.NgaySinh = new DateTime(int.Parse(nfNamMoi.Text), int.Parse(nfThangMoi.Text), int.Parse(nfNgayMoi.Text)); } if (cbbGioiTinhMoi.SelectedIndex > -1) { nvbh.GioiTinh = cbbGioiTinhMoi.Value.ToString() != "0"; } if (!string.IsNullOrEmpty(txtSoCMNDMoi.Text)) { nvbh.SoCMTND = txtSoCMNDMoi.Text; } if (!string.IsNullOrEmpty(nfNgayCapMoi.Text) && !string.IsNullOrEmpty(nfThangCapMoi.Text) && !string.IsNullOrEmpty(nfNamCapMoi.Text)) { nvbh.NgayCapCMTND = new DateTime(int.Parse(nfNamCapMoi.Text), int.Parse(nfThangCapMoi.Text), int.Parse(nfNgayCapMoi.Text)); } if (cbbNoiCapCMNDMoi.SelectedIndex > -1) { nvbh.NoiCapCMTND = cbbNoiCapCMNDMoi.Value.ToString(); } if (!string.IsNullOrEmpty(txtDiaChiMoi.Text)) { nvbh.DiaChiLienHe = txtDiaChiMoi.Text; } nvbh.NoiDangKyKCB = txtNoiDangKyKCBMoi.Value == null ? "" : txtNoiDangKyKCBMoi.Value.ToString(); nvbh.SoTheBHYT = txtSoTheBHYTSua.Text; nvbh.TuThangBHYT = bhc.SetValueDatetime(spinTuNamBHYTSua, cbbTuThangBHYTSua, 1); nvbh.DenThangBHYT = bhc.SetValueDatetime(spinDenNamBHYTSua, cbbDenThangBHYTSua, 1); nvbh.BHXHTrangThaiDangKyCQBH = chkDaDangKyCQBHSua.Checked; nvbh.NgayDangKyBHXH = bhc.SetValueDatetime(spinNamDangKyBHXHSua, cbbThangDangKyBHXHSua, 1); nvbh.DangDongBHXH = chkDongBHXH.Checked; nvbh.DangDongBHYT = chkDongBHYT.Checked; nvbh.DangDongBHTN = chkDongBHTN.Checked; //nvbh.TrangThaiCapSoBHXH = cbbTrangThaiCapSoSua.SelectedItem.Value; nvbh.TrangThaiCapSoBHXH = hdfTrangThaiCapSoSua.Text; //nvbh.TrangThaiCapTheBHYT = cboTrangThaiCapThe.SelectedItem.Value; nvbh.TrangThaiCapTheBHYT = hdfTrangThaiCapThe.Text; nvbh.NoiCapSoBHXH = hdfNoiCapSoBHXHSua.Text; nvbh.SoSoBHXH = txtSoSoBHXHSua.Text; if (!string.IsNullOrEmpty(txtLuongBaoHiemSua.Text)) { nvbh.LuongBaoHiem = decimal.Parse(txtLuongBaoHiemSua.Text); } if (!string.IsNullOrEmpty(txtPhuCapCVSua.Text)) { nvbh.PhuCapCV = decimal.Parse(txtPhuCapCVSua.Text); } if (!string.IsNullOrEmpty(txtPhuCapKhacSua.Text)) { nvbh.PhuCapKhac = decimal.Parse(txtPhuCapKhacSua.Text); } if (!string.IsNullOrEmpty(txtPhuCapTNNgheSua.Text)) { nvbh.PhuCapTNN = decimal.Parse(txtPhuCapTNNgheSua.Text); } if (!string.IsNullOrEmpty(txtPhuCapTNVKSua.Text)) { nvbh.PhuCapTNVK = decimal.Parse(txtPhuCapTNVKSua.Text); } //if (dfNgayCapSoBHXHSua.Value != null && !dfNgayCapSoBHXHSua.SelectedDate.ToString().Contains("0001")) // nvbh.NgayCapSoBHXH = dfNgayCapSoBHXHSua.SelectedDate; if (!Util.GetInstance().IsDateNull(dfNgayCapSoBHXHSua.SelectedDate)) { nvbh.NgayCapSoBHXH = dfNgayCapSoBHXHSua.SelectedDate; } int thangold = nvbh.ThoiGianDongBHXHTruocKhiVaoCongTy; nvbh.ThoiGianDongBHXHTruocKhiVaoCongTy = int.Parse(nfSoThangDongTruocSua.Text == "" ? "0" : nfSoThangDongTruocSua.Text) + int.Parse(nfSoNamDongTruocSua.Text == "" ? "0" : nfSoNamDongTruocSua.Text) * 12; nvbh.ThoiGianDongBaoHiem = (nvbh.ThoiGianDongBaoHiem - thangold) + nvbh.ThoiGianDongBHXHTruocKhiVaoCongTy; nvc.UpdateNhanVien_BaoHiem(nvbh); #region update ngược lại bảng hồ sơ var hsc = new HoSoController(); DAL.HOSO hoso = hsc.GetByMaCB(hdfIDNhanVienBaoHiem.Text); if (!string.IsNullOrEmpty(txtHoTenMoi.Text)) { hoso.HO_TEN = txtHoTenMoi.Text; hoso.TEN_CB = new CommonUtil().GetFirstNamFromFullName(txtHoTenMoi.Text); } else { hoso.HO_TEN = txtHoTenCu.Text; } if (!string.IsNullOrEmpty(nfNgayMoi.Text) && !string.IsNullOrEmpty(nfThangMoi.Text) && !string.IsNullOrEmpty(nfNamMoi.Text)) { hoso.NGAY_SINH = new DateTime(int.Parse(nfNamMoi.Text), int.Parse(nfThangMoi.Text), int.Parse(nfNgayMoi.Text)); } else if (!string.IsNullOrEmpty(nfNgayCu.Text) && !string.IsNullOrEmpty(nfThangCu.Text) && !string.IsNullOrEmpty(nfNamCu.Text)) { hoso.NGAY_SINH = new DateTime(int.Parse(nfNamCu.Text), int.Parse(nfThangCu.Text), int.Parse(nfNgayCu.Text)); } if (cbbGioiTinhMoi.SelectedIndex > -1) { hoso.MA_GIOITINH = cbbGioiTinhMoi.Value.ToString() == "0" ? "F" : "M"; } else { hoso.MA_GIOITINH = cbbGioiTinhCu.Value.ToString() == "0" ? "F" : "M"; } if (!string.IsNullOrEmpty(txtSoCMNDMoi.Text)) { hoso.SO_CMND = txtSoCMNDMoi.Text; } else { hoso.SO_CMND = txtSoCMNDCu.Text; } if (!string.IsNullOrEmpty(nfNgayCapMoi.Text) && !string.IsNullOrEmpty(nfThangCapMoi.Text) && !string.IsNullOrEmpty(nfNamCapMoi.Text)) { hoso.NGAYCAP_CMND = new DateTime(int.Parse(nfNamCapMoi.Text), int.Parse(nfThangCapMoi.Text), int.Parse(nfNgayCapMoi.Text)); } else if (!string.IsNullOrEmpty(nfNgayCapCu.Text) && !string.IsNullOrEmpty(nfThangCapCu.Text) && !string.IsNullOrEmpty(nfNamCapCu.Text)) { hoso.NGAYCAP_CMND = new DateTime(int.Parse(nfNamCapCu.Text), int.Parse(nfThangCapCu.Text), int.Parse(nfNgayCapCu.Text)); } if (cbbNoiCapCMNDMoi.SelectedIndex > -1) { hoso.MA_NOICAP_CMND = cbbNoiCapCMNDMoi.Value.ToString(); } if (!string.IsNullOrEmpty(txtDiaChiMoi.Text)) { hoso.DIA_CHI_LH = txtDiaChiMoi.Text; } else { hoso.DIA_CHI_LH = txtDiaChiCu.Text; } if (!string.IsNullOrEmpty(hdfNoiDungKyKCBMoi.Text)) { hoso.MA_NOI_KCB = hdfNoiDungKyKCBMoi.Text; } if (!string.IsNullOrEmpty(txtSoTheBHYTSua.Text)) { hoso.SOTHE_BHYT = txtSoTheBHYTSua.Text; } if (cbbTuThangBHYTSua.SelectedIndex > -1 && !string.IsNullOrEmpty(spinTuNamBHYTSua.Value.ToString())) { hoso.NGAY_DONGBH = new DateTime(int.Parse(spinTuNamBHYTSua.Text), int.Parse(cbbTuThangBHYTSua.Value.ToString()), 1); } if (cbbDenThangBHYTSua.SelectedIndex > -1 && !string.IsNullOrEmpty(spinDenNamBHYTSua.Value.ToString())) { hoso.NGAY_HETHAN_BHYT = new DateTime(int.Parse(spinDenNamBHYTSua.Text), int.Parse(cbbDenThangBHYTSua.Value.ToString()), 1); } //nvbh.NoiCapSoBHXH = txtNoiCapSoBHXHSua.Text; if (!string.IsNullOrEmpty(txtSoSoBHXHSua.Text)) { hoso.SOTHE_BHXH = txtSoSoBHXHSua.Text; } hsc.UpDateHoSoBaoHiem(hoso); #endregion grpQuanLyThongTinBaoHiem.Reload(); wdThayDoiThongTin.Hide(); }
//lưu nhân viên đóng mới public void btnLuuThem_Click(object sender, DirectEventArgs e) { //Kiểm tra nhân viên này đã được lưu ở trên bảng BHNhanVien_BaoHiem chưa NhanVien_BaoHiemController nbc = new NhanVien_BaoHiemController(); if (new NhanVien_BaoHiemController().GetNhanVien_BaoHiemByMaNhanVien(txtMaCanBo.Text) != null) { RM.RegisterClientScriptBlock("relTrungCanBo", " alert('Cán bộ này đã được quản lý ở phân hệ bảo hiểm');"); return; } if (nfSoThangDongTruocThem.Text == "") { RM.RegisterClientScriptBlock("relChuaNhapThoiGian", " alert('Bạn chưa nhập thời gian đóng trước khi vào công ty cho cán bộ này');"); } // Lưu thông tin vào bảng bhNhanVien_BaoHiem NhanVien_BaoHiemController nvc = new NhanVien_BaoHiemController(); HoSoController hsc = new HoSoController(); DAL.HOSO hoso = hsc.GetByMaCB(txtMaCanBo.Text); DAL.BHNHANVIEN_BAOHIEM nvbh = new DAL.BHNHANVIEN_BAOHIEM(); nvbh.IDNhanVien_BaoHiem = int.Parse(hoso.PR_KEY.ToString()); nvbh.MaNhanVien = hoso.MA_CB; nvbh.HoTen = hoso.HO_TEN; nvbh.Ten = new CommonUtil().GetFirstNamFromFullName(hoso.HO_TEN); nvbh.GioiTinh = hoso.MA_GIOITINH != "F"; nvbh.NgaySinh = hoso.NGAY_SINH; nvbh.HoKhauThuongTruTamTru = hoso.HO_KHAU; nvbh.DiaChiLienHe = hoso.DIA_CHI_LH; nvbh.SoCMTND = hoso.SO_CMND; nvbh.NgayCapCMTND = new SoftCore.Util().IsDateNull(hoso.NGAYCAP_CMND) ? null : hoso.NGAYCAP_CMND; nvbh.NoiCapCMTND = hoso.MA_NOICAP_CMND ?? ""; nvbh.MaChucVu = hoso.MA_CHUCVU; nvbh.LuongBaoHiem = decimal.Parse(nfLuongBaoHiem.Value.ToString()); nvbh.LoaiBHYT = ""; string[] arr = hdfPhuCap.Text.Split(';'); nvbh.PhuCapCV = int.Parse(arr[0]); nvbh.PhuCapKhac = int.Parse(arr[3]); nvbh.PhuCapTNVK = int.Parse(arr[2]); nvbh.PhuCapTNN = int.Parse(arr[1]); // hdfPhuCap.Text = phucapcv.ToString() + ";" + phucaptnn.ToString() + ";" + phucaptnvk.ToString() + ";" + phucapkhac.ToString(); nvbh.NoiDangKyKCB = hoso.MA_NOI_KCB; nvbh.SoTheBHYT = txtSoTheBHYT.Text; nvbh.TuThangBHYT = new BaoHiemController().SetValueDatetime(spinTuNamBHYT, cbbTuThangBHYT, 1); nvbh.DenThangBHYT = new BaoHiemController().SetValueDatetime(spinDenNamBHYT, cbbDenThangBHYT, 1); nvbh.BHXHTrangThaiDangKyCQBH = chkTrangThaiDangKy.Checked; nvbh.NgayDangKyBHXH = new BaoHiemController().SetValueDatetime(spinNamBHXH, cbbThangBHXH, 1); //nvbh.TrangThaiCapSoBHXH = cbbTrangthaiCapSo.SelectedItem.Value ?? "ChuaCapSo"; nvbh.TrangThaiCapSoBHXH = hdfTrangThaiCapSo.Text; //nvbh.TrangThaiCapTheBHYT = cbbTrangThaiCapThe.SelectedItem.Value ?? "ChuaCapThe"; nvbh.TrangThaiCapTheBHYT = hdfTrangThaiCapThe.Text; nvbh.NoiCapSoBHXH = txtNoiCapSoBHXH.Text; nvbh.SoSoBHXH = txtSoSoBHXH.Text; if (!util.IsDateNull(dfNgayCapSo.SelectedDate)) { nvbh.NgayCapSoBHXH = dfNgayCapSo.SelectedDate; } nvbh.DangDongBHXH = chkBHXH.Checked; nvbh.DangDongBHYT = chkBHYT.Checked; nvbh.DangDongBHTN = chkBHTN.Checked; nvbh.ThoiGianDongBHXHTruocKhiVaoCongTy = int.Parse(nfSoThangDongTruocThem.Text == "" ? "0" : nfSoThangDongTruocThem.Text) + int.Parse(nfSoNamDongTruocThem.Text == "" ? "0" : nfSoNamDongTruocThem.Text) * 12; //nvbh.ThoiGianDongBaoHiem = nvc.TinhSoThangDongBaoHiem(nvbh.IDNhanVien_BaoHiem, nvbh.ThoiGianDongBHXHTruocKhiVaoCongTy); nvbh.ThoiGianDongBaoHiem = nvbh.ThoiGianDongBHXHTruocKhiVaoCongTy; nvbh.MaDonVi = Session["MaDonVi"].ToString(); nvbh.UserID = CurrentUser.ID; nvbh.DateCreate = DateTime.Now; QuanLyThongTinBaoHiemController qlc = new QuanLyThongTinBaoHiemController(); qlc.LuuNhanVienDongMoi(nvbh); Dialog.ShowNotification("Cập nhật dữ liệu thành công"); if (e.ExtraParams["Close"] == "True") { wdThongTinDongBHNhanVien.Hide(); RM.RegisterClientScriptBlock("rs30", "grpQuanLyThongTinBaoHiem_store.reload();"); } else { RM.RegisterClientScriptBlock("rs32", "grpQuanLyThongTinBaoHiem_store.reload();"); } RM.RegisterClientScriptBlock("rs31", "resetFormThem();"); }