示例#1
0
        void ConfigureDlg()
        {
            enumcomboOperation.ItemsEnum = typeof(ExpenseType);
            enumcomboOperation.Binding.AddBinding(Entity, s => s.TypeOperation, w => w.SelectedItem).InitializeFromSource();

            var filterCasher = new EmployeeFilter(UoW);

            filterCasher.ShowFired           = false;
            yentryCasher.RepresentationModel = new ViewModel.EmployeesVM(filterCasher);
            yentryCasher.Binding.AddBinding(Entity, s => s.Casher, w => w.Subject).InitializeFromSource();

            var filterEmployee = new EmployeeFilter(UoW);

            filterEmployee.ShowFired           = false;
            yentryEmployee.RepresentationModel = new ViewModel.EmployeesVM(filterEmployee);
            yentryEmployee.Binding.AddBinding(Entity, s => s.Employee, w => w.Subject).InitializeFromSource();
            yentryEmployee.ChangedByUser += (sender, e) => UpdateEmployeeBalaceInfo();

            ydateDocument.Binding.AddBinding(Entity, s => s.Date, w => w.Date).InitializeFromSource();

            OrmMain.GetObjectDescription <ExpenseCategory> ().ObjectUpdated += OnExpenseCategoryUpdated;
            OnExpenseCategoryUpdated(null, null);
            comboExpense.Binding.AddBinding(Entity, s => s.ExpenseCategory, w => w.SelectedItem).InitializeFromSource();

            yspinMoney.Binding.AddBinding(Entity, s => s.Money, w => w.ValueAsDecimal).InitializeFromSource();

            ytextviewDescription.Binding.AddBinding(Entity, s => s.Description, w => w.Buffer.Text).InitializeFromSource();

            ExpenseType type = (ExpenseType)enumcomboOperation.SelectedItem;

            ylabelEmployeeWageBalance.Visible = type == ExpenseType.EmployeeAdvance ||
                                                type == ExpenseType.Salary;
            UpdateEmployeeBalaceInfo();
        }
示例#2
0
        public CashFlow(
            ISubdivisionRepository subdivisionRepository, ICommonServices commonServices, ICategoryRepository categoryRepository)
        {
            _subdivisionRepository = subdivisionRepository ?? throw new ArgumentNullException(nameof(subdivisionRepository));
            _commonServices        = commonServices ?? throw new ArgumentNullException(nameof(commonServices));

            if (categoryRepository == null)
            {
                throw new ArgumentNullException(nameof(categoryRepository));
            }

            Build();

            UoW = UnitOfWorkFactory.CreateWithoutRoot();
            comboPart.ItemsEnum            = typeof(ReportParts);
            comboIncomeCategory.ItemsList  = categoryRepository.IncomeCategories(UoW);
            comboExpenseCategory.Sensitive = comboIncomeCategory.Sensitive = false;
            var now = DateTime.Now;

            dateStart.Date = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0);
            dateEnd.Date   = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59);

            var officeFilter = new EmployeeFilterViewModel();

            officeFilter.SetAndRefilterAtOnce(
                x => x.Status           = EmployeeStatus.IsWorking,
                x => x.RestrictCategory = EmployeeCategory.office);
            var employeeFactory = new EmployeeJournalFactory(officeFilter);

            evmeCashier.SetEntityAutocompleteSelectorFactory(employeeFactory.CreateWorkingOfficeEmployeeAutocompleteSelectorFactory());

            evmeEmployee.SetEntityAutocompleteSelectorFactory(employeeFactory.CreateWorkingEmployeeAutocompleteSelectorFactory());

            var recurciveConfig = OrmMain.GetObjectDescription <ExpenseCategory>().TableView.RecursiveTreeConfig;
            var list            = categoryRepository.ExpenseCategories(UoW);

            list.Insert(0, allItem);
            var model = recurciveConfig.CreateModel((IList)list);

            comboExpenseCategory.Model = model.Adapter;
            comboExpenseCategory.PackStart(new CellRendererText(), true);
            comboExpenseCategory.SetCellDataFunc(comboExpenseCategory.Cells[0], HandleCellLayoutDataFunc);
            comboExpenseCategory.SetActiveIter(model.IterFromNode(allItem));

            UserSubdivisions = GetSubdivisionsForUser();
            specialListCmbCashSubdivisions.SetRenderTextFunc <Subdivision>(s => s.Name);
            specialListCmbCashSubdivisions.ItemsList = UserSubdivisions;

            ylblOrganisations.Visible = specialListCmbOrganisations.Visible = false;
            Organisations             = UoW.GetAll <Organization>();
            specialListCmbOrganisations.SetRenderTextFunc <Organization>(s => s.Name);
            specialListCmbOrganisations.ItemsList = Organisations;

            int  currentUserId = commonServices.UserService.CurrentUserId;
            bool canCreateCashReportsForOrganisations =
                commonServices.PermissionService.ValidateUserPresetPermission("can_create_cash_reports_for_organisations", currentUserId);

            checkOrganisations.Visible  = canCreateCashReportsForOrganisations;
            checkOrganisations.Toggled += CheckOrganisationsToggled;
        }
