Esempio n. 1
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.IncomingInvoiceEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.IncomingInvoiceEdit, Entity.Warehouse);

            entryInvoiceNumber.IsEditable = entryWaybillNumber.IsEditable = ytextviewComment.Editable
                                                                                = referenceContractor.IsEditable = referenceWarehouse.IsEditable = editing;
            incominginvoiceitemsview1.Sensitive = editing;

            entryInvoiceNumber.Binding.AddBinding(Entity, e => e.InvoiceNumber, w => w.Text).InitializeFromSource();
            entryWaybillNumber.Binding.AddBinding(Entity, e => e.WaybillNumber, w => w.Text).InitializeFromSource();
            labelTimeStamp.Binding.AddBinding(Entity, e => e.DateString, w => w.LabelProp).InitializeFromSource();

            referenceWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.IncomingInvoiceEdit);
            referenceWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();

            referenceContractor.RepresentationModel = new CounterpartyVM(new CounterpartyFilter(UoW));
            referenceContractor.Binding.AddBinding(Entity, e => e.Contractor, w => w.Subject).InitializeFromSource();

            incominginvoiceitemsview1.DocumentUoW = UoWGeneric;
            ytextviewComment.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
        }
Esempio n. 2
0
        protected override void ConfigureWithUow()
        {
            enumcomboDocumentType.ItemsEnum   = typeof(DocumentType);
            enumcomboDocumentType.HiddenItems = new[] { DocumentType.DeliveryDocument as object };

            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery();

            if (ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("user_have_access_only_to_warehouse_and_complaints") &&
                !ServicesConfig.CommonServices.UserService.GetCurrentUser(UoW).IsAdmin)
            {
                yentryrefWarehouse.Sensitive = yentryrefWarehouse.CanEditReference = false;
            }

            if (CurrentUserSettings.Settings.DefaultWarehouse != null)
            {
                yentryrefWarehouse.Subject = UoW.GetById <Warehouse>(CurrentUserSettings.Settings.DefaultWarehouse.Id);
            }

            var filter = new EmployeeRepresentationFilterViewModel();

            filter.SetAndRefilterAtOnce(
                x => x.RestrictCategory = EmployeeCategory.driver,
                x => x.Status           = EmployeeStatus.IsWorking
                );
            yentryrefDriver.RepresentationModel = new EmployeesVM(filter);
            dateperiodDocs.StartDate            = DateTime.Today.AddDays(-7);
            dateperiodDocs.EndDate = DateTime.Today.AddDays(1);

            comboMovementStatus.ItemsEnum = typeof(MovementDocumentStatus);
        }
Esempio n. 3
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.IncomingWaterEdit, Entity.IncomingWarehouse, Entity.WriteOffWarehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.IncomingWaterEdit, Entity.IncomingWarehouse, Entity.WriteOffWarehouse);

            buttonFill.Sensitive = referenceProduct.IsEditable = spinAmount.Sensitive
                                                                     = referenceSrcWarehouse.IsEditable = referenceDstWarehouse.IsEditable = editing;
            incomingwatermaterialview1.Sensitive = editing;

            labelTimeStamp.Binding.AddBinding(Entity, e => e.DateString, w => w.LabelProp).InitializeFromSource();
            spinAmount.Binding.AddBinding(Entity, e => e.Amount, w => w.ValueAsInt).InitializeFromSource();

            referenceProduct.SubjectType = typeof(Nomenclature);
            referenceProduct.Binding.AddBinding(Entity, e => e.Product, w => w.Subject).InitializeFromSource();
            referenceSrcWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.IncomingWaterEdit);
            referenceSrcWarehouse.Binding.AddBinding(Entity, e => e.WriteOffWarehouse, w => w.Subject).InitializeFromSource();
            referenceDstWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.IncomingWaterEdit);
            referenceDstWarehouse.Binding.AddBinding(Entity, e => e.IncomingWarehouse, w => w.Subject).InitializeFromSource();

            incomingwatermaterialview1.DocumentUoW = UoWGeneric;
        }
