public SelfDeliveryDocumentDlg() { this.Build(); UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <SelfDeliveryDocument>(); Entity.Author = EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW); if (Entity.Author == null) { MessageDialogHelper.RunErrorDialog("Ваш пользователь не привязан к действующему сотруднику, вы не можете создавать складские документы, так как некого указывать в качестве кладовщика."); FailInitialize = true; return; } Entity.Warehouse = StoreDocumentHelper.GetDefaultWarehouse(UoW, WarehousePermissions.SelfDeliveryEdit); var validationResult = CheckPermission(EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW)); if (!validationResult.CanRead) { MessageDialogHelper.RunErrorDialog("Нет прав для доступа к документу отпуска самовывоза"); FailInitialize = true; return; } if (!validationResult.CanCreate) { MessageDialogHelper.RunErrorDialog("Нет прав для создания документа отпуска самовывоза"); FailInitialize = true; return; } canEditDocument = true; ConfigureDlg(); }
public OrderWithoutShipmentForDebtViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory uowFactory, ICommonServices commonServices) : base(uowBuilder, uowFactory, commonServices) { bool canCreateBillsWithoutShipment = CommonServices.PermissionService.ValidateUserPresetPermission("can_create_bills_without_shipment", CurrentUser.Id); if (uowBuilder.IsNewEntity) { if (canCreateBillsWithoutShipment) { if (!AskQuestion("Вы действительно хотите создать счет без отгрузки на долг?")) { AbortOpening(); } else { Entity.Author = EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW); } } else { AbortOpening("У Вас нет прав на выставление счетов без отгрузки."); } } TabName = "Счет без отгрузки на долг"; EntityUoWBuilder = uowBuilder; SendDocViewModel = new SendDocumentByEmailViewModel(new EmailRepository(), EmployeeSingletonRepository.GetInstance(), commonServices.InteractiveService, UoW); }
public override bool Save() { if (!Entity.CanEdit) { return(false); } var valid = new QSValidator <WriteoffDocument> (UoWGeneric.Root); if (valid.RunDlgIfNotValid((Gtk.Window) this.Toplevel)) { return(false); } Entity.LastEditor = EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW); Entity.LastEditedTime = DateTime.Now; if (Entity.LastEditor == null) { MessageDialogHelper.RunErrorDialog("Ваш пользователь не привязан к действующему сотруднику, вы не можете изменять складские документы, так как некого указывать в качестве кладовщика."); return(false); } logger.Info("Сохраняем акт списания..."); UoWGeneric.Save(); logger.Info("Ok."); return(true); }
public CashIncomeDlg(IPermissionService permissionService) { this.Build(); UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <Income>(); Entity.Casher = EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW); if (Entity.Casher == null) { MessageDialogHelper.RunErrorDialog("Ваш пользователь не привязан к действующему сотруднику, вы не можете создавать кассовые документы, так как некого указывать в качестве кассира."); FailInitialize = true; return; } var userPermission = permissionService.ValidateUserPermission(typeof(Income), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id); canCreate = userPermission.CanCreate; if (!userPermission.CanCreate) { MessageDialogHelper.RunErrorDialog("Отсутствуют права на создание приходного ордера"); FailInitialize = true; return; } if (!accessfilteredsubdivisionselectorwidget.Configure(UoW, false, typeof(Income))) { MessageDialogHelper.RunErrorDialog(accessfilteredsubdivisionselectorwidget.ValidationErrorMessage); FailInitialize = true; return; } Entity.Date = DateTime.Now; ConfigureDlg(); }
private void OnButtonCopyScheduleSetClicked(object sender, EventArgs args) { var selectedScheduleSet = ytreeDriverScheduleSets.GetSelectedObject() as DriverWorkScheduleSet; if (selectedScheduleSet != null && selectedScheduleSet.Id == 0) { ServicesConfig.CommonServices.InteractiveService.ShowMessage(ImportanceLevel.Info, "Перед копированием новой версии необходимо сохранить сотрудника"); return; } if (selectedScheduleSet != null && ServicesConfig.CommonServices.InteractiveService.Question( $"Скопировать и активировать выбранную версию графиков работы водителя (Код: {selectedScheduleSet.Id})?" ) ) { var employeeForCurrentUser = EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW); var newScheduleSet = (DriverWorkScheduleSet)selectedScheduleSet.Clone(); newScheduleSet.Author = employeeForCurrentUser; newScheduleSet.LastEditor = employeeForCurrentUser; newScheduleSet.IsCreatedAutomatically = false; Entity.AddActiveDriverWorkScheduleSet(newScheduleSet); } }
public override bool Save() { var validationContext = new Dictionary <object, object> { { "IsSelfDelivery", true } }; var valid = new QSValidator <Expense>(UoWGeneric.Root, validationContext); if (valid.RunDlgIfNotValid((Gtk.Window) this.Toplevel)) { return(false); } Entity.AcceptSelfDeliveryPaid(CallTaskWorker); if (UoW.IsNew) { logger.Info("Создаем документ распределения налички по юр лицу..."); selfDeliveryCashOrganisationDistributor.DistributeExpenseCash(UoW, Entity.Order, Entity); } else { logger.Info("Меняем документ распределения налички по юр лицу..."); selfDeliveryCashOrganisationDistributor.UpdateRecords(UoW, Entity.Order, Entity, EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW)); } logger.Info("Сохраняем расходный ордер..."); UoWGeneric.Save(); logger.Info("Ok"); return(true); }
void ActionSelfdeliveryOrders_Activated(object sender, System.EventArgs e) { OrderJournalFilterViewModel filter = new OrderJournalFilterViewModel(); filter.SetAndRefilterAtOnce( x => x.AllowStatuses = new OrderStatus[] { OrderStatus.WaitForPayment, OrderStatus.OnLoading, OrderStatus.Accepted, OrderStatus.Closed }, x => x.RestrictOnlySelfDelivery = true, x => x.RestrictWithoutSelfDelivery = false, x => x.RestrictHideService = true, x => x.RestrictOnlyService = false, x => x.RestrictLessThreeHours = false ); filter.HidenByDefault = true; var selfDeliveriesJournal = new SelfDeliveriesJournalViewModel( filter, UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, new CallTaskWorker(CallTaskSingletonFactory.GetInstance(), new CallTaskRepository(), OrderSingletonRepository.GetInstance(), EmployeeSingletonRepository.GetInstance(), new BaseParametersProvider(), ServicesConfig.CommonServices.UserService, SingletonErrorReporter.Instance), new OrderPaymentSettings()); tdiMain.AddTab(selfDeliveriesJournal); }
public override bool Save () { if(!Entity.CanEdit) return false; if(CheckWarehouseItems() == false){ MessageDialogHelper.RunErrorDialog("На складе не хватает материалов"); return false; } var valid = new QSValidator<IncomingWater> (UoWGeneric.Root); if (valid.RunDlgIfNotValid ((Gtk.Window)this.Toplevel)) return false; Entity.LastEditor = EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser (UoW); Entity.LastEditedTime = DateTime.Now; if(Entity.LastEditor == null) { MessageDialogHelper.RunErrorDialog ("Ваш пользователь не привязан к действующему сотруднику, вы не можете изменять складские документы, так как некого указывать в качестве кладовщика."); return false; } logger.Info ("Сохраняем документ производства..."); UoWGeneric.Save (); logger.Info ("Ok."); return true; }
void ActionDistrictsActivated(object sender, System.EventArgs e) { var filter = new DistrictsSetJournalFilterViewModel { HidenByDefault = true }; tdiMain.OpenTab(() => new DistrictsSetJournalViewModel(filter, UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, EmployeeSingletonRepository.GetInstance(), new EntityDeleteWorker(), true, true)); }
private void OnButtonCopyDistrictPrioritySetClicked(object sender, EventArgs e) { if (!(ytreeDistrictPrioritySets.GetSelectedObject() is DriverDistrictPrioritySet selectedDistrictPrioritySet)) { return; } if (selectedDistrictPrioritySet.Id == 0) { ServicesConfig.CommonServices.InteractiveService.ShowMessage(ImportanceLevel.Info, "Перед копированием новой версии необходимо сохранить сотрудника"); return; } var newDistrictPrioritySet = DriverDistrictPriorityHelper.CopyPrioritySetWithActiveDistricts( selectedDistrictPrioritySet, out var notCopiedPriorities ); newDistrictPrioritySet.IsCreatedAutomatically = false; if (notCopiedPriorities.Any()) { var messageBuilder = new StringBuilder( "Для некоторых приоритетов районов\n" + $"из выбранной для копирования версии (Код: {selectedDistrictPrioritySet.Id})\n" + "не были найдены связанные районы из активной\n" + "версии районов. Список приоритетов районов,\n" + "которые не будут скопированы:\n" ); foreach (var driverDistrictPriority in notCopiedPriorities) { messageBuilder.AppendLine( $"Район: ({driverDistrictPriority.District.Id}) {driverDistrictPriority.District.DistrictName}. " + $"Приоритет: {driverDistrictPriority.Priority + 1}" ); } ServicesConfig.InteractiveService.ShowMessage(ImportanceLevel.Warning, messageBuilder.ToString()); } var driverDistrictPrioritySetViewModel = new DriverDistrictPrioritySetViewModel( newDistrictPrioritySet, UoW, UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, new BaseParametersProvider(), EmployeeSingletonRepository.GetInstance() ); driverDistrictPrioritySetViewModel.EntityAccepted += (o, eventArgs) => { Entity.AddActiveDriverDistrictPrioritySet(newDistrictPrioritySet); }; TabParent.AddSlaveTab(this, driverDistrictPrioritySetViewModel); }
public RegradingOfGoodsDocumentDlg() { this.Build(); UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <RegradingOfGoodsDocument> (); Entity.Author = EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW); if (Entity.Author == null) { MessageDialogHelper.RunErrorDialog("Ваш пользователь не привязан к действующему сотруднику, вы не можете создавать складские документы, так как некого указывать в качестве кладовщика."); FailInitialize = true; return; } Entity.Warehouse = StoreDocumentHelper.GetDefaultWarehouse(UoW, WarehousePermissions.RegradingOfGoodsEdit); ConfigureDlg(); }
public override bool Save() { if (!Entity.CanEdit) { return(false); } var valid = new QS.Validation.QSValidator <SelfDeliveryDocument>(UoWGeneric.Root); if (valid.RunDlgIfNotValid((Gtk.Window) this.Toplevel)) { return(false); } Entity.LastEditor = EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW); Entity.LastEditedTime = DateTime.Now; if (Entity.LastEditor == null) { MessageDialogHelper.RunErrorDialog("Ваш пользователь не привязан к действующему сотруднику, вы не можете изменять складские документы, так как некого указывать в качестве кладовщика."); return(false); } Entity.UpdateOperations(UoW); Entity.UpdateReceptions(UoW, GoodsReceptionList, new NomenclatureRepository(new NomenclatureParametersProvider()), new BottlesRepository()); IStandartNomenclatures standartNomenclatures = new BaseParametersProvider(); var callTaskWorker = new CallTaskWorker( CallTaskSingletonFactory.GetInstance(), new CallTaskRepository(), OrderSingletonRepository.GetInstance(), EmployeeSingletonRepository.GetInstance(), new BaseParametersProvider(), ServicesConfig.CommonServices.UserService, SingletonErrorReporter.Instance); if (Entity.FullyShiped(UoW, standartNomenclatures, new RouteListItemRepository(), new SelfDeliveryRepository(), new CashRepository(), callTaskWorker)) { MessageDialogHelper.RunInfoDialog("Заказ отгружен полностью."); } logger.Info("Сохраняем документ самовывоза..."); UoWGeneric.Save(); //FIXME Необходимо проверить правильность этого кода, так как если заказ именялся то уведомление на его придет и без кода. //А если в каком то месте нужно получать уведомления об изменениях текущего объекта, то логично чтобы этот объект на него и подписался. //OrmMain.NotifyObjectUpdated(new object[] { Entity.Order }); logger.Info("Ok."); return(true); }
public SelfDeliveryDocumentDlg(int id) { this.Build(); UoWGeneric = UnitOfWorkFactory.CreateForRoot <SelfDeliveryDocument>(id); var validationResult = CheckPermission(EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW)); if (!validationResult.CanRead) { MessageDialogHelper.RunErrorDialog("Нет прав для доступа к документу отпуска самовывоза"); FailInitialize = true; return; } canEditDocument = validationResult.CanUpdate; ConfigureDlg(); }
private void OpenDriverWorkScheduleSetEditWindow() { if (!(ytreeDriverScheduleSets.GetSelectedObject() is DriverWorkScheduleSet workScheduleSet)) { return; } var driverWorkScheduleSetViewModel = new DriverWorkScheduleSetViewModel( workScheduleSet, UoW, ServicesConfig.CommonServices, new BaseParametersProvider(), EmployeeSingletonRepository.GetInstance() ); TabParent.AddSlaveTab(this, driverWorkScheduleSetViewModel); }
private void OpenDistrictPrioritySetEditWindow() { if (!(ytreeDistrictPrioritySets.GetSelectedObject() is DriverDistrictPrioritySet districtPrioritySet)) { return; } var driverDistrictPrioritySetViewModel = new DriverDistrictPrioritySetViewModel( districtPrioritySet, UoW, UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, new BaseParametersProvider(), EmployeeSingletonRepository.GetInstance() ); TabParent.AddSlaveTab(this, driverDistrictPrioritySetViewModel); }
private void UpdateCashDistributionsDocuments() { var editor = EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW); var document = UoW.Session.QueryOver <CashOrganisationDistributionDocument>() .Where(x => x.Income.Id == Entity.Id).List().FirstOrDefault(); if (document != null) { switch (document.Type) { case CashOrganisationDistributionDocType.IncomeCashDistributionDoc: incomeCashOrganisationDistributor.UpdateRecords(UoW, (IncomeCashDistributionDocument)document, Entity, editor); break; case CashOrganisationDistributionDocType.RouteListItemCashDistributionDoc: routeListCashOrganisationDistributor.UpdateIncomeCash(UoW, Entity.RouteListClosing, Entity, Entity.Money); break; } } }
private void UpdateCashDistributionsDocuments() { var editor = EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW); var document = UoW.Session.QueryOver <CashOrganisationDistributionDocument>() .Where(x => x.Expense.Id == Entity.Id).List().FirstOrDefault(); if (document != null) { switch (document.Type) { case CashOrganisationDistributionDocType.ExpenseCashDistributionDoc: expenseCashOrganisationDistributor.UpdateRecords(UoW, (ExpenseCashDistributionDocument)document, Entity, editor); break; case CashOrganisationDistributionDocType.FuelExpenseCashOrgDistributionDoc: fuelCashOrganisationDistributor.UpdateRecords(UoW, (FuelExpenseCashDistributionDocument)document, Entity, editor); break; } } }
private void Configure() { buttonRun.Clicked += (sender, args) => OnUpdate(); yentryrefWarehouse.SubjectType = typeof(Warehouse); yentryrefWarehouse.ChangedByUser += YentryrefWarehouseChangedByUser; if (CurrentUserSettings.Settings.DefaultWarehouse != null) { yentryrefWarehouse.Subject = CurrentUserSettings.Settings.DefaultWarehouse; } dateperiodpickerMaxSales.StartDate = DateTime.Today.AddYears(-1); dateperiodpickerMaxSales.EndDate = DateTime.Today.AddHours(23).AddMinutes(59).AddSeconds(59); dateperiodpickerMaxSales.PeriodChangedByUser += DateperiodpickerMaxSalesPeriodChangedByUser; GeographicGroupNodes = new GenericObservableList <GeographicGroupNode>( UoW.GetAll <GeographicGroup>().Select(x => new GeographicGroupNode(x)).ToList()); GeographicGroup employeeGeographicGroup = EmployeeSingletonRepository.GetInstance() .GetEmployeeForCurrentUser(UoW).Subdivision.GetGeographicGroup(); if (employeeGeographicGroup != null) { var foundGeoGroup = GeographicGroupNodes.FirstOrDefault(x => x.GeographicGroup.Id == employeeGeographicGroup.Id); if (foundGeoGroup != null) { foundGeoGroup.Selected = true; } } ytreeviewGeographicGroup.ColumnsConfig = FluentColumnsConfig <GeographicGroupNode> .Create() .AddColumn("Выбрать").AddToggleRenderer(x => x.Selected).Editing() .AddColumn("Район города").AddTextRenderer(x => x.GeographicGroup.Name) .Finish(); ytreeviewGeographicGroup.ItemsDataSource = GeographicGroupNodes; ytreeviewGeographicGroup.HeadersVisible = false; }
private void OpenDriverWorkScheduleSetCreateWindow() { var newDriverWorkScheduleSet = new DriverWorkScheduleSet { Driver = Entity, IsCreatedAutomatically = false }; var driverWorkScheduleSetViewModel = new DriverWorkScheduleSetViewModel( newDriverWorkScheduleSet, UoW, ServicesConfig.CommonServices, new BaseParametersProvider(), EmployeeSingletonRepository.GetInstance() ); driverWorkScheduleSetViewModel.EntityAccepted += (o, eventArgs) => { Entity.AddActiveDriverWorkScheduleSet(newDriverWorkScheduleSet); }; TabParent.AddSlaveTab(this, driverWorkScheduleSetViewModel); }
public void FillForRoutelist(int routelistId) { var cashier = EmployeeSingletonRepository.GetInstance().GetEmployeeForCurrentUser(UoW); if (cashier == null) { MessageDialogHelper.RunErrorDialog("Ваш пользователь не привязан к действующему сотруднику, вы не можете закрыть МЛ, так как некого указывать в качестве кассира."); return; } var rl = UoW.GetById <RouteList>(routelistId); Entity.IncomeCategory = CategoryRepository.RouteListClosingIncomeCategory(UoW); Entity.TypeOperation = IncomeType.DriverReport; Entity.Date = DateTime.Now; Entity.Casher = cashier; Entity.Employee = rl.Driver; Entity.Description = $"Закрытие МЛ №{rl.Id} от {rl.Date:d}"; Entity.RouteListClosing = rl; Entity.RelatedToSubdivision = rl.ClosingSubdivision; }
public static Widget Create(PanelViewType type) { switch (type) { case PanelViewType.CounterpartyView: return(new CounterpartyPanelView()); case PanelViewType.DeliveryPointView: return(new DeliveryPointPanelView()); case PanelViewType.DeliveryPricePanelView: return(new DeliveryPricePanelView()); case PanelViewType.UndeliveredOrdersPanelView: return(new UndeliveredOrdersPanelView()); case PanelViewType.EmailsPanelView: return(new EmailsPanelView()); case PanelViewType.CallTaskPanelView: return(new CallTaskPanelView(new BaseParametersProvider(), EmployeeSingletonRepository.GetInstance())); case PanelViewType.ComplaintPanelView: return(new ComplaintPanelView(new ComplaintsRepository())); case PanelViewType.SmsSendPanelView: return(new SmsSendPanelView()); case PanelViewType.FixedPricesPanelView: var fixedPricesDialogOpener = new FixedPricesDialogOpener(); FixedPricesPanelViewModel fixedPricesPanelViewModel = new FixedPricesPanelViewModel(fixedPricesDialogOpener); return(new FixedPricesPanelView(fixedPricesPanelViewModel)); default: throw new NotSupportedException(); } }
void ActionCallTasks_Activate(object sender, System.EventArgs e) { tdiMain.OpenTab( "CRM", () => new TasksView(EmployeeSingletonRepository.GetInstance(), new BottlesRepository(), new CallTaskRepository(), new PhoneRepository()), null ); /* * tdiMain.OpenTab( * "CRM", * () => new BusinessTasksJournalViewModel(new CallTaskFilterViewModel(), * new BusinessTasksJournalFooterViewModel(), * UnitOfWorkFactory.GetDefaultFactory, * ServicesConfig.CommonServices, * EmployeeSingletonRepository.GetInstance(), * new BottlesRepository(), * new CallTaskRepository(), * new PhoneRepository()) { SelectionMode = JournalSelectionMode.Multiple}, null * ); */ }
public CashExpenseDlg(int id, IPermissionService permissionService) { this.Build(); UoWGeneric = UnitOfWorkFactory.CreateForRoot <Expense>(id); if (!accessfilteredsubdivisionselectorwidget.Configure(UoW, false, typeof(Expense))) { MessageDialogHelper.RunErrorDialog(accessfilteredsubdivisionselectorwidget.ValidationErrorMessage); FailInitialize = true; return; } var userPermission = permissionService.ValidateUserPermission(typeof(Expense), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id); if (!userPermission.CanRead) { MessageDialogHelper.RunErrorDialog("Отсутствуют права на просмотр расходного ордера"); FailInitialize = true; return; } canEdit = userPermission.CanUpdate; var permmissionValidator = new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance()); canEditRectroactively = permmissionValidator.Validate(typeof(Expense), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id, nameof(RetroactivelyClosePermission)); ConfigureDlg(); }
static void AutofacClassConfig() { var builder = new ContainerBuilder(); #region База builder.Register(c => UnitOfWorkFactory.GetDefaultFactory).As <IUnitOfWorkFactory>(); builder.RegisterType <BaseParametersProvider>().AsSelf(); #endregion #region Сервисы #region GtkUI builder.RegisterType <GtkMessageDialogsInteractive>().As <IInteractiveMessage>(); builder.RegisterType <GtkQuestionDialogsInteractive>().As <IInteractiveQuestion>(); builder.RegisterType <GtkInteractiveService>().As <IInteractiveService>(); #endregion GtkUI builder.Register(c => ServicesConfig.CommonServices).As <ICommonServices>(); builder.RegisterType <UserService>().As <IUserService>(); #endregion #region Vodovoz #region Adapters builder.RegisterType <UndeliveriesViewOpener>().As <IUndeliveriesViewOpener>(); #endregion #region Services builder.Register(c => VodovozGtkServicesConfig.EmployeeService).As <IEmployeeService>(); builder.RegisterType <GtkFilePicker>().As <IFilePickerService>(); builder.Register(c => new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance())).As <IEntityExtendedPermissionValidator>(); builder.RegisterType <EmployeeService>().As <IEmployeeService>(); #endregion #region Selectors builder.RegisterType <NomenclatureSelectorFactory>().As <INomenclatureSelectorFactory>(); builder.RegisterType <OrderSelectorFactory>().As <IOrderSelectorFactory>(); builder.RegisterType <RdlPreviewOpener>().As <IRDLPreviewOpener>(); #endregion #region Интерфейсы репозиториев builder.RegisterType <SubdivisionRepository>().As <ISubdivisionRepository>(); builder.Register(c => EmployeeSingletonRepository.GetInstance()).As <IEmployeeRepository>(); builder.RegisterType <WarehouseRepository>().As <IWarehouseRepository>(); builder.Register(c => UserSingletonRepository.GetInstance()).As <IUserRepository>(); #endregion #region Mango builder.RegisterType <MangoManager>().AsSelf(); #endregion #endregion #region Навигация builder.RegisterType <ClassNamesHashGenerator>().As <IPageHashGenerator>(); builder.Register((ctx) => new AutofacViewModelsTdiPageFactory(AppDIContainer)).As <IViewModelsPageFactory>(); builder.Register((ctx) => new AutofacTdiPageFactory(AppDIContainer)).As <ITdiPageFactory>(); builder.Register((ctx) => new AutofacViewModelsGtkPageFactory(AppDIContainer)).AsSelf(); builder.RegisterType <TdiNavigationManager>().AsSelf().As <INavigationManager>().As <ITdiCompatibilityNavigation>().SingleInstance(); builder.Register(cc => new ClassNamesBaseGtkViewResolver(typeof(InternalTalkView), typeof(DeletionView))).As <IGtkViewResolver>(); #endregion #region Старые диалоги builder.RegisterAssemblyTypes(System.Reflection.Assembly.GetAssembly(typeof(CounterpartyDlg))) .Where(t => t.IsAssignableTo <ITdiTab>()) .AsSelf(); #endregion #region Старые общие диалоги builder.RegisterType <ReportViewDlg>().AsSelf(); #endregion #region ViewModels builder.Register(x => new AutofacViewModelResolver(AppDIContainer)).As <IViewModelResolver>(); builder.RegisterAssemblyTypes( System.Reflection.Assembly.GetAssembly(typeof(InternalTalkViewModel)), System.Reflection.Assembly.GetAssembly(typeof(ComplaintViewModel))) .Where(t => t.IsAssignableTo <ViewModelBase>() && t.Name.EndsWith("ViewModel")) .AsSelf(); #endregion #region Repository builder.RegisterAssemblyTypes(System.Reflection.Assembly.GetAssembly(typeof(CounterpartyContractRepository))) .Where(t => t.Name.EndsWith("Repository")) .AsSelf(); #endregion AppDIContainer = builder.Build(); }
private void ConfigureDlg() { if (Entity.Id == 0) { Entity.OrganisationForSalary = commonOrganisationProvider.GetCommonOrganisation(UoW); } canManageDriversAndForwarders = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_manage_drivers_and_forwarders"); canManageOfficeWorkers = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_manage_office_workers"); canEditOrganisationForSalary = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_edit_organisation_for_salary"); ConfigureCategory(); ConfigureSubdivision(); OnRussianCitizenToggled(null, EventArgs.Empty); dataentryDrivingNumber.MaxLength = 20; dataentryDrivingNumber.Binding.AddBinding(Entity, e => e.DrivingLicense, w => w.Text).InitializeFromSource(); UoWGeneric.Root.PropertyChanged += OnPropertyChanged; notebookMain.Page = 0; notebookMain.ShowTabs = false; GenderComboBox.ItemsEnum = typeof(Gender); GenderComboBox.Binding.AddBinding(Entity, e => e.Gender, w => w.SelectedItemOrNull).InitializeFromSource(); subdivisionService = SubdivisionParametersProvider.Instance; yenumcomboStatus.ItemsEnum = typeof(EmployeeStatus); yenumcomboStatus.Binding.AddBinding(Entity, e => e.Status, w => w.SelectedItem).InitializeFromSource(); chkDriverForOneDay.Binding.AddBinding(Entity, e => e.IsDriverForOneDay, w => w.Active).InitializeFromSource(); cmbDriverOf.ItemsEnum = typeof(CarTypeOfUse); cmbDriverOf.Binding.AddBinding(Entity, e => e.DriverOf, w => w.SelectedItemOrNull).InitializeFromSource(); dataentryLastName.Binding.AddBinding(Entity, e => e.LastName, w => w.Text).InitializeFromSource(); dataentryName.Binding.AddBinding(Entity, e => e.Name, w => w.Text).InitializeFromSource(); dataentryPatronymic.Binding.AddBinding(Entity, e => e.Patronymic, w => w.Text).InitializeFromSource(); dataentryInnerPhone.Binding.AddBinding(Entity, e => e.InnerPhone, w => w.Text, new Gamma.Binding.Converters.NumbersToStringConverter()).InitializeFromSource(); entryAddressCurrent.Binding.AddBinding(Entity, e => e.AddressCurrent, w => w.Text).InitializeFromSource(); entryAddressRegistration.Binding.AddBinding(Entity, e => e.AddressRegistration, w => w.Text).InitializeFromSource(); entryInn.Binding.AddBinding(Entity, e => e.INN, w => w.Text).InitializeFromSource(); dataentryAndroidLogin.Binding.AddBinding(Entity, e => e.AndroidLogin, w => w.Text).InitializeFromSource(); dataentryAndroidPassword.Binding.AddBinding(Entity, e => e.AndroidPassword, w => w.Text).InitializeFromSource(); var filterDefaultForwarder = new EmployeeFilterViewModel(); filterDefaultForwarder.SetAndRefilterAtOnce( x => x.Category = EmployeeCategory.forwarder, x => x.Status = EmployeeStatus.IsWorking ); repEntDefaultForwarder.RepresentationModel = new EmployeesVM(filterDefaultForwarder); repEntDefaultForwarder.Binding.AddBinding(Entity, e => e.DefaultForwarder, w => w.Subject).InitializeFromSource(); referenceNationality.SubjectType = typeof(Nationality); referenceNationality.Binding.AddBinding(Entity, e => e.Nationality, w => w.Subject).InitializeFromSource(); referenceCitizenship.SubjectType = typeof(Citizenship); referenceCitizenship.Binding.AddBinding(Entity, e => e.Citizenship, w => w.Subject).InitializeFromSource(); referenceUser.SubjectType = typeof(User); referenceUser.CanEditReference = false; referenceUser.Binding.AddBinding(Entity, e => e.User, w => w.Subject).InitializeFromSource(); referenceUser.Sensitive = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_manage_users"); yenumcombobox13.ItemsEnum = typeof(RegistrationType); yenumcombobox13.Binding.AddBinding(Entity, e => e.Registration, w => w.SelectedItemOrNull).InitializeFromSource(); comboDriverType.ItemsEnum = typeof(DriverType); comboDriverType.Binding.AddBinding(Entity, e => e.DriverType, w => w.SelectedItemOrNull).InitializeFromSource(); ydatepicker1.Binding.AddBinding(Entity, e => e.BirthdayDate, w => w.DateOrNull).InitializeFromSource(); dateFired.Binding.AddBinding(Entity, e => e.DateFired, w => w.DateOrNull).InitializeFromSource(); dateHired.Binding.AddBinding(Entity, e => e.DateHired, w => w.DateOrNull).InitializeFromSource(); dateCalculated.Binding.AddBinding(Entity, e => e.DateCalculated, w => w.DateOrNull).InitializeFromSource(); photoviewEmployee.Binding.AddBinding(Entity, e => e.Photo, w => w.ImageFile).InitializeFromSource(); photoviewEmployee.GetSaveFileName = () => Entity.FullName; attachmentFiles.AttachToTable = OrmConfig.GetDBTableName(typeof(Employee)); if (Entity.Id != 0) { attachmentFiles.ItemId = UoWGeneric.Root.Id; attachmentFiles.UpdateFileList(); } phonesView.UoW = UoWGeneric; if (UoWGeneric.Root.Phones == null) { UoWGeneric.Root.Phones = new List <Phone>(); } phonesView.Phones = UoWGeneric.Root.Phones; accountsView.ParentReference = new ParentReferenceGeneric <Employee, Account>(UoWGeneric, o => o.Accounts); accountsView.SetTitle("Банковские счета сотрудника"); ydateFirstWorkDay.Binding.AddBinding(Entity, e => e.FirstWorkDay, w => w.DateOrNull).InitializeFromSource(); yspinTripsPriority.Binding.AddBinding(Entity, e => e.TripPriority, w => w.ValueAsShort).InitializeFromSource(); yspinDriverSpeed.Binding.AddBinding(Entity, e => e.DriverSpeed, w => w.Value, new MultiplierToPercentConverter()).InitializeFromSource(); minAddressesSpin.Binding.AddBinding(Entity, e => e.MinRouteAddresses, w => w.ValueAsInt).InitializeFromSource(); maxAddressesSpin.Binding.AddBinding(Entity, e => e.MaxRouteAddresses, w => w.ValueAsInt).InitializeFromSource(); checkbuttonRussianCitizen.Binding.AddBinding(Entity, e => e.IsRussianCitizen, w => w.Active).InitializeFromSource(); checkVisitingMaster.Binding.AddBinding(Entity, e => e.VisitingMaster, w => w.Active).InitializeFromSource(); checkChainStoreDriver.Binding.AddBinding(Entity, e => e.IsChainStoreDriver, w => w.Active).InitializeFromSource(); ylblUserLogin.TooltipText = "При сохранении сотрудника создаёт нового пользователя с введённым логином и отправляет сотруднику SMS с сгенерированным паролем"; yentryUserLogin.Binding.AddBinding(Entity, e => e.LoginForNewUser, w => w.Text); yentryUserLogin.Sensitive = CanCreateNewUser; specialListCmbOrganisation.ItemsList = UoW.GetAll <Organization>(); specialListCmbOrganisation.Binding.AddBinding(Entity, e => e.OrganisationForSalary, w => w.SelectedItem).InitializeFromSource(); specialListCmbOrganisation.Sensitive = canEditOrganisationForSalary; ConfigureWorkSchedules(); ConfigureDistrictPriorities(); ytreeviewEmployeeDocument.ColumnsConfig = FluentColumnsConfig <EmployeeDocument> .Create() .AddColumn("Документ").AddTextRenderer(x => x.Document.GetEnumTitle()) .AddColumn("Доп. название").AddTextRenderer(x => x.Name) .Finish(); ytreeviewEmployeeDocument.SetItemsSource(Entity.ObservableDocuments); ytreeviewEmployeeContract.ColumnsConfig = FluentColumnsConfig <EmployeeContract> .Create() .AddColumn("Договор").AddTextRenderer(x => x.EmployeeContractTemplate.TemplateType.GetEnumTitle()) .AddColumn("Название").AddTextRenderer(x => x.Name) .AddColumn("Дата начала").AddTextRenderer(x => x.FirstDay.ToString("dd/MM/yyyy")) .AddColumn("Дата конца").AddTextRenderer(x => x.LastDay.ToString("dd/MM/yyyy")) .Finish(); ytreeviewEmployeeContract.SetItemsSource(Entity.ObservableContracts); wageParametersView.ViewModel = new EmployeeWageParametersViewModel ( Entity, this, UoW, new HierarchicalPresetPermissionValidator(EmployeeSingletonRepository.GetInstance(), new PermissionRepository()), UserSingletonRepository.GetInstance(), ServicesConfig.CommonServices, NavigationManagerProvider.NavigationManager ); logger.Info("Ok"); }
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; } }
protected void OnButtonAddEnumItemClicked(object sender, QS.Widgets.EnumItemClickedEventArgs e) { DocumentType type = (DocumentType)e.ItemEnum; switch (type) { case DocumentType.MovementDocument: TabParent.OpenTab( DialogHelper.GenerateDialogHashName(Document.GetDocClass(type), 0), () => { return(new MovementDocumentViewModel( EntityUoWBuilder.ForCreate(), UnitOfWorkFactory.GetDefaultFactory, new WarehousePermissionService(), VodovozGtkServicesConfig.EmployeeService, new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance()), new NomenclatureSelectorFactory(), new OrderSelectorFactory(), new WarehouseRepository(), UserSingletonRepository.GetInstance(), new RdlPreviewOpener(), ServicesConfig.CommonServices )); }, this ); break; case DocumentType.IncomingInvoice: TabParent.OpenTab( DialogHelper.GenerateDialogHashName(Document.GetDocClass(type), 0), () => { return(new IncomingInvoiceViewModel( EntityUoWBuilder.ForCreate(), UnitOfWorkFactory.GetDefaultFactory, new WarehousePermissionService(), VodovozGtkServicesConfig.EmployeeService, new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance()), new NomenclatureSelectorFactory(), new OrderSelectorFactory(), new WarehouseRepository(), new RdlPreviewOpener(), ServicesConfig.CommonServices )); }, this ); break; case DocumentType.IncomingWater: case DocumentType.WriteoffDocument: case DocumentType.SelfDeliveryDocument: case DocumentType.CarLoadDocument: case DocumentType.CarUnloadDocument: case DocumentType.InventoryDocument: case DocumentType.ShiftChangeDocument: case DocumentType.RegradingOfGoodsDocument: default: TabParent.OpenTab( DialogHelper.GenerateDialogHashName(Document.GetDocClass(type), 0), () => OrmMain.CreateObjectDialog(Document.GetDocClass(type)), this ); break; } }
protected void OnButtonEditClicked(object sender, EventArgs e) { if (tableDocuments.GetSelectedObjects().GetLength(0) > 0) { int id = (tableDocuments.GetSelectedObjects() [0] as ViewModel.DocumentVMNode).Id; DocumentType DocType = (tableDocuments.GetSelectedObjects() [0] as ViewModel.DocumentVMNode).DocTypeEnum; switch (DocType) { case DocumentType.IncomingInvoice: TabParent.OpenTab( DialogHelper.GenerateDialogHashName <IncomingInvoice>(id), () => { return(new IncomingInvoiceViewModel( EntityUoWBuilder.ForOpen(id), UnitOfWorkFactory.GetDefaultFactory, new WarehousePermissionService(), VodovozGtkServicesConfig.EmployeeService, new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance()), new NomenclatureSelectorFactory(), new OrderSelectorFactory(), new WarehouseRepository(), new RdlPreviewOpener(), ServicesConfig.CommonServices )); }, this ); break; case DocumentType.IncomingWater: TabParent.OpenTab( DialogHelper.GenerateDialogHashName <IncomingWater>(id), () => new IncomingWaterDlg(id), this); break; case DocumentType.MovementDocument: TabParent.OpenTab( DialogHelper.GenerateDialogHashName <MovementDocument>(id), () => { return(new MovementDocumentViewModel( EntityUoWBuilder.ForOpen(id), UnitOfWorkFactory.GetDefaultFactory, new WarehousePermissionService(), VodovozGtkServicesConfig.EmployeeService, new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), EmployeeSingletonRepository.GetInstance()), new NomenclatureSelectorFactory(), new OrderSelectorFactory(), new WarehouseRepository(), UserSingletonRepository.GetInstance(), new RdlPreviewOpener(), ServicesConfig.CommonServices )); }, this ); break; case DocumentType.WriteoffDocument: TabParent.OpenTab( DialogHelper.GenerateDialogHashName <WriteoffDocument>(id), () => new WriteoffDocumentDlg(id), this); break; case DocumentType.InventoryDocument: TabParent.OpenTab( DialogHelper.GenerateDialogHashName <InventoryDocument>(id), () => new InventoryDocumentDlg(id), this); break; case DocumentType.ShiftChangeDocument: TabParent.OpenTab( DialogHelper.GenerateDialogHashName <ShiftChangeWarehouseDocument>(id), () => new ShiftChangeWarehouseDocumentDlg(id), this); break; case DocumentType.RegradingOfGoodsDocument: TabParent.OpenTab( DialogHelper.GenerateDialogHashName <RegradingOfGoodsDocument>(id), () => new RegradingOfGoodsDocumentDlg(id), this); break; case DocumentType.SelfDeliveryDocument: TabParent.OpenTab( DialogHelper.GenerateDialogHashName <SelfDeliveryDocument>(id), () => new SelfDeliveryDocumentDlg(id), this); break; case DocumentType.CarLoadDocument: TabParent.OpenTab( DialogHelper.GenerateDialogHashName <CarLoadDocument>(id), () => new CarLoadDocumentDlg(id), this); break; case DocumentType.CarUnloadDocument: TabParent.OpenTab( DialogHelper.GenerateDialogHashName <CarUnloadDocument>(id), () => new CarUnloadDocumentDlg(id), this); break; default: throw new NotSupportedException("Тип документа не поддерживается."); } } }
private void UpdateTranferDocuments(RouteList from, RouteList to) { var addressTransferController = new AddressTransferController(EmployeeSingletonRepository.GetInstance()); addressTransferController.UpdateDocuments(from, to, UoW); }
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(); }