Exemplo n.º 1
0
        public DataTable GetReportContractDetail(List<Hre_ProfileEntity> lstProfile, DateTime? _DateSignedStart, DateTime? _DateSignedEnd, string _ContractNo, Guid? _ContractTypeID, bool isCreateTemplate, String nameReport)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoCat_ContractType = new CustomBaseRepository<Cat_ContractType>(unitOfWork);
                var repoHre_Contract = new CustomBaseRepository<Hre_Contract>(unitOfWork);
                var repoHre_AppendixContract = new CustomBaseRepository<Hre_AppendixContract>(unitOfWork);
                var repoCat_OrgStructure = new CustomBaseRepository<Cat_OrgStructure>(unitOfWork);
                var repoCat_OrgStructureType = new CustomBaseRepository<Cat_OrgStructureType>(unitOfWork);

                var lstContracType = repoCat_ContractType.FindBy(s => s.IsDelete == null).ToList();
                DataTable tb = GetSchema_ContractDetail(nameReport, lstContracType);

                if (isCreateTemplate)
                {
                    return tb.ConfigTable();
                }

                #region code BC

                //var profileQueryable = unitOfWork.CreateQueryable<Hre_Profile>(Guid.Empty,
                //    d => d.DateHire >= monthStart && d.DateHire <= monthEnd);

                //if (!string.IsNullOrWhiteSpace(codeEmp))
                //{
                //    profileQueryable = profileQueryable.Where(d => d.CodeEmp.Contains(codeEmp));
                //}

                //if (!string.IsNullOrWhiteSpace(profileName))
                //{
                //    profileQueryable = profileQueryable.Where(d => d.ProfileName.Contains(profileName));
                //}

                //if (listOrgID != null && listOrgID.Count() > 0)
                //{
                //    profileQueryable = profileQueryable.Where(d => d.OrgStructureID.HasValue && listOrgID.Contains(d.OrgStructureID.Value));
                //}

                string status = string.Empty;
                //List<object> listModel = new List<object>();

                //listModel = new List<object>();
                //listModel.AddRange(new object[16]);
                //listModel[2] = null;
                //listModel[8] = monthStart;
                //listModel[9] = monthEnd;
                //listModel[14] = null;
                //listModel[15] = Int32.MaxValue - 1;
                //List<Hre_ProfileEntity> lstProfile = GetData<Hre_ProfileEntity>(listModel, ConstantSql.hrm_hr_sp_get_Profile, ref status);

                //var profileQueryable = unitOfWork.CreateQueryable<Hre_Profile>(Guid.Empty,
                //    d => d.DateHire >= monthStart && d.DateHire <= monthEnd);

                //if (!string.IsNullOrWhiteSpace(codeEmp))
                //{
                //    lstProfile = lstProfile.Where(d => d.CodeEmp.Contains(codeEmp)).ToList();
                //}

                //if (!string.IsNullOrWhiteSpace(profileName))
                //{
                //    lstProfile = lstProfile.Where(d => d.ProfileName.Contains(profileName)).ToList();
                //}

                //if (listOrgID != null && listOrgID.Count() > 0)
                //{
                //    lstProfile = lstProfile.Where(d => d.OrgStructureID.HasValue && listOrgID.Contains(d.OrgStructureID.Value)).ToList();
                //}

                //List<Hre_ProfileEntity> lstProfile = profileQueryable.Select(d => new Hre_ProfileEntity
                //{
                //    ID = d.ID,
                //    CodeEmp = d.CodeEmp,
                //    CodeAttendance = d.CodeAttendance,
                //    ProfileName = d.ProfileName,
                //    DateOfBirth = d.DateOfBirth,
                //    Gender = d.Gender,
                //    PlaceOfBirth = d.PlaceOfBirth,
                //    PAddress = d.PAddress,
                //    IDNo = d.IDNo,
                //    IDDateOfIssue = d.IDDateOfIssue,
                //    IDPlaceOfIssue = d.IDPlaceOfIssue,
                //    DateHire = d.DateHire,
                //    DateQuit = d.DateQuit,
                //    StatusSyn = d.StatusSyn,
                //    PositionName = d.Cat_Position.PositionName,
                //    SalaryClassName = d.Cat_SalaryClass.SalaryClassName,
                //    OrgStructureID=d.OrgStructureID
                //}).ToList();

                List<Guid> lstProfileIDs = lstProfile.Select(m => m.ID).Distinct().ToList();
                string E_APPROVED = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_APPROVED.ToString();

                #region getdata COntract Appendix

                // string status = string.Empty;
                var hreServiceContract = new Hre_ContractServices();
                List<object> paraContract = new List<object>();
                paraContract.AddRange(new object[16]);
                paraContract[13] = E_APPROVED;
                paraContract[14] = 1;
                paraContract[15] = Int32.MaxValue - 1;

                var AppendixServices = new Hre_AppendixContractServices();
                List<object> paraAppendix = new List<object>();
                paraAppendix.AddRange(new object[7]);
                paraAppendix[5] = 1;
                paraAppendix[6] = Int32.MaxValue - 1;

                #endregion

                var lstContractAll = new List<Hre_Contract>().Select(m => new
                {
                    m.ID,
                    m.Status,
                    m.ContractTypeID,
                    m.ProfileID,
                    m.DateStart,
                    m.DateEnd,
                    m.ContractNo,
                    m.DateSigned
                }).ToList();

                foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                {
                    lstContractAll.AddRange(unitOfWork.CreateQueryable<Hre_Contract>(Guid.Empty, m => m.Status == E_APPROVED
                        && lstProfileID.Contains(m.ProfileID)).Select(m => new
                        {
                            m.ID,
                            m.Status,
                            m.ContractTypeID,
                            m.ProfileID,
                            m.DateStart,
                            m.DateEnd,
                            m.ContractNo,
                            m.DateSigned
                        }).ToList());
                }
                if (_DateSignedStart != null)
                    lstContractAll = lstContractAll.Where(s => s.DateSigned != null && s.DateSigned >= _DateSignedStart).ToList();
                if (_DateSignedEnd != null)
                    lstContractAll = lstContractAll.Where(s => s.DateSigned != null && s.DateSigned <= _DateSignedEnd).ToList();
                if (_ContractNo != string.Empty && _ContractNo != null)
                    lstContractAll = lstContractAll.Where(s => s.ContractNo != null && s.ContractNo == _ContractNo).ToList();
                if (_ContractTypeID != null && _ContractTypeID != Guid.Empty)
                    lstContractAll = lstContractAll.Where(s => s.ContractTypeID == _ContractTypeID).ToList();

                List<Guid> lstContractIDs = lstContractAll.Select(m => m.ID).ToList();

                var lstAppendixContract = new List<Hre_AppendixContractEntity>().Select(m => new
                {
                    m.ID,
                    m.ContractID,
                    m.Code,
                    m.DateofEffect,
                    m.DateEndAppendixContract
                }).ToList();

                foreach (var lstContractID in lstContractIDs.Chunk(1000))
                {
                    lstAppendixContract.AddRange(unitOfWork.CreateQueryable<Hre_AppendixContract>(Guid.Empty,
                        m => lstContractID.Contains(m.ContractID)).Select(m => new
                        {
                            m.ID,
                            m.ContractID,
                            m.Code,
                            m.DateofEffect,
                            m.DateEndAppendixContract
                        }).ToList());
                }

                var lstOrg = repoCat_OrgStructure.GetAll().ToList();
                var orgTypes = repoCat_OrgStructureType.GetAll().ToList();

                #region Phu luc hd
                var lstContractExtend = new List<Hre_ContractExtend>().Select(s => new
                {
                    s.ContractID,
                    s.AnnexCode,
                    s.DateStart,
                    s.DateEnd
                }).ToList();

                foreach (var lstContractID in lstContractIDs.Chunk(1000))
                {
                    lstContractExtend.AddRange(unitOfWork.CreateQueryable<Hre_ContractExtend>(Guid.Empty, s => lstContractID.Contains(s.ContractID.Value)).Select(s => new
                    {
                        s.ContractID,
                        s.AnnexCode,
                        s.DateStart,
                        s.DateEnd
                    }).ToList());
                }

                #endregion

                int stt = 0;
                foreach (var profile in lstProfile)
                {
                    stt++;
                    DataRow dr = tb.NewRow();
                    dr["Stt"] = stt;
                    dr["CodeEmp"] = profile.CodeEmp;
                    dr["ProfileName"] = profile.ProfileName;

                    //var orgId = profile.OrgStructureID;
                    //var orgBranch = LibraryService.GetNearestParent(orgId, OrgUnit.E_BRANCH, lstOrg, orgTypes);
                    //var orgOrg = LibraryService.GetNearestParent(orgId, OrgUnit.E_DEPARTMENT, lstOrg, orgTypes);
                    //var orgTeam = LibraryService.GetNearestParent(orgId, OrgUnit.E_TEAM, lstOrg, orgTypes);
                    //var orgSection = LibraryService.GetNearestParent(orgId, OrgUnit.E_SECTION, lstOrg, orgTypes);
                    //var orgDivision = LibraryService.GetNearestParent(orgId, OrgUnit.E_DIVISION, lstOrg, orgTypes);
                    //var orgUnit = LibraryService.GetNearestParent(orgId, OrgUnit.E_UNIT, lstOrg, orgTypes);


                    dr["E_DIVISION"] = profile.E_DIVISION;

                    dr["E_UNIT"] = profile.E_UNIT;

                    dr["E_DEPARTMENT"] = profile.E_DEPARTMENT;

                    dr["E_TEAM"] = profile.E_TEAM;

                    dr["E_SECTION"] = profile.E_SECTION;

                    //if (orgDivision != null)
                    //{
                    //    dr["E_DIVISION"] = orgDivision.OrgStructureName;
                    //}
                    //if (orgUnit != null)
                    //{
                    //    dr["E_UNIT"] = orgUnit.OrgStructureName;
                    //}
                    //if (orgOrg != null)
                    //{
                    //    dr["E_DEPARTMENT"] = orgOrg.OrgStructureName;
                    //}
                    //if (orgTeam != null)
                    //{
                    //    dr["E_TEAM"] = orgTeam.OrgStructureName;
                    //}
                    //if (orgSection != null)
                    //{
                    //    dr["E_SECTION"] = orgSection.OrgStructureName;
                    //}
                    if (!string.IsNullOrWhiteSpace(profile.PositionName))
                    {
                        dr["Position"] = profile.PositionName;
                    }
                    if (profile.DateOfBirth != null)
                    {
                        dr["DateOfBirth"] = profile.DateOfBirth;
                    }
                    if (profile.Gender != null)
                    {
                        dr["Gender"] = profile.Gender.TranslateString();
                    }

                    if (profile.PlaceOfBirth != null)
                    {
                        dr["PlaceOfBirth"] = profile.PlaceOfBirth;
                    }
                    if (profile.PAddress != null)
                    {
                        dr["PAddress"] = profile.PAddress;
                    }
                    if (profile.IDNo != null)
                    {
                        dr["IDNo"] = profile.IDNo;
                    }
                    if (profile.IDDateOfIssue != null)
                    {
                        dr["IDDateOfIssue"] = profile.IDDateOfIssue;
                    }
                    if (profile.IDPlaceOfIssue != null)
                    {
                        dr["IDPlaceOfIssue"] = profile.IDPlaceOfIssue;
                    }
                    if (profile.DateHire != null)
                    {
                        dr["DateHire"] = profile.DateHire;
                    }

                    if (!string.IsNullOrWhiteSpace(profile.SalaryClassName))
                    {
                        dr["SalaryClass"] = profile.SalaryClassName;
                    }
                    var lstContractByProfile = lstContractAll.Where(m => m.ProfileID == profile.ID).OrderBy(m => m.DateStart).ToList();
                    var lstContractByProfileID = lstContractByProfile.Select(m => m.ID).ToList();
                    var lstAppendixContractByProfile = lstAppendixContract.Where(m => lstContractByProfileID.Contains(m.ContractID)).ToList();

                    foreach (var ContractType in lstContracType)
                    {
                        string ContractCode = ContractType.Code;
                        if (string.IsNullOrEmpty(ContractCode))
                            continue;

                        var ContractOfProfileByType = lstContractByProfile.Where(m => m.ContractTypeID == ContractType.ID).FirstOrDefault();
                        if (ContractOfProfileByType != null)
                        {
                            if (ContractOfProfileByType.ContractNo != null)
                                dr[ContractCode + "_" + "ContractNo"] = ContractOfProfileByType.ContractNo;
                            if (ContractOfProfileByType.DateStart != null)
                                dr[ContractCode + "_" + "DateStart"] = ContractOfProfileByType.DateStart;
                            if (ContractOfProfileByType.DateEnd != null)
                                dr[ContractCode + "_" + "DateEnd"] = ContractOfProfileByType.DateEnd;

                            var lstAppendixContractByContract = lstAppendixContractByProfile.Where(m => m.ContractID == ContractOfProfileByType.ID).OrderBy(m => m.DateofEffect).ToList();
                            int numAppendix = 0;
                            foreach (var AppendixContract in lstAppendixContractByContract)
                            {
                                numAppendix++;
                                if (numAppendix > 3)
                                    continue;
                                if (string.IsNullOrEmpty(AppendixContract.Code))
                                    continue;
                                dr[ContractCode + "_" + numAppendix + "_" + "Code"] = AppendixContract.Code;
                                if (AppendixContract.DateofEffect != null)
                                {
                                    dr[ContractCode + "_" + numAppendix + "_" + "DateofEffect"] = AppendixContract.DateofEffect;
                                }
                                if (AppendixContract.DateEndAppendixContract != null)
                                {
                                    dr[ContractCode + "_" + numAppendix + "_" + "DateEndAppendixContract"] = AppendixContract.DateEndAppendixContract;
                                }
                            }
                            var lstContractExtendByContract = lstContractExtend.Where(s => s.ContractID == ContractOfProfileByType.ID).OrderBy(s => s.DateStart).ToList();
                            int numContractExtend = 0;
                            foreach (var objContractExtend in lstContractExtendByContract)
                            {
                                numContractExtend++;
                                if (numContractExtend > 5)
                                    continue;
                                if (objContractExtend.AnnexCode != null)
                                    dr[ContractCode + "_" + numContractExtend + "_" + "CodeExtend"] = objContractExtend.AnnexCode;
                                if (objContractExtend.DateStart != null)
                                    dr[ContractCode + "_" + numContractExtend + "_" + "DateStartExtend"] = objContractExtend.DateStart;
                                if (objContractExtend.DateEnd != null)
                                    dr[ContractCode + "_" + numContractExtend + "_" + "DateEndExtend"] = objContractExtend.DateEnd;
                            }
                        }
                    }
                    tb.Rows.Add(dr);
                }
                #endregion
                var configs = new Dictionary<string, Dictionary<string, object>>();
                return tb.ConfigTable(configs);
            }
        }
