public void LuuNhanVienDongMoi(BHNHANVIEN_BAOHIEM nvbh) { BHNHANVIEN_BAOHIEM nv = new BHNHANVIEN_BAOHIEM(); nv = nvbh; dataContext.BHNHANVIEN_BAOHIEMs.InsertOnSubmit(nv); dataContext.SubmitChanges(); //Lưu biến động bảo hiểm DAL.BHBIENDONGBAOHIEM bdbh = new DAL.BHBIENDONGBAOHIEM(); bdbh.IDQuyDinhBienDong = dataContext.BHQUYDINHBIENDONGs.SingleOrDefault(p => p.MaBienDong == "TDMBH").IDQuyDinhBienDong; bdbh.IDNhanVien_BaoHiem = nvbh.IDNhanVien_BaoHiem; bdbh.TuNgay = nv.NgayDangKyBHXH == null ? DateTime.Now : nv.NgayDangKyBHXH.Value; bdbh.Loai = dataContext.BHQUYDINHBIENDONGs.SingleOrDefault(p => p.MaBienDong == "TDMBH").LoaiAnhHuong; bdbh.MaNhanVien = nvbh.MaNhanVien; bdbh.HoTen = nvbh.HoTen; bdbh.MaSo = nvbh.SoSoBHXH; bdbh.NgaySinh = nvbh.NgaySinh; bdbh.GioiTinh = nvbh.GioiTinh ?? true; bdbh.ChucVu = ""; if (dataContext.DM_CHUCVUs.SingleOrDefault(p => p.MA_CHUCVU == nvbh.MaChucVu) != null) { var singleOrDefault = dataContext.DM_CHUCVUs.SingleOrDefault(p => p.MA_CHUCVU == nvbh.MaChucVu); if (singleOrDefault != null) { bdbh.ChucVu = singleOrDefault.TEN_CHUCVU; } } bdbh.TienLuongMoi = nvbh.LuongBaoHiem; bdbh.PhuCapCVMoi = nvbh.PhuCapCV; bdbh.PhuCapTNNgheMoi = nvbh.PhuCapTNN; bdbh.PhuCapTNVKMoi = nvbh.PhuCapTNVK; bdbh.ThangDangKy = nvbh.NgayDangKyBHXH ?? DateTime.Now; bdbh.DaCoSo = string.IsNullOrEmpty(nvbh.SoSoBHXH) ? bdbh.DaCoSo = false : bdbh.DaCoSo = true; bdbh.DaDuyet = true; bdbh.UserID = nvbh.UserID; bdbh.DateCreate = DateTime.Now; bdbh.MaDonVi = nvbh.MaDonVi; bdbh.DienGiai = ""; dataContext.BHBIENDONGBAOHIEMs.InsertOnSubmit(bdbh); dataContext.SubmitChanges(); }
// sự kiện nút lưu thêm protected void bt_addclick(object sender, DirectEventArgs e) { //get usercontrol all DAL.BHBIENDONGBAOHIEM bdbh = new DAL.BHBIENDONGBAOHIEM(); bdbh.MaNhanVien = txtMaCanBo1.Text; bdbh.HoTen = txtHoTen1.Text; bdbh.NgaySinh = Convert.ToDateTime(dfNgaySinh1.Value); bdbh.MaSo = txtSoSoBHXH1.Text; bdbh.IDQuyDinhBienDong = Convert.ToInt32(hdfIDQuyDinhBienDong.Text); bdbh.IDNhanVien_BaoHiem = Convert.ToInt32(hdfIdNhanVien_BaoHiem.Text); bdbh.TuNgay = Convert.ToDateTime(dfTuNgay1.Value); if (Radio1.Checked == true) { bdbh.TruyThuBHXH = decimal.Parse("0" + NumberField2.Text); bdbh.TruyThuBHYT = decimal.Parse("0" + NumberField3.Text); } else if (Radio2.Checked == true) { bdbh.ThoaiThuBHXH = decimal.Parse("0" + NumberField2.Text); bdbh.ThoaiThuBHYT = decimal.Parse("0" + NumberField3.Text); } if (!new SoftCore.Util().IsDateNull(dfDenNgay1.SelectedDate)) { bdbh.DenNgay = Convert.ToDateTime(dfDenNgay1.Value); } DAL.BHQUYDINHBIENDONG qdbd = new BHQUYDINHBIENDONGController().Lay1QuyDinhBienDong(bdbh.IDQuyDinhBienDong); BHNHANVIEN_BAOHIEM hs = new NhanVien_BaoHiemController().GetNhanVien_BaoHiemByMaNhanVien(hdfMaNhanVien.Value.ToString()); if (!string.IsNullOrEmpty(hs.LuongBaoHiem.ToString())) { txtLuongDongBHXHCu1.Text = hs.LuongBaoHiem.ToString(); txtLuongDongBHXHMoi1.Text = txtLuongDongBHXHCu1.Text; } if (!string.IsNullOrEmpty(hs.PhuCapCV.ToString())) { txtPhuCapCVCu1.Text = hs.PhuCapCV.ToString(); txtPhuCapCVMoi1.Text = txtPhuCapCVCu1.Text; } if (!string.IsNullOrEmpty(hs.PhuCapTNVK.ToString())) { txtPhuCapTNVKCu1.Text = hs.PhuCapTNVK.ToString(); txtPhuCapTNVKMoi1.Text = txtPhuCapTNVKCu1.Text; } if (!string.IsNullOrEmpty(hs.PhuCapTNN.ToString())) { txtPhuCapTNNCu1.Text = hs.PhuCapTNN.ToString(); txtPhuCapTNNMoi1.Text = txtPhuCapTNNCu1.Text; } if (qdbd.LoaiAnhHuong == "TMD" || qdbd.LoaiAnhHuong == "GMD") { bdbh.TienLuongCu = txtLuongDongBHXHCu1.Text == "" ? 0 : Convert.ToDecimal(txtLuongDongBHXHCu1.Text.Replace('.', ',')); bdbh.PhuCapTNVKCu = txtPhuCapTNVKCu1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNVKCu1.Text.Replace('.', ',')); bdbh.PhuCapNgheCu = txtPhuCapTNNCu1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNNCu1.Text.Replace('.', ',')); bdbh.PhuCapCVCu = txtPhuCapCVCu1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapCVCu1.Text.Replace('.', ',')); bdbh.TienLuongMoi = txtLuongDongBHXHMoi1.Text == "" ? 0 : Convert.ToDecimal(txtLuongDongBHXHMoi1.Text.Replace('.', ',')); bdbh.PhuCapCVMoi = txtPhuCapCVMoi1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapCVMoi1.Text.Replace('.', ',')); bdbh.PhuCapTNNgheMoi = txtPhuCapTNNMoi1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNNMoi1.Text.Replace('.', ',')); bdbh.PhuCapTNVKMoi = txtPhuCapTNVKMoi1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNVKMoi1.Text.Replace('.', ',')); bdbh.TienLuongMoi = txtLuongDongBHXHMoi1.Text == "" ? 0 : Convert.ToDecimal(txtLuongDongBHXHMoi1.Text.Replace('.', ',')); } if (qdbd.LoaiAnhHuong == "TLD") { bdbh.TienLuongCu = 0; bdbh.PhuCapTNVKCu = 0; bdbh.PhuCapNgheCu = 0; bdbh.PhuCapCVCu = 0; bdbh.TienLuongMoi = txtLuongDongBHXHMoi1.Text == "" ? 0 : Convert.ToDecimal(txtLuongDongBHXHMoi1.Text.Replace('.', ',')); bdbh.PhuCapCVMoi = txtPhuCapCVMoi1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapCVMoi1.Text.Replace('.', ',')); bdbh.PhuCapTNNgheMoi = txtPhuCapTNNMoi1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNNMoi1.Text.Replace('.', ',')); bdbh.PhuCapTNVKMoi = txtPhuCapTNVKMoi1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNVKMoi1.Text.Replace('.', ',')); bdbh.TienLuongMoi = txtLuongDongBHXHMoi1.Text == "" ? 0 : Convert.ToDecimal(txtLuongDongBHXHMoi1.Text.Replace('.', ',')); } if (qdbd.LoaiAnhHuong == "GLD") { bdbh.TienLuongCu = txtLuongDongBHXHCu1.Text == "" ? 0 : Convert.ToDecimal(txtLuongDongBHXHCu1.Text.Replace('.', ',')); bdbh.PhuCapTNVKCu = txtPhuCapTNVKCu1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNVKCu1.Text.Replace('.', ',')); bdbh.PhuCapNgheCu = txtPhuCapTNNCu1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNNCu1.Text.Replace('.', ',')); bdbh.PhuCapCVCu = txtPhuCapCVCu1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapCVCu1.Text.Replace('.', ',')); bdbh.TienLuongMoi = 0; bdbh.PhuCapCVMoi = 0; bdbh.PhuCapTNNgheMoi = 0; bdbh.PhuCapTNVKMoi = 0; bdbh.TienLuongMoi = 0; } if (qdbd.LoaiAnhHuong.Contains("TruyThu")) { bdbh.TruyThuBHXH = nfTruyThuBHXH.Text == "" ? 0 : Convert.ToDecimal(nfTruyThuBHXH.Text.Replace('.', ',')); bdbh.TruyThuBHYT = nfTruyThuBHYT.Text == "" ? 0 : Convert.ToDecimal(nfTruyThuBHYT.Text.Replace('.', ',')); } if (qdbd.LoaiAnhHuong.Contains("ThoaiThu")) { bdbh.ThoaiThuBHXH = nfThoaiThuBHXH.Text == "" ? 0 : Convert.ToDecimal(nfThoaiThuBHXH.Text.Replace('.', ',')); bdbh.ThoaiThuBHYT = nfThoaiThuBHYT.Text == "" ? 0 : Convert.ToDecimal(nfThoaiThuBHYT.Text.Replace('.', ',')); } bdbh.DaCoSo = chkDaCoSo.Checked; bdbh.KhongTraThe = chkKhongTraThe.Checked; bdbh.DienGiai = txtDienGiai1.Text; bdbh.UserID = CurrentUser.ID; bdbh.MaDonVi = Session["MaDonVi"].ToString(); bdbh.DateCreate = DateTime.Now; //bdbh.ThangDangKy = DateTime.Now; if (!SoftCore.Util.GetInstance().IsDateNull(dfNgayDangKyVoiCQBH.SelectedDate)) { bdbh.ThangDangKy = (DateTime)dfNgayDangKyVoiCQBH.Value; } bdbh.ChucVu = ""; //update tinh trangg dong cho nhan vien BHNHANVIEN_BAOHIEM nvbh = new NhanVien_BaoHiemController().GetNhanVien_BaoHiemByMaNhanVien(Convert.ToInt32(hdfIdNhanVien_BaoHiem.Text)); nvbh.IDNhanVien_BaoHiem = Convert.ToInt32(hdfIdNhanVien_BaoHiem.Text); nvbh.DangDongBHXH = chkBHXH1.Checked; nvbh.DangDongBHYT = chkBHYT1.Checked; nvbh.DangDongBHTN = chkBHTN1.Checked; bdbh.NgaySinh = nvbh.NgaySinh; bdbh.GioiTinh = nvbh.GioiTinh ?? true; bdbh.Loai = qdbd.LoaiAnhHuong; new QuanLyBienDongBaoHiemController().InsertBienDongBaoHiem(bdbh); new NhanVien_BaoHiemController().UpdateNhanVien_BaoHiem(nvbh); Dialog.ShowNotification("Thông báo", "Đã cập nhật thành công"); if (e.ExtraParams["Command"] == "Insert") { if (hdfMaLoaiBienDong.Text == "TMD" || hdfMaLoaiBienDong.Text == "GMD") { UpdateNguocNhanVien_BaoHiem(); } } if (e.ExtraParams["Close"] == "True") { //wdThemSuaBienDongNhanVien.Hide(); wdThemSuaBienDongNhanVien.Hide(); } grpChiTietNhanVien.Reload(); grpBienDongBaoHiem.Reload(); // update ngược lại bảng NHANVIEN_BAOHIEM }