Пример #1
0
        public List<Eva_EvalutionDataEntity> SummaryEvalutionData(int year, Guid? _TimesGetDataID, string orgStructureID, DateTime? _daystart, DateTime? _dayend,string userLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                //    #region Get Data
                string status = string.Empty;
                List<Eva_EvalutionDataEntity> lstEvalutionDataEntity = new List<Eva_EvalutionDataEntity>();

                //    //ds nv
                var hrService = new Hre_ProfileServices();
                var service = new BaseService();
                List<object> strOrgIDs = new List<object>();
                strOrgIDs.AddRange(new object[1]);
                strOrgIDs[0] = (object)orgStructureID;

                var lstProfile = hrService.GetData<Hre_ProfileEntity>(strOrgIDs, ConstantSql.hrm_eva_sp_getdata_ProfileByOrg, userLogin, ref status).ToList();
                if (lstProfile == null || lstProfile.Count == 0)
                    return lstEvalutionDataEntity;
                List<Guid> lstProfileIDs = lstProfile.Select(s => s.ID).ToList();
                IUnitOfWork unitOfWork = new UnitOfWork(context);
                var lstattattendancetable = new List<Att_AttendanceTable>().Select(d => new
                {
                    d.LateEarlyDeductionHours,
                    d.ProfileID
                }).ToList();

                foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                {
                    lstattattendancetable.AddRange(unitOfWork.CreateQueryable<Att_AttendanceTable>(Guid.Empty,
                        d => lstProfileID.Contains(d.ProfileID) && d.MonthYear >= _daystart
                            && d.MonthYear <= _dayend).Select(d => new
                            {
                                d.LateEarlyDeductionHours,
                                d.ProfileID
                            }).ToList());
                }

                #region Lay cau hinh luu vao cot C1->C16
                Sys_AttOvertimePermitConfigServices sysServices = new Sys_AttOvertimePermitConfigServices();
                string DataC1 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C1);
                string DataC2 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C2);
                string DataC3 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C3);
                string DataC4 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C4);
                string DataC5 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C5);
                string DataC6 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C6);
                string DataC7 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C7);
                string DataC8 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C8);
                string DataC9 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C9);
                string DataC10 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C10);
                string DataC11 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C11);
                string DataC12 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C12);
                string DataC13 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C13);
                string DataC14 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C14);
                string DataC15 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C15);
                string DataC16 = sysServices.GetConfigValue<string>(AppConfig.HRM_EVA_CONFIG_SAVE_C16);
                #endregion

                string[] lstDataC1 = null;
                string[] lstDataC2 = null;
                string[] lstDataC3 = null;
                string[] lstDataC4 = null;
                string[] lstDataC5 = null;
                string[] lstDataC6 = null;
                string[] lstDataC7 = null;
                string[] lstDataC8 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC1 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC2 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC3 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC4 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC5 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC6 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC7 = null;
                List<Cat_LeaveDayTypeEntity> templstleavedaytypeC8 = null;
                List<object> tempobjparam = new List<object>();
                tempobjparam.Add(orgStructureID);
                var tempcatService = new Cat_LeaveDayTypeServices();
                var templstcatLeaveDayType = tempcatService.GetData<Cat_LeaveDayTypeEntity>(tempobjparam, ConstantSql.hrm_cat_getdata_LeaveDayType, userLogin, ref status).ToList();
                if (templstcatLeaveDayType.Count > 0)
                {

                    #region Loai Nghi
                    #region C1
                    if (DataC1 != null)
                    {
                        DataC1 = DataC1.Replace(" ", "").Trim();
                        lstDataC1 = DataC1.Split(',').ToArray();
                        if (lstDataC1 != null && lstDataC1.Count() > 0)
                        {
                            templstleavedaytypeC1 = templstcatLeaveDayType.Where(s => lstDataC1.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C2
                    if (DataC2 != null)
                    {
                        DataC2 = DataC2.Replace(" ", "").Trim();
                        lstDataC2 = DataC2.Split(',').ToArray();
                        if (lstDataC2 != null && lstDataC2.Count() > 0)
                        {
                            templstleavedaytypeC2 = templstcatLeaveDayType.Where(s => lstDataC2.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C3
                    if (DataC3 != null)
                    {
                        DataC3 = DataC3.Replace(" ", "").Trim();
                        lstDataC3 = DataC3.Split(',').ToArray();
                        if (lstDataC3 != null && lstDataC3.Count() > 0)
                        {
                            templstleavedaytypeC3 = templstcatLeaveDayType.Where(s => lstDataC3.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C4
                    if (DataC4 != null)
                    {
                        DataC4 = DataC4.Replace(" ", "").Trim();
                        lstDataC4 = DataC4.Split(',').ToArray();
                        if (lstDataC4 != null && lstDataC4.Count() > 0)
                        {
                            templstleavedaytypeC4 = templstcatLeaveDayType.Where(s => lstDataC4.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C5
                    if (DataC5 != null)
                    {
                        DataC5 = DataC5.Replace(" ", "").Trim();
                        lstDataC5 = DataC5.Split(',').ToArray();
                        if (lstDataC5 != null && lstDataC5.Count() > 0)
                        {
                            templstleavedaytypeC5 = templstcatLeaveDayType.Where(s => lstDataC5.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C6
                    if (DataC6 != null)
                    {
                        DataC6 = DataC6.Replace(" ", "").Trim();
                        lstDataC6 = DataC6.Split(',').ToArray();
                        if (lstDataC6 != null && lstDataC6.Count() > 0)
                        {
                            templstleavedaytypeC6 = templstcatLeaveDayType.Where(s => lstDataC6.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C7
                    if (DataC7 != null)
                    {
                        DataC7 = DataC7.Replace(" ", "").Trim();
                        lstDataC7 = DataC7.Split(',').ToArray();
                        if (lstDataC7 != null && lstDataC7.Count() > 0)
                        {
                            templstleavedaytypeC7 = templstcatLeaveDayType.Where(s => lstDataC7.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #region C8
                    if (DataC8 != null)
                    {
                        DataC8 = DataC8.Replace(" ", "").Trim();
                        lstDataC8 = DataC8.Split(',').ToArray();
                        if (lstDataC8 != null && lstDataC8.Count() > 0)
                        {
                            templstleavedaytypeC8 = templstcatLeaveDayType.Where(s => lstDataC8.Contains(s.Code)).ToList();
                        }
                    }
                    #endregion
                    #endregion
                }
                #region doi tuong loc theo loai nghi
                //var catService = new Cat_LeaveDayTypeServices();
                //List<object> objparam = new List<object>();
                //objparam.Add(orgStructureID);
                //var lstcatLeaveDayType = catService.GetData<Cat_LeaveDayTypeEntity>(objparam, ConstantSql.hrm_cat_getdata_LeaveDayType, ref status).ToList();
                //var lstleavedaytypeC1 = lstcatLeaveDayType.Where(s => s.Code == "P").ToList();
                //var lstleavedaytypeC2 = lstcatLeaveDayType.Where(s => s.Code == "M" || s.Code == "SM" || s.Code == "SP" || s.Code == "DL" || s.Code == "DSP").ToList();
                //var lstleavedaytypeC3 = lstcatLeaveDayType.Where(s => s.Code == "SU" || s.Code == "SC").ToList();
                //var lstleavedaytypeC4 = lstcatLeaveDayType.Where(s => s.Code == "DP" || s.Code == "SD").ToList();
                //var lstleavedaytypeC5 = lstcatLeaveDayType.Where(s => s.Code == "AL").ToList();
                //var lstleavedaytypeC7 = lstcatLeaveDayType.Where(s => s.Code == "D").ToList();
                Dictionary<string, List<Cat_LeaveDayTypeEntity>> dicLeaveByType = new Dictionary<string, List<Cat_LeaveDayTypeEntity>>();
                //dicLeaveByType.Add("C1", lstleavedaytypeC1);
                //dicLeaveByType.Add("C2", lstleavedaytypeC2);
                //dicLeaveByType.Add("C3", lstleavedaytypeC3);
                //dicLeaveByType.Add("C4", lstleavedaytypeC4);
                //dicLeaveByType.Add("C5", lstleavedaytypeC5);
                //dicLeaveByType.Add("C7", lstleavedaytypeC7);
                if (templstleavedaytypeC1 != null && templstleavedaytypeC1.Count > 0)
                    dicLeaveByType.Add("C1", templstleavedaytypeC1);
                if (templstleavedaytypeC2 != null && templstleavedaytypeC2.Count > 0)
                    dicLeaveByType.Add("C2", templstleavedaytypeC2);
                if (templstleavedaytypeC3 != null && templstleavedaytypeC3.Count > 0)
                    dicLeaveByType.Add("C3", templstleavedaytypeC3);
                if (templstleavedaytypeC4 != null && templstleavedaytypeC4.Count > 0)
                    dicLeaveByType.Add("C4", templstleavedaytypeC4);
                if (templstleavedaytypeC5 != null && templstleavedaytypeC5.Count > 0)
                    dicLeaveByType.Add("C5", templstleavedaytypeC5);
                if (templstleavedaytypeC6 != null && templstleavedaytypeC6.Count > 0)
                    dicLeaveByType.Add("C6", templstleavedaytypeC6);
                if (templstleavedaytypeC7 != null && templstleavedaytypeC7.Count > 0)
                    dicLeaveByType.Add("C7", templstleavedaytypeC7);
                if (templstleavedaytypeC8 != null && templstleavedaytypeC8.Count > 0)
                    dicLeaveByType.Add("C8", templstleavedaytypeC8);
                #endregion
                #region ngay nghi
                string strE_APPROVED = LeaveDayStatus.E_APPROVED.ToString();
                var lstLeaveDay = new List<Att_LeaveDay>().Select(d => new
                {
                    d.LeaveDayTypeID,
                    d.ProfileID,
                    d.LeaveDays,
                    d.DateStart,
                    d.DateEnd
                }).ToList();

                foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                {
                    lstLeaveDay.AddRange(unitOfWork.CreateQueryable<Att_LeaveDay>(Guid.Empty,
                        d => lstProfileID.Contains(d.ProfileID) && d.DateStart <= _dayend
                            && d.DateEnd >= _daystart && d.Status == strE_APPROVED).Select(d => new
                            {
                                d.LeaveDayTypeID,
                                d.ProfileID,
                                d.LeaveDays,
                                d.DateStart,
                                d.DateEnd
                            }).ToList());
                }
                #endregion
                #region ky luat
                var lsthreDiscipline = new List<Hre_Discipline>().Select(d => new
                {
                    d.DisciplinedTypesSuggestID,
                    d.ProfileID
                }).ToList();

                foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                {
                    lsthreDiscipline.AddRange(unitOfWork.CreateQueryable<Hre_Discipline>(Guid.Empty,
                        d => lstProfileID.Contains(d.ProfileID) && d.DateOfEffective >= _daystart
                            && d.DateOfEffective <= _dayend).Select(d => new
                            {
                                d.DisciplinedTypesSuggestID,
                                d.ProfileID
                            }).ToList());
                }
                #endregion
                #region loai ky luat
                List<object> paraDisciplinedTypes = new List<object>();
                paraDisciplinedTypes.AddRange(new object[3]);
                paraDisciplinedTypes[1] = 1;
                paraDisciplinedTypes[2] = int.MaxValue;
                var catSerciceDisciplinedTypes = new Cat_DisciplinedTypesServices();
                var lstDisciplinedTypes = catSerciceDisciplinedTypes.GetData<Cat_DisciplinedTypesEntity>(paraDisciplinedTypes, ConstantSql.hrm_cat_sp_get_DisciplinedTypes, userLogin, ref status);
                //var objDisciplinedTypeVW = lstDisciplinedTypes.Where(s => s.Code == "VW").FirstOrDefault();
                //var objDisciplinedTypeWW = lstDisciplinedTypes.Where(s => s.Code == "WW").FirstOrDefault();
                //var objDisciplinedTypeDS = lstDisciplinedTypes.Where(s => s.Code == "DS").FirstOrDefault();

                Cat_DisciplinedTypesEntity tempobjDisciplinedType11 = null;
                Cat_DisciplinedTypesEntity tempobjDisciplinedType12 = null;
                Cat_DisciplinedTypesEntity tempobjDisciplinedType13 = null;
                #endregion
                #region Loai ky luat
                if (lstDisciplinedTypes != null)
                {
                    #region C11
                    if (DataC11 != null)
                    {
                        DataC11 = DataC11.Replace(" ", "").Trim();
                        tempobjDisciplinedType11 = lstDisciplinedTypes.Where(s => s.Code == DataC11).FirstOrDefault();
                    }
                    #endregion
                    #region C12
                    if (DataC12 != null)
                    {
                        DataC12 = DataC12.Replace(" ", "").Trim();
                        tempobjDisciplinedType12 = lstDisciplinedTypes.Where(s => s.Code == DataC12).FirstOrDefault();
                    }
                    #endregion
                    #region C13
                    if (DataC13 != null)
                    {
                        DataC13 = DataC13.Replace(" ", "").Trim();
                        tempobjDisciplinedType13 = lstDisciplinedTypes.Where(s => s.Code == DataC13).FirstOrDefault();
                    }
                    #endregion
                }

                #endregion
                #region Danh gia
                var kaiServiceKaizenData = new Kai_KaiZenDataServices();
                var listKaiKaizenData = new List<Kai_KaizenData>().Select(d => new
                {
                    d.Accumulate,
                    d.MarkPerform,
                    d.ProfileID
                }).ToList();

                foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                {
                    listKaiKaizenData.AddRange(unitOfWork.CreateQueryable<Kai_KaizenData>(Guid.Empty, d => d.ProfileID.HasValue
                        && lstProfileID.Contains(d.ProfileID.Value) && d.Month >= _daystart && d.Month <= _dayend).Select(d => new
                        {
                            d.Accumulate,
                            d.MarkPerform,
                            d.ProfileID
                        }).ToList());
                }
                #endregion
                #region Loai thieu quet the la quen quet the voi ma la FC
                var objTamScanResonMissID = unitOfWork.CreateQueryable<Cat_TAMScanReasonMiss>(Guid.Empty, s => s.Code.Trim() == "FC").Select(s => s.ID).FirstOrDefault();
                #endregion
                #region lay du lieu quen quet the
          
                var lstworkDayProfiles = new List<Att_Workday>().Select(d => new
                {
                    d.ProfileID,
                    d.WorkDate
                    
                }).ToList();
                if (objTamScanResonMissID != null)
                {
                    List<string> lstType = new List<string> 
                    { 
                        WorkdayType.E_MISS_IN.ToString(),
                        WorkdayType.E_MISS_IN_OUT.ToString(),
                        WorkdayType.E_MISS_OUT.ToString()
                    };
                    foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                    {
                        lstworkDayProfiles.AddRange(unitOfWork.CreateQueryable<Att_Workday>(Guid.Empty, d => lstProfileID.Contains(d.ProfileID) && _daystart <= d.WorkDate && d.WorkDate <= _dayend && lstType.Contains(d.Type) && d.MissInOutReason == objTamScanResonMissID).Select(d => new
                        {
                            d.ProfileID,
                            d.WorkDate
                        }).ToList());
                    }
                }
              
                #endregion
                bool? _tempC9LATEEARLYDEDUCTIONHOURS = false;
                bool? _tempC9FAILINGTORECORDCARD = false;
                bool? _tempC10LATEEARLYDEDUCTIONHOURS = false;
                bool? _tempC10FAILINGTORECORDCARD = false;

                #region xac dinh dlieu luu cot C9 va C10
                if (DataC9 != null)
                {
                    if (DataC9.Replace(" ", "").Trim() == "LATEEARLYDEDUCTIONHOURS")
                    {
                        _tempC9LATEEARLYDEDUCTIONHOURS = true;
                    }
                    else if (DataC9.Replace(" ", "").Trim() == "FAILINGTORECORDCARD")
                    {
                        _tempC9FAILINGTORECORDCARD = true;
                    }
                }
                if (DataC10 != null)
                {
                    if (DataC10.Replace(" ", "").Trim() == "LATEEARLYDEDUCTIONHOURS")
                    {
                        _tempC10LATEEARLYDEDUCTIONHOURS = true;
                    }
                    else if (DataC10.Replace(" ", "").Trim() == "FAILINGTORECORDCARD")
                    {
                        _tempC10FAILINGTORECORDCARD = true;
                    }
                }
                #endregion
                #region xac dinh dlieu luu cot C14->C16
                bool? _tempC14MARKPERFORM = false;
                bool? _tempC14ACCUMULATE = false;
                bool? _tempC15MARKPERFORM = false;
                bool? _tempC15ACCUMULATE = false;
                bool? _tempC16MARKPERFORM = false;
                bool? _tempC16ACCUMULATE = false;

                if (DataC14 != null)
                {
                    if (DataC14.Replace(" ", "").Trim() == "MARKPERFORM")
                    {
                        _tempC14MARKPERFORM = true;
                    }
                    else if (DataC14.Replace(" ", "").Trim() == "ACCUMULATE")
                    {
                        _tempC14ACCUMULATE = true;
                    }
                }
                if (DataC15 != null)
                {
                    if (DataC15.Replace(" ", "").Trim() == "MARKPERFORM")
                    {
                        _tempC15MARKPERFORM = true;
                    }
                    else if (DataC15.Replace(" ", "").Trim() == "ACCUMULATE")
                    {
                        _tempC15ACCUMULATE = true;
                    }
                }
                if (DataC16 != null)
                {
                    if (DataC16.Replace(" ", "").Trim() == "MARKPERFORM")
                    {
                        _tempC16MARKPERFORM = true;
                    }
                    else if (DataC16.Replace(" ", "").Trim() == "ACCUMULATE")
                    {
                        _tempC16ACCUMULATE = true;
                    }
                }

                #endregion

                foreach (var profile in lstProfile)
                {
                    Eva_EvalutionDataEntity entity = new Eva_EvalutionDataEntity();
                    entity.CodeEmp = profile.CodeEmp;
                    entity.ProfileName = profile.ProfileName;
                    entity.ProfileID = profile.ID;
                    entity.TimesGetDataID = _TimesGetDataID;
                    entity.Year = new DateTime(year, 01, 01);
                    int C1 = 0;
                    int C2 = 0;
                    int C3 = 0;
                    int C4 = 0;
                    int C5 = 0;
                    int C6 = 0;
                    int C7 = 0;
                    int C8 = 0;
                    int C9 = 0;
                    int C10 = 0;
                    var lstLeaveDayprofile = lstLeaveDay.Where(s => s.ProfileID == profile.ID).ToList();
                    if (lstLeaveDayprofile.Count > 0)
                    {
                        foreach (var attLeaveDayprofile in lstLeaveDayprofile)
                        {
                            #region C1->C8
                            foreach (var item in dicLeaveByType)
                            {
                                List<Cat_LeaveDayTypeEntity> lstLeavetype = (List<Cat_LeaveDayTypeEntity>)item.Value;
                                int temp = 0;
                                if (attLeaveDayprofile.LeaveDayTypeID != null && lstLeavetype.Any(m => m.ID == attLeaveDayprofile.LeaveDayTypeID) && attLeaveDayprofile.LeaveDays > 0)
                                {
                                    string _strLeaveDays = attLeaveDayprofile.LeaveDays.ToString();
                                    string[] _partLeaveDays = _strLeaveDays.Split('.');
                                    int _intLeaveDays = int.Parse(_partLeaveDays[0]);
                                    if (_partLeaveDays.Count() > 1)
                                    {
                                        int _modLeaveDays = int.Parse(_partLeaveDays[1]);
                                        if (_modLeaveDays > 0)
                                        {
                                            temp += _intLeaveDays + 1;
                                        }
                                    }
                                    else
                                    {
                                        temp += _intLeaveDays;
                                    }
                                }
                                if (item.Key == "C1")
                                {
                                    C1 += temp;
                                }
                                if (item.Key == "C2")
                                {
                                    C2 += temp;
                                }
                                if (item.Key == "C3")
                                {
                                    C3 += temp;
                                }
                                if (item.Key == "C4")
                                {
                                    C4 += temp;
                                }
                                if (item.Key == "C5")
                                {
                                    C5 += temp;
                                }
                                if (item.Key == "C6")
                                {
                                    C6 += temp;
                                }
                                if (item.Key == "C7")
                                {
                                    C7 += temp;
                                }
                                if (item.Key == "C8")
                                {
                                    C8 += temp;
                                }
                            }
                        }
                            #endregion
                    }

                    #region tong tre som va quen quet the C9->C10
                    #region C9
                    if (_tempC9LATEEARLYDEDUCTIONHOURS == true)
                    {
                        var lstattattendancetableprofile = lstattattendancetable.Where(s => s.ProfileID == profile.ID).ToList();
                        if (lstattattendancetableprofile.Count > 0)
                        {
                            C9 = lstattattendancetableprofile.Where(s => s.LateEarlyDeductionHours > 0).Count();
                        }
                    }
                    else if (_tempC9FAILINGTORECORDCARD == true)
                    {
                        var lstworkDayprofile = lstworkDayProfiles.Where(s => s.ProfileID == profile.ID).ToList();
                        if (lstworkDayprofile.Count > 0)
                        {
                            C9 = lstworkDayprofile.Count();
                        }
                        if (lstLeaveDayprofile.Count > 0)
                        {
                            foreach (var objWorkDay in lstworkDayprofile)
                            {
                                var objLeaveDayByWorkDay = lstLeaveDayprofile.Where(s => s.DateStart <= objWorkDay.WorkDate && s.DateEnd >= objWorkDay.WorkDate).ToList();
                                if (objLeaveDayByWorkDay.Count > 0)
                                {
                                    C9 -= 1;
                                }
                            }
                        }
                    }
                    #endregion
                    #region C10
                    if (_tempC10LATEEARLYDEDUCTIONHOURS == true)
                    {
                        var lstattattendancetableprofile = lstattattendancetable.Where(s => s.ProfileID == profile.ID).ToList();
                        if (lstattattendancetableprofile.Count > 0)
                        {
                            C10 = lstattattendancetableprofile.Where(s => s.LateEarlyDeductionHours > 0).Count();
                        }
                    }
                    else if (_tempC10FAILINGTORECORDCARD == true)
                    {
                        var lstworkDayprofile = lstworkDayProfiles.Where(s => s.ProfileID == profile.ID).ToList();
                        if (lstworkDayprofile.Count > 0)
                        {
                            C10 = lstworkDayprofile.Count();
                        }
                        if (lstLeaveDayprofile.Count>0)
                        {
                            foreach (var objWorkDay in lstworkDayprofile)
                            {
                                var objLeaveDayByWorkDay = lstLeaveDayprofile.Where(s => s.DateStart <= objWorkDay.WorkDate && s.DateEnd >= objWorkDay.WorkDate).ToList();
                                if (objLeaveDayByWorkDay.Count > 0)
                                {
                                    C10 -= 1;
                                }
                            }
                        }
                    }
                    #endregion
                    #endregion
                    if (C1 > 0)
                        entity.C1 = C1;
                    if (C2 > 0)
                        entity.C2 = C2;
                    if (C3 > 0)
                        entity.C3 = C3;
                    if (C4 > 0)
                        entity.C4 = C4;
                    if (C5 > 0)
                        entity.C5 = C5;
                    if (C6 > 0)
                        entity.C6 = C6;
                    if (C7 > 0)
                        entity.C7 = C7;
                    if (C8 > 0)
                        entity.C8 = C8;
                    if (C9 > 0)
                        entity.C9 = C9;
                    if (C10 > 0)
                        entity.C10 = C10;
                    #region C11->C13
                    if (lsthreDiscipline.Count > 0)
                    {
                        var lsthreDisciplineprofile = lsthreDiscipline.Where(s => s.ProfileID == profile.ID).ToList();
                        if (lsthreDisciplineprofile.Count > 0)
                        {
                            if (tempobjDisciplinedType11 != null)
                            {
                                var lsthreDiscipline11 = lsthreDisciplineprofile.Where(s => s.DisciplinedTypesSuggestID == tempobjDisciplinedType11.ID).ToList();
                                if (lsthreDiscipline11.Count > 0)
                                    entity.C11 = lsthreDiscipline11.Count;
                            }
                            if (tempobjDisciplinedType12 != null)
                            {
                                var lsthreDiscipline12 = lsthreDisciplineprofile.Where(s => s.DisciplinedTypesSuggestID == tempobjDisciplinedType12.ID).ToList();
                                if (lsthreDiscipline12.Count > 0)
                                    entity.C12 = lsthreDiscipline12.Count;
                            }
                            if (tempobjDisciplinedType13 != null)
                            {
                                var lsthreDiscipline13 = lsthreDisciplineprofile.Where(s => s.DisciplinedTypesSuggestID == tempobjDisciplinedType13.ID).ToList();
                                if (lsthreDiscipline13.Count > 0)
                                    entity.C13 = lsthreDiscipline13.Count;
                            }
                        }
                    }
                    #endregion
                    #region C14->C16
                    if (listKaiKaizenData.Count > 0)
                    {
                        var listKaiKaizenDataprofile = listKaiKaizenData.Where(s => s.ProfileID == profile.ID).ToList();
                        int _tempAccumulate = 0;
                        int _MarkPerform = 0;
                        if (listKaiKaizenDataprofile.Count > 0)
                        {
                            #region Danh Gia
                            _MarkPerform = listKaiKaizenDataprofile.Where(s => s.MarkPerform > 0).Count();
                            _tempAccumulate = int.Parse(listKaiKaizenDataprofile.Select(s => s.Accumulate).Sum().ToString());
                            #region C14
                            if (_tempC14MARKPERFORM == true && _MarkPerform > 0)
                            {
                                entity.C14 = _MarkPerform;
                            }
                            else if (_tempC14ACCUMULATE == true && _tempAccumulate > 0)
                            {
                                entity.C14 = _tempAccumulate;
                            }
                            #endregion
                            #region C15
                            if (_tempC15MARKPERFORM == true && _MarkPerform > 0)
                            {
                                entity.C15 = _MarkPerform;
                            }
                            else if (_tempC15ACCUMULATE == true && _tempAccumulate > 0)
                            {
                                entity.C15 = _tempAccumulate;
                            }
                            #endregion
                            #region C16
                            if (_tempC16MARKPERFORM == true && _MarkPerform > 0)
                            {
                                entity.C16 = _MarkPerform;
                            }
                            else if (_tempC16ACCUMULATE == true && _tempAccumulate > 0)
                            {
                                entity.C16 = _tempAccumulate;
                            }
                            #endregion
                            #endregion
                        }

                    }
                    #endregion
                    if (entity != null)
                    {
                        lstEvalutionDataEntity.Add(entity);
                    }
                }
                return lstEvalutionDataEntity;
                //    #endregion
            }
        }
Пример #2
0
        public Att_LeaveDayModel Post([Bind]Att_LeaveDayModel model)
        {
            string status = "";
            string message = string.Empty;
            //truong hop edit 1 nhan vien
            if (model.ProfileID != Guid.Empty)
            {
                model.ProfileIds = model.ProfileID.ToString();
            }
            BaseService baseService = new BaseService();
            List<Guid> lstProfileIDs = new List<Guid>();
            #region Xu ly lay lst nhan vien cuoi cung
            //xu ly chon nhan vien hay chon phong ban
            if (!string.IsNullOrEmpty(model.ProfileIds))
            {
                List<Guid> lstMulti = new List<Guid>();
                var lst = model.ProfileIds.Split(',');
                foreach (var item in lst)
                {
                    Guid _Id = new Guid(item);
                    lstMulti.Add(_Id);
                }
                lstProfileIDs = lstMulti;
            }
            else
            {
                if (model.strOrgStructureIDs == "")
                {
                    model.strOrgStructureIDs = null;
                }
                List<object> lstObj = new List<object>();
                lstObj.Add(model.strOrgStructureIDs);
                lstObj.Add(null);
                lstObj.Add(null);
                List<Hre_ProfileEntity> lstOrg = baseService.GetData<Hre_ProfileEntity>(lstObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, UserLogin, ref status).ToList();
                lstProfileIDs = lstOrg.Select(d => d.ID).ToList();
                //neu co loai tru
                if(!string.IsNullOrEmpty(model.ProfileIDsExclude) && lstProfileIDs.Count>0)
                {
                    List<Guid> lstProfileIDsExclude = new List<Guid>();
                    var lst = model.ProfileIDsExclude.Split(',');
                    foreach (var item in lst)
                    {
                        Guid _Id = new Guid(item);
                        lstProfileIDsExclude.Add(_Id);
                    }
                    lstProfileIDs = lstProfileIDs.Where(d => !lstProfileIDsExclude.Contains(d)).ToList();
                }
            }
            if (lstProfileIDs.Count()==0)
            {
                message = string.Format(ConstantMessages.FieldNotAllowNull.TranslateString(), ("ProfileID").TranslateString());
                model.ActionStatus = message;
                return model;
            }
            #endregion
            if (model.HoursFrom != null)
            {
                model.DateStart = new DateTime(model.DateStart.Year, model.DateStart.Month, model.DateStart.Day, model.HoursFrom.Value.Hour, model.HoursFrom.Value.Minute, 0);

            }
            if (model.HoursTo != null)
            {
                model.DateEnd = new DateTime(model.DateStart.Year, model.DateStart.Month, model.DateStart.Day, model.HoursTo.Value.Hour, model.HoursTo.Value.Minute, 0);
            }
            #region Validate

         
            var checkValidate = true;
            if(model.IsPortal ==true)
            {
                checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Att_LeaveDayModel>(model, "Att_LeaveDayPortal", ref message);
            }
            else
            {
                checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Att_LeaveDayModel>(model, "Att_LeaveDay", ref message);
            }
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return model;
            }
            if (model.LeaveDays == 0 && model.LeaveHours == 0)
            {
                model.ActionStatus = ConstantMessages.AccessDenied.TranslateString();
                return model;
            }
            #endregion



            //TimeSpan ts = new TimeSpan(model.HoursFrom.Value.Hour, model.HoursFrom.Value.Minute, 0);
            //model.DateStart = model.DateStart + ts;


            if (model.DurationType != LeaveDayDurationType.E_FULLSHIFT.ToString())
            {
                if (model.HoursFrom.HasValue)
                    model.DateStart = new DateTime(model.DateStart.Year, model.DateStart.Month, model.DateStart.Day, model.HoursFrom.Value.Hour, model.HoursFrom.Value.Minute, model.HoursFrom.Value.Second);
                if (model.HoursTo.HasValue)
                    model.DateEnd = new DateTime(model.DateEnd.Year, model.DateEnd.Month, model.DateEnd.Day, model.HoursTo.Value.Hour, model.HoursTo.Value.Minute, model.HoursTo.Value.Second);

                if (model.DurationType == LeaveDayDurationType.E_FIRSTHALFSHIFT.ToString() || model.DurationType == LeaveDayDurationType.E_LASTHALFSHIFT.ToString())
                {
                    model.LeaveDays = 0.5;
                }
            }

            ActionService service = new ActionService(UserLogin);
            List<object> lstobject = new List<object>();
            lstobject.AddRange(new object[11]);
            //lstobject[4] = DateTime.MinValue; //DateFrom
            //lstobject[5] = DateTime.MaxValue; //DateTo
            lstobject[9] = 1;
            //lstobject[10] = int.MaxValue;
            lstobject[10] = Int32.MaxValue - 1;
      
            string strMessages = "";
            var _catLeaveDay = new Att_LeavedayServices();
            List<Att_LeaveDayEntity> lstLeaveDayInDbUpdate = _catLeaveDay.GetData<Att_LeaveDayEntity>(lstobject, ConstantSql.hrm_att_sp_get_Leaveday, UserLogin, ref status);

            #region [Hien.Nguyen] - Kiểm tra trùng khi đăng kí cùng một ngày và cùng loại ngày nghỉ

            //if (lstLeaveDayInDbUpdate != null)
            //{
            //    if (model.ID == Guid.Empty)
            //    {
            //        if (lstLeaveDayInDbUpdate.Any(m => m.ProfileID == model.ProfileID && m.DateStart <= model.DateEnd && m.DateEnd >= model.DateStart && m.LeaveDayTypeID == model.LeaveDayTypeID))
            //        {
            //            model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate);
            //            return model;
            //        }
            //    }
            //    else
            //    {
            //        var leaveDay = _catLeaveDay.GetData<Att_LeaveDayEntity>(model.ID, ConstantSql.hrm_att_sp_get_LeaveDayById, ref status).FirstOrDefault();
            //        if (leaveDay != null)
            //        {
            //            if (leaveDay.LeaveDayTypeID != model.LeaveDayTypeID || leaveDay.DateStart != model.DateStart || leaveDay.DateEnd != model.DateEnd || leaveDay.ProfileID != model.ProfileID)
            //            {
            //                if (lstLeaveDayInDbUpdate.Any(m => m.ProfileID == model.ProfileID && m.DateStart <= model.DateEnd && m.DateEnd >= model.DateStart && m.LeaveDayTypeID == model.LeaveDayTypeID))
            //                {
            //                    model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate);
            //                    return model;
            //                }
            //            }
            //        }
            //    }
            //}

            #endregion

            #region Kiểm tra đăng ký trùng 1 ngày chỉ 1 loại ngày nghỉ nếu là Loại Toàn Ca, Còn lại thì 2 loại ngày nghỉ
            if (model.ID != Guid.Empty)//nếu là chỉnh sửa thì loại bỏ dòng đó ra khỏi list tổng
            {
                lstLeaveDayInDbUpdate = lstLeaveDayInDbUpdate.Where(m => m.ID != model.ID).ToList();
            }
            if (model.DurationType == LeaveDayDurationType.E_FULLSHIFT.ToString())//Toàn ca chỉ được dk 1 dòng
            {
                if (lstLeaveDayInDbUpdate.Any(m => lstProfileIDs.Contains(m.ProfileID) && m.DateStart <= model.DateEnd && m.DateEnd >= model.DateStart))
                {
                    //model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate);
                    model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + string.Format(ConstantMessages.FieldDuplicate.TranslateString(), ConstantDisplay.HRM_Evaluation_Information.TranslateString()));
                    return model;
                }
            }
            else//Ngược lại thì đk 2 dòng
            {
                if (lstLeaveDayInDbUpdate.Any(m => lstProfileIDs.Contains(m.ProfileID) && m.DateStart <= model.DateEnd && m.DateEnd >= model.DateStart && m.DurationType == LeaveDayDurationType.E_FULLSHIFT.ToString()))
                {
                    //  model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate);
                    model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + string.Format(ConstantMessages.FieldDuplicate.TranslateString(), ConstantDisplay.HRM_Evaluation_Information.TranslateString()));
                    return model;
                }
                else if (lstLeaveDayInDbUpdate.Where(m => lstProfileIDs.Contains(m.ProfileID) && m.DateStart <= model.DateEnd && m.DateEnd >= model.DateStart && m.DurationType != LeaveDayDurationType.E_FULLSHIFT.ToString()).Count() > 1)
                {
                    // model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate);
                    model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + string.Format(ConstantMessages.FieldDuplicate.TranslateString(), ConstantDisplay.HRM_Evaluation_Information.TranslateString()));
                    return model;
                }
            }


            #endregion

            #region Triet.Mai Kiểm tra vượt giới hạn cho 1 tháng
            //string[] ProfileArr = model.ProfileIds.Split(',');
            //List<Guid> lstProfileID = new List<Guid>();
            //foreach (var item in lstProfileIDs)
            //{
            //    Guid ProfileID = item;
            //    //Guid.TryParse(item, out ProfileID);
            //    if (ProfileID != Guid.Empty)
            //        lstProfileID.Add(ProfileID);
            //}
            var LeaveDayEntity = model.CopyData<Att_LeaveDayEntity>();
            string Error = (new Att_LeavedayServices()).ValidateOverDayInMonth(LeaveDayEntity, lstProfileIDs);
            if (Error != string.Empty)
            {
                model.SetPropertyValue(Constant.ActionStatus, Error);
                return model;
            }
            #endregion

            List<Att_LeaveDayEntity> lstSM = new List<Att_LeaveDayEntity>();
            Att_ProcessApprovedServices smService = new Att_ProcessApprovedServices();

            if (!string.IsNullOrEmpty(model.ProfileIds))
            {
            
                //string[] arrProfileIds = model.ProfileIds.Split(',');
                strMessages = "";
                if (strMessages != "")
                {
                    // model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate);
                    model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + string.Format(ConstantMessages.FieldDuplicate.TranslateString(), ConstantDisplay.HRM_Evaluation_Information.TranslateString()));
                    return model;
                }
                else
                {
                    var leavedayTypeServices = new Cat_LeaveDayTypeServices();
                    var lstLeavedayType = leavedayTypeServices.GetData<Cat_LeaveDayTypeEntity>(model.LeaveDayTypeID, ConstantSql.hrm_cat_sp_get_LeaveDayTypeById, UserLogin, ref status).FirstOrDefault();


                    if (lstProfileIDs.Count()==1)
                    {

                        var guiId = lstProfileIDs[0];
                        Att_LeaveDayModel modelSave = model.CopyData<Att_LeaveDayModel>();
                        modelSave.ProfileID = guiId;
                        #region Kiểm tra Tổng Số Ngày Nghỉ
                        if (lstLeavedayType != null)
                        {
                            if (model.LeaveDays > lstLeavedayType.MaxPerTimes)
                            {
                                modelSave.ActionStatus = "ErrorTotalLeave";
                                return modelSave;
                            }
                            if (model.LeaveDays > lstLeavedayType.MaxPerYear)
                            {
                                modelSave.ActionStatus = "ErrorTotalLeave";
                                return modelSave;
                            }
                        }
                        #endregion

                        modelSave = service.UpdateOrCreate<Att_LeaveDayEntity, Att_LeaveDayModel>(modelSave);
                        if (modelSave.ActionStatus == NotificationType.Success.ToString())
                        {
                            lstSM.Add(modelSave.Copy<Att_LeaveDayEntity>());
                        }
                        smService.GetEmailToSend_LeaveDay(lstSM, UserLogin);
                        return modelSave;
                    }
                  
                    foreach (var ProfileId in lstProfileIDs)
                    {
                        var guiId = ProfileId;
                        Att_LeaveDayModel modelSave = model.CopyData<Att_LeaveDayModel>();
                        modelSave.ProfileID = guiId;

                        #region Kiểm tra Tổng Số Ngày Nghỉ
                        if (lstLeavedayType != null)
                        {
                            if (model.LeaveDays > lstLeavedayType.MaxPerTimes)
                            {
                                modelSave.ActionStatus = "ErrorTotalLeave";
                                return modelSave;
                            }
                            if (model.LeaveDays > lstLeavedayType.MaxPerYear)
                            {
                                modelSave.ActionStatus = "ErrorTotalLeave";
                                return modelSave;
                            }
                        }
                        #endregion

                        modelSave = service.UpdateOrCreate<Att_LeaveDayEntity, Att_LeaveDayModel>(modelSave);
                        if (modelSave.ActionStatus == NotificationType.Success.ToString())
                        {
                            lstSM.Add(modelSave.Copy<Att_LeaveDayEntity>());
                        }
                        else
                        {
                            smService.GetEmailToSend_LeaveDay(lstSM, UserLogin);
                            return modelSave;
                        }
                    }
                }
                smService.GetEmailToSend_LeaveDay(lstSM, UserLogin);

                model.SetPropertyValue(Constant.ActionStatus, NotificationType.Success.ToString());
                return model;
            }
            else
            {
                //Đã kiểm tra ở trên , nên không cần kt dưới này - [hien.nguyen]
                //if (lstLeaveDayInDbUpdate != null && lstLeaveDayInDbUpdate.Any(d => d.ID != model.ID && d.ProfileID == model.ProfileID && d.DateStart <= model.DateEnd && d.DateEnd >= model.DateStart))
                //{
                //    strMessages = lstLeaveDayInDbUpdate.Where(d => d.ProfileID == model.ProfileID).FirstOrDefault().ProfileName;
                //    model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate);
                //    return model;
                //}
                //else
                model = service.UpdateOrCreate<Att_LeaveDayEntity, Att_LeaveDayModel>(model);
                if (model.ActionStatus == NotificationType.Success.ToString())
                {
                    lstSM.Add(model.Copy<Att_LeaveDayEntity>());
                    smService.GetEmailToSend_LeaveDay(lstSM, UserLogin);
                }
                return model;
            }
        }
Пример #3
0
        public List<Sal_HoldSalaryEntity> ComputeHoldSalary(Guid? cutOffDurationID, Guid[] ProfileIDs, string orgStructureID, Guid TimeAnalyze, string userLoginName)
        {
            using (var context = new VnrHrmDataContext())
            {
                #region Get Data
                string status = string.Empty;
                List<Sal_HoldSalaryEntity> lstHoldSalaryEntity = new List<Sal_HoldSalaryEntity>();

                //ds kỳ công
                var cutOffServies = new Att_CutOffDurationServices();
                var lstObjCutOff = new List<object>();
                lstObjCutOff.Add(null);
                lstObjCutOff.Add(1);
                lstObjCutOff.Add(int.MaxValue - 1);
                var lstCutOff = cutOffServies.GetData<Att_CutOffDurationEntity>(Common.DotNetToOracle(cutOffDurationID.Value.ToString()), ConstantSql.hrm_att_sp_get_CutOffDurationById, userLoginName, ref status).FirstOrDefault();

                //ds nv
                var hrService = new Hre_ProfileServices();
                List<object> strOrgIDs = new List<object>();
                strOrgIDs.AddRange(new object[3]);
                strOrgIDs[0] = (object)orgStructureID;
                var lstProfile = hrService.GetData<Hre_ProfileEntity>(strOrgIDs, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, userLoginName, ref status);

                if (ProfileIDs != null)
                {
                    lstProfile = lstProfile.Where(s => ProfileIDs.Contains(s.ID)).ToList();
                }

                //ds ngày nghỉ
                var leaveDayServices = new Att_LeavedayServices();
                var lstObjLeaveDay = new List<object>();
                lstObjLeaveDay.AddRange(new object[11]);
                lstObjLeaveDay[4] = lstCutOff.DateStart;
                lstObjLeaveDay[5] = lstCutOff.DateEnd;
                lstObjLeaveDay[9] = 1;
                lstObjLeaveDay[10] = int.MaxValue - 1;
                var lstLeaveDay = leaveDayServices.GetData<Att_LeaveDayEntity>(lstObjLeaveDay, ConstantSql.hrm_att_sp_get_Leaveday,userLoginName, ref status);

                //ds loại ngày nghỉ
                var leavedayTypeServices = new Cat_LeaveDayTypeServices();
                var lstObjLeavedayType = new List<object>();
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(1);
                lstObjLeavedayType.Add(int.MaxValue - 1);
                var lstLeavedayType = leavedayTypeServices.GetData<Cat_LeaveDayTypeEntity>(lstObjLeavedayType, ConstantSql.hrm_cat_sp_get_LeaveDayType,userLoginName, ref status);

                lstObjLeavedayType = new List<object>();
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(EnumDropDown.EntityType.E_CountAnalyzeHoldSalary.ToString());
                lstObjLeavedayType.Add(1);
                lstObjLeavedayType.Add(int.MaxValue - 1);
                var ListNameEntity = leavedayTypeServices.GetData<Cat_NameEntityEntity>(lstObjLeavedayType, ConstantSql.hrm_cat_sp_get_NameEntityByKPI,userLoginName, ref status);

                ////ds chế độ lương
                //var Sal_GradeServices = new Sal_GradeServices();
                //var lstObjSal_Grade = new List<object>();
                //lstObjSal_Grade.AddRange(new object[7]);
                //lstObjSal_Grade[3] = lstCutOff.DateStart;
                //lstObjSal_Grade[4] = lstCutOff.DateEnd;//sửa lại store lấy lên tất cả các grade mà ko có ngày kết thúc
                //lstObjSal_Grade[5] = 1;
                //lstObjSal_Grade[6] = int.MaxValue - 1;
                //var lstSal_Grade = Sal_GradeServices.GetData<Sal_GradeEntity>(lstObjSal_Grade, ConstantSql.hrm_sal_sp_get_Sal_Grade, ref status).ToList();

                Sys_AttOvertimePermitConfigServices Sys_Services = new Sys_AttOvertimePermitConfigServices();
                double DATECLOSE_SALARY = Sys_Services.GetConfigValue<double>(AppConfig.HRM_SAL_DATECLOSE_SALARY);

                foreach (var profile in lstProfile)
                {

                    Sal_HoldSalaryEntity entity = new Sal_HoldSalaryEntity();

                    entity.ProfileID = profile.ID;
                    entity.CodeEmp = profile.CodeEmp;
                    entity.ProfileName = profile.ProfileName;
                    entity.CodeAttendance = profile.CodeAttendance;
                    entity.EmployeeTypeName = profile.EmployeeTypeName;
                    entity.WorkPlaceName = profile.WorkPlaceName;
                    entity.IDNo = profile.IDNo;
                    entity.MonthSalary = lstCutOff.MonthYear;
                    entity.TimeAnalyzeID = TimeAnalyze;
                    entity.CatNameEntity = ListNameEntity.FirstOrDefault(m => m.ID == TimeAnalyze) != null ? ListNameEntity.FirstOrDefault(m => m.ID == TimeAnalyze).NameEntityName : "";
                    var lstLeavedayByProfileID = lstLeaveDay.Where(s => profile.ID == s.ProfileID).ToList();

                    #region NV Nghỉ việc trước ngày 18
                    if (profile.DateQuit != null)
                    {
                        if (profile.DateQuit.Value <= lstCutOff.DateEnd && profile.IsSettlement != true)
                        {
                            //if (profile.DateQuit.Value.Day <= 18)
                            //{
                            entity.Terminate = true;
                            lstHoldSalaryEntity.Add(entity);
                            continue;
                            //}
                        }
                    }
                    #endregion

                    #region kiểm tra nghỉ quá 12 ngày
                    if (lstLeavedayByProfileID.Count > 0)
                    {
                        var lstLeavedayTypeBy12 = lstLeavedayType.Where(m => m.Code == "SP" || m.Code == "SC" || m.Code == "DSP" || m.Code == "DL" || m.Code == "M").ToList();
                        var _tmp = lstLeavedayByProfileID.Where(m => !lstLeavedayTypeBy12.Any(t => t.ID == m.LeaveDayTypeID)).ToList();
                        double count = 0;
                        foreach (var i in _tmp)
                        {
                            count += i.LeaveDays != null ? (double)i.LeaveDays : 0;
                        }
                        if (count >= 12)
                        {
                            entity.DayLeave = (int)count;
                            lstHoldSalaryEntity.Add(entity);
                            continue;
                        }
                    }
                    #endregion

                    #region trường hợp đăng ký thai sản trước ngày 18
                    if (lstLeavedayByProfileID.Count > 0)
                    {
                        var lstLeavedayTypeBy12 = lstLeavedayType.Where(m => m.Code == "M").ToList();
                        var _tmp = lstLeavedayByProfileID.FirstOrDefault(m => lstLeavedayTypeBy12.Any(t => t.ID == m.LeaveDayTypeID) && m.DateStart.Day < 18);
                        if (_tmp != null)
                        {
                            entity.IsLeaveM = true;
                            lstHoldSalaryEntity.Add(entity);
                            continue;
                        }
                    }
                    #endregion

                    #region Nghỉ liên tục 3 ngày
                    if (lstLeavedayByProfileID.Count > 0)
                    {
                        var lstLeavedayTypeBy3 = lstLeavedayType.Where(m => m.Code == "D").ToList();
                        //lấy ngày nghỉ theo loại ngày nghỉ D
                        var lstLeavedayByProfileID3 = lstLeavedayByProfileID.Where(m => lstLeavedayTypeBy3.Any(t => t.ID == m.LeaveDayTypeID)).ToList();

                        lstLeavedayByProfileID3 = lstLeavedayByProfileID3.Where(m => m.DateEnd.Day <= DATECLOSE_SALARY).ToList();
                        double count = 0;
                        //còn 1 bug đó là khi đăng ký 3 dòng  liền kế ngày nhau
                        foreach (var i in lstLeavedayByProfileID3)
                        {
                            count = i.LeaveDays != null ? (double)i.LeaveDays : 0;
                            if (count >= 3)
                            {
                                entity.IsLeaveContinuous = true;
                                break;
                            }
                        }
                        if (entity.IsLeaveContinuous != null && entity.IsLeaveContinuous == true)
                        {
                            lstHoldSalaryEntity.Add(entity);
                            continue;
                        }
                    }

                    #endregion
                }
                return lstHoldSalaryEntity;
                #endregion



            }

        }
Пример #4
0
        DataTable CreateReportDetailedMonthlyStaySchema(Guid[] leaveDayTypeIDs, DateTime? _dateStart, DateTime? _dateend)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));

                string status = string.Empty;
                DataTable tb = new DataTable("Att_ReportDetailedMonthlyStayEntity");

                var leaveDayTypeService = new Cat_LeaveDayTypeServices();
                var lstObjLeaveDayType = new List<object>();
                lstObjLeaveDayType.Add(null);
                lstObjLeaveDayType.Add(null);
                lstObjLeaveDayType.Add(1);
                lstObjLeaveDayType.Add(100000000);

                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.CodeEmp);
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.ProfileName);
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.PositionName);
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.JobTitleName);
                //tb.Columns.Add(Att_ReportLeaveMonthEntity.FieldNames.DateQuit);
                //tb.Columns.Add(Att_ReportLeaveMonthEntity.FieldNames.LeaveDayTypeName);
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.Paid);
                //var lstLeavedayType = leaveDayTypeService.GetData<Cat_LeaveDayTypeEntity>(lstObjLeaveDayType, ConstantSql.hrm_cat_sp_get_LeaveDayType, ref status).ToList();
                var lstLeavedayType = unitOfWork.CreateQueryable<Cat_LeaveDayType>(s => s.Code != null).ToList();
                if (_dateStart != null && _dateend != null)
                {
                    for (DateTime date = _dateStart.Value; date <= _dateend.Value; date = date.AddDays(1))
                    {
                        if (!tb.Columns.Contains("Day" + date.Day.ToString()))
                        {
                            tb.Columns.Add("Day" + date.Day.ToString(), typeof(double));
                        }
                    }
                }
                if (leaveDayTypeIDs != null && leaveDayTypeIDs[0] != null)
                {
                    lstLeavedayType = lstLeavedayType.Where(s => leaveDayTypeIDs.Contains(s.ID)).ToList();
                }

                foreach (var item in lstLeavedayType)
                {
                    if (!string.IsNullOrEmpty(item.Code.Trim()) && !tb.Columns.Contains(item.Code.Trim()))
                    {
                        tb.Columns.Add(item.Code.Trim());
                    }
                }
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.E_COMPANY);
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.E_BRANCH);
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.E_UNIT);
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.E_DIVISION);
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.E_DEPARTMENT);
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.E_TEAM);
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.E_SECTION);


                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.DateFrom, typeof(DateTime));
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.DateTo, typeof(DateTime));
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.UserExport);
                tb.Columns.Add(Att_ReportDetailedMonthlyStayEntity.FieldNames.DateExport, typeof(DateTime));
                return tb;
            }
        }