示例#3
0
        void ConfigureDlg()
        {
            var filterEmployee = new EmployeeFilter(UoW);

            filterEmployee.ShowFired           = false;
            yentryEmployee.RepresentationModel = new ViewModel.EmployeesVM(filterEmployee);
            yentryEmployee.Binding.AddBinding(Entity, e => e.Accountable, w => w.Subject).InitializeFromSource();

            var filterCasher = new EmployeeFilter(UoW);

            filterCasher.ShowFired           = false;
            yentryCasher.RepresentationModel = new ViewModel.EmployeesVM(filterCasher);
            yentryCasher.Binding.AddBinding(Entity, e => e.Casher, w => w.Subject).InitializeFromSource();

            ydateDocument.Binding.AddBinding(Entity, s => s.Date, w => w.Date).InitializeFromSource();

            OrmMain.GetObjectDescription <ExpenseCategory>().ObjectUpdated += OnExpenseCategoryUpdated;
            OnExpenseCategoryUpdated(null, null);
            comboExpense.Binding.AddBinding(Entity, s => s.ExpenseCategory, w => w.SelectedItem).InitializeFromSource();

            yspinMoney.Binding.AddBinding(Entity, s => s.Money, w => w.ValueAsDecimal).InitializeFromSource();

            ytextviewDescription.Binding.AddBinding(Entity, s => s.Description, w => w.Buffer.Text).InitializeFromSource();

            ytreeviewDebts.ColumnsConfig = ColumnsConfigFactory.Create <RecivedAdvance>()
                                           .AddColumn("Закрыть").AddToggleRenderer(a => a.Selected).Editing()
                                           .AddColumn("Дата").AddTextRenderer(a => a.Advance.Date.ToString())
                                           .AddColumn("Получено").AddTextRenderer(a => a.Advance.Money.ToString("C"))
                                           .AddColumn("Непогашено").AddTextRenderer(a => a.Advance.UnclosedMoney.ToString("C"))
                                           .AddColumn("Статья").AddTextRenderer(a => a.Advance.ExpenseCategory.Name)
                                           .AddColumn("Основание").AddTextRenderer(a => a.Advance.Description)
                                           .Finish();
        }
