private dsTinhLuong.tblEmpSalaryRow GetLuongCu(string empID, dsTinhLuong.tblEmpSalaryRow luongMoi) { var l = _ds.tblEmpSalary.Where(i => i.EmployeeID == empID && ((i.BeginDate <= kyLuong_TuNgay && i.EndDate >= kyLuong_TuNgay) || (i.BeginDate <= kyLuong_DenNgay.AddDays(-1) && i.EndDate >= kyLuong_DenNgay.AddDays(-1))) && i.id != (luongMoi == null ? new Guid() : luongMoi.id) ).OrderByDescending(i => i.DateChange).FirstOrDefault(); if (l != null) { if (l["BasicSalary"] == DBNull.Value) { l["BasicSalary"] = 0; } if (l["BasicSalary_Ins"] == DBNull.Value) { l["BasicSalary_Ins"] = 0; } } return(l); }
public TinhLuongHelper(dsTinhLuong ds, DateTime tuNgay, DateTime denNgay, string EmployeeID) { this._ds = ds; _soNgayCongTrongThang = Ham.DemNgayCong(tuNgay, denNgay) > 26 ? 26 : Ham.DemNgayCong(tuNgay, denNgay); kyLuong_TuNgay = tuNgay; kyLuong_DenNgay = denNgay; luongMoi = GetLuongMoi(EmployeeID); luongCu = GetLuongCu(EmployeeID, luongMoi); if (luongCu != null && luongCu.EndDate < tuNgay) { luongCu = null; } if (luongMoi == null) { var kq1 = _ds.p_tinhLuong_GetAllKetQuaQuetThe.FirstOrDefault(i => i.EmployeeID == EmployeeID); if (kq1 == null) { var db1 = new iHRM.Core.Business.DbObject.dcDatabaseDataContext(Provider.ConnectionString); var e = db1.tblEmployees.FirstOrDefault(i => i.EmployeeID == EmployeeID); if (e != null) { _Luong1Ngay = (e.BasicSalary ?? 0) / _soNgayCongTrongThang; } } else { _Luong1Ngay = (DbHelper.DrGetDouble(kq1, "BasicSalary")) / _soNgayCongTrongThang; } } else { _Luong1Ngay = (DbHelper.DrGetDouble(luongMoi, "BasicSalary")) / _soNgayCongTrongThang; } _LuongCBCu = DbHelper.DrGetDouble(luongCu, "BasicSalary"); _LuongPCCu = DbHelper.DrGetDouble(luongCu, "BasicSalary_Ins"); _LuongCBMoi = DbHelper.DrGetDouble(luongMoi, "BasicSalary"); _LuongPCMoi = DbHelper.DrGetDouble(luongMoi, "BasicSalary_Ins"); }
private dsTinhLuong.tblEmpSalaryRow GetLuongCu(string empID, dsTinhLuong.tblEmpSalaryRow luongMoi) { var rs = _ds.tblEmpSalary.Where(p => p.EmployeeID == empID && p.DateChange > kyLuong_TuNgay && p.DateChange <= kyLuong_DenNgay); if (rs.Count() >= 2) { var l = rs.OrderByDescending(p => p.DateChange).Skip(1).First(); if (l["BasicSalary"] == DBNull.Value) { l["BasicSalary"] = 0; } if (l["BasicSalary_Ins"] == DBNull.Value) { l["BasicSalary_Ins"] = 0; } return(l); } else if (rs.Count() == 1) { var l = _ds.tblEmpSalary.Where(p => p.EmployeeID == empID && p.DateChange < kyLuong_TuNgay).OrderByDescending(p => p.DateChange); if (l.Count() == 0) { return(null); } if (l.First()["BasicSalary"] == DBNull.Value) { l.First()["BasicSalary"] = 0; } if (l.First()["BasicSalary_Ins"] == DBNull.Value) { l.First()["BasicSalary_Ins"] = 0; } return(l.First()); } else { return(null); } }
private dsTinhLuong.tblEmpSalaryRow GetLuongCu(string empID, dsTinhLuong.tblEmpSalaryRow luongMoi) { var rs = _ds.tblEmpSalary.Where(p => p.EmployeeID == empID && p.EndDate >= kyLuong_TuNgay && p.EndDate < kyLuong_DenNgay && p.id != luongMoi.id); // lương cũ thì phải < EndDate if (rs.Count() >= 1) { var l = rs.OrderByDescending(p => p.BeginDate).First(); if (l["BasicSalary"] == DBNull.Value) { l["BasicSalary"] = 0; } if (l["BasicSalary_Ins"] == DBNull.Value) { l["BasicSalary_Ins"] = 0; } return(l); } else { return(null); } }