Beispiel #1
0
        void ConfigureDlg()
        {
            enumStatus.Sensitive         = enumType.Sensitive = false;
            enumStatusEditable.Sensitive = true;
            notebook1.ShowTabs           = false;
            notebook1.CurrentPage        = 0;

            enumcomboWithSerial.ItemsEnum = typeof(ServiceClaimEquipmentSerialType);
            enumcomboWithSerial.Binding.AddBinding(Entity, e => e.WithSerial, w => w.SelectedItem).InitializeFromSource();
            enumStatus.ItemsEnum = typeof(ServiceClaimStatus);
            enumStatus.Binding.AddBinding(Entity, e => e.Status, w => w.SelectedItem).InitializeFromSource();
            enumType.ItemsEnum = typeof(ServiceClaimType);
            enumType.Binding.AddBinding(Entity, e => e.ServiceClaimType, w => w.SelectedItem).InitializeFromSource();
            enumPaymentType.ItemsEnum = typeof(PaymentType);
            enumPaymentType.Binding.AddBinding(Entity, e => e.Payment, w => w.SelectedItem).InitializeFromSource();

            checkRepeated.Binding.AddBinding(Entity, e => e.RepeatedService, w => w.Active).InitializeFromSource();
            dataNumber.Binding.AddBinding(Entity, e => e.Id, w => w.LabelProp, new IdToStringConverter()).InitializeFromSource();
            labelTotalPrice.Binding.AddFuncBinding(Entity, e => e.TotalPrice.ToString("C"), w => w.LabelProp).InitializeFromSource();
            datePickUpDate.Binding.AddBinding(Entity, e => e.ServiceStartDate, w => w.Date).InitializeFromSource();
            textReason.Binding.AddBinding(Entity, e => e.Reason, w => w.Buffer.Text).InitializeFromSource();
            textKit.Binding.AddBinding(Entity, e => e.Kit, w => w.Buffer.Text).InitializeFromSource();
            textDiagnosticsResult.Binding.AddBinding(Entity, e => e.DiagnosticsResult, w => w.Buffer.Text).InitializeFromSource();

            referenceCounterparty.RepresentationModel = new ViewModel.CounterpartyVM(new CounterpartyFilter(UoW));
            referenceCounterparty.Binding.AddBinding(Entity, e => e.Counterparty, w => w.Subject).InitializeFromSource();

            referenceEngineer.RepresentationModel = new EmployeesVM();
            referenceEngineer.Binding.AddBinding(Entity, e => e.Engineer, w => w.Subject).InitializeFromSource();

            yentryEquipmentReplacement.ItemsQuery = _equipmentRepository.AvailableOnDutyEquipmentQuery();
            yentryEquipmentReplacement.SetObjectDisplayFunc <Equipment> (e => e.Title);
            yentryEquipmentReplacement.Binding
            .AddBinding(UoWGeneric.Root, serviceClaim => serviceClaim.ReplacementEquipment, widget => widget.Subject)
            .InitializeFromSource();

            referenceDeliveryPoint.Sensitive = (UoWGeneric.Root.Counterparty != null);
            referenceDeliveryPoint.Binding.AddBinding(Entity, e => e.DeliveryPoint, w => w.Subject).InitializeFromSource();

            referenceNomenclature.ItemsQuery = _nomenclatureRepository.NomenclatureOfItemsForService();
            referenceNomenclature.Binding.AddBinding(Entity, e => e.Nomenclature, w => w.Subject).InitializeFromSource();

            referenceEquipment.SubjectType = typeof(Equipment);
            referenceEquipment.Sensitive   = (UoWGeneric.Root.Nomenclature != null);
            referenceEquipment.Binding.AddBinding(Entity, e => e.Equipment, w => w.Subject).InitializeFromSource();

            treePartsAndServices.ItemsDataSource = UoWGeneric.Root.ObservableServiceClaimItems;
            treeHistory.ItemsDataSource          = UoWGeneric.Root.ObservableServiceClaimHistory;

            treePartsAndServices.ColumnsConfig = FluentColumnsConfig <ServiceClaimItem> .Create()
                                                 .AddColumn("Номенклатура").SetDataProperty(node => node.Nomenclature != null ? node.Nomenclature.Name : "-")
                                                 .AddColumn("Кол-во").AddNumericRenderer(node => node.Count)
                                                 .Adjustment(new Adjustment(0, 0, 1000000, 1, 100, 0))
                                                 .AddSetter((c, node) => c.Digits = node.Nomenclature.Unit == null ? 0 : (uint)node.Nomenclature.Unit.Digits)
                                                 .AddSetter((c, i) => c.Editable  = isEditable)
                                                 .WidthChars(10)
                                                 .AddColumn("Цена").AddNumericRenderer(node => node.Price).Digits(2)
                                                 .AddTextRenderer(node => CurrencyWorks.CurrencyShortName, false)
                                                 .AddColumn("Сумма").AddNumericRenderer(node => node.Total).Digits(2)
                                                 .AddTextRenderer(node => CurrencyWorks.CurrencyShortName, false)
                                                 .Finish();

            treeHistory.ColumnsConfig = FluentColumnsConfig <ServiceClaimHistory> .Create()
                                        .AddColumn("Дата").SetDataProperty(node => node.Date.ToShortDateString())
                                        .AddColumn("Время").SetDataProperty(node => node.Date.ToString("HH:mm"))
                                        .AddColumn("Статус").SetDataProperty(node => node.Status.GetEnumTitle())
                                        .AddColumn("Сотрудник").SetDataProperty(node => node.Employee == null ? " - " : node.Employee.FullName)
                                        .AddColumn("Комментарий").SetDataProperty(node => node.Comment)
                                        .Finish();

            UoWGeneric.Root.ObservableServiceClaimItems.ElementChanged += (aList, aIdx) => FixPrice(aIdx [0]);
            configureAvailableNextStatus();
            Entity.PropertyChanged += Entity_PropertyChanged;

            if (UoWGeneric.Root.ServiceClaimType == ServiceClaimType.JustService)
            {
                referenceDeliveryPoint.Visible     = false;
                labelDeliveryPoint.Visible         = false;
                yentryEquipmentReplacement.Visible = false;
                labelReplacement.Visible           = false;
            }
            datePickUpDate.IsEditable = Entity.InitialOrder == null;
            Menu menu            = new Menu();
            var  menuItemInitial = new MenuItem("Перейти к начальному заказу");

            menuItemInitial.Sensitive  = Entity.InitialOrder != null;
            menuItemInitial.Activated += MenuInitialOrderActivated;
            menu.Add(menuItemInitial);
            var menuItemFinal = new MenuItem("Перейти к финальному заказу");

            menuItemFinal.Sensitive  = Entity.FinalOrder != null;
            menuItemFinal.Activated += MenuFinalOrderActivated;
            menu.Add(menuItemFinal);
            menuActions.Menu = menu;
            menu.ShowAll();
        }