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));
        }
Ejemplo n.º 2
0
        public ActionResult Index(string id)
        {
            ViewBag.value = id;
            List <SelectListItem>     selectListItem = new List <SelectListItem>();
            SupplierInvoicesViewModel SI             = new SupplierInvoicesViewModel();

            SI.suppliersObj    = new SuppliersViewModel();
            SI.paymentTermsObj = new PaymentTermsViewModel();
            SI.companiesObj    = new CompaniesViewModel();
            SI.TaxTypeObj      = new TaxTypesViewModel();
            Settings s = new Settings();

            SI.InvoiceDateFormatted      = DateTime.Today.ToString(s.dateformat);
            SI.suppliersObj.SupplierList = new List <SelectListItem>();
            selectListItem = new List <SelectListItem>();
            List <SuppliersViewModel> SuppList = Mapper.Map <List <Supplier>, List <SuppliersViewModel> >(_supplierBusiness.GetAllSuppliers());

            foreach (SuppliersViewModel Supp in SuppList)
            {
                selectListItem.Add(new SelectListItem
                {
                    Text     = Supp.CompanyName,
                    Value    = Supp.ID.ToString(),
                    Selected = false
                });
            }
            SI.suppliersObj.SupplierList = selectListItem;

            SI.paymentTermsObj.PaymentTermsList = new List <SelectListItem>();
            selectListItem = new List <SelectListItem>();
            List <PaymentTermsViewModel> PayTermList = Mapper.Map <List <PaymentTerms>, List <PaymentTermsViewModel> >(_paymentTermsBusiness.GetAllPayTerms());

            foreach (PaymentTermsViewModel PayT in PayTermList)
            {
                selectListItem.Add(new SelectListItem
                {
                    Text     = PayT.Description,
                    Value    = PayT.Code,
                    Selected = false
                });
            }
            SI.paymentTermsObj.PaymentTermsList = selectListItem;

            SI.companiesObj.CompanyList = new List <SelectListItem>();
            selectListItem = new List <SelectListItem>();
            List <CompaniesViewModel> CompaniesList = Mapper.Map <List <Companies>, List <CompaniesViewModel> >(_companiesBusiness.GetAllCompanies());

            foreach (CompaniesViewModel Cmp in CompaniesList)
            {
                selectListItem.Add(new SelectListItem
                {
                    Text     = Cmp.Name,
                    Value    = Cmp.Code,
                    Selected = false
                });
            }
            SI.companiesObj.CompanyList = selectListItem;

            SI.TaxTypeObj.TaxTypesList = new List <SelectListItem>();
            selectListItem             = new List <SelectListItem>();
            List <TaxTypesViewModel> TaxTypeList = Mapper.Map <List <TaxTypes>, List <TaxTypesViewModel> >(_taxTypesBusiness.GetAllTaxTypes());

            foreach (TaxTypesViewModel TaTy in TaxTypeList)
            {
                selectListItem.Add(new SelectListItem
                {
                    Text     = TaTy.Description,
                    Value    = TaTy.Code,
                    Selected = false
                });
            }
            SI.TaxTypeObj.TaxTypesList = selectListItem;

            selectListItem = new List <SelectListItem>();
            List <ChartOfAccountsViewModel> chartOfAccountList = Mapper.Map <List <ChartOfAccounts>, List <ChartOfAccountsViewModel> >(_otherExpenseBusiness.GetAllAccountTypes("SUP"));

            foreach (ChartOfAccountsViewModel cav in chartOfAccountList)
            {
                selectListItem.Add(new SelectListItem
                {
                    Text     = cav.TypeDesc,
                    Value    = cav.Code + ":" + cav.ISEmploy,
                    Selected = false,
                });
            }
            SI.AccountTypesList = selectListItem;

            selectListItem = new List <SelectListItem>();
            List <EmployeeViewModel> employeeViewModelList = Mapper.Map <List <Employee>, List <EmployeeViewModel> >(_otherExpenseBusiness.GetAllEmployeesByType("OTH"));

            foreach (EmployeeViewModel EVM in employeeViewModelList)
            {
                selectListItem.Add(new SelectListItem
                {
                    Text     = EVM.Name,
                    Value    = EVM.ID.ToString(),
                    Selected = false,
                });
            }
            SI.SubTypeList = selectListItem;
            return(View(SI));
        }