public Eva_PerformanceModel GetById(Guid id)
        {
            string status = string.Empty;
            var performanceService = new Eva_PerformanceServices();
                       
            var model = new Eva_PerformanceModel();
            var service = new ActionService(UserLogin);
            var entity = service.GetByIdUseStore<Eva_PerformanceEntity>(id, ConstantSql.hrm_eva_sp_get_PerformanceById, ref status);
            if (entity != null)
            {
                model = entity.CopyData<Eva_PerformanceModel>();
                // model.AttachFileLast = model.AttachFile;

                #region Đọc Xml từ db và chuyển sang string

                if (model != null)
                {
                    var doc = performanceService.ReadXml(model.AttachFile, AttachFileEntity.FieldNames.FullName);
                    model.AttachFileLast = string.Join(",", doc.ToArray());
                    model.AttachFile = model.AttachFileLast;
                    model.AttachFiles = doc;
                }
                #endregion
            }

            model.ActionStatus = status;
            return model;
        }
 public Eva_PerformanceModel DeleteOrRemove(string id)
 {
     ActionService service = new ActionService(UserLogin);
     var result = service.DeleteOrRemove<Eva_PerformanceEntity, Eva_PerformanceModel>(id);
     var performanceService = new Eva_PerformanceServices();
     var idItem = id.Split(',');
     for (int i = 1; i < idItem.Count(); i++)
     {
         var idInt = Guid.Parse(idItem[i]).TryGetValue<Guid>();
         if (idInt != Guid.Empty)
         {
             performanceService.DeletePerformance(idInt);
         }
     }
     return result;
 }
        public Eva_PerformanceEvaModel GetById(Guid id)
        {
            string status = string.Empty;
            var model = new Eva_PerformanceEvaModel();
            var service = new ActionService(UserLogin);

            #region Thêm vào bảng Eva_performanceEvaDetail trước khi vào màn hình chờ đánh giá
            //truoc khi vào màn hình chờ đánh giá , sẽ thêm vào bảng eva_performanceEvaDetail nếu bảng này chưa có data ứng với performanceID
            var performanceService = new Eva_PerformanceServices();
            performanceService.AddPerformanceEvaDetail360(id);
            #endregion
            

           // var isEvaluation = false;
            var entity = service.GetByIdUseStore<Eva_PerformanceEvaEntity>(id, ConstantSql.hrm_eva_sp_get_PerformanceEvaById, ref status);
            if (entity != null)
            {
                model = entity.CopyData<Eva_PerformanceEvaModel>();
                
                Eva_PerformanceEvaServices service1 = new Eva_PerformanceEvaServices();
                var performanceservice = new Eva_PerformanceServices();
                if (model != null)
                {
                    model.IsSuperiorHasPerformance = service1.CheckSuperiorHasPerformance(model.PerformanceID ?? Guid.Empty, model.ID);
                    model.IsEvaluation = service1.CheckOrder(model.PerformanceID ?? Guid.Empty, model.ID);
                    model.AttachFileLast = performanceservice.GetAttachFileByOrderNo(model.PerformanceID ?? Guid.Empty, model.OrderEva ?? 0);
                    model.AttachFile = performanceservice.GetAttachFileByOrderNo(model.PerformanceID ?? Guid.Empty, model.OrderEva ?? 0);
                }
            }
            model.ActionStatus = status;

            #region lấy khoảng thời gian cho phép nhập điểm
            var serv = new Sys_AttOvertimePermitConfigServices();
            var dateEndMark = serv.GetConfigValue<DateTime>(AppConfig.HRM_EVA_CONFIG_DATEENDMARK);
            var dateStartMark = serv.GetConfigValue<DateTime?>(AppConfig.HRM_EVA_CONFIG_DATESTARTMARK);
            model.DateStartMark = dateStartMark;
            model.DateEndMark = dateEndMark;
            #endregion


            return model;
        }
