Ejemplo n.º 1
0
 public SendMessageViewModel(
     IUnitOfWorkFactory unitOfWorkFactory,
     INavigationManager navigation,
     IInteractiveMessage interactive,
     ProstorSmsService prostorSmsService,
     OrderMessagesModel orderMessages,
     IValidator validator = null) : base(navigation)
 {
     this.interactive       = interactive ?? throw new ArgumentNullException(nameof(interactive));
     this.prostorSmsService = prostorSmsService ?? throw new ArgumentNullException(nameof(prostorSmsService));
     this.orderMessages     = orderMessages ?? throw new ArgumentNullException(nameof(orderMessages));
     IsModal        = true;
     Title          = "Отправка СМС";
     WindowPosition = QS.Dialog.WindowGravity.Center;
     MessageText    = orderMessages.DefaultMessage;
 }
Ejemplo n.º 2
0
        void ConfigureDlg()
        {
            AutofacScope  = MainClass.AppDIContainer.BeginLifetimeScope();
            interactive   = AutofacScope.Resolve <IInteractiveMessage>();
            navigation    = AutofacScope.Resolve <INavigationManager>();
            orderMessages = AutofacScope.Resolve <OrderMessagesModel>(new TypedParameter(typeof(WorkOrder), Entity));
            validator     = AutofacScope.Resolve <IValidator>();

            labelCreated.LabelProp = $"{Entity.CreatedDate} - {Entity.CreatedBy?.Name}";

            this.Title = String.Format(GetTitleFormat(Entity.OrderTypeClass), UoW.IsNew ? "???" : Entity.Id.ToString(), Entity.Date, Entity.Hour);

            comboStatus.ItemsList = OrderStateRepository.GetStates(UoW, Entity.OrderTypeClass);
            comboStatus.Binding.AddBinding(Entity, e => e.OrderState, w => w.SelectedItem).InitializeFromSource();

            comboMark.ItemsList = UoW.GetAll <CarBrand>();
            if (Entity.CarModel != null)
            {
                comboMark.SelectedItem = Entity.CarModel.Brand;
            }
            comboModel.Binding.AddBinding(Entity, e => e.CarModel, w => w.SelectedItem).InitializeFromSource();

            if (Entity.OrderTypeClass.IsShowAdditionalWidgets)
            {
                comboManufacturer.ShowSpecialStateNot = true;
                comboManufacturer.ItemsList           = UoW.GetAll <Manufacturer>();

                comboStock.ShowSpecialStateNot = true;
                comboStock.ItemsList           = UoW.GetAll <Warehouse>();
            }
            else
            {
                labelGlass.Visible     = labelManufacturer.Visible = comboManufacturer.Visible = labelStock.Visible =
                    comboStock.Visible = labelEurocode.Visible = entryEurocode.Visible = false;
            }

            comboYear.Model      = new ListStore(typeof(string));
            comboYear.TextColumn = 0;

            for (int year = 1980; year <= DateTime.Today.Year; year++)
            {
                comboYear.AppendText(year.ToString());
            }

            comboYear.Binding.AddBinding(Entity, e => e.CarYearText, w => w.Entry.Text).InitializeFromSource();
            comboManufacturer.Binding.AddBinding(Entity, e => e.Manufacturer, w => w.SelectedItem).InitializeFromSource();
            comboStock.Binding.AddBinding(Entity, e => e.Stock, w => w.SelectedItem).InitializeFromSource();
            entryPhone.Binding.AddBinding(Entity, e => e.Phone, w => w.Text).InitializeFromSource();
            entryEurocode.Binding.AddBinding(Entity, e => e.Eurocode, w => w.Text).InitializeFromSource();

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

            yradioInstallNone.BindValueWhenActivated                     = yradioTintingNone.BindValueWhenActivated
                                                                         = yradioArmoringNone.BindValueWhenActivated = yradioPastingNone.BindValueWhenActivated = Warranty.None;
            yradioInstall6Month.BindValueWhenActivated                   = yradioTinting6Month.BindValueWhenActivated
                                                                         = yradioArmoring6Month.BindValueWhenActivated = yradioPasting6Month.BindValueWhenActivated = Warranty.SixMonth;
            yradioInstall1Year.BindValueWhenActivated                    = yradioTinting1Year.BindValueWhenActivated
                                                                         = yradioArmoring1Year.BindValueWhenActivated = yradioPasting1Year.BindValueWhenActivated = Warranty.OneYear;
            yradioInstall2Year.BindValueWhenActivated                    = yradioTinting2Year.BindValueWhenActivated
                                                                         = yradioArmoring2Year.BindValueWhenActivated = yradioPasting2Year.BindValueWhenActivated = Warranty.TwoYear;
            yradioInstall3Year.BindValueWhenActivated                    = yradioTinting3Year.BindValueWhenActivated
                                                                         = yradioArmoring3Year.BindValueWhenActivated = yradioPasting3Year.BindValueWhenActivated = Warranty.ThreeYear;
            yradioInstallIndefinitely.BindValueWhenActivated             = yradioTintingIndefinitely.BindValueWhenActivated
                                                                         = yradioArmoringIndefinitely.BindValueWhenActivated = yradioPastingIndefinitely.BindValueWhenActivated = Warranty.Indefinitely;
            yradioInstallNoWarranty.BindValueWhenActivated               = yradioTintingNoWarranty.BindValueWhenActivated
                                                                         = yradioArmoringNoWarranty.BindValueWhenActivated = yradioPastingNoWarranty.BindValueWhenActivated = Warranty.NoWarranty;

            yradioInstallNone.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();
            yradioInstall6Month.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();
            yradioInstall1Year.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();
            yradioInstall2Year.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();
            yradioInstall3Year.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();
            yradioInstallIndefinitely.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();
            yradioInstallNoWarranty.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();

            yradioTintingNone.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();
            yradioTinting6Month.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();
            yradioTinting1Year.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();
            yradioTinting2Year.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();
            yradioTinting3Year.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();
            yradioTintingIndefinitely.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();
            yradioTintingNoWarranty.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();

            yradioArmoringNone.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();
            yradioArmoring6Month.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();
            yradioArmoring1Year.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();
            yradioArmoring2Year.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();
            yradioArmoring3Year.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();
            yradioArmoringIndefinitely.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();
            yradioArmoringNoWarranty.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();

            yradioPastingNone.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();
            yradioPasting6Month.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();
            yradioPasting1Year.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();
            yradioPasting2Year.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();
            yradioPasting3Year.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();
            yradioPastingIndefinitely.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();
            yradioPastingNoWarranty.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();

            CellRendererToggle CellPay = new CellRendererToggle();

            CellPay.Activatable = true;
            CellPay.Toggled    += onCellPayToggled;

            Gtk.CellRendererSpin CellCost = new CellRendererSpin();
            CellCost.Editable = true;
            CellCost.Digits   = 2;
            Adjustment adjCost = new Adjustment(0, 0, 100000000, 100, 1000, 0);

            CellCost.Adjustment = adjCost;
            CellCost.Edited    += OnCostSpinEdited;

            treeviewCost.AppendColumn("", CellPay, "active", 1);
            treeviewCost.AppendColumn("Название", new CellRendererText(), "text", 2);
            treeviewCost.AppendColumn("Стоимость", CellCost, RenderPriceColumn);

            setInTablePerformers();

            ((CellRendererToggle)treeviewCost.Columns[0].CellRenderers[0]).Activatable = true;

            treeviewCost.Model = ServiceListStore;
            treeviewCost.ShowAll();
            //fixme Изменить запрос
            var sql = "SELECT ser.id, ser.name, ser.price FROM services ser " +
                      "JOIN service_order_type ordt on ser.id = ordt.id_service " +
                      "JOIN order_type ord on ord.id = ordt.id_type_order " +
                      "WHERE ord.name = @order_type ORDER BY ord.name";
            var cmd = new MySqlCommand(sql, QSMain.connectionDB);

            cmd.Parameters.AddWithValue("@order_type", Entity.OrderTypeClass.Name.ToString());
            using (MySqlDataReader rdr = cmd.ExecuteReader())
            {
                while (rdr.Read())
                {
                    ServiceListStore.AppendValues(rdr.GetInt32("id"),
                                                  false,
                                                  rdr.GetString("name"),
                                                  DBWorks.GetDouble(rdr, "price", 0),
                                                  (long)-1,
                                                  false, false, false
                                                  );
                }
            }

            ytreeOtherOrders.ColumnsConfig = ColumnsConfigFactory.Create <WorkOrder>()
                                             .AddColumn("Тип").AddTextRenderer(x => x.OrderTypeClass.Name) // x.OrderType.GetEnumTitle()
                                             .AddColumn("Состояние").AddTextRenderer(x => x.OrderState != null ? x.OrderState.Name : null)
                                             .AddSetter((c, x) => c.Background = x.OrderState != null ? x.OrderState.Color : null)
                                             .AddColumn("Дата").AddTextRenderer(x => x.Date.ToShortDateString())
                                             .AddColumn("Марка").AddTextRenderer(x => x.CarModel != null ? x.CarModel.Brand.Name : null)
                                             .AddColumn("Модель").AddTextRenderer(x => x.CarModel != null ? x.CarModel.Name : null)
                                             .AddColumn("Еврокод").AddTextRenderer(x => x.Eurocode)
                                             .AddColumn("Производитель").AddTextRenderer(x => x.Manufacturer != null ? x.Manufacturer.Name : null)
                                             .AddColumn("Сумма").AddTextRenderer(x => x.Pays.Sum(p => p.Cost).ToString("C"))
                                             .AddColumn("Комментарий").AddTextRenderer(x => x.Comment)
                                             .AddColumn("Номер").AddTextRenderer(x => x.Id.ToString())
                                             .Finish();

            ytreeEuroCode.ColumnsConfig = ColumnsConfigFactory.Create <StoreItem>()
                                          .AddColumn("Еврокод").AddTextRenderer(x => x.EuroCode)
                                          .AddColumn("Производитель").AddTextRenderer(x => x.Manufacturer.Name)
                                          .AddColumn("Количество").AddNumericRenderer(x => x.Amount)
                                          .AddColumn("Цена").AddNumericRenderer(x => x.Cost)
                                          .Finish();

            buttonPrint.Sensitive    = !Entity.OrderTypeClass.IsOtherType;
            buttonSMSHistory.Visible = orderMessages.CountSentMessages() > 0;
            TestCanSave();
            SetEuroCode();

            Entity.PropertyChanged += Entity_PropertyChanged;
        }