Пример #1
0
        public PayrollAllowanceMasterDTO GetPayrollMasterByMasterId(int Id)
        {
            PayrollAllowanceMaster    Record       = _unitOfWork.PayrollAllowanceMasterRepository.GetById(Id);
            PayrollAllowanceMasterDTO ReturnRecord = PayrollAllowanceMasterRequestFormatter.ConvertRespondentInfoToDTO(Record);
            List <SelectListItem>     EarningDeductionSelectList = new List <SelectListItem>();

            EarningDeductionSelectList.Add(new SelectListItem {
                Text = "Earning", Value = "E"
            });
            EarningDeductionSelectList.Add(new SelectListItem {
                Text = "Saving", Value = "N"
            });
            EarningDeductionSelectList.Add(new SelectListItem {
                Text = "Deduction", Value = "D"
            });

            List <SelectListItem> AllowanceTypeSelectList = new List <SelectListItem>();

            AllowanceTypeSelectList.Add(new SelectListItem {
                Text = "Earning", Value = "E"
            });
            AllowanceTypeSelectList.Add(new SelectListItem {
                Text = "Saving", Value = "N"
            });
            AllowanceTypeSelectList.Add(new SelectListItem {
                Text = "Deduction", Value = "D"
            });
            List <SelectListItem> PercentageAmountSelectList = new List <SelectListItem>();

            PercentageAmountSelectList.Add(new SelectListItem {
                Text = "Amount", Value = "A"
            });
            PercentageAmountSelectList.Add(new SelectListItem {
                Text = "Percentage", Value = "P"
            });
            ReturnRecord.EarningDeductionSelectList = EarningDeductionSelectList;
            ReturnRecord.AllowanceTypeSelectList    = AllowanceTypeSelectList;
            ReturnRecord.PercentageAmountSelectList = PercentageAmountSelectList;
            return(ReturnRecord);
        }
Пример #2
0
        //to be removed once nondefault work is done
        public PayrollAllowanceMasterDTO GetPayrollDetailByMasterId(int Id, int officeId)
        {
            PayrollAllowanceMaster Record = _unitOfWork.PayrollAllowanceMasterRepository.GetById(Id);
            IEnumerable <PayrollAllowanceDetail>    AllowanceDetail = Record.PayrollAllowanceDetails;
            IEnumerable <PayrollAllowanceDetailDTO> Detail          = PayrollAllowanceDetailResponseFormatter.GetAllTPayrollDetailDTO(AllowanceDetail);
            PayrollAllowanceMasterDTO ReturnRecord = PayrollAllowanceMasterRequestFormatter.ConvertRespondentInfoToDTO(Record);

            ReturnRecord.PayrollAllowanceDetails = Detail;

            IEnumerable <EmployeeCodeName> EmployeeList = GetAllRelatedEmployees(officeId);


            List <SelectListItem> SelectedEmployeeList = new List <SelectListItem>();

            foreach (var row in Detail)
            {
                SelectedEmployeeList.Add(new SelectListItem
                {
                    Text  = GetEmployeeName(row.EmployeeCode),
                    Value = row.EmployeeCode.ToString()
                });
            }

            List <SelectListItem> DropDownEmployee = new List <SelectListItem>();

            foreach (var row in EmployeeList)
            {
                bool selected = false;
                foreach (var Test in SelectedEmployeeList)
                {
                    if (row.Value == Test.Value && row.Text == Test.Text)
                    {
                        selected = true;
                        break;
                    }
                }
                DropDownEmployee.Add(new SelectListItem
                {
                    Text     = row.Text,
                    Value    = row.Value,
                    Selected = selected
                });
            }
            List <AssignedEmployees> AssignedEmployeesList = new List <AssignedEmployees>();

            foreach (var str in EmployeeList)
            {
                int Value = Convert.ToInt32(str.Value);
                if (Detail.Any(x => x.EmployeeCode == Value))
                {
                    PayrollAllowanceDetailDTO PayrollAllowanceDetails = Detail.Where(x => x.EmployeeCode == Value).FirstOrDefault();
                    AssignedEmployees         AssignedEmployeeRow     = new AssignedEmployees()
                    {
                        EmployeeCode     = PayrollAllowanceDetails.EmployeeCode,
                        EmployeeName     = GetEmployeeName(PayrollAllowanceDetails.EmployeeCode),
                        PercentageAmount = PayrollAllowanceDetails.PercentageAmount,
                        Selected         = true,
                        Value            = PayrollAllowanceDetails.Value != null ? PayrollAllowanceDetails.Value : Convert.ToDecimal("0")
                    };
                    AssignedEmployeesList.Add(AssignedEmployeeRow);
                }
                else
                {
                    AssignedEmployees AssignedEmployeeRow = new AssignedEmployees()
                    {
                        EmployeeCode     = Convert.ToInt32(str.Value),
                        EmployeeName     = GetEmployeeName(Convert.ToInt32(str.Value)),
                        PercentageAmount = "",
                        Selected         = false,
                        Value            = Convert.ToDecimal("0")
                    };
                    AssignedEmployeesList.Add(AssignedEmployeeRow);
                }
            }
            ReturnRecord.AssignedEmployees    = AssignedEmployeesList;
            ReturnRecord.SelectedEmployeeList = SelectedEmployeeList;
            ReturnRecord.EmployeeList         = DropDownEmployee;
            return(ReturnRecord);
        }