Esempio n. 4
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.MovementEdit, Entity.FromWarehouse, Entity.ToWarehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.MovementEdit, Entity.FromWarehouse, Entity.ToWarehouse);

            enumMovementType.Sensitive = referenceEmployee.IsEditable = referenceWarehouseTo.Sensitive
                                                                            = yentryrefWagon.IsEditable = textComment.Sensitive = editing;
            movementdocumentitemsview1.Sensitive = editing;

            textComment.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
            labelTimeStamp.Binding.AddBinding(Entity, e => e.DateString, w => w.LabelProp).InitializeFromSource();

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

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

            referenceWarehouseTo.ItemsQuery = StoreDocumentHelper.GetWarehouseQuery();
            referenceWarehouseTo.Binding.AddBinding(Entity, e => e.ToWarehouse, w => w.Subject).InitializeFromSource();
            referenceWarehouseFrom.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.MovementEdit);
            referenceWarehouseFrom.Binding.AddBinding(Entity, e => e.FromWarehouse, w => w.Subject).InitializeFromSource();
            referenceWarehouseFrom.IsEditable         = StoreDocumentHelper.CanEditDocument(WarehousePermissions.MovementEdit, Entity.FromWarehouse);
            referenceDeliveryPointTo.CanEditReference = false;
            referenceDeliveryPointTo.SubjectType      = typeof(DeliveryPoint);
            referenceDeliveryPointTo.Binding.AddBinding(Entity, e => e.ToDeliveryPoint, w => w.Subject).InitializeFromSource();
            referenceDeliveryPointFrom.CanEditReference = false;
            referenceDeliveryPointFrom.SubjectType      = typeof(DeliveryPoint);
            referenceDeliveryPointFrom.Binding.AddBinding(Entity, e => e.FromDeliveryPoint, w => w.Subject).InitializeFromSource();
            var filterEmployee = new EmployeeFilter(UoW);

            referenceEmployee.RepresentationModel = new EmployeesVM(filterEmployee);
            referenceEmployee.Binding.AddBinding(Entity, e => e.ResponsiblePerson, w => w.Subject).InitializeFromSource();

            yentryrefWagon.SubjectType = typeof(MovementWagon);
            yentryrefWagon.Binding.AddBinding(Entity, e => e.MovementWagon, w => w.Subject).InitializeFromSource();

            ylabelTransportationStatus.Binding.AddBinding(Entity, e => e.TransportationDescription, w => w.LabelProp).InitializeFromSource();

            MovementDocumentCategory[] filteredDoctypeList = { MovementDocumentCategory.counterparty };
            object[] MovementDocumentList = Array.ConvertAll(filteredDoctypeList, x => (object)x);
            enumMovementType.ItemsEnum = typeof(MovementDocumentCategory);
            enumMovementType.AddEnumToHideList(MovementDocumentList);
            enumMovementType.Binding.AddBinding(Entity, e => e.Category, w => w.SelectedItem).InitializeFromSource();
            if (Entity.Id == 0)
            {
                Entity.Category = MovementDocumentCategory.Transportation;
            }

            buttonDelivered.Sensitive = Entity.TransportationStatus == TransportationStatus.Submerged &&
                                        CurrentPermissions.Warehouse[WarehousePermissions.MovementEdit, Entity.ToWarehouse];

            movementdocumentitemsview1.DocumentUoW = UoWGeneric;
        }