Exemple #4
0
        public DataTable GetReportEvalutionData(int year, Guid? _TimesGetDataID, string orgStructureID, bool _IsCreateTemplate, DateTime? _dateStart,
            DateTime? _dateEnd, DateTime? _dateFrom, DateTime? _dateTo, Guid? _JobTitleID, Guid? _PositionID, Guid? _WorkPlaceID, Guid? _RankID,string userLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                DataTable table = CreateReportEvalutionSchema(_dateFrom, _dateTo, userLogin);
                if (_IsCreateTemplate)
                    return table;
                string status = string.Empty;
                List<Eva_EvalutionDataEntity> lstEvalutionDataEntity = new List<Eva_EvalutionDataEntity>();
                DateTime _datetime = new DateTime(year, 01, 01);
                //Ngay goc
                DateTime datetimeNode = _dateEnd.Value;
                List<object> paraEvalutionData = new List<object>();
                paraEvalutionData.AddRange(new object[17]);
                paraEvalutionData[0] = orgStructureID;
                paraEvalutionData[1] = year;
                paraEvalutionData[2] = _datetime;
                //paraEvalutionData[3] = time;
                paraEvalutionData[10] = _TimesGetDataID;

                paraEvalutionData[11] = _JobTitleID;
                paraEvalutionData[12] = _PositionID;
                paraEvalutionData[13] = _WorkPlaceID;
                paraEvalutionData[14] = _RankID;

                paraEvalutionData[15] = 1;
                paraEvalutionData[16] = int.MaxValue - 1;
                var evaServiceEvalutionData = new Eva_EvalutionDataServices();
                //chi danh gia nhung nv ngay vao lam <= ngay goc
                var lstEvalutionData = evaServiceEvalutionData.GetData<Eva_EvalutionDataEntity>(paraEvalutionData, ConstantSql.hrm_eva_getdata_EvalutionData, userLogin, ref status);
                Guid[] lstSalaryClassIDs = null;
                Guid[] lstProfielIds = null;
                if (lstEvalutionData != null)
                {
                    lstSalaryClassIDs = lstEvalutionData.Where(s => s.SalaryClassID != null).Select(s => s.SalaryClassID.Value).Distinct().ToArray();
                    lstProfielIds = lstEvalutionData.Where(s => s.ProfileID != null).Select(s => s.ProfileID.Value).Distinct().ToArray();
                }
                #region luong co ban
                List<object> paraBasicSalary = new List<object>();
                paraBasicSalary.AddRange(new object[10]);
                DateTime _dateMin = DateTime.MinValue;

                paraBasicSalary[2] = orgStructureID;
                paraBasicSalary[3] = _dateMin;
                paraBasicSalary[4] = datetimeNode;
                paraBasicSalary[5] = _dateMin;
                paraBasicSalary[6] = datetimeNode;
                paraBasicSalary[8] = 1;
                paraBasicSalary[9] = int.MaxValue - 1;
                var salServiceBasicSalary = new Sal_BasicSalaryServices();
                var lstBasicSalary = salServiceBasicSalary.GetData<Sal_BasicSalaryEntity>(paraBasicSalary, ConstantSql.hrm_sal_sp_get_BasicPayroll, userLogin, ref status);
                if (lstBasicSalary != null && lstProfielIds != null)
                    lstBasicSalary = lstBasicSalary.Where(s => lstProfielIds.Contains(s.ProfileID)).ToList();
                List<object> paraSalaryRank = new List<object>();
                paraSalaryRank.AddRange(new object[4]);
                paraSalaryRank[2] = 1;
                paraSalaryRank[3] = int.MaxValue;
                var catServiceSalaryRank = new Cat_SalaryRankServices();
                var lstSalaryRank = catServiceSalaryRank.GetData<Cat_SalaryRankEntity>(paraSalaryRank, ConstantSql.hrm_cat_sp_get_SalaryRank, userLogin, ref status);
                if (lstSalaryRank != null && lstSalaryClassIDs != null)
                    lstSalaryRank = lstSalaryRank.Where(s => s.DateOfEffect <= datetimeNode && lstSalaryClassIDs.Contains(s.SalaryClassID.Value)).ToList();
                #endregion
                #region phu cap
                List<object> paraUnusualAllowance = new List<object>();
                paraUnusualAllowance.AddRange(new object[9]);

                paraBasicSalary[3] = _dateMin;
                paraBasicSalary[4] = datetimeNode;
                paraUnusualAllowance[7] = 1;
                paraUnusualAllowance[8] = int.MaxValue - 1;
                var salServiceUnusualAllowance = new Sal_UnusualAllowanceServices();
                var lstUnusualAllowance = salServiceUnusualAllowance.GetData<Sal_UnusualAllowanceEntity>(paraUnusualAllowance, ConstantSql.hrm_sal_sp_get_UnusualED, userLogin, ref status);
                List<Guid> lstUnusualAllowanceIDs = null;
                if (lstUnusualAllowance != null)
                {
                    //lstUnusualAllowance = lstUnusualAllowance.Where(s => s.MonthEnd <= datetimeNode || (s.MonthStart <= datetimeNode && s.MonthEnd == null)).ToList();
                    lstUnusualAllowanceIDs = lstUnusualAllowance.Where(s => s.UnusualEDTypeID != null).Select(s => s.UnusualEDTypeID.Value).Distinct().ToList();
                }

                #endregion
                #region loai phu cap
                List<object> paraUnusualAllowanceCfg = new List<object>();
                paraUnusualAllowanceCfg.AddRange(new object[6]);
                paraUnusualAllowanceCfg[4] = 1;
                paraUnusualAllowanceCfg[5] = int.MaxValue - 1;
                var catServiceUnusualAllowanceCfg = new Cat_UnusualAllowanceCfgServices();
                var lstUnusualAllowanceCfg = catServiceUnusualAllowanceCfg.GetData<Cat_UnusualAllowanceCfgEntity>(paraUnusualAllowanceCfg, ConstantSql.hrm_cat_sp_get_UnusualAllowanceCfg, userLogin, ref status);
                if (lstUnusualAllowanceCfg != null && lstUnusualAllowanceIDs != null)
                    lstUnusualAllowanceCfg = lstUnusualAllowanceCfg.Where(s => lstUnusualAllowanceIDs.Contains(s.ID)).ToList();
                #endregion
                #region lay lich su danh gia
                List<Eva_PerformanceEntity> lstPerformance = null;
                int _yearFrom = DateTime.MinValue.Year;
                int _yearTo = DateTime.MinValue.Year;
                if (_dateFrom != null && _dateTo != null)
                {
                    _yearFrom = _dateFrom.Value.Year;
                    _yearTo = _dateTo.Value.Year;
                    var evaServicePerformance = new Eva_PerformanceServices();
                    List<object> paraPerformance = new List<object>();
                    paraPerformance.AddRange(new object[20]);
                    paraPerformance[2] = orgStructureID;
                    paraPerformance[18] = 1;
                    paraPerformance[19] = int.MaxValue - 1;
                    lstPerformance = evaServicePerformance.GetData<Eva_PerformanceEntity>(paraPerformance, ConstantSql.hrm_eva_sp_get_PerformanceGeneral, userLogin, ref status);
                    if (lstPerformance != null)
                        lstPerformance = lstPerformance.Where(s => s.YearEvaluation != null).ToList();
                    if (lstPerformance.Count != 0)
                        lstPerformance = lstPerformance.Where(s => s.YearEvaluation.Value.Year >= _yearFrom && s.YearEvaluation.Value.Year <= _yearTo).ToList();
                }
                #endregion
                DateTime dateFirstKi = _dateStart.Value;
                foreach (var item in lstEvalutionData)
                {
                    DataRow row = table.NewRow();
                    #region thong tin nhan vien
                    row[Eva_ReportEvalutionDataEntity.FieldNames.CodeEmp] = item.CodeEmp;
                    row[Eva_ReportEvalutionDataEntity.FieldNames.ProfileName] = item.ProfileName;
                    row[Eva_ReportEvalutionDataEntity.FieldNames.E_DEPARTMENT] = item.E_DEPARTMENT;
                    row[Eva_ReportEvalutionDataEntity.FieldNames.E_DIVISION] = item.E_DIVISION;
                    row[Eva_ReportEvalutionDataEntity.FieldNames.E_SECTION] = item.E_SECTION;
                    row[Eva_ReportEvalutionDataEntity.FieldNames.E_TEAM] = item.E_TEAM;
                    row[Eva_ReportEvalutionDataEntity.FieldNames.E_UNIT] = item.E_UNIT;
                    row[Eva_ReportEvalutionDataEntity.FieldNames.GroupCode] = item.CostCentreCode;
                    row[Eva_ReportEvalutionDataEntity.FieldNames.LocationByGroupCode] = item.WorkPlaceCode;
                    row[Eva_ReportEvalutionDataEntity.FieldNames.ReportEvalutionDataNode] = datetimeNode;
                    #endregion
                    #region tham nien
                    if (item.DateOfBirth != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.Age] = DateTime.Today.Year - item.DateOfBirth.Value.Year;
                    if (item.DateHire != null)
                    {
                        row[Eva_ReportEvalutionDataEntity.FieldNames.Entering] = item.DateHire;
                        double dayServiceYear;
                        dayServiceYear = datetimeNode.Subtract(item.DateHire.Value).TotalDays;
                        double _TotalYear = dayServiceYear / 360;
                        double _tempYear = 0;
                        if (_TotalYear > 0)
                        {
                            string[] parts = _TotalYear.ToString().Split('.');
                            double _intMonth = double.Parse(parts[0]);
                            if (parts.Length > 1)
                            {
                                double _modMonth = double.Parse("0." + parts[1]) * 12;
                                if (_modMonth >= 10)
                                {
                                    _tempYear = _intMonth + (_modMonth / 100);
                                }
                                else
                                {
                                    _tempYear = _intMonth + (_modMonth / 10);
                                }
                            }
                            row[Eva_ReportEvalutionDataEntity.FieldNames.ServiceYear] = String.Format("{0:0.0}", _tempYear); ;
                        }
                        if (item.DateHire.Value > dateFirstKi)
                        {
                            if (_TotalYear > 0)
                                row[Eva_ReportEvalutionDataEntity.FieldNames.ServiceYearKi] = String.Format("{0:0.0}", _tempYear);
                        }
                        else
                        {
                            row[Eva_ReportEvalutionDataEntity.FieldNames.ServiceYearKi] = 1.0;
                        }
                    }
                    #endregion

                    var objBasicSalary = lstBasicSalary.Where(s => s.ProfileID == item.ProfileID).FirstOrDefault();
                    if (objBasicSalary != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.BasicSalary] = double.Parse(objBasicSalary.GrossAmount);
                    row[Eva_ReportEvalutionDataEntity.FieldNames.Rank] = item.SalaryClassName;
                    row[Eva_ReportEvalutionDataEntity.FieldNames.QualificationAbilitytitle] = item.AbilityTitleVNI;
                    if (item.SalaryClassID != null)
                    {
                        var objSalaryRank = lstSalaryRank.Where(s => s.SalaryClassID == item.SalaryClassID).FirstOrDefault();
                        if (objSalaryRank != null)
                            row[Eva_ReportEvalutionDataEntity.FieldNames.RankZone] = objSalaryRank.SalaryRankName;
                    }
                    row[Eva_ReportEvalutionDataEntity.FieldNames.JobTitle] = item.JobTitleName;
                    Guid[] lstUnusualAllowanceProfileCfgIds = null;
                    if (lstUnusualAllowance != null)
                    {
                        lstUnusualAllowance = lstUnusualAllowance.Where(s => s.ProfileID == item.ProfileID && s.UnusualEDTypeID != null).ToList();
                        lstUnusualAllowanceProfileCfgIds = lstUnusualAllowance.Select(s => s.UnusualEDTypeID.Value).ToArray();
                    }
                    if (lstUnusualAllowanceCfg != null && lstUnusualAllowanceProfileCfgIds != null)
                        lstUnusualAllowanceCfg = lstUnusualAllowanceCfg.Where(s => lstUnusualAllowanceProfileCfgIds.Contains(s.ID)).ToList();
                    double? totalUnusualAllowance = 0;
                    if (lstUnusualAllowanceCfg != null)
                    {
                        foreach (var itemUnusualAllowanceCfg in lstUnusualAllowanceCfg)
                        {
                            var objUnusualAllowance = lstUnusualAllowance.Where(s => s.UnusualEDTypeID == itemUnusualAllowanceCfg.ID).OrderByDescending(s => s.MonthEnd).FirstOrDefault();
                            if (objUnusualAllowance != null)
                            {
                                row[itemUnusualAllowanceCfg.Code] = objUnusualAllowance.Amount;
                                totalUnusualAllowance += objUnusualAllowance.Amount;
                            }
                        }
                    }
                    #region lich su danh gia
                    if (_dateFrom != null && _dateTo != null && lstPerformance != null)
                    {
                        _yearFrom = _dateFrom.Value.Year;
                        _yearTo = _dateTo.Value.Year;
                        var lstPerformanceProfile = lstPerformance.Where(s => s.ProfileID == item.ProfileID).OrderByDescending(s => s.YearEvaluation).ToList();
                        if (lstPerformanceProfile.Count != 0)
                        {
                            while (_yearTo >= _yearFrom)
                            {
                                var objPerformanceFirst = lstPerformanceProfile.Where(s => s.YearEvaluation.Value.Year == _yearTo).OrderByDescending(s => s.YearEvaluation).FirstOrDefault();
                                _yearTo -= 1;
                                var objPerformance = lstPerformanceProfile.Where(s => s.YearEvaluation.Value.Year == _yearTo).OrderByDescending(s => s.YearEvaluation).FirstOrDefault();
                                int _yeartemp = _yearTo + 1;
                                if (objPerformanceFirst != null && objPerformanceFirst.Level1Name != null)
                                {
                                    if (objPerformanceFirst.RankID != null && objPerformance != null && objPerformance.Level1Name != null && objPerformance.RankID != null)
                                    {
                                        if (objPerformanceFirst.RankID != objPerformance.RankID)
                                        {
                                            row["Year" + _yeartemp] = "(" + objPerformanceFirst.Level1Name + ")";
                                            row["Year" + _yearTo] = "(" + objPerformance.Level1Name + ")";
                                            _yearTo -= 1;
                                            while (_yearTo >= _yearFrom)
                                            {
                                                var objPerformanceYear = lstPerformanceProfile.Where(s => s.YearEvaluation.Value.Year == _yearTo).OrderByDescending(s => s.YearEvaluation).FirstOrDefault();
                                                if (objPerformanceYear != null && objPerformanceYear.Level1Name != null)
                                                    row["Year" + _yearTo] = "(" + objPerformanceYear.Level1Name + ")";
                                                _yearTo -= 1;
                                            }
                                        }
                                        else
                                        {
                                            row["Year" + _yeartemp] = objPerformanceFirst.Level1Name;
                                        }
                                    }
                                    else
                                    {
                                        row["Year" + _yeartemp] = objPerformanceFirst.Level1Name;
                                    }
                                }
                            }
                        }
                        row[Eva_ReportEvalutionDataEntity.FieldNames.HistoryDateFrom] = _dateFrom.Value.ToShortDateString();
                    }
                    #endregion
                    if (totalUnusualAllowance > 0)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.TotalSalaryAllowance] = totalUnusualAllowance;
                    if (item.Year != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.Year] = item.Year;
                    //if (item.Time !=null)
                    //    row[Eva_ReportEvalutionDataEntity.FieldNames.Time] = item.Time;
                    #region lan danh gia
                    if (item.TimeEvalutionData != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.TimeEvalutionData] = item.TimeEvalutionData;
                    if (item.TimeEvalutionDataCode != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.TimeEvalutionDataCode] = item.TimeEvalutionDataCode;

                    #endregion


                    #region C1->C32
                    if (item.C1 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C1] = item.C1;
                    if (item.C2 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C2] = item.C2;
                    if (item.C3 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C3] = item.C3;
                    if (item.C4 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C4] = item.C4;
                    if (item.C5 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C5] = item.C5;
                    if (item.C6 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C6] = item.C6;
                    if (item.C7 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C7] = item.C7;
                    if (item.C8 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C8] = item.C8;
                    if (item.C9 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C9] = item.C9;
                    if (item.C10 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C10] = item.C10;
                    if (item.C11 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C11] = item.C11;
                    if (item.C12 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C12] = item.C12;
                    if (item.C13 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C13] = item.C13;
                    if (item.C14 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C14] = item.C14;
                    if (item.C15 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C15] = item.C15;
                    if (item.C16 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C16] = item.C16;
                    if (item.C17 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C17] = item.C17;
                    if (item.C18 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C18] = item.C18;
                    if (item.C19 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C19] = item.C19;
                    if (item.C20 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C20] = item.C20;
                    if (item.C21 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C21] = item.C21;
                    if (item.C22 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C22] = item.C22;
                    if (item.C23 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C23] = item.C23;
                    if (item.C24 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C24] = item.C24;
                    if (item.C25 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C25] = item.C25;
                    if (item.C26 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C26] = item.C26;
                    if (item.C27 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C27] = item.C27;
                    if (item.C28 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C28] = item.C28;
                    if (item.C29 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C29] = item.C29;
                    if (item.C30 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C30] = item.C30;
                    if (item.C31 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C31] = item.C31;
                    if (item.C32 != null)
                        row[Eva_ReportEvalutionDataEntity.FieldNames.C32] = item.C32;
                    #endregion
                    #region Bo sung
                    //int _tempC1 = 0;
                    //int _TempC2 = 0;
                    //int _tempC3 = 0;
                    //int _tempC4 = 0;
                    //int _tempC5 = 0;
                    //int _tempC6 = 0;
                    //int _tempC7 = 0;
                    //int _tempC8 = 0;
                    //int _tempC9 = 0;
                    //#region TotalC1C2
                    //if (item.C1 != null)
                    //    _tempC1 = item.C1.Value;
                    //if (item.C2 != null)
                    //    _TempC2 = item.C2.Value;
                    //if (item.C1 != null || item.C2 != null)
                    //    row[Eva_ReportEvalutionDataEntity.FieldNames.TotalC1C2] = _tempC1 + _TempC2;
                    //#endregion
                    //#region TotalC3C4C5C6C7
                    //if (item.C3 != null)
                    //    _tempC3 = item.C3.Value;
                    //if (item.C4 != null)
                    //    _tempC4 = item.C4.Value;
                    //if (item.C5 != null)
                    //    _tempC5 = item.C5.Value;
                    //if (item.C6 != null)
                    //    _tempC6 = item.C6.Value;
                    //if (item.C7 != null)
                    //    _tempC7 = item.C7.Value;
                    //if (item.C3 != null || item.C4 != null || item.C5 != null || item.C6 != null || item.C7 != null)
                    //    row[Eva_ReportEvalutionDataEntity.FieldNames.TotalC3C4C5C6C7] = _tempC3 + _tempC4 + _tempC5 + _tempC6 + _tempC7;
                    //#endregion
                    //#region TotalC1C2C3C4C5C6C7
                    //if (item.C1 != null || item.C2 != null || item.C3 != null || item.C4 != null || item.C5 != null || item.C6 != null || item.C7 != null)
                    //    row[Eva_ReportEvalutionDataEntity.FieldNames.TotalC1C2C3C4C5C6C7] = _tempC1 + _TempC2 + _tempC3 + _tempC4 + _tempC5 + _tempC6 + _tempC7;
                    //#endregion
                    //#region  TotalC8C9
                    //if (item.C8 != null)
                    //    _tempC8 = item.C8.Value;
                    //if (item.C9 != null)
                    //    _tempC9 = item.C9.Value;
                    //if (item.C8 != null || item.C9 != null)
                    //    row[Eva_ReportEvalutionDataEntity.FieldNames.TotalC8C9] = _tempC8 + _tempC9;
                    //#endregion                    
                    #endregion
                    #region thoi gian danh gia
                    row[Eva_ReportEvalutionDataEntity.FieldNames.DateStart] = _dateStart;
                    row[Eva_ReportEvalutionDataEntity.FieldNames.DateEnd] = _dateEnd;
                    #endregion
                    table.Rows.Add(row);
                }
                return table.ConfigTable();
                //    #endregion
            }
        }
        public Eva_PerformanceEvaModel Post([Bind]Eva_PerformanceEvaModel model)
        {
            #region Validate

            string message = string.Empty;
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Eva_PerformanceEvaModel>(model, "Eva_PerformanceEva", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return model;
            }

            #endregion

            //ActionService service = new ActionService(UserLogin);
            //return service.UpdateOrCreate<Eva_PerformanceEvaEntity, Eva_PerformanceEvaModel>(model);
            var PerformanceEvaSevice = new Eva_PerformanceEvaServices();
            var PerformanceEvaEntity = model.CopyData<Eva_PerformanceEvaEntity>();
            PerformanceEvaEntity.PerformanceEvaDetails = model.PerformanceEvaDetails.Translate<Eva_PerformanceEvaDetailEntity>();
            
            #region chuyển attachFile thành xml để ghi vào db
            if (PerformanceEvaEntity != null && model.AttachFiles.Any())
            {
                var lstFiles = new List<AttachFileEntity>();
                foreach (var fileItem in model.AttachFiles)
                {
                    if (!string.IsNullOrEmpty(fileItem))
                    {
                        var attachFile = new AttachFileEntity(fileItem);
                        lstFiles.Add(attachFile);
                    }
                }
                var performanceService = new Eva_PerformanceServices();
                var doc = performanceService.WriteXml(lstFiles);
                PerformanceEvaEntity.AttachFile = performanceService.XmlToString(doc);
            }
            #endregion


            PerformanceEvaSevice.EditPerformanceEva(PerformanceEvaEntity);
            return model;

        }