Пример #5
0
        DataTable CreateReportGeneralMonthlyAttendanceSchema(string UserLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                string status = string.Empty;
                DataTable tb = new DataTable("Att_ReportGeneralMonthlyAttendanceEntity");

                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.CodeEmp);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.ProfileName);
                //tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.CodeOrg);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.DepartmentCode);

                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.PositionName);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.JobTitleName);

                //tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.Department);
                //tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.DeptCode);
                //    tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.OrderExcel);
                //tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.Cat_Section);
                //tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.SectCode);
                //tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.LaborType);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.DateHire, typeof(DateTime));
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.DateQuit, typeof(DateTime));

                for (int i = 1; i <= 31; i++)
                {
                    //DataColumn column = new DataColumn(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.Data + i);
                    //column.Caption = i.ToString();
                    //tb.Columns.Add(column);
                    if (!tb.Columns.Contains(i.ToString()))
                        tb.Columns.Add(i.ToString());
                }
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.StandardWorkDays, typeof(double));
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.StandardWorkDaysFormula, typeof(double));
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.RealWorkingDays, typeof(double));
                //   tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.LateEarlyHours);
                var leavedayTypeServices = new Cat_LeaveDayTypeServices();
                var lstObjLeavedayType = new List<object>();
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(1);
                lstObjLeavedayType.Add(100000000);
                var lstLeavedayType = leavedayTypeServices.GetData<Cat_LeaveDayTypeEntity>(lstObjLeavedayType, ConstantSql.hrm_cat_sp_get_LeaveDayType, UserLogin, ref status).Where(s => s.Code != null).Select(m => new { m.Code, m.CodeStatistic }).ToList();

                var overtimeTypeServices = new Cat_OvertimeTypeServices();
                var lstObjOvertimeType = new List<object>();
                lstObjOvertimeType.Add(null);
                lstObjOvertimeType.Add(null);
                lstObjOvertimeType.Add(null);
                lstObjOvertimeType.Add(1);
                lstObjOvertimeType.Add(10000000);


                foreach (var leaveDayType in lstLeavedayType)
                {
                    string fieldName = leaveDayType.Code;
                    string aliasName = leaveDayType.Code;

                    if (!string.IsNullOrWhiteSpace(leaveDayType.CodeStatistic))
                    {
                        fieldName = leaveDayType.CodeStatistic;
                        aliasName = leaveDayType.CodeStatistic;
                    }

                    fieldName = fieldName.ToString().Replace('.', '_');

                    if (!string.IsNullOrWhiteSpace(fieldName))
                    {
                        if (!tb.Columns.Contains(fieldName))
                        {
                            DataColumn column = new DataColumn(fieldName, typeof(double));
                            column.Caption = aliasName.ToString();
                            tb.Columns.Add(column);
                        }

                        if (!tb.Columns.Contains("h" + fieldName))
                        {
                            DataColumn column = new DataColumn("h" + fieldName, typeof(double));
                            column.Caption = "h" + aliasName.ToString();
                            tb.Columns.Add(column);
                        }
                    }
                }
                if (!tb.Columns.Contains(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.ANL))
                {
                    tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.ANL);
                }
                var lstOvertimeType = overtimeTypeServices.GetData<Cat_OvertimeTypeEntity>(lstObjOvertimeType, ConstantSql.hrm_cat_sp_get_OvertimeType, UserLogin, ref status).Where(s => s.Code != null && s.OvertimeTypeName != null).Select(m => m.Code).ToList();
                // lstLeavedayType.AddRange(lstOvertimeType);

                foreach (var overtimeTypeCode in lstOvertimeType)
                {
                    string typeCode = overtimeTypeCode.ToString().Replace('.', '_');

                    if (!string.IsNullOrWhiteSpace(typeCode))
                    {
                        if (!tb.Columns.Contains(typeCode))
                        {
                            DataColumn column = new DataColumn(typeCode, typeof(double));
                            column.Caption = overtimeTypeCode.ToString();
                            tb.Columns.Add(column);
                        }
                    }
                }

                // tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.Count);
                //tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.Cat_OrgStructure);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.Comment);

                // ngay lam tra luong
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.PaidWorkDayCount, typeof(double));
                // tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.Hour);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.LateEarlyDeductionHours, typeof(double));
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.LateEarlyDeductionDays, typeof(double));
                // tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.WorkingPlace);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.AnlDayAvailable, typeof(double));
                //    tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.WorkHours);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.WorkPaidHours, typeof(double));
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.LateEarlyMinutes, typeof(double));
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.LateInMinutes, typeof(double));
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.EarlyOutMinutes, typeof(double));
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.NightShiftHours, typeof(double));
                //    tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.Cat_WorkPlace);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.TotalNightShiftHours, typeof(double));
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.WorkPaidHourOver8, typeof(double));
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.NightHourOver6, typeof(double));

                //  tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.UsableLeave);
                // tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.CurrentMonth);
                //  tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.YearToDate);
                //  tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.SickLeave);
                //   tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.SickYearToDate);
                //   tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.CountLateLess2H);
                // tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.CountLateMore2H);
                //  tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.SumMuteLateEarly);
                //   tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.CountLateEarly);
                //    tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.SumCODayOT);
                //  tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.CountCOLeavday);
                // tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.SickCurrentMonth);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.BranchCode);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.TeamCode);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.SectionCode);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.DepartmentName);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.BranchName);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.TeamName);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.SectionName);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.DateFrom, typeof(DateTime));
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.DateTo, typeof(DateTime));
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.UserExport);
                tb.Columns.Add(Att_ReportGeneralMonthlyAttendanceEntity.FieldNames.DateExport, typeof(DateTime));
                return tb;
            }
        }