Esempio n. 5
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.SelfDeliveryEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.SelfDeliveryEdit, Entity.Warehouse);

            yentryrefOrder.IsEditable = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = editing;
            selfdeliverydocumentitemsview1.Sensitive = vBoxBottles.Sensitive = editing;

            ylabelDate.Binding.AddFuncBinding(Entity, e => e.TimeStamp.ToString("g"), w => w.LabelProp).InitializeFromSource();
            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.SelfDeliveryEdit);
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();
            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
            var filter = new OrdersFilter(UoW);

            filter.SetAndRefilterAtOnce(
                x => x.RestrictSelfDelivery = true,
                x => x.RestrictStatus       = OrderStatus.Accepted
                );
            yentryrefOrder.RepresentationModel = new ViewModel.OrdersVM(filter);
            yentryrefOrder.Binding.AddBinding(Entity, e => e.Order, w => w.Subject).InitializeFromSource();
            yentryrefOrder.CanEditReference = QSMain.User.Permissions["can_delete"];

            UpdateOrderInfo();
            Entity.UpdateStockAmount(UoW);
            Entity.UpdateAlreadyUnloaded(UoW);
            selfdeliverydocumentitemsview1.DocumentUoW = UoWGeneric;
            //bottlereceptionview1.UoW = UoW;
            UpdateWidgets();

            IColumnsConfig bottlesColumnsConfig = FluentColumnsConfig <GoodsReceptionVMNode> .Create()
                                                  .AddColumn("Номенклатура").AddTextRenderer(node => node.Name)
                                                  .AddColumn("Кол-во").AddNumericRenderer(node => node.Amount).WidthChars(3)
                                                  .Adjustment(new Gtk.Adjustment(0, 0, 9999, 1, 100, 0))
                                                  .Editing(true)
                                                  .AddColumn("")
                                                  .Finish();

            yTreeBottles.ColumnsConfig = bottlesColumnsConfig;
            FillTrees();

            IColumnsConfig goodsColumnsConfig = FluentColumnsConfig <GoodsReceptionVMNode> .Create()
                                                .AddColumn("Номенклатура").AddTextRenderer(node => node.Name)
                                                .AddColumn("Кол-во").AddNumericRenderer(node => node.Amount)
                                                .Adjustment(new Gtk.Adjustment(0, 0, 9999, 1, 100, 0))
                                                .Editing(true)
                                                .AddColumn("Категория").AddTextRenderer(node => node.Category.GetEnumTitle())
                                                .AddColumn("")
                                                .Finish();

            yTreeOtherGoods.ColumnsConfig   = goodsColumnsConfig;
            yTreeOtherGoods.ItemsDataSource = GoodsReceptionList;
        }
        void ConfigureDlg()
        {
            var editing   = !UoW.IsNew && StoreDocumentHelper.CanEditDocument(WarehousePermissions.ShiftChangeEdit, Entity.Warehouse);
            var canCreate = UoW.IsNew && !StoreDocumentHelper.CheckCreateDocument(WarehousePermissions.ShiftChangeCreate, Entity.Warehouse);

            if (!canCreate && UoW.IsNew)
            {
                FailInitialize = true;
                return;
            }

            if (!editing && !UoW.IsNew)
            {
                MessageDialogWorks.RunWarningDialog("У вас нет прав на изменение этого документа.");
            }

            ydatepickerDocDate.Sensitive = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = editing || canCreate;
            shiftchangewarehousedocumentitemsview1.Sensitive = editing || canCreate;
            ydatepickerDocDate.Binding.AddBinding(Entity, e => e.TimeStamp, w => w.Date).InitializeFromSource();
            if (UoW.IsNew)
            {
                yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.ShiftChangeCreate);
            }
            if (!UoW.IsNew)
            {
                yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.ShiftChangeEdit);
            }
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();

            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            string errorMessage       = "Не установлены единицы измерения у следующих номенклатур :" + Environment.NewLine;
            int    wrongNomenclatures = 0;

            foreach (var item in UoWGeneric.Root.Items)
            {
                if (item.Nomenclature.Unit == null)
                {
                    errorMessage += string.Format("Номер: {0}. Название: {1}{2}",
                                                  item.Nomenclature.Id, item.Nomenclature.Name, Environment.NewLine);
                    wrongNomenclatures++;
                }
            }
            if (wrongNomenclatures > 0)
            {
                MessageDialogWorks.RunErrorDialog(errorMessage);
                FailInitialize = true;
                return;
            }

            shiftchangewarehousedocumentitemsview1.DocumentUoW = UoWGeneric;
        }
Esempio n. 7
0
        public StockMovements()
        {
            this.Build();
            UoW = UnitOfWorkFactory.CreateWithoutRoot();
            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery();
            filter = new SelectableParametersReportFilter(UoW);

            if (CurrentUserSettings.Settings.DefaultWarehouse != null)
            {
                yentryrefWarehouse.Subject = CurrentUserSettings.Settings.DefaultWarehouse;
            }

            if (ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("user_have_access_only_to_warehouse_and_complaints") &&
                !ServicesConfig.CommonServices.UserService.GetCurrentUser(UoW).IsAdmin)
            {
                yentryrefWarehouse.Sensitive = false;
            }

            ConfigureDlg();
        }