示例#4
0
        void ConfigureDlg()
        {
            enumcomboOperation.ItemsEnum = typeof(IncomeType);
            enumcomboOperation.Binding.AddBinding(Entity, s => s.TypeOperation, w => w.SelectedItem).InitializeFromSource();

            var filterCasher = new EmployeeFilter(UoW);

            filterCasher.ShowFired           = false;
            yentryCasher.RepresentationModel = new ViewModel.EmployeesVM(filterCasher);
            yentryCasher.Binding.AddBinding(Entity, s => s.Casher, w => w.Subject).InitializeFromSource();

            var filter = new EmployeeFilter(UoW);

            filter.ShowFired = false;
            yentryEmployee.RepresentationModel = new ViewModel.EmployeesVM(filter);
            yentryEmployee.Binding.AddBinding(Entity, s => s.Employee, w => w.Subject).InitializeFromSource();

            var filterRL = new RouteListsFilter(UoW);

            filterRL.OnlyStatuses = new RouteListStatus[] { RouteListStatus.EnRoute, RouteListStatus.OnClosing };
            yEntryRouteList.RepresentationModel = new ViewModel.RouteListsVM(filterRL);
            yEntryRouteList.Binding.AddBinding(Entity, s => s.RouteListClosing, w => w.Subject).InitializeFromSource();
            yEntryRouteList.CanEditReference = QSMain.User.Permissions["can_delete"];

            yEntryRouteList.Hidden        += YEntryRouteList_ValueOrVisibilityChanged;
            yEntryRouteList.Shown         += YEntryRouteList_ValueOrVisibilityChanged;
            yEntryRouteList.ChangedByUser += YEntryRouteList_ValueOrVisibilityChanged;

            yentryClient.ItemsQuery = Repository.CounterpartyRepository.ActiveClientsQuery();
            yentryClient.Binding.AddBinding(Entity, s => s.Customer, w => w.Subject).InitializeFromSource();

            ydateDocument.Binding.AddBinding(Entity, s => s.Date, w => w.Date).InitializeFromSource();

            OrmMain.GetObjectDescription <ExpenseCategory> ().ObjectUpdated += OnExpenseCategoryUpdated;
            OnExpenseCategoryUpdated(null, null);
            comboExpense.Binding.AddBinding(Entity, s => s.ExpenseCategory, w => w.SelectedItem).InitializeFromSource();

            OrmMain.GetObjectDescription <IncomeCategory> ().ObjectUpdated += OnIncomeCategoryUpdated;
            OnIncomeCategoryUpdated(null, null);
            comboCategory.Binding.AddBinding(Entity, s => s.IncomeCategory, w => w.SelectedItem).InitializeFromSource();

            checkNoClose.Binding.AddBinding(Entity, e => e.NoFullCloseMode, w => w.Active);

            yspinMoney.Binding.AddBinding(Entity, s => s.Money, w => w.ValueAsDecimal).InitializeFromSource();

            ytextviewDescription.Binding.AddBinding(Entity, s => s.Description, w => w.Buffer.Text).InitializeFromSource();

            ytreeviewDebts.ColumnsConfig = ColumnsConfigFactory.Create <Selectable <Expense> > ()
                                           .AddColumn("Закрыть").AddToggleRenderer(a => a.Selected).Editing()
                                           .AddColumn("Дата").AddTextRenderer(a => a.Value.Date.ToString())
                                           .AddColumn("Получено").AddTextRenderer(a => a.Value.Money.ToString("C"))
                                           .AddColumn("Непогашено").AddTextRenderer(a => a.Value.UnclosedMoney.ToString("C"))
                                           .AddColumn("Статья").AddTextRenderer(a => a.Value.ExpenseCategory.Name)
                                           .AddColumn("Основание").AddTextRenderer(a => a.Value.Description)
                                           .Finish();
        }
示例#5
0
        public void Destroy()
        {
            logger.Debug("{0} called Destroy()", this.GetType());
            var description = OrmMain.GetObjectDescription <TEntity> ();

            if (description != null)
            {
                description.ObjectUpdatedGeneric -= OnExternalUpdate;
            }
        }
        public void OpenEntityDlg(int id)
        {
            if (OrmMain.GetObjectDescription(typeof(TEntity)).SimpleDialog)
            {
                EntityEditSimpleDialog.RunSimpleDialog((GetMyTab().TabParent as Widget).Toplevel as Window, typeof(TEntity), id);
                return;
            }

            ITdiTab dlg = OrmMain.CreateObjectDialog(typeof(TEntity), id);

            GetMyTab().TabParent.AddTab(dlg, GetMyTab());
        }
 public void Destroy()
 {
     logger.Debug("{0} called Destroy()", this.GetType());
     base.Destroy();
     foreach (var type in subcribeOnTypes)
     {
         var map = OrmMain.GetObjectDescription(type);
         if (map != null)
         {
             map.ObjectUpdated -= OnExternalUpdateCommon;
         }
     }
 }
