Пример #1
0
        public ContractForm()
        {
            _contractService     = DiConfig.Resolve <IContractService>();
            _categoryService     = DiConfig.Resolve <ICategoryService>();
            _workPaymentService  = DiConfig.Resolve <IContractWorkPaymentService>();
            _paymentService      = DiConfig.Resolve <IPaymentService>();
            _nakladnoyService    = DiConfig.Resolve <INakladnoyService>();
            _actInvoiceService   = DiConfig.Resolve <IActInvoiceService>();
            _organizationService = DiConfig.Resolve <IOrganizationService>();

            ContractModel = new ContractUIViewModel();

            InitializeComponent();

            ContractModel.Validate();

            Grid1.DataContext = ContractModel;
        }
Пример #2
0
        public ContractForm(int id)
        {
            _contractService     = DiConfig.Resolve <IContractService>();
            _workPaymentService  = DiConfig.Resolve <IContractWorkPaymentService>();
            _paymentService      = DiConfig.Resolve <IPaymentService>();
            _nakladnoyService    = DiConfig.Resolve <INakladnoyService>();
            _actInvoiceService   = DiConfig.Resolve <IActInvoiceService>();
            _organizationService = DiConfig.Resolve <IOrganizationService>();

            var model        = _contractService.GetById(id);
            var organization = _organizationService.GetById(model.OrganizationId ?? 0);
            var workTypes    = _workPaymentService.GetAll(a => a.ContractId == model.Id);

            ContractModel = new ContractUIViewModel {
                Id             = id,
                BranchId       = model.BranchId,
                CategoryId     = model.CategoryId,
                ContractAmount = model.ContractAmount,
                ContractDate   = model.ContractDate,
                ContractNumber = model.ContractNumber,
                HasActInvoice  = model.ActInvoices.Count > 0,
                HasNakladnoy   = model.Nakladnoys.Count > 0,
                IsTreaguare    = model.IsTriguare,
                ObjectName     = model.ObjectName,
                Organization   = new OrganizationUIViewModel {
                    Id            = organization.Id,
                    AccountNumber = organization.AccountNumber,
                    Okohx         = organization.Okohx,
                    Name          = organization.Name,
                    Inn           = organization.Inn,
                    BankName1     = organization.BankName1,
                    Mfo1          = organization.Mfo1,
                    BankName2     = organization.BankName2,
                    Mfo2          = organization.Mfo2,
                    BankName3     = organization.BankName3,
                    Mfo3          = organization.Mfo3,
                    PhoneNumbers  = organization.PhoneNumbers,
                    Position      = organization.Position,
                    Chief         = organization.Chief,
                    KS            = organization.KS,
                    LS            = organization.LS,
                    Foundation    = organization.Foundation,
                    Postcode      = organization.Postcode,
                    TypeOwnership = organization.TypeOwnership,
                    LegalAddress  = organization.LegalAddress
                },
                WorkTypeId1 = workTypes[0].WorkTypeId,
                Amount1     = workTypes[0].Amount,
                PeriodId1   = workTypes[0].PeriodId,

                WorkTypeId2 = workTypes[1].WorkTypeId,
                Amount2     = workTypes[1].Amount,
                PeriodId2   = workTypes[1].PeriodId,

                WorkTypeId3 = workTypes[2].WorkTypeId,
                Amount3     = workTypes[2].Amount,
                PeriodId3   = workTypes[2].PeriodId,

                WorkTypeId4 = workTypes[3].WorkTypeId,
                Amount4     = workTypes[3].Amount,
                PeriodId4   = workTypes[3].PeriodId,

                WorkTypeId5 = workTypes[4].WorkTypeId,
                Amount5     = workTypes[4].Amount,
                PeriodId5   = workTypes[4].PeriodId
            };

            InitializeComponent();

            ContractModel.Validate();

            Grid1.DataContext           = ContractModel;
            ContractTreaguare.IsEnabled = false;
        }