Exemplo n.º 2
0
        public ActionResult UpdateEvaContract([Bind]Hre_ContractModel model)
        {
            string status = string.Empty;
            Guid convertProfileID = Guid.Empty;
            string message = string.Empty;
            var lstContractEidt = new List<Hre_ContractEntity>();
            List<Guid> lstIDs = new List<Guid>();
            var insuranceServices = new Sal_InsuranceSalaryServices();
            var ContractServices = new Hre_ContractServices();
            if (model.selectedIds != null && model.selectedIds.IndexOf(',') > 1)
            {
                var lstID = model.selectedIds.Split(',');
                for (int i = 0; i < lstID.Length; i++)
                {
                    convertProfileID = Common.ConvertToGuid(lstID[i]);
                    lstIDs.Add(convertProfileID);
                }
            }
            else
            {
                convertProfileID = Common.ConvertToGuid(model.selectedIds);
                lstIDs.Add(convertProfileID);
            }

            var actionService = new ActionService(UserLogin);
            var appendixContractServices = new Hre_AppendixContractServices();
            var objContract = new List<object>();
            objContract.AddRange(new object[21]);
            objContract[19] = 1;
            objContract[20] = int.MaxValue - 1;
            var lstContract = actionService.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_Contract, ref status).ToList();
            if (lstIDs != null)
            {
                lstContract = lstContract.Where(s => lstIDs.Contains(s.ID)).ToList();
            }

            foreach (var item in lstContract)
            {
                if (model.RankDetailForNextContract != null)
                {
                    item.RankDetailForNextContract = model.RankDetailForNextContract;
                }

                if (model.DateEndNextContract != null)
                {
                    item.DateEndNextContract = model.DateEndNextContract;
                }

                // Son.Vo - 20150613 - theo task 0049393
                if (lstContract.Count == 1 && model.RankDetailForNextContract == null)
                {
                    item.RankDetailForNextContract = item.RankRateID;
                }

                message = ContractServices.Edit(item);
            }

            return Json(message, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 3
0
        public ActionResult EditContractByEvaContract([Bind]Hre_ContractModel model)
        {
            string status = string.Empty;
            Guid convertProfileID = Guid.Empty;
            string message = string.Empty;
            var lstContractEidt = new List<Hre_ContractEntity>();
            List<Guid> lstIDs = new List<Guid>();
            var insuranceServices = new Sal_InsuranceSalaryServices();
            var contractServices = new Hre_ContractServices();

            if (model.selectedIds != null && model.selectedIds.IndexOf(',') > 1)
            {
                var lstID = model.selectedIds.Split(',');
                for (int i = 0; i < lstID.Length; i++)
                {
                    convertProfileID = Common.ConvertToGuid(lstID[i]);
                    lstIDs.Add(convertProfileID);
                }
            }
            else
            {
                convertProfileID = Common.ConvertToGuid(model.selectedIds);
                lstIDs.Add(convertProfileID);
            }

            var actionService = new ActionService(UserLogin);
            var appendixContractServices = new Hre_AppendixContractServices();
            var objContract = new List<object>();
            objContract.AddRange(new object[21]);
            objContract[19] = 1;
            objContract[20] = int.MaxValue - 1;
            var lstContract = actionService.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_Contract, ref status).ToList();
            if (lstIDs != null)
            {
                lstContract = lstContract.Where(s => lstIDs.Contains(s.ID)).ToList();
            }

            var objAppendixContarct = new List<object>();
            objAppendixContarct.AddRange(new object[7]);
            objAppendixContarct[5] = 1;
            objAppendixContarct[6] = int.MaxValue - 1;
            var lstAppendixContract = actionService.GetData<Hre_AppendixContractEntity>(objAppendixContarct, ConstantSql.hrm_hr_sp_get_AppendixContract, ref status).ToList();

            var contractTypeService = new Cat_ContractTypeServices();
            var lstObjContractType = new List<object>();
            lstObjContractType.Add(null);
            lstObjContractType.Add(null);
            lstObjContractType.Add(null);
            lstObjContractType.Add(null);
            lstObjContractType.Add(1);
            lstObjContractType.Add(int.MaxValue - 1);
            var lstContractType = actionService.GetData<Cat_ContractTypeEntity>(lstObjContractType, ConstantSql.hrm_cat_sp_get_ContractType, ref status).ToList();


            foreach (var item in lstContract)
            {
                if (item.DateExtend == null)
                {
                    item.DateExtend = item.DateEnd;
                }

                    item.ContractResult = model.ContractResult;
                    item.ContractEvaType = model.ContractEvaType;
                    item.ContractEvaType = model.ContractEvaType;
                    item.DateOfContractEva = model.DateOfContractEva;
                    item.EvaluationResult = model.EvaluationResult;
                    item.TypeOfPass = model.TypeOfPass;
                    item.RankDetailForNextContract = model.RankDetailForNextContract;
                    item.NextContractTypeID = model.NextContractTypeID;
                    item.StatusEvaluation = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_WAITING.ToString();
                    var nextContracttype = lstContractType.Where(s => s.ID == model.NextContractTypeID).FirstOrDefault();
                    var contractEntity = new Hre_ContractEntity();
                    contractEntity = item.CopyData<Hre_ContractEntity>();
                    if (item.DateEnd != null)
                    {
                        contractEntity.DateStart = item.DateEnd.Value.AddDays(1);
                    }
                    SetNewDateEndNextContractByContractAndNextContractID(contractEntity, model.NextContractTypeID.Value);
                    item.DateEndNextContract = contractEntity.DateEndNextContract;
                    message = contractServices.Edit(item);
            }

            return Json(message, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 4
0
        public ActionResult ExtendContract([Bind]Hre_ContractModel model)
        {
            string status = string.Empty;
            Guid convertProfileID = Guid.Empty;
            string message = string.Empty;
            var lstContractEidt = new List<Hre_ContractEntity>();
            List<Guid> lstIDs = new List<Guid>();
            var insuranceServices = new Sal_InsuranceSalaryServices();
            var ContractServices = new Hre_ContractServices();
            var ExtendContractServices = new Hre_ContractExtendServices();
            if (model.selectedIds != null && model.selectedIds.IndexOf(',') > 1)
            {
                var lstID = model.selectedIds.Split(',');
                for (int i = 0; i < lstID.Length; i++)
                {
                    convertProfileID = Common.ConvertToGuid(lstID[i]);
                    lstIDs.Add(convertProfileID);
                }
            }
            else
            {
                convertProfileID = Common.ConvertToGuid(model.selectedIds);
                lstIDs.Add(convertProfileID);
            }

            var actionService = new ActionService(UserLogin);
            var appendixContractServices = new Hre_AppendixContractServices();
            var objContract = new List<object>();
            objContract.AddRange(new object[21]);
            objContract[19] = 1;
            objContract[20] = int.MaxValue - 1;
            var lstContract = actionService.GetData<Hre_ContractEntity>(objContract, ConstantSql.hrm_hr_sp_get_Contract, ref status).ToList();
            if (lstIDs != null)
            {
                lstContract = lstContract.Where(s => lstIDs.Contains(s.ID)).ToList();
            }

            foreach (var item in lstContract)
            {
                item.DateExtend = model.DateExtendTo;
                ContractServices.Edit(item);
                Hre_ContractExtendEntity Entity = new Hre_ContractExtendEntity();
                Entity.ContractID = item.ID;
                Entity.DateStart = model.DateExtendFrom;
                Entity.DateEnd = model.DateExtendTo;
                message = ExtendContractServices.Add(Entity);
            }

            return Json(message, JsonRequestBehavior.AllowGet);
        }