Esempio n. 8
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.WriteoffEdit, Entity.WriteoffWarehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.WriteoffEdit, Entity.WriteoffWarehouse);

            referenceEmployee.IsEditable         = referenceWarehouse.IsEditable = textComment.Editable = editing;
            writeoffdocumentitemsview1.Sensitive = editing;

            textComment.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
            labelTimeStamp.Binding.AddBinding(Entity, e => e.DateString, w => w.LabelProp).InitializeFromSource();

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

            referenceWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.WriteoffEdit);
            referenceWarehouse.Binding.AddBinding(Entity, e => e.WriteoffWarehouse, w => w.Subject).InitializeFromSource();
            referenceDeliveryPoint.SubjectType      = typeof(DeliveryPoint);
            referenceDeliveryPoint.CanEditReference = false;
            referenceDeliveryPoint.Binding.AddBinding(Entity, e => e.DeliveryPoint, w => w.Subject).InitializeFromSource();
            referenceEmployee.RepresentationModel = new EmployeesVM(new EmployeeFilter(UoW));
            referenceEmployee.Binding.AddBinding(Entity, e => e.ResponsibleEmployee, w => w.Subject).InitializeFromSource();
            comboType.ItemsEnum = typeof(WriteoffType);
            referenceDeliveryPoint.Sensitive = referenceCounterparty.Sensitive = (UoWGeneric.Root.Client != null);
            comboType.EnumItemSelected      += (object sender, Gamma.Widgets.ItemSelectedEventArgs e) => {
                referenceWarehouse.Sensitive     = WriteoffType.warehouse.Equals(comboType.SelectedItem);
                referenceDeliveryPoint.Sensitive = WriteoffType.counterparty.Equals(comboType.SelectedItem) && UoWGeneric.Root.Client != null;
                referenceCounterparty.Sensitive  = WriteoffType.counterparty.Equals(comboType.SelectedItem);
            };
            //FIXME Списание с контрагента не реализовано. Поэтому блокирует выбор типа списания.
            comboType.Sensitive    = false;
            comboType.SelectedItem = UoWGeneric.Root.Client != null ?
                                     WriteoffType.counterparty :
                                     WriteoffType.warehouse;

            writeoffdocumentitemsview1.DocumentUoW = UoWGeneric;
        }
Esempio n. 9
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.InventoryEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.InventoryEdit, Entity.Warehouse);

            ydatepickerDocDate.Sensitive = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = editing;
            inventoryitemsview.Sensitive = editing;

            ydatepickerDocDate.Binding.AddBinding(Entity, e => e.TimeStamp, w => w.Date).InitializeFromSource();
            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.InventoryEdit);
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();

            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            string errorMessage       = "Не установлены единицы измерения у следующих номенклатур :" + Environment.NewLine;
            int    wrongNomenclatures = 0;

            foreach (var item in UoWGeneric.Root.Items)
            {
                if (item.Nomenclature.Unit == null)
                {
                    errorMessage += string.Format("Номер: {0}. Название: {1}{2}",
                                                  item.Nomenclature.Id, item.Nomenclature.Name, Environment.NewLine);
                    wrongNomenclatures++;
                }
            }
            if (wrongNomenclatures > 0)
            {
                MessageDialogWorks.RunErrorDialog(errorMessage);
                FailInitialize = true;
                return;
            }

            inventoryitemsview.DocumentUoW = UoWGeneric;
        }
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.RegradingOfGoodsEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.RegradingOfGoodsEdit, Entity.Warehouse);

            yentryrefWarehouse.IsEditable       = ytextviewCommnet.Editable = editing;
            regradingofgoodsitemsview.Sensitive = editing;

            ylabelDate.Binding.AddFuncBinding(Entity, e => e.TimeStamp.ToString("g"), w => w.LabelProp).InitializeFromSource();
            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.RegradingOfGoodsEdit);
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();
            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            regradingofgoodsitemsview.DocumentUoW = UoWGeneric;
            if (Entity.Items.Count > 0)
            {
                yentryrefWarehouse.Sensitive = false;
            }

            var permmissionValidator = new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance());

            Entity.CanEdit = permmissionValidator.Validate(typeof(RegradingOfGoodsDocument), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));
            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                ytextviewCommnet.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                yentryrefWarehouse.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                regradingofgoodsitemsview.Sensitive = false;

                buttonSave.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }
        }
