Exemplo n.º 1
0
        void ConfigureDlg()
        {
            TabName = "Приходный кассовый ордер самовывоза";

            Entity.TypeDocument = IncomeInvoiceDocumentType.IncomeInvoiceSelfDelivery;

            permissioncommentview.UoW             = UoW;
            permissioncommentview.Title           = "Комментарий по проверке закрытия МЛ: ";
            permissioncommentview.Comment         = Entity.CashierReviewComment;
            permissioncommentview.PermissionName  = "can_edit_cashier_review_comment";
            permissioncommentview.Comment         = Entity.CashierReviewComment;
            permissioncommentview.CommentChanged += (comment) => Entity.CashierReviewComment = comment;

            enumcomboOperation.ItemsEnum = typeof(IncomeType);
            enumcomboOperation.Binding.AddBinding(Entity, s => s.TypeOperation, w => w.SelectedItem).InitializeFromSource();
            enumcomboOperation.Sensitive = false;
            Entity.TypeOperation         = IncomeType.Payment;

            var filterCasher = new EmployeeFilterViewModel();

            filterCasher.Status = Domain.Employees.EmployeeStatus.IsWorking;
            yentryCasher.RepresentationModel = new EmployeesVM(filterCasher);
            yentryCasher.Binding.AddBinding(Entity, s => s.Casher, w => w.Subject).InitializeFromSource();
            yentryCasher.Sensitive = false;

            var filterOrders = new OrdersFilter(UoW);

            filterOrders.SetAndRefilterAtOnce(
                x => x.RestrictStatus              = OrderStatus.WaitForPayment,
                x => x.AllowPaymentTypes           = new PaymentType[] { PaymentType.cash, PaymentType.BeveragesWorld },
                x => x.RestrictSelfDelivery        = true,
                x => x.RestrictWithoutSelfDelivery = false,
                x => x.RestrictHideService         = true,
                x => x.RestrictOnlyService         = false
                );
            yentryOrder.RepresentationModel = new OrdersVM(filterOrders);
            yentryOrder.Binding.AddBinding(Entity, x => x.Order, x => x.Subject).InitializeFromSource();

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

            NotifyConfiguration.Instance.BatchSubscribeOnEntity <IncomeCategory>(
                s => comboCategory.ItemsList = CategoryRepository.SelfDeliveryIncomeCategories(UoW)
                );
            comboCategory.ItemsList = CategoryRepository.SelfDeliveryIncomeCategories(UoW);
            comboCategory.Binding.AddBinding(Entity, s => s.IncomeCategory, 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();

            if (!CanEdit)
            {
                table1.Sensitive = false;
                ytextviewDescription.Editable = false;
                buttonSave.Sensitive          = false;
                accessfilteredsubdivisionselectorwidget.Sensitive = false;
            }

            UpdateSubdivision();
        }
Exemplo n.º 2
0
        void ConfigureDlg()
        {
            TabName = "Расходный кассовый ордер самовывоза";

            Entity.TypeDocument = ExpenseInvoiceDocumentType.ExpenseInvoiceSelfDelivery;

            enumcomboOperation.ItemsEnum = typeof(ExpenseType);
            enumcomboOperation.Binding.AddBinding(Entity, s => s.TypeOperation, w => w.SelectedItem).InitializeFromSource();
            enumcomboOperation.Sensitive = false;
            Entity.TypeOperation         = ExpenseType.ExpenseSelfDelivery;

            var filterOrders = new OrdersFilter(UoW);

            filterOrders.SetAndRefilterAtOnce(
                x => x.RestrictStatus              = OrderStatus.WaitForPayment,
                x => x.AllowPaymentTypes           = new PaymentType[] { PaymentType.cash, PaymentType.BeveragesWorld },
                x => x.RestrictSelfDelivery        = true,
                x => x.RestrictWithoutSelfDelivery = false,
                x => x.RestrictHideService         = true,
                x => x.RestrictOnlyService         = false
                );
            yentryOrder.RepresentationModel = new OrdersVM(filterOrders);
            yentryOrder.Binding.AddBinding(Entity, x => x.Order, x => x.Subject).InitializeFromSource();

            var filterCasher = new EmployeeFilterViewModel();

            filterCasher.Status = Domain.Employees.EmployeeStatus.IsWorking;
            yentryCasher.RepresentationModel = new EmployeesVM(filterCasher);
            yentryCasher.Binding.AddBinding(Entity, s => s.Casher, w => w.Subject).InitializeFromSource();
            yentryCasher.Sensitive = false;

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

            NotifyConfiguration.Instance.BatchSubscribeOnEntity <ExpenseCategory>(
                s => comboExpense.ItemsList = CategoryRepository.ExpenseSelfDeliveryCategories(UoW)
                );
            comboExpense.ItemsList = CategoryRepository.ExpenseSelfDeliveryCategories(UoW);
            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();

            UpdateSubdivision();

            if (!CanEdit)
            {
                table1.Sensitive = false;
                accessfilteredsubdivisionselectorwidget.Sensitive = false;
                buttonSave.Sensitive          = false;
                ytextviewDescription.Editable = false;
            }
        }
Exemplo n.º 3
0
        protected void OnBtnChooseOrderClicked(object sender, EventArgs e)
        {
            var filter = new OrdersFilter(UnitOfWorkFactory.CreateWithoutRoot());

            filter.SetAndRefilterAtOnce(
                x => x.RestrictCounterparty = oldOrder.Client,
                x => x.HideStatuses         = new Enum[] { OrderStatus.WaitForPayment }
                );
            Buttons buttons = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_delete") ? Buttons.All : (Buttons.Add | Buttons.Edit);
            PermissionControlledRepresentationJournal dlg = new PermissionControlledRepresentationJournal(new OrdersVM(filter), buttons)
            {
                Mode = JournalSelectMode.Single
            };

            MyTab.TabParent.AddTab(dlg, MyTab, false);

            dlg.ObjectSelected += (s, ea) => {
                var selectedId = ea.GetSelectedIds().FirstOrDefault();
                if (selectedId == 0)
                {
                    return;
                }
                if (oldOrder.Id == selectedId)
                {
                    MessageDialogHelper.RunErrorDialog("Перенесённый заказ не может совпадать с недовезённым!");
                    OnBtnChooseOrderClicked(sender, ea);
                    return;
                }
                newOrder        = undelivery.NewOrder = UoW.GetById <Order>(selectedId);
                newOrder.Author = this.oldOrder.Author;
                SetLabelsAcordingToNewOrder();
                undelivery.NewDeliverySchedule = newOrder.DeliverySchedule;
                if ((oldOrder.PaymentType == Domain.Client.PaymentType.ByCard) &&
                    (oldOrder.OrderTotalSum == newOrder.OrderTotalSum) &&
                    MessageDialogHelper.RunQuestionDialog("Перенести на выбранный заказ Оплату по Карте?"))
                {
                    newOrder.PaymentType       = oldOrder.PaymentType;
                    newOrder.OnlineOrder       = oldOrder.OnlineOrder;
                    newOrder.PaymentByCardFrom = oldOrder.PaymentByCardFrom;
                }
            };
        }
Exemplo n.º 4
0
        public void ConfigureDlg(IUnitOfWork uow, UndeliveredOrder undelivery)
        {
            this.Sensitive = false;
            yEForUndeliveredOrder.Changed += OnUndeliveredOrderChanged;

            CanChangeProblemSource = commonServices.PermissionService.ValidateUserPresetPermission("can_change_undelivery_problem_source", commonServices.UserService.CurrentUserId);
            this.undelivery        = undelivery;
            UoW      = uow;
            oldOrder = undelivery.OldOrder;
            newOrder = undelivery.NewOrder;
            if (undelivery.Id > 0 && undelivery.InProcessAtDepartment != null)
            {
                InitialProcDepartmentName = undelivery.InProcessAtDepartment.Name;
            }
            if (undelivery.Id > 0)
            {
                foreach (GuiltyInUndelivery g in undelivery.ObservableGuilty)
                {
                    initialGuiltyList.Add(
                        new GuiltyInUndelivery {
                        Id = g.Id,
                        UndeliveredOrder = g.UndeliveredOrder,
                        GuiltySide       = g.GuiltySide,
                        GuiltyDepartment = g.GuiltyDepartment
                    }
                        );
                }
            }
            var filterOrders = new OrdersFilter(UoW);
            List <OrderStatus> hiddenStatusesList = new List <OrderStatus>();
            var grantedStatusesArray = OrderRepository.GetStatusesForOrderCancelation();

            foreach (OrderStatus status in Enum.GetValues(typeof(OrderStatus)))
            {
                if (!grantedStatusesArray.Contains(status))
                {
                    hiddenStatusesList.Add(status);
                }
            }
            filterOrders.SetAndRefilterAtOnce(x => x.HideStatuses = hiddenStatusesList.Cast <Enum>().ToArray());
            yEForUndeliveredOrder.Changed += (sender, e) => {
                oldOrder       = undelivery.OldOrder;
                lblInfo.Markup = undelivery.GetOldOrderInfo();
                if (undelivery.Id <= 0)
                {
                    undelivery.OldOrderStatus = oldOrder.OrderStatus;
                }
                routeListDoesNotExist = oldOrder != null && (undelivery.OldOrderStatus == OrderStatus.NewOrder ||
                                                             undelivery.OldOrderStatus == OrderStatus.Accepted ||
                                                             undelivery.OldOrderStatus == OrderStatus.WaitForPayment);

                guiltyInUndeliveryView.ConfigureWidget(UoW, undelivery, !routeListDoesNotExist);
                SetSensitivities();
                SetVisibilities();
                GetFines();
                RemoveItemsFromEnums();
            };
            yEForUndeliveredOrder.RepresentationModel = new OrdersVM(filterOrders);
            yEForUndeliveredOrder.Binding.AddBinding(undelivery, x => x.OldOrder, x => x.Subject).InitializeFromSource();
            yEForUndeliveredOrder.CanEditReference = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_delete");

            yDateDriverCallTime.Binding.AddBinding(undelivery, t => t.DriverCallTime, w => w.DateOrNull).InitializeFromSource();
            if (undelivery.Id <= 0)
            {
                yDateDriverCallTime.DateOrNull = DateTime.Now;
            }

            yEnumCMBDriverCallPlace.ItemsEnum = typeof(DriverCallType);
            yEnumCMBDriverCallPlace.Binding.AddBinding(undelivery, p => p.DriverCallType, w => w.SelectedItem).InitializeFromSource();

            yDateDispatcherCallTime.Binding.AddBinding(undelivery, t => t.DispatcherCallTime, w => w.DateOrNull).InitializeFromSource();
            if (undelivery.Id <= 0)
            {
                yDateDispatcherCallTime.DateOrNull = DateTime.Now;
            }

            referenceNewDeliverySchedule.ItemsQuery = DeliveryScheduleRepository.AllQuery();
            referenceNewDeliverySchedule.SetObjectDisplayFunc <DeliverySchedule>(e => e.Name);
            referenceNewDeliverySchedule.Binding.AddBinding(undelivery, s => s.NewDeliverySchedule, w => w.Subject).InitializeFromSource();
            referenceNewDeliverySchedule.Sensitive = false;

            SetLabelsAcordingToNewOrder();

            yEnumCMBStatus.ItemsEnum         = typeof(UndeliveryStatus);
            yEnumCMBStatus.SelectedItem      = undelivery.UndeliveryStatus;
            yEnumCMBStatus.EnumItemSelected += (s, e) => {
                SetSensitivities();
                undelivery.SetUndeliveryStatus((UndeliveryStatus)e.SelectedItem);
            };

            yentInProcessAtDepartment.SubjectType = typeof(Subdivision);
            yentInProcessAtDepartment.Binding.AddBinding(undelivery, d => d.InProcessAtDepartment, w => w.Subject).InitializeFromSource();
            yentInProcessAtDepartment.ChangedByUser += (s, e) => {
                undelivery.AddCommentToTheField(
                    UoW,
                    CommentedFields.Reason,
                    String.Format(
                        "сменил(а) \"в работе у отдела\" \nс \"{0}\" на \"{1}\"",
                        InitialProcDepartmentName,
                        undelivery.InProcessAtDepartment.Name
                        )
                    );
            };

            if (undelivery.Id <= 0)
            {
                yentInProcessAtDepartment.Subject = SubdivisionsRepository.GetQCDepartment(UoW);
            }

            refRegisteredBy.RepresentationModel = new EmployeesVM(UoW);
            refRegisteredBy.Binding.AddBinding(undelivery, s => s.EmployeeRegistrator, w => w.Subject).InitializeFromSource();

            yEnumCMBDriverCallPlace.EnumItemSelected += CMBSelectedItemChanged;

            txtReason.Binding.AddBinding(undelivery, u => u.Reason, w => w.Buffer.Text).InitializeFromSource();

            lblInfo.Markup = undelivery.GetOldOrderInfo();

            yenumcomboboxTransferType.ItemsEnum = typeof(TransferType);
            yenumcomboboxTransferType.Binding.AddBinding(undelivery, u => u.OrderTransferType, w => w.SelectedItemOrNull).InitializeFromSource();

            comboProblemSource.SetRenderTextFunc <UndeliveryProblemSource>(k => k.GetFullName);
            comboProblemSource.Binding.AddBinding(undelivery, u => u.ProblemSourceItems, w => w.ItemsList).InitializeFromSource();
            comboProblemSource.Binding.AddBinding(undelivery, u => u.ProblemSource, w => w.SelectedItem).InitializeFromSource();
            comboProblemSource.Sensitive = CanChangeProblemSource;

            yTreeFines.ColumnsConfig = ColumnsConfigFactory.Create <FineItem>()
                                       .AddColumn("Номер").AddTextRenderer(node => node.Fine.Id.ToString())
                                       .AddColumn("Сотудники").AddTextRenderer(node => node.Employee.ShortName)
                                       .AddColumn("Сумма штрафа").AddTextRenderer(node => CurrencyWorks.GetShortCurrencyString(node.Money))
                                       .Finish();

            yenumcomboboxTransferType.Visible = undelivery?.NewOrder != null;

            undelivery.PropertyChanged += (sender, e) => {
                if (e.PropertyName != "NewOrder")
                {
                    return;
                }

                if (undelivery.NewOrder == null)
                {
                    yenumcomboboxTransferType.Visible = false;
                    undelivery.OrderTransferType      = null;
                    return;
                }

                yenumcomboboxTransferType.Visible = true;
            };

            GetFines();
            SetVisibilities();
            SetSensitivities();
        }