示例#8
0
        /// <summary>
        /// Создает новый базовый клас и подписывается на обновления для типа TEntity, при этом конструкторе необходима реализация NeedUpdateFunc (TEntity updatedSubject)
        /// </summary>
        protected RepresentationModelEntityBase()
        {
            var description = OrmMain.GetObjectDescription <TEntity> ();

            if (description != null)
            {
                description.ObjectUpdatedGeneric += OnExternalUpdate;
            }
            else
            {
                logger.Warn("Невозможно подписаться на обновления класа {0}. Не найден класс маппинга.", typeof(TEntity));
            }
        }
 /// <summary>
 /// Создает новый базовый клас и подписывается на обновления указанных типов, при этом конструкторе необходима реализация NeedUpdateFunc (object updatedSubject);
 /// </summary>
 protected RepresentationModelEntitySubscribingBase(params Type[] subcribeOnTypes)
 {
     this.subcribeOnTypes = subcribeOnTypes;
     foreach (var type in subcribeOnTypes)
     {
         var map = OrmMain.GetObjectDescription(type);
         if (map != null)
         {
             map.ObjectUpdated += OnExternalUpdateCommon;
         }
         else
         {
             logger.Warn("Невозможно подписаться на обновления класа {0}. Не найден класс маппинга.", type);
         }
     }
 }
示例#10
0
        public void LoadAutocompletion(string[] searchText, int takeCount)
        {
            if (loadedItems == null)
            {
                LoadAllItems();
            }

            IList filtred;
            var   map            = OrmMain.GetObjectDescription(typeof(TEntity));
            var   searchProvider = map?.TableView?.SearchProvider;

            if (searchProvider == null)
            {
                filtred = loadedItems.Where(x => searchText.All(st => GetTitle(x).IndexOf(st, StringComparison.CurrentCultureIgnoreCase) > -1)).ToList();
            }
            else
            {
                filtred = loadedItems.Where(x => searchText.All(st => searchProvider.Match(x, st))).ToList();
            }

            AutocompleteLoaded?.Invoke(this, new AutocompleteUpdatedEventArgs(filtred));
        }
示例#11
0
 private void AdditionalUpdateSubscribe()
 {
     OrmMain.GetObjectDescription <Employee>().ObjectUpdatedGeneric += Handle_ObjectUpdatedGeneric;
 }