Esempio n. 11
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.CarUnloadEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.CarUnloadEdit, Entity.Warehouse);

            yentryrefRouteList.IsEditable      = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = editing;
            returnsreceptionview1.Sensitive    =
                bottlereceptionview1.Sensitive =
                    nonserialequipmentreceptionview1.Sensitive =
                        defectiveitemsreceptionview1.Sensitive = editing;

            bottlereceptionview1.UoW             =
                defectiveitemsreceptionview1.UoW =
                    returnsreceptionview1.UoW    = UoW;

            ylabelDate.Binding.AddFuncBinding(Entity, e => e.TimeStamp.ToString("g"), w => w.LabelProp).InitializeFromSource();
            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.CarUnloadEdit);
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();
            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
            var filter = new RouteListsFilter(UoW);

            filter.SetAndRefilterAtOnce(x => x.RestrictStatus = RouteListStatus.EnRoute);
            yentryrefRouteList.RepresentationModel            = new ViewModel.RouteListsVM(filter);
            yentryrefRouteList.Binding.AddBinding(Entity, e => e.RouteList, w => w.Subject).InitializeFromSource();
            yentryrefRouteList.CanEditReference = QSMain.User.Permissions["can_delete"];

            defectiveitemsreceptionview1.Warehouse = returnsreceptionview1.Warehouse = Entity.Warehouse;

            UpdateWidgetsVisible();
            if (!UoW.IsNew)
            {
                LoadReception();
            }
        }
Esempio n. 12
0
        protected override void ConfigureWithUow()
        {
            enumcomboDocumentType.ItemsEnum   = typeof(DocumentType);
            enumcomboDocumentType.HiddenItems = new[] { DocumentType.DeliveryDocument as object };

            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery();
            if (CurrentUserSettings.Settings.DefaultWarehouse != null)
            {
                yentryrefWarehouse.Subject = UoW.GetById <Warehouse>(CurrentUserSettings.Settings.DefaultWarehouse.Id);
            }
            var filter = new EmployeeFilterViewModel();

            filter.SetAndRefilterAtOnce(
                x => x.RestrictCategory = EmployeeCategory.driver,
                x => x.Status           = EmployeeStatus.IsWorking
                );
            yentryrefDriver.RepresentationModel = new EmployeesVM(filter);
            dateperiodDocs.StartDate            = DateTime.Today.AddDays(-7);
            dateperiodDocs.EndDate = DateTime.Today.AddDays(1);

            comboMovementStatus.ItemsEnum = typeof(MovementDocumentStatus);
        }
Esempio n. 13
0
		void ConfigureDlg()
		{
			if(StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.IncomingWaterEdit, Entity.IncomingWarehouse, Entity.WriteOffWarehouse)) {
				FailInitialize = true;
				return;
			}

			var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.IncomingWaterEdit, Entity.IncomingWarehouse, Entity.WriteOffWarehouse);
			buttonFill.Sensitive = referenceProduct.IsEditable = spinAmount.Sensitive
				= referenceSrcWarehouse.IsEditable = referenceDstWarehouse.IsEditable = editing;
			incomingwatermaterialview1.Sensitive = editing;

			labelTimeStamp.Binding.AddBinding(Entity, e => e.DateString, w => w.LabelProp).InitializeFromSource();
			spinAmount.Binding.AddBinding(Entity, e => e.Amount, w => w.ValueAsInt).InitializeFromSource();

			referenceProduct.SubjectType = typeof(Nomenclature);
			referenceProduct.Binding.AddBinding(Entity, e => e.Product, w => w.Subject).InitializeFromSource();
			referenceSrcWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.IncomingWaterEdit);
			referenceSrcWarehouse.Binding.AddBinding(Entity, e => e.WriteOffWarehouse, w => w.Subject).InitializeFromSource();
			referenceDstWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.IncomingWaterEdit);
			referenceDstWarehouse.Binding.AddBinding(Entity, e => e.IncomingWarehouse, w => w.Subject).InitializeFromSource();

			incomingwatermaterialview1.DocumentUoW = UoWGeneric;

			var permmissionValidator = new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance());
			Entity.CanEdit = permmissionValidator.Validate(typeof(IncomingWater), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));
			if(!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date) {
				spinAmount.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
				referenceProduct.Sensitive = false;
				referenceDstWarehouse.Sensitive = false;
				referenceSrcWarehouse.Sensitive = false;
				buttonFill.Sensitive = false;
				incomingwatermaterialview1.Sensitive = false;
				buttonSave.Sensitive = false;
			} else {
				Entity.CanEdit = true;
			}
		}