Exemple #6
0
        /// <summary> Lấy file đính kèm theo cấp bậc đánh giá </summary>
        /// <param name="PerformanceID"></param>
        /// <returns></returns>
        public string GetAttachFileByOrderNo(Guid PerformanceID, int orderNo)
        {
            string attachFile = "";
            //lay thu tu đánh giá của người trước
            orderNo = orderNo - 1;
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoP = new Eva_PerformanceRepository(unitOfWork);
                var repoPE = new Eva_PerformanceEvaRepository(unitOfWork);
                Eva_Performance performance = repoP.GetById(PerformanceID);
                if (performance != null && !string.IsNullOrEmpty(performance.AttachFile) && performance.IsDelete == null)
                {
                    attachFile = performance.AttachFile;
                }
                var ilEva_PerformanceEva = repoPE.FindBy(x => x.PerformanceID == PerformanceID
                    && x.IsDelete == null && x.OrderEva == orderNo).Select(p => p.AttachFile).FirstOrDefault();
                if (ilEva_PerformanceEva != null)
                {
                    attachFile = ilEva_PerformanceEva;
                }
            }

            #region Đọc Xml từ db và chuyển sang string

            if (!string.IsNullOrEmpty(attachFile))
            {
                var performanceService = new Eva_PerformanceServices();
                var doc = performanceService.ReadXml(attachFile, AttachFileEntity.FieldNames.FullName);
                attachFile = string.Join(",", doc.ToArray());
            }
            #endregion

            return attachFile;
        }
        public Eva_PerformanceModel Post([Bind]Eva_PerformanceModel model)
        {
            #region Validate

            string message = string.Empty;
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Eva_PerformanceModel>(model, "Eva_Performance", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return model;
            }
            #endregion

            var strEvaluatorIds = model.EvaluatorIDList;
            model.EvaluatorIDs = new List<Guid>();
            if (!string.IsNullOrEmpty(strEvaluatorIds))
            {
                var evaluators = strEvaluatorIds.Split(',');
                foreach (var evaluator in evaluators)
                {
                    if (!string.IsNullOrEmpty(evaluator))
                    {
                        var evaluatorGuid = Guid.Parse(evaluator);
                        model.EvaluatorIDs.Add(evaluatorGuid);
                    }
                }
            }

            var performanceService = new Eva_PerformanceServices();
            var evaluatorEntity = model.CopyData<Eva_PerformanceEntity>();
            evaluatorEntity.KPIs = model.KPIs.Translate<Eva_KPIEntity>();
            if (model.ID == Guid.Empty && performanceService.CheckPerformanceExist(evaluatorEntity))
            {
                model.ActionStatus = ConstantDisplay.HRM_Evaluation_Performance_Duplicate.TranslateString();
                return model;
            }

            #region chuyển attachFile thành xml để ghi vào db
            if (evaluatorEntity != null && model.AttachFiles !=null&& model.AttachFiles.Any())
            {
                var lstFiles = new List<AttachFileEntity>();
                foreach (var fileItem in model.AttachFiles)
                {
                    if (!string.IsNullOrEmpty(fileItem))
                    {
                        var attachFile = new AttachFileEntity(fileItem);
                        lstFiles.Add(attachFile);
                    }
                }
                var doc = performanceService.WriteXml(lstFiles);
                evaluatorEntity.AttachFile = performanceService.XmlToString(doc);
            }
            #endregion
            
            if (model.ID == Guid.Empty)
            {
                model = performanceService.AddPerfomance360(evaluatorEntity, false).CopyData<Eva_PerformanceModel>();
            }
            else
            {
                performanceService.Edit(evaluatorEntity);
            }
            return model;
        }