Пример #6
0
        DataTable CreateReportMonthlyHourFlightLocalchema(string UserLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                string status = string.Empty;
                DataTable tb = new DataTable("ReportMonthlyHourFlightLocal");

                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.CodeEmp);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.ProfileName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DepartmentCode);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.PositionName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.JobTitleName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.StdWorkDayCount, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.RealWorkDayCount, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.PaidWorkDayCount, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.AnlDayAvailable, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.NightShiftHours, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.LateEarlyDeductionHours, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.AnlDayTaken, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Note);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.ResignedDate, typeof(DateTime));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.StartingDate, typeof(DateTime));

                //tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Note);

                for (int i = 1; i <= 31; i++)
                {
                    DataColumn column = new DataColumn(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Data + i);
                    column.Caption = i.ToString();
                    tb.Columns.Add(column);
                }

                #region MyRegion
                var leavedayTypeServices = new Cat_LeaveDayTypeServices();
                var lstObjLeavedayType = new List<object>();
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(1);
                lstObjLeavedayType.Add(100000000);
                var lstLeavedayType = leavedayTypeServices.GetData<Cat_LeaveDayTypeEntity>(lstObjLeavedayType, ConstantSql.hrm_cat_sp_get_LeaveDayType, UserLogin, ref status).Where(s => s.Code != null).Select(m => m.Code).ToList();


                foreach (var item in lstLeavedayType)
                {
                    if (!tb.Columns.Contains(item))
                    {
                        tb.Columns.Add(item);
                    }
                }

                #endregion
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.BranchCode);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TeamCode);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SectionCode);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DepartmentName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.BranchName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TeamName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SectionName);

                var jobTypeServices = new Cat_JobTypeServices();
                var lstjobType = new List<object>();
                lstjobType.Add(null);
                lstjobType.Add(null);
                lstjobType.Add(1);
                lstjobType.Add(100000000);
                var listjobType = jobTypeServices.GetData<Cat_JobTypeEntity>(lstjobType, ConstantSql.hrm_cat_sp_get_JobType, UserLogin, ref status).Where(s => s.Code != null).Select(m => new { m.RoleID, m.Code }).ToList();


                var roleServices = new Cat_RoleServices();
                var lstRole = new List<object>();
                lstRole.Add(null);
                lstRole.Add(null);
                lstRole.Add(1);
                lstRole.Add(100000000);
                var listRole = roleServices.GetData<Cat_RoleEntity>(lstRole, ConstantSql.hrm_cat_sp_get_Role, UserLogin, ref status).Where(s => s.Code != null).Select(m => new { m.Code, m.ID }).ToList();

                foreach (var roleEntity in listRole)
                {
                    var lstJobTypeByRole = listjobType.Where(s => s.RoleID == roleEntity.ID).ToList();
                    foreach (var item in lstJobTypeByRole)
                    {
                        var CodeRoleAndJobType = roleEntity.Code + "_" + item.Code;
                        if (!tb.Columns.Contains(CodeRoleAndJobType))
                        {
                            tb.Columns.Add(CodeRoleAndJobType);
                        }
                    }
                }
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateFrom, typeof(DateTime));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateTo, typeof(DateTime));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.UserExport);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateExport, typeof(DateTime));
                return tb;
            }
        }