Esempio n. 14
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.RegradingOfGoodsEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.RegradingOfGoodsEdit, Entity.Warehouse);

            yentryrefWarehouse.IsEditable       = ytextviewCommnet.Editable = editing;
            regradingofgoodsitemsview.Sensitive = editing;

            ylabelDate.Binding.AddFuncBinding(Entity, e => e.TimeStamp.ToString("g"), w => w.LabelProp).InitializeFromSource();
            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.RegradingOfGoodsEdit);
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();
            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            regradingofgoodsitemsview.DocumentUoW = UoWGeneric;
            if (Entity.Items.Count > 0)
            {
                yentryrefWarehouse.Sensitive = false;
            }
        }
Esempio n. 15
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.CarLoadEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.CarLoadEdit, Entity.Warehouse);
            yentryrefRouteList.IsEditable  = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = editing;
            carloaddocumentview1.Sensitive = editing;

            ylabelDate.Binding.AddFuncBinding(Entity, e => e.TimeStamp.ToString("g"), w => w.LabelProp).InitializeFromSource();
            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.CarLoadEdit);
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();
            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
            var filter = new RouteListsFilter(UoW);

            filter.SetAndRefilterAtOnce(x => x.RestrictStatus = RouteListStatus.InLoading);
            yentryrefRouteList.RepresentationModel            = new ViewModel.RouteListsVM(filter);
            yentryrefRouteList.Binding.AddBinding(Entity, e => e.RouteList, w => w.Subject).InitializeFromSource();
            yentryrefRouteList.CanEditReference = QSMain.User.Permissions["can_delete"];

            enumPrint.ItemsEnum = typeof(CarLoadPrintableDocuments);

            UpdateRouteListInfo();
            Entity.UpdateStockAmount(UoW);
            Entity.UpdateAlreadyLoaded(UoW);
            Entity.UpdateInRouteListAmount(UoW);
            carloaddocumentview1.DocumentUoW = UoWGeneric;
            carloaddocumentview1.SetButtonEditing(editing);
            if (UoW.IsNew && Entity.Warehouse != null)
            {
                carloaddocumentview1.FillItemsByWarehouse();
            }
        }
Esempio n. 16
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.IncomingWaterEdit, Entity.IncomingWarehouse, Entity.WriteOffWarehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.IncomingWaterEdit, Entity.IncomingWarehouse, Entity.WriteOffWarehouse);

            buttonFill.Sensitive = yentryProduct.IsEditable = spinAmount.Sensitive
                                                                  = referenceSrcWarehouse.IsEditable = referenceDstWarehouse.IsEditable = editing;
            incomingwatermaterialview1.Sensitive = editing;

            labelTimeStamp.Binding.AddBinding(Entity, e => e.DateString, w => w.LabelProp).InitializeFromSource();
            spinAmount.Binding.AddBinding(Entity, e => e.Amount, w => w.ValueAsInt).InitializeFromSource();

            referenceSrcWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.IncomingWaterEdit);
            referenceSrcWarehouse.Binding.AddBinding(Entity, e => e.WriteOffWarehouse, w => w.Subject).InitializeFromSource();
            referenceDstWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.IncomingWaterEdit);
            referenceDstWarehouse.Binding.AddBinding(Entity, e => e.IncomingWarehouse, w => w.Subject).InitializeFromSource();

            incomingwatermaterialview1.DocumentUoW = UoWGeneric;

            var permmissionValidator = new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance());

            Entity.CanEdit = permmissionValidator.Validate(typeof(IncomingWater), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));
            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                spinAmount.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                yentryProduct.Sensitive              = false;
                referenceDstWarehouse.Sensitive      = false;
                referenceSrcWarehouse.Sensitive      = false;
                buttonFill.Sensitive                 = false;
                incomingwatermaterialview1.Sensitive = false;
                buttonSave.Sensitive                 = false;
            }
            else
            {
                Entity.CanEdit = true;
            }

            var nomenclatureFilter = new NomenclatureFilterViewModel()
            {
                HidenByDefault = true
            };
            var nomenclatureRepository = new EntityRepositories.Goods.NomenclatureRepository(new NomenclatureParametersProvider());

            var counterpartySelectorFactory =
                new DefaultEntityAutocompleteSelectorFactory <Counterparty, CounterpartyJournalViewModel, CounterpartyJournalFilterViewModel>(
                    ServicesConfig.CommonServices);

            var nomenclatureAutoCompleteSelectorFactory =
                new NomenclatureAutoCompleteSelectorFactory <Nomenclature, NomenclaturesJournalViewModel>(
                    ServicesConfig.CommonServices,
                    nomenclatureFilter,
                    counterpartySelectorFactory,
                    nomenclatureRepository,
                    UserSingletonRepository.GetInstance()
                    );

            yentryProduct.SetEntityAutocompleteSelectorFactory(nomenclatureAutoCompleteSelectorFactory);
            yentryProduct.Binding.AddBinding(Entity, e => e.Product, w => w.Subject).InitializeFromSource();
        }
