示例#1
0
        private void Fill()
        {
            ContractorsLogic contractors = new ContractorsLogic(manager);

            DataGV.AutoGenerateColumns = false;
            List <Contractor>     resultA         = contractors.GetAll();
            List <ContractorView> contractorsView = new List <ContractorView>();

            foreach (Contractor a in resultA)
            {
                ContractorView c = new ContractorView(a, manager);
                contractorsView.Add(c);
            }
            view = new SortableBindingList <ContractorView>(contractorsView);
            DataGV.DataSource = view;
            DataGV.AutoResizeRows();
            DataGV.Update();

            PersonCB.SelectedIndex = 0;
            ContractorTypesDDL.Items.Clear();
            ContractorTypesLogic types = new ContractorTypesLogic(manager);

            ContractorTypesDDL.DisplayMember = "Name";
            ContractorTypesDDL.ValueMember   = "ID";
            ContractorType all = new ContractorType();

            all.ID   = -1;
            all.Name = " - всі - ";
            ContractorTypesDDL.Items.Add(all);
            foreach (var a in types.GetAll())
            {
                ContractorTypesDDL.Items.Add(a);
            }
            ContractorTypesDDL.SelectedIndex = 0;
        }
        public ContractorView GetContractor(int id)
        {
            var model = new ContractorView();

            var contractor = _context.Contractors
                             .Include(c => c.ContractorInvoices)
                             .ThenInclude(i => i.ContractorInvoiceItems)
                             .FirstOrDefault(c => c.Id == id);

            model.Id      = contractor.Id;
            model.Company = contractor.Company;

            foreach (var invoice in contractor.ContractorInvoices)
            {
                var modelInvoice = new ContractorView.ContractorInvoice
                {
                    InvRef = invoice.InvRef
                };
                modelInvoice.Id = invoice.Id;

                foreach (var item in invoice.ContractorInvoiceItems)
                {
                    var modelItem = new ContractorView.ContractorInvoiceItem
                    {
                        Item     = item.Item,
                        Amount   = item.Amount,
                        GST      = item.GST,
                        Onbill   = item.Onbill,
                        ItemNote = item.ItemNote
                    };
                    modelInvoice.ContractorInvoiceItems.Add(modelItem);
                }
                model.ContractorInvoices.Add(modelInvoice);
            }

            //var invoice = new ContractorView.ContractorInvoice { InvoiceRef = "GB001" };
            //var invoice1 = new ContractorView.ContractorInvoice { InvoiceRef = "GB002" };
            //var invoice2 = new ContractorView.ContractorInvoice { InvoiceRef = "GB003" };
            //var invoice3 = new ContractorView.ContractorInvoice { InvoiceRef = "GB004" };
            //model.ContractorInvoices.Add(invoice);
            //model.ContractorInvoices.Add(invoice1);
            //model.ContractorInvoices.Add(invoice2);
            //model.ContractorInvoices.Add(invoice3);
            return(model);
        }
示例#3
0
        public static ContractorView ConvertToContractorView(this Contractor contractor)
        {
            ContractorView tempView = new ContractorView();
            tempView.Id = contractor.Id;
            tempView.Name = contractor.Name;
            tempView.Description = contractor.Description;
            tempView.ResponsibleHead = contractor.ResponsibleHead;
            tempView.Address = contractor.Address;
            tempView.PhoneNumber1 = contractor.PhoneNumber1;
            tempView.PhoneNumber2 = contractor.PhoneNumber2;
            tempView.MailAddress = contractor.MailAddress;
            tempView.BankAccountNumber = contractor.BankAccountNumber;
            tempView.InvoiceName = contractor.InvoiceName;
            tempView.MailAddress = contractor.MailAddress;
            tempView.TaxOffice = contractor.TaxOffice;
            tempView.TaxNumber = contractor.TaxNumber;
            tempView.ContractorStatusId = contractor.ContractorStatus.Id;

            return tempView;
        }
        public IActionResult Index(int id)
        {
            ContractorView model = _contractorService.GetContractor(id);

            return(View(model));
        }
示例#5
0
        private void Fill()
        {
            ContractorsLogic contractors = new ContractorsLogic(manager);
            DataGV.AutoGenerateColumns = false;
            List<Contractor> resultA = contractors.GetAll();
            List<ContractorView> contractorsView = new List<ContractorView>();
            foreach (Contractor a in resultA)
            {
                ContractorView c = new ContractorView(a,manager);
                contractorsView.Add(c);
            }
            view = new SortableBindingList<ContractorView>(contractorsView);
            DataGV.DataSource = view;
            DataGV.AutoResizeRows();
            DataGV.Update();

            PersonCB.SelectedIndex = 0;
            ContractorTypesDDL.Items.Clear();
            ContractorTypesLogic types = new ContractorTypesLogic(manager);
            ContractorTypesDDL.DisplayMember = "Name";
            ContractorTypesDDL.ValueMember = "ID";
            ContractorType all = new ContractorType();
            all.ID = -1;
            all.Name = " - всі - ";
            ContractorTypesDDL.Items.Add(all);
            foreach (var a in types.GetAll())
            {
                ContractorTypesDDL.Items.Add(a);
            }
            ContractorTypesDDL.SelectedIndex = 0;
        }