Пример #7
0
        DataTable CreateReportMonthlyTimeSheetV2Schema(string UserLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                string status = string.Empty;
                DataTable tb = new DataTable("ReportMonthlyTimeSheetV2");

                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateHire, typeof(DateTime));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateEndProbation, typeof(DateTime));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.CodeEmp);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.ProfileName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DepartmentCode);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.PositionName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.JobTitleName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.StdWorkDayCount, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.RealWorkDayCount, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.PaidWorkDayCount, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.HourPerDay, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.AnlDayAvailable, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.NightShiftHours, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.LateEarlyDeductionHours, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.AnlDayTaken, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Note);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.ResignedDate, typeof(DateTime));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.StartingDate, typeof(DateTime));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateFrom, typeof(DateTime));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateTo, typeof(DateTime));

                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.UnPaidLeave, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SickDayTaken, typeof(Double));
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TotalPregnancy, typeof(Double));

                //tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Note);

                for (int i = 1; i <= 45; i++)
                {
                    DataColumn column = new DataColumn(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Data + i);
                    column.Caption = i.ToString();

                    tb.Columns.Add(column);
                }

                #region MyRegion

                var leavedayTypeServices = new Cat_LeaveDayTypeServices();
                //var lstObjLeavedayType = new List<object>();
                //lstObjLeavedayType.Add(null);
                //lstObjLeavedayType.Add(null);
                //lstObjLeavedayType.Add(1);
                //lstObjLeavedayType.Add(100000000);
                //var lstLeavedayType = leavedayTypeServices.GetData<Cat_LeaveDayTypeEntity>(lstObjLeavedayType, ConstantSql.hrm_cat_sp_get_LeaveDayType, ref status).Where(s => s.CodeStatistic != null).Select(m => m.CodeStatistic).ToList();
                var lstLeavedayType = unitOfWork.CreateQueryable<Cat_LeaveDayType>(Guid.Empty, s => s.CodeStatistic != null).Select(m => m.CodeStatistic).ToList();

                foreach (var item in lstLeavedayType)
                {
                    if (!tb.Columns.Contains(item))
                    {
                        tb.Columns.Add(item, typeof(double));
                    }
                }

                var lstOvertimeType = unitOfWork.CreateQueryable<Cat_OvertimeType>(Guid.Empty, s => s.CodeStatistic != null).Select(m => m.CodeStatistic).ToList();

                foreach (var item in lstOvertimeType)
                {
                    if (!tb.Columns.Contains(item))
                    {
                        tb.Columns.Add(item, typeof(double));
                    }
                }

                #endregion
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.BranchCode);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TeamCode);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SectionCode);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DepartmentName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.BranchName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TeamName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SectionName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Channel);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Region);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Area);

                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_COMPANY);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_BRANCH);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_UNIT);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_DIVISION);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_DEPARTMENT);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_TEAM);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_SECTION);


                var jobTypeServices = new Cat_JobTypeServices();
                var lstjobType = new List<object>();
                lstjobType.Add(null);
                lstjobType.Add(null);
                lstjobType.Add(1);
                lstjobType.Add(100000000);
                var listjobType = jobTypeServices.GetData<Cat_JobTypeEntity>(lstjobType, ConstantSql.hrm_cat_sp_get_JobType, UserLogin, ref status).Where(s => s.Code != null).Select(m => m.Code).ToList();
                foreach (var item in listjobType)
                {
                    if (!tb.Columns.Contains(item))
                    {
                        tb.Columns.Add(item, typeof(double));
                        tb.Columns.Add(item + "_Sector", typeof(double));
                    }
                }
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.UserExport);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateExport, typeof(DateTime));
                return tb;
            }
        }