Esempio n. 17
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.InventoryEdit, Entity.Warehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.InventoryEdit, Entity.Warehouse);

            ydatepickerDocDate.Sensitive = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = editing;

            ytreeviewItems.Sensitive                   =
                buttonAdd.Sensitive                    =
                    buttonFillItems.Sensitive          =
                        buttonFine.Sensitive           =
                            buttonDeleteFine.Sensitive = editing;

            ydatepickerDocDate.Binding.AddBinding(Entity, e => e.TimeStamp, w => w.Date).InitializeFromSource();
            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.InventoryEdit);
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();

            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            string errorMessage       = "Не установлены единицы измерения у следующих номенклатур :" + Environment.NewLine;
            int    wrongNomenclatures = 0;

            foreach (var item in UoWGeneric.Root.Items)
            {
                if (item.Nomenclature.Unit == null)
                {
                    errorMessage += string.Format("Номер: {0}. Название: {1}{2}",
                                                  item.Nomenclature.Id, item.Nomenclature.Name, Environment.NewLine);
                    wrongNomenclatures++;
                }
            }
            if (wrongNomenclatures > 0)
            {
                MessageDialogHelper.RunErrorDialog(errorMessage);
                FailInitialize = true;
                return;
            }

            var permmissionValidator =
                new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), _employeeRepository);

            Entity.CanEdit =
                permmissionValidator.Validate(
                    typeof(InventoryDocument), ServicesConfig.UserService.CurrentUserId, nameof(RetroactivelyClosePermission));

            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                ydatepickerDocDate.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                yentryrefWarehouse.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                ytextviewCommnet.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                buttonSave.Sensitive                       = false;
                ytreeviewItems.Sensitive                   =
                    buttonAdd.Sensitive                    =
                        buttonFillItems.Sensitive          =
                            buttonFine.Sensitive           =
                                buttonDeleteFine.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }

            filter = new SelectableParametersReportFilter(UoW);

            var nomenclatureParam = filter.CreateParameterSet(
                "Номенклатуры",
                "nomenclature",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Nomenclature> resultAlias = null;
                var query = UoW.Session.QueryOver <Nomenclature>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var filterCriterion = f();
                        if (filterCriterion != null)
                        {
                            query.Where(filterCriterion);
                        }
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.OfficialName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Nomenclature> >());
                return(query.List <SelectableParameter>());
            })
                );

            var nomenclatureTypeParam = filter.CreateParameterSet(
                "Типы номенклатур",
                "nomenclature_type",
                new ParametersEnumFactory <NomenclatureCategory>()
                );

            nomenclatureParam.AddFilterOnSourceSelectionChanged(nomenclatureTypeParam,
                                                                () => {
                var selectedValues = nomenclatureTypeParam.GetSelectedValues();
                if (!selectedValues.Any())
                {
                    return(null);
                }
                return(Restrictions.On <Nomenclature>(x => x.Category).IsIn(nomenclatureTypeParam.GetSelectedValues().ToArray()));
            }
                                                                );

            //Предзагрузка. Для избежания ленивой загрузки
            UoW.Session.QueryOver <ProductGroup>().Fetch(SelectMode.Fetch, x => x.Childs).List();

            filter.CreateParameterSet(
                "Группы товаров",
                "product_group",
                new RecursiveParametersFactory <ProductGroup>(UoW,
                                                              (filters) => {
                var query = UoW.Session.QueryOver <ProductGroup>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }
                return(query.List());
            },
                                                              x => x.Name,
                                                              x => x.Childs)
                );

            var filterViewModel = new SelectableParameterReportFilterViewModel(filter);
            var filterWidget    = new SelectableParameterReportFilterView(filterViewModel);

            vboxParameters.Add(filterWidget);
            filterWidget.Show();

            ConfigNomenclatureColumns();
        }
