Ejemplo n.º 1
0
        public ActionResult Index(string id)
        {
            OtherExpenseViewModel otherExpenseViewModelObj = null;

            ViewBag.value = id;
            Settings s = new Settings();

            try
            {
                otherExpenseViewModelObj = new OtherExpenseViewModel();
                otherExpenseViewModelObj.ExpenseDateFormatted = DateTime.Today.ToString(s.dateformat);
                otherExpenseViewModelObj.Today = DateTime.Today.ToString(s.dateformat);
                List <SelectListItem>           selectListItem     = new List <SelectListItem>();
                List <ChartOfAccountsViewModel> chartOfAccountList = Mapper.Map <List <ChartOfAccounts>, List <ChartOfAccountsViewModel> >(_otherExpenseBusiness.GetAllAccountTypes("OE"));
                foreach (ChartOfAccountsViewModel cav in chartOfAccountList)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text  = cav.TypeDesc,
                        Value = cav.Code + ":" + cav.ISEmploy,

                        Selected = false,
                    });
                }
                otherExpenseViewModelObj.AccountTypes = selectListItem;
                selectListItem = null;
                selectListItem = new List <SelectListItem>();
                List <BankViewModel> bankList = Mapper.Map <List <Bank>, List <BankViewModel> >(_otherExpenseBusiness.GetAllBankes());
                foreach (BankViewModel bvm in bankList)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = bvm.Name,
                        Value    = bvm.Code,
                        Selected = false
                    });
                }
                otherExpenseViewModelObj.bankList = selectListItem;

                otherExpenseViewModelObj.CompanyList = new List <SelectListItem>();
                selectListItem = new List <SelectListItem>();
                List <CompaniesViewModel> companiesList = Mapper.Map <List <Companies>, List <CompaniesViewModel> >(_otherExpenseBusiness.GetAllCompanies());
                foreach (CompaniesViewModel cvm in companiesList)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = cvm.Name,
                        Value    = cvm.Code.ToString(),
                        Selected = false
                    });
                }
                otherExpenseViewModelObj.CompanyList = selectListItem;

                otherExpenseViewModelObj.paymentModeList = new List <SelectListItem>();
                selectListItem = new List <SelectListItem>();
                List <PaymentModesViewModel> PaymentModeList = Mapper.Map <List <PaymentModes>, List <PaymentModesViewModel> >(_otherExpenseBusiness.GetAllPaymentModes());
                foreach (PaymentModesViewModel PMVM in PaymentModeList)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = PMVM.Description,
                        Value    = PMVM.Code,
                        Selected = false
                    });
                }
                otherExpenseViewModelObj.paymentModeList = selectListItem;
                //selectListItem = new List<SelectListItem>();
                //List<EmployeeViewModel> empList = Mapper.Map<List<Employee>, List<EmployeeViewModel>>(_otherExpenseBusiness.GetAllEmployees());
                //foreach (EmployeeViewModel evm in empList)
                //{
                //    selectListItem.Add(new SelectListItem
                //    {
                //        Text = evm.Name,
                //        Value = evm.ID.ToString(),
                //        Selected = false
                //    });
                //}
                //otherExpenseViewModelObj.EmployeeList = selectListItem;
                selectListItem = null;
                selectListItem = new List <SelectListItem>();
                List <EmployeeTypeViewModel> empTypeList = Mapper.Map <List <EmployeeType>, List <EmployeeTypeViewModel> >(_otherExpenseBusiness.GetAllEmployeeTypes());
                foreach (EmployeeTypeViewModel etvm in empTypeList)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = etvm.Name,
                        Value    = etvm.Code,
                        Selected = false
                    });
                }
                otherExpenseViewModelObj.EmployeeTypeList = selectListItem;

                otherExpenseViewModelObj.ApprovalStatusList = new List <SelectListItem>();
                selectListItem = new List <SelectListItem>();
                List <ApprovalStatusViewModel> approvalStatus = Mapper.Map <List <ApprovalStatus>, List <ApprovalStatusViewModel> >(_approvalStatusBusiness.GetAllApprovalStatus());
                foreach (ApprovalStatusViewModel BL in approvalStatus)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = BL.Description,
                        Value    = BL.Code,
                        Selected = false
                    });
                }
                otherExpenseViewModelObj.ApprovalStatusList = selectListItem;

                Permission permission = Session["UserRights"] as Permission;
                string     p          = permission.SubPermissionList.Where(li => li.Name == "DaysFilter").First().AccessCode;
                if (p.Contains("R") || p.Contains("W"))
                {
                    otherExpenseViewModelObj.ShowDaysFilter = true;
                }
                else
                {
                    otherExpenseViewModelObj.ShowDaysFilter = false;
                }
                p = null;
                p = permission.SubPermissionList.Where(li => li.Name == "ApprovalFilter").First().AccessCode;
                if (p.Contains("R") || p.Contains("W"))
                {
                    otherExpenseViewModelObj.ApprovalFilter = true;
                }
                else
                {
                    otherExpenseViewModelObj.ApprovalFilter = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(View(otherExpenseViewModelObj));
        }