Пример #8
0
        /// <summary>
        /// Lấy Dữ Liệu BC BẢNG CÔNG HÀNG THÁNG
        /// </summary>
        /// <returns></returns>

        DataTable CreateReportMonthlyTimeSheetSchema(string UserLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                string status = string.Empty;
                DataTable tb = new DataTable();

                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.CodeEmp);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.ProfileName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.CodeOrg);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.DepartmentCode);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.BranchCode);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.TeamCode);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.SectionCode);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.DepartmentName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.BranchName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.TeamName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.SectionName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.PositionName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.JobTitleName);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.CodeCenter);

                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.StdWorkDayCount);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.RealWorkDayCount);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.PaidWorkDayCount);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.AnlDayAvailable);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.NightShiftHours);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.LateEarlyDeductionHours);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.AnlDayTaken);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.Note);
                #region MyRegion
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.UnPaidLeave);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.Allowance1);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.Allowance2);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.COBeginPeriod);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.COEndPeriod);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.UsableLeave);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.CurrentMonth);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.YearToDate);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.SickLeave);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.SickYearToDate);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.CountLateLess2H);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.CountLateMore2H);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.SumMuteLateEarly);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.CountLateEarly);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.SumCODayOT);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.CountCOLeavday);
                tb.Columns.Add(Att_ReportMonthlyTimeSheetEntity.FieldNames.SickCurrentMonth);
                #endregion

                #region MyRegion
                var leavedayTypeServices = new Cat_LeaveDayTypeServices();
                var lstObjLeavedayType = new List<object>();
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(null);
                lstObjLeavedayType.Add(1);
                lstObjLeavedayType.Add(100000000);
                var lstLeavedayType = leavedayTypeServices.GetData<Cat_LeaveDayTypeEntity>(lstObjLeavedayType, ConstantSql.hrm_cat_sp_get_LeaveDayType, UserLogin, ref status).Where(s => s.Code != null).Select(m => m.Code).ToList();

                var overtimeTypeServices = new Cat_OvertimeTypeServices();
                var lstObjOvertimeType = new List<object>();
                lstObjOvertimeType.Add(null);
                lstObjOvertimeType.Add(null);
                lstObjOvertimeType.Add(null);
                lstObjOvertimeType.Add(1);
                lstObjOvertimeType.Add(10000000);
                var lstOvertimeType = overtimeTypeServices.GetData<Cat_OvertimeTypeEntity>(lstObjOvertimeType, ConstantSql.hrm_cat_sp_get_OvertimeType, UserLogin, ref status).Where(s => s.Code != null && s.OvertimeTypeName != null).Select(m => m.OvertimeTypeName).ToList();

                lstLeavedayType.AddRange(lstOvertimeType);

                foreach (var item in lstLeavedayType)
                {
                    if (!tb.Columns.Contains(item))
                    {
                        tb.Columns.Add(item);
                    }
                }
                #endregion


                return tb;
            }
        }