Esempio n. 18
0
        void ConfigureDlg()
        {
            canEdit = !UoW.IsNew && StoreDocumentHelper.CanEditDocument(WarehousePermissions.ShiftChangeEdit, Entity.Warehouse);

            if (Entity.Id != 0 && Entity.TimeStamp < DateTime.Today)
            {
                var permissionValidator = new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance());
                canEdit &= permissionValidator.Validate(typeof(ShiftChangeWarehouseDocument), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission));
            }

            canCreate = UoW.IsNew && !StoreDocumentHelper.CheckCreateDocument(WarehousePermissions.ShiftChangeCreate, Entity.Warehouse);

            if (!canCreate && UoW.IsNew)
            {
                FailInitialize = true;
                return;
            }

            if (!canEdit && !UoW.IsNew)
            {
                MessageDialogHelper.RunWarningDialog("У вас нет прав на изменение этого документа.");
            }

            ydatepickerDocDate.Sensitive = yentryrefWarehouse.IsEditable = ytextviewCommnet.Editable = canEdit || canCreate;

            ytreeviewNomenclatures.Sensitive =
                buttonFillItems.Sensitive    =
                    buttonAdd.Sensitive      = canEdit || canCreate;

            ytreeviewNomenclatures.ItemsDataSource = Entity.ObservableItems;
            ytreeviewNomenclatures.YTreeModel?.EmitModelChanged();

            ydatepickerDocDate.Binding.AddBinding(Entity, e => e.TimeStamp, w => w.Date).InitializeFromSource();
            if (UoW.IsNew)
            {
                yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.ShiftChangeCreate);
            }
            if (!UoW.IsNew)
            {
                yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery(WarehousePermissions.ShiftChangeEdit);
            }
            yentryrefWarehouse.Binding.AddBinding(Entity, e => e.Warehouse, w => w.Subject).InitializeFromSource();
            yentryrefWarehouse.Changed += OnWarehouseChanged;

            ytextviewCommnet.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            string errorMessage       = "Не установлены единицы измерения у следующих номенклатур :" + Environment.NewLine;
            int    wrongNomenclatures = 0;

            foreach (var item in Entity.Items)
            {
                if (item.Nomenclature.Unit == null)
                {
                    errorMessage += string.Format("Номер: {0}. Название: {1}{2}",
                                                  item.Nomenclature.Id, item.Nomenclature.Name, Environment.NewLine);
                    wrongNomenclatures++;
                }
            }
            if (wrongNomenclatures > 0)
            {
                MessageDialogHelper.RunErrorDialog(errorMessage);
                FailInitialize = true;
                return;
            }

            filter = new SelectableParametersReportFilter(UoW);

            var nomenclatureParam = filter.CreateParameterSet(
                "Номенклатуры",
                "nomenclature",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Nomenclature> resultAlias = null;
                var query = UoW.Session.QueryOver <Nomenclature>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var filterCriterion = f();
                        if (filterCriterion != null)
                        {
                            query.Where(filterCriterion);
                        }
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.OfficialName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Nomenclature> >());
                return(query.List <SelectableParameter>());
            })
                );

            var nomenclatureTypeParam = filter.CreateParameterSet(
                "Типы номенклатур",
                "nomenclature_type",
                new ParametersEnumFactory <NomenclatureCategory>()
                );

            nomenclatureParam.AddFilterOnSourceSelectionChanged(nomenclatureTypeParam,
                                                                () => {
                var selectedValues = nomenclatureTypeParam.GetSelectedValues();
                if (!selectedValues.Any())
                {
                    return(null);
                }
                return(Restrictions.On <Nomenclature>(x => x.Category).IsIn(nomenclatureTypeParam.GetSelectedValues().ToArray()));
            }
                                                                );

            //Предзагрузка. Для избежания ленивой загрузки
            UoW.Session.QueryOver <ProductGroup>().Fetch(SelectMode.Fetch, x => x.Childs).List();

            filter.CreateParameterSet(
                "Группы товаров",
                "product_group",
                new RecursiveParametersFactory <ProductGroup>(UoW,
                                                              (filters) => {
                var query = UoW.Session.QueryOver <ProductGroup>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }
                return(query.List());
            },
                                                              x => x.Name,
                                                              x => x.Childs)
                );

            var filterViewModel = new SelectableParameterReportFilterViewModel(filter);
            var filterWidget    = new SelectableParameterReportFilterView(filterViewModel);

            vboxParameters.Add(filterWidget);
            filterWidget.Show();

            ConfigureNomenclaturesView();
        }