示例#12
0
        private void ConfigureDlg()
        {
            Entity.ObservableFuelDocuments.ElementAdded   += ObservableFuelDocuments_ElementAdded;
            Entity.ObservableFuelDocuments.ElementRemoved += ObservableFuelDocuments_ElementRemoved;
            referenceCar.SubjectType = typeof(Car);
            referenceCar.ItemsQuery  = CarRepository.ActiveCarsQuery();
            referenceCar.Binding.AddBinding(Entity, rl => rl.Car, widget => widget.Subject).InitializeFromSource();
            referenceCar.Sensitive = editing;

            var filterDriver = new EmployeeFilter(UoW);

            filterDriver.SetAndRefilterAtOnce(
                x => x.RestrictCategory = EmployeeCategory.driver,
                x => x.ShowFired        = false
                );
            referenceDriver.RepresentationModel = new EmployeesVM(filterDriver);
            referenceDriver.Binding.AddBinding(Entity, rl => rl.Driver, widget => widget.Subject).InitializeFromSource();
            referenceDriver.Sensitive = editing;

            previousForwarder = Entity.Forwarder;
            var filterForwarder = new EmployeeFilter(UoW);

            filterForwarder.SetAndRefilterAtOnce(
                x => x.RestrictCategory = EmployeeCategory.forwarder,
                x => x.ShowFired        = false
                );
            referenceForwarder.RepresentationModel = new EmployeesVM(filterForwarder);
            referenceForwarder.Binding.AddBinding(Entity, rl => rl.Forwarder, widget => widget.Subject).InitializeFromSource();
            referenceForwarder.Sensitive = editing;
            referenceForwarder.Changed  += ReferenceForwarder_Changed;

            var filterLogistican = new EmployeeFilter(UoW);

            filterLogistican.SetAndRefilterAtOnce(x => x.ShowFired = false);
            referenceLogistican.RepresentationModel = new EmployeesVM(filterLogistican);
            referenceLogistican.Binding.AddBinding(Entity, rl => rl.Logistican, widget => widget.Subject).InitializeFromSource();
            referenceLogistican.Sensitive = editing;

            speccomboShift.ItemsList = DeliveryShiftRepository.ActiveShifts(UoW);
            speccomboShift.Binding.AddBinding(Entity, rl => rl.Shift, widget => widget.SelectedItem).InitializeFromSource();
            speccomboShift.Sensitive = editing;

            yspinActualDistance.Binding.AddBinding(Entity, rl => rl.ActualDistance, widget => widget.ValueAsDecimal).InitializeFromSource();
            yspinActualDistance.Sensitive = editing;

            datePickerDate.Binding.AddBinding(Entity, rl => rl.Date, widget => widget.Date).InitializeFromSource();
            datePickerDate.Sensitive = editing;

            ycheckConfirmDifferences.Binding.AddBinding(Entity, e => e.DifferencesConfirmed, w => w.Active).InitializeFromSource();
            ycheckConfirmDifferences.Sensitive = editing && Entity.Status == RouteListStatus.OnClosing;

            decimal unclosedAdvanceMoney = AccountableDebtsRepository.EmloyeeDebt(UoW, Entity.Driver);

            ylabelUnclosedAdvancesMoney.LabelProp =
                String.Format(unclosedAdvanceMoney > 0m ? "<span foreground='red'><b>Долг: {0}</b></span>" : "", unclosedAdvanceMoney);

            ytextClosingComment.Binding.AddBinding(Entity, e => e.ClosingComment, w => w.Buffer.Text).InitializeFromSource();
            ytextClosingComment.Sensitive = editing;
            labelOrderEarly.Text          = "Сдано ранее:" + GetCashOrder().ToString();
            spinCashOrder.Value           = 0;
            advanceSpinbutton.Value       = 0;
            advanceSpinbutton.Visible     = false;

            ycheckNormalWage.Binding.AddSource(Entity)
            .AddFuncBinding(x => x.Driver.WageCalcType == WageCalculationType.normal && x.Car.IsCompanyHavings, w => w.Visible)
            .AddBinding(x => x.NormalWage, w => w.Active)
            .InitializeFromSource();
            ycheckNormalWage.Sensitive = editing && QSMain.User.Permissions["change_driver_wage"];

            PerformanceHelper.AddTimePoint("Создан диалог");

            //Предварительная загрузка объектов для ускорения.

            /*			Vodovoz.Domain.Orders.Order orderAlias = null;
             *                      var clients = UoW.Session.QueryOver<RouteListItem>()
             *                              .Where(rli => rli.RouteList.Id == Entity.Id)
             *                              .JoinAlias(rli => rli.Order, () => orderAlias)
             *                              .Fetch(rli => rli.Order.Client).Eager
             *                              .List();
             *                              //.Select(Projections. a => orderAlias.Client).Future();
             *                              //.List<Counterparty>();
             */
            PerformanceHelper.AddTimePoint("Предварительная загрузка");

            routeListAddressesView.UoW       = UoW;
            routeListAddressesView.RouteList = Entity;
            foreach (RouteListItem item in routeListAddressesView.Items)
            {
                item.Order.ObservableOrderItems.ElementChanged += ObservableOrderItems_ElementChanged;
                item.Order.ObservableOrderItems.ElementAdded   += ObservableOrderItems_ElementAdded;
                item.Order.ObservableOrderItems.ElementRemoved += ObservableOrderItems_ElementRemoved;

                item.Order.ObservableOrderEquipments.ElementChanged += ObservableOrderItems_ElementChanged;
                item.Order.ObservableOrderEquipments.ElementAdded   += ObservableOrderItems_ElementAdded;
                item.Order.ObservableOrderEquipments.ElementRemoved += ObservableOrderItems_ElementRemoved;

                item.Order.ObservableOrderDepositItems.ElementChanged += ObservableOrderItems_ElementChanged;
                item.Order.ObservableOrderDepositItems.ElementAdded   += ObservableOrderItems_ElementAdded;
                item.Order.ObservableOrderDepositItems.ElementRemoved += ObservableOrderItems_ElementRemoved;
            }
            routeListAddressesView.Items.ElementChanged   += OnRouteListItemChanged;
            routeListAddressesView.OnClosingItemActivated += OnRouteListItemActivated;
            routeListAddressesView.IsEditing        = editing;
            routeListAddressesView.ColumsVisibility = !ycheckHideCells.Active;
            ycheckHideCells.Sensitive = editing;
            PerformanceHelper.AddTimePoint("заполнили список адресов");
            ReloadReturnedToWarehouse();
            var returnableOrderItems = routeListAddressesView.Items
                                       .Where(address => address.IsDelivered())
                                       .SelectMany(address => address.Order.OrderItems)
                                       .Where(orderItem => !orderItem.Nomenclature.IsSerial)
                                       .Where(orderItem => Nomenclature.GetCategoriesForShipment().Any(nom => nom == orderItem.Nomenclature.Category));

            foreach (var item in returnableOrderItems)
            {
                if (allReturnsToWarehouse.All(r => r.NomenclatureId != item.Nomenclature.Id))
                {
                    allReturnsToWarehouse.Add(new RouteListRepository.ReturnsNode {
                        Name           = item.Nomenclature.Name,
                        Trackable      = item.Nomenclature.IsSerial,
                        NomenclatureId = item.Nomenclature.Id,
                        Amount         = 0
                    });
                }
            }
            PerformanceHelper.AddTimePoint("Получили возврат на склад");
            //FIXME Убрать из этого места первоначальное заполнение. Сейчас оно вызывается при переводе статуса на сдачу. После того как не нормально не переведенных в закрытие маршрутников, тут заполение можно убрать.
            if (!Entity.ClosingFilled)
            {
                Entity.FirstFillClosing();
            }

            PerformanceHelper.AddTimePoint("Закончено первоначальное заполнение");

            hbox6.Remove(vboxHidenPanel);
            rightsidepanel1.Panel   = vboxHidenPanel;
            rightsidepanel1.IsHided = true;

            expander1.Expanded = false;

            routelistdiscrepancyview.FindDiscrepancies(Entity.Addresses, allReturnsToWarehouse);
            routelistdiscrepancyview.FineChanged += Routelistdiscrepancyview_FineChanged;
            routelistdiscrepancyview.Sensitive    = editing;
            PerformanceHelper.AddTimePoint("Заполнили расхождения");

            buttonAddFuelDocument.Sensitive             = Entity.Car?.FuelType?.Cost != null && Entity.Driver != null && editing;
            buttonDeleteFuelDocument.Sensitive          = Entity.Car?.FuelType?.Cost != null && Entity.Driver != null && editing;
            ytreeviewFuelDocuments.ItemsDataSource      = Entity.ObservableFuelDocuments;
            ytreeviewFuelDocuments.Reorderable          = true;
            Entity.ObservableFuelDocuments.ListChanged += ObservableFuelDocuments_ListChanged;
            UpdateFuelDocumentsColumns();

            enummenuRLActions.ItemsEnum        = typeof(RouteListActions);
            enummenuRLActions.EnumItemClicked += EnummenuRLActions_EnumItemClicked;
            enummenuRLActions.Sensitive        = editing;

            CheckWage();

            LoadDataFromFine();
            OnItemsUpdated();
            PerformanceHelper.AddTimePoint("Загрузка штрафов");
            GetFuelInfo();
            UpdateFuelInfo();
            PerformanceHelper.AddTimePoint("Загрузка бензина");

            PerformanceHelper.Main.PrintAllPoints(logger);

            //Подписки на обновления
            OrmMain.GetObjectDescription <CarUnloadDocument>().ObjectUpdatedGeneric += OnCalUnloadUpdated;

            enumPrint.ItemsEnum        = typeof(RouteListPrintDocuments);
            enumPrint.EnumItemClicked += (sender, e) => PrintSelectedDocument((RouteListPrintDocuments)e.ItemEnum);

            ylabelRecalculatedMileage.Binding.AddFuncBinding(Entity, e => e.RecalculatedDistance.HasValue ? $" {e.RecalculatedDistance} км" : "", w => w.LabelProp).InitializeFromSource();
            checkSendToMileageCheck.Binding.AddBinding(Entity, x => x.MileageCheck, w => w.Active).InitializeFromSource();
            Entity.PropertyChanged += Entity_PropertyChanged;
            //FIXME костыли, необходимо избавится от этого кода когда решим проблему с сессиями и flush nhibernate
            HasChanges          = true;
            UoW.CanCheckIfDirty = false;
        }
示例#13
0
 public override void Destroy()
 {
     OrmMain.GetObjectDescription <CarUnloadDocument>().ObjectUpdatedGeneric -= OnCalUnloadUpdated;
     base.Destroy();
 }