private void AddPhoneRow(Phone newPhone) { datatablePhones.NRows = RowNum + 1; var phoneDataCombo = new yListComboBox(); phoneDataCombo.WidthRequest = 100; phoneDataCombo.SetRenderTextFunc((PhoneType x) => x.Name); phoneDataCombo.ItemsList = phoneTypes; phoneDataCombo.Binding.AddBinding(newPhone, e => e.PhoneType, w => w.SelectedItem).InitializeFromSource(); datatablePhones.Attach(phoneDataCombo, (uint)0, (uint)1, RowNum, RowNum + 1, AttachOptions.Fill | AttachOptions.Expand, (AttachOptions)0, (uint)0, (uint)0); Gtk.Label textPhoneLabel = new Gtk.Label("+7"); datatablePhones.Attach(textPhoneLabel, (uint)1, (uint)2, RowNum, RowNum + 1, (AttachOptions)0, (AttachOptions)0, (uint)0, (uint)0); var phoneDataEntry = new yValidatedEntry(); phoneDataEntry.ValidationMode = ValidationType.phone; phoneDataEntry.Tag = newPhone; phoneDataEntry.WidthChars = 19; phoneDataEntry.Binding.AddBinding(newPhone, e => e.Number, w => w.Text).InitializeFromSource(); datatablePhones.Attach(phoneDataEntry, (uint)2, (uint)3, RowNum, RowNum + 1, AttachOptions.Expand | AttachOptions.Fill, (AttachOptions)0, (uint)0, (uint)0); HandsetView handset = new HandsetView(newPhone.DigitsNumber); datatablePhones.Attach(handset, (uint)3, (uint)4, RowNum, RowNum + 1, (AttachOptions)0, (AttachOptions)0, (uint)0, (uint)0); Gtk.Label textAdditionalLabel = new Gtk.Label("доб."); datatablePhones.Attach(textAdditionalLabel, (uint)4, (uint)5, RowNum, RowNum + 1, (AttachOptions)0, (AttachOptions)0, (uint)0, (uint)0); var additionalDataEntry = new yEntry(); additionalDataEntry.WidthRequest = 50; additionalDataEntry.MaxLength = 10; additionalDataEntry.Binding.AddBinding(newPhone, e => e.Additional, w => w.Text).InitializeFromSource(); datatablePhones.Attach(additionalDataEntry, (uint)5, (uint)6, RowNum, RowNum + 1, AttachOptions.Fill, (AttachOptions)0, (uint)0, (uint)0); Gtk.Label labelName = new Gtk.Label("имя:"); datatablePhones.Attach(labelName, (uint)6, (uint)7, RowNum, RowNum + 1, (AttachOptions)0, (AttachOptions)0, (uint)0, (uint)0); var entryName = new yEntry(); //entryName.WidthRequest = 50; entryName.MaxLength = 150; entryName.Binding.AddBinding(newPhone, e => e.Name, w => w.Text).InitializeFromSource(); datatablePhones.Attach(entryName, (uint)7, (uint)8, RowNum, RowNum + 1, AttachOptions.Expand | AttachOptions.Fill, (AttachOptions)0, (uint)0, (uint)0); Gtk.Button deleteButton = new Gtk.Button(); Gtk.Image image = new Gtk.Image(); image.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-delete", global::Gtk.IconSize.Menu); deleteButton.Image = image; deleteButton.Clicked += OnButtonDeleteClicked; datatablePhones.Attach(deleteButton, (uint)8, (uint)9, RowNum, RowNum + 1, (AttachOptions)0, (AttachOptions)0, (uint)0, (uint)0); datatablePhones.ShowAll(); RowNum++; }
public void ConfigureDlg() { Entity.ObservableAddresses.ElementAdded += ObservableAddresses_ElementAdded; Entity.ObservableAddresses.ElementRemoved += ObservableAddresses_ElementRemoved; Entity.ObservableAddresses.ElementChanged += ObservableAddresses_ElementChanged;; entityviewmodelentryCar.SetEntityAutocompleteSelectorFactory( new DefaultEntityAutocompleteSelectorFactory <Car, CarJournalViewModel, CarJournalFilterViewModel>(ServicesConfig.CommonServices)); entityviewmodelentryCar.Binding.AddBinding(Entity, e => e.Car, w => w.Subject).InitializeFromSource(); entityviewmodelentryCar.CompletionPopupSetWidth(false); entityviewmodelentryCar.Sensitive = logisticanEditing; var filterDriver = new EmployeeRepresentationFilterViewModel(); filterDriver.SetAndRefilterAtOnce( x => x.RestrictCategory = EmployeeCategory.driver, x => x.Status = EmployeeStatus.IsWorking ); referenceDriver.RepresentationModel = new EmployeesVM(filterDriver); referenceDriver.Binding.AddBinding(Entity, rl => rl.Driver, widget => widget.Subject).InitializeFromSource(); referenceDriver.Sensitive = logisticanEditing; var filterForwarder = new EmployeeRepresentationFilterViewModel(); filterForwarder.SetAndRefilterAtOnce( x => x.RestrictCategory = EmployeeCategory.forwarder, x => x.Status = EmployeeStatus.IsWorking ); referenceForwarder.RepresentationModel = new EmployeesVM(filterForwarder); referenceForwarder.Binding.AddBinding(Entity, rl => rl.Forwarder, widget => widget.Subject).InitializeFromSource(); referenceForwarder.Sensitive = logisticanEditing; referenceForwarder.Changed += ReferenceForwarder_Changed; referenceLogistican.RepresentationModel = new EmployeesVM(); referenceLogistican.Binding.AddBinding(Entity, rl => rl.Logistician, widget => widget.Subject).InitializeFromSource(); referenceLogistican.Sensitive = logisticanEditing; speccomboShift.ItemsList = _deliveryShiftRepository.ActiveShifts(UoW); speccomboShift.Binding.AddBinding(Entity, rl => rl.Shift, widget => widget.SelectedItem).InitializeFromSource(); speccomboShift.Sensitive = logisticanEditing; datePickerDate.Binding.AddBinding(Entity, rl => rl.Date, widget => widget.Date).InitializeFromSource(); datePickerDate.Sensitive = logisticanEditing; ylabelLastTimeCall.Binding.AddFuncBinding(Entity, e => GetLastCallTime(e.LastCallTime), w => w.LabelProp).InitializeFromSource(); yspinActualDistance.Sensitive = allEditing; buttonMadeCall.Sensitive = allEditing; buttonRetriveEnRoute.Sensitive = Entity.Status == RouteListStatus.OnClosing && isUserLogist && ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_retrieve_routelist_en_route"); buttonNewFine.Sensitive = allEditing; buttonRefresh.Sensitive = allEditing; //Заполняем иконки var ass = Assembly.GetAssembly(typeof(MainClass)); statusIcons.Add(RouteListItemStatus.EnRoute, new Gdk.Pixbuf(ass, "Vodovoz.icons.status.car.png")); statusIcons.Add(RouteListItemStatus.Completed, new Gdk.Pixbuf(ass, "Vodovoz.icons.status.face-smile-grin.png")); statusIcons.Add(RouteListItemStatus.Overdue, new Gdk.Pixbuf(ass, "Vodovoz.icons.status.face-angry.png")); statusIcons.Add(RouteListItemStatus.Canceled, new Gdk.Pixbuf(ass, "Vodovoz.icons.status.face-crying.png")); statusIcons.Add(RouteListItemStatus.Transfered, new Gdk.Pixbuf(ass, "Vodovoz.icons.status.face-uncertain.png")); ytreeviewAddresses.ColumnsConfig = ColumnsConfigFactory.Create <RouteListKeepingItemNode>() .AddColumn("№ п/п").AddNumericRenderer(x => x.RouteListItem.IndexInRoute + 1) .AddColumn("Заказ") .AddTextRenderer(node => node.RouteListItem.Order.Id.ToString()) .AddColumn("Адрес") .AddTextRenderer(node => node.RouteListItem.Order.DeliveryPoint == null ? "Требуется точка доставки" : node.RouteListItem.Order.DeliveryPoint.ShortAddress) .AddColumn("Время") .AddTextRenderer(node => node.RouteListItem.Order.DeliverySchedule == null ? "" : node.RouteListItem.Order.DeliverySchedule.Name) .AddColumn("Статус") .AddPixbufRenderer(x => statusIcons[x.Status]) .AddEnumRenderer(node => node.Status, excludeItems: new Enum[] { RouteListItemStatus.Transfered }) .AddSetter((c, n) => c.Editable = allEditing && n.Status != RouteListItemStatus.Transfered) .AddColumn("Отгрузка") .AddNumericRenderer(node => node.RouteListItem.Order.OrderItems .Where(b => b.Nomenclature.Category == NomenclatureCategory.water && b.Nomenclature.TareVolume == TareVolume.Vol19L) .Sum(b => b.Count)) .AddColumn("Возврат тары") .AddNumericRenderer(node => node.RouteListItem.Order.BottlesReturn) .AddColumn("Сдали по факту") .AddNumericRenderer(node => node.RouteListItem.DriverBottlesReturned) .AddColumn("Статус изменен") .AddTextRenderer(node => node.LastUpdate) .AddColumn("Комментарий") .AddTextRenderer(node => node.Comment) .Editable(allEditing) .AddColumn("Переносы") .AddTextRenderer(node => node.Transferred) .RowCells() .AddSetter <CellRenderer>((cell, node) => cell.CellBackgroundGdk = node.RowColor) .Finish(); ytreeviewAddresses.Selection.Mode = SelectionMode.Multiple; ytreeviewAddresses.Selection.Changed += OnSelectionChanged; ytreeviewAddresses.Sensitive = allEditing; ytreeviewAddresses.RowActivated += YtreeviewAddresses_RowActivated; //Point! //Заполняем телефоны if (Entity.Driver != null && Entity.Driver.Phones.Count > 0) { uint rows = Convert.ToUInt32(Entity.Driver.Phones.Count + 1); PhonesTable1.Resize(rows, 2); Label label = new Label(); label.LabelProp = $"{Entity.Driver.FullName}"; PhonesTable1.Attach(label, 0, 2, 0, 1); for (uint i = 1; i < rows; i++) { Label l = new Label(); l.LabelProp = "+7 " + Entity.Driver.Phones[Convert.ToInt32(i - 1)].Number; l.Selectable = true; PhonesTable1.Attach(l, 0, 1, i, i + 1); HandsetView h = new HandsetView(Entity.Driver.Phones[Convert.ToInt32(i - 1)].DigitsNumber); PhonesTable1.Attach(h, 1, 2, i, i + 1); } } if (Entity.Forwarder != null && Entity.Forwarder.Phones.Count > 0) { uint rows = Convert.ToUInt32(Entity.Forwarder.Phones.Count + 1); PhonesTable2.Resize(rows, 2); Label label = new Label(); label.LabelProp = $"{Entity.Forwarder.FullName}"; PhonesTable2.Attach(label, 0, 2, 0, 1); for (uint i = 1; i < rows; i++) { Label l = new Label(); l.LabelProp = "+7 " + Entity.Forwarder.Phones[Convert.ToInt32(i - 1)].Number; l.Selectable = true; PhonesTable2.Attach(l, 0, 1, i, i + 1); HandsetView h = new HandsetView(Entity.Forwarder.Phones[Convert.ToInt32(i - 1)].DigitsNumber); PhonesTable2.Attach(h, 1, 2, i, i + 1); } } //Телефон PhonesTable1.ShowAll(); PhonesTable2.ShowAll(); phoneLogistican.MangoManager = phoneDriver.MangoManager = phoneForwarder.MangoManager = MainClass.MainWin.MangoManager; phoneLogistican.Binding.AddBinding(Entity, e => e.Logistician, w => w.Employee).InitializeFromSource(); phoneDriver.Binding.AddBinding(Entity, e => e.Driver, w => w.Employee).InitializeFromSource(); phoneForwarder.Binding.AddBinding(Entity, e => e.Forwarder, w => w.Employee).InitializeFromSource(); //Заполняем информацию о бутылях UpdateBottlesSummaryInfo(); UpdateNodes(); }
private void RefreshData() { if (_counterparty == null) { buttonSaveComment.Sensitive = false; return; } labelName.Text = _counterparty.FullName; SetupPersonalManagers(); textviewComment.Buffer.Text = _counterparty.Comment; var latestOrder = _orderRepository.GetLatestCompleteOrderForCounterparty(InfoProvider.UoW, _counterparty); if (latestOrder != null) { var daysFromLastOrder = (DateTime.Today - latestOrder.DeliveryDate.Value).Days; labelLatestOrderDate.Text = string.Format( "{0} ({1} {2} назад)", latestOrder.DeliveryDate.Value.ToShortDateString(), daysFromLastOrder, NumberToTextRus.Case(daysFromLastOrder, "день", "дня", "дней") ); } else { labelLatestOrderDate.Text = "(Выполненных заказов нет)"; } var currentOrders = _orderRepository.GetCurrentOrders(InfoProvider.UoW, _counterparty); ytreeCurrentOrders.SetItemsSource <Order>(currentOrders); vboxCurrentOrders.Visible = currentOrders.Count > 0; foreach (var child in PhonesTable.Children) { PhonesTable.Remove(child); child.Destroy(); } uint rowsCount = Convert.ToUInt32(_counterparty.Phones.Count) + 1; PhonesTable.Resize(rowsCount, 2); for (uint row = 0; row < rowsCount - 1; row++) { Label label = new Label(); label.Selectable = true; label.Markup = $"{_counterparty.Phones[Convert.ToInt32(row)].LongText}"; HandsetView handsetView = new HandsetView(_counterparty.Phones[Convert.ToInt32(row)].DigitsNumber); PhonesTable.Attach(label, 0, 1, row, row + 1); PhonesTable.Attach(handsetView, 1, 2, row, row + 1); } Label labelAddPhone = new Label() { LabelProp = "Щёлкните чтобы\n добавить телефон-->" }; PhonesTable.Attach(labelAddPhone, 0, 1, rowsCount - 1, rowsCount); Image addIcon = new Image(); addIcon.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-add", IconSize.Menu); Button btn = new Button(); btn.Image = addIcon; btn.Clicked += OnBtnAddPhoneClicked; PhonesTable.Attach(btn, 1, 2, rowsCount - 1, rowsCount); PhonesTable.ShowAll(); btn.Sensitive = buttonSaveComment.Sensitive = _counterpartyPermissionResult.CanUpdate && _counterparty.Id != 0; }
public void Refresh() { DeliveryPoint = (InfoProvider as IDeliveryPointInfoProvider)?.DeliveryPoint; if (DeliveryPoint == null) { buttonSaveComment.Sensitive = false; return; } buttonSaveComment.Sensitive = true; labelAddress.Text = DeliveryPoint.CompiledAddress; foreach (var child in PhonesTable.Children) { PhonesTable.Remove(child); child.Destroy(); } uint rowsCount = Convert.ToUInt32(DeliveryPoint.Phones.Count) + 1; PhonesTable.Resize(rowsCount, 2); for (uint row = 0; row < rowsCount - 1; row++) { Label label = new Label(); label.Selectable = true; label.Markup = $"{DeliveryPoint.Phones[Convert.ToInt32(row)].LongText}"; HandsetView handsetView = new HandsetView(DeliveryPoint.Phones[Convert.ToInt32(row)].DigitsNumber); PhonesTable.Attach(label, 0, 1, row, row + 1); PhonesTable.Attach(handsetView, 1, 2, row, row + 1); } Label labelAddPhone = new Label() { LabelProp = "Щёлкните чтоб\n добавить телефон-->" }; PhonesTable.Attach(labelAddPhone, 0, 1, rowsCount - 1, rowsCount); Image addIcon = new Image(); addIcon.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-add", IconSize.Menu); Button btn = new Button(); btn.Image = addIcon; btn.Clicked += OnBtnAddPhoneClicked; PhonesTable.Attach(btn, 1, 2, rowsCount - 1, rowsCount); PhonesTable.ShowAll(); var bottlesAtDeliveryPoint = BottlesRepository.GetBottlesAtDeliveryPoint(InfoProvider.UoW, DeliveryPoint); var bottlesAvgDeliveryPoint = DeliveryPointRepository.GetAvgBottlesOrdered(InfoProvider.UoW, DeliveryPoint, 5); lblBottlesQty.LabelProp = $"{bottlesAtDeliveryPoint} шт. (сред. зак.: {bottlesAvgDeliveryPoint:G3})"; var bottlesAtCounterparty = BottlesRepository.GetBottlesAtCounterparty(InfoProvider.UoW, DeliveryPoint.Counterparty); debtByClientLabel.LabelProp = $"{bottlesAtCounterparty} шт."; var depositsAtDeliveryPoint = DepositRepository.GetDepositsAtDeliveryPoint(InfoProvider.UoW, DeliveryPoint, null); labelDeposits.LabelProp = CurrencyWorks.GetShortCurrencyString(depositsAtDeliveryPoint); textviewComment.Buffer.Text = DeliveryPoint.Comment; var currentOrders = OrderRepository.GetLatestOrdersForDeliveryPoint(InfoProvider.UoW, DeliveryPoint, 5); ytreeLastOrders.SetItemsSource <Order>(currentOrders); vboxLastOrders.Visible = currentOrders.Any(); table2.ShowAll(); }
private void DrawNewRow(Phone newPhone) { if (hBoxList?.FirstOrDefault() == null) { hBoxList = new List <HBox>(); } HBox hBox = new HBox(); var phoneDataCombo = new yListComboBox(); phoneDataCombo.WidthRequest = 100; phoneDataCombo.SetRenderTextFunc((PhoneType x) => x.Name); phoneDataCombo.ItemsList = viewModel.PhoneTypes; phoneDataCombo.Binding.AddBinding(newPhone, e => e.PhoneType, w => w.SelectedItem).InitializeFromSource(); phoneDataCombo.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.Sensitive).InitializeFromSource(); hBox.Add(phoneDataCombo); hBox.SetChildPacking(phoneDataCombo, true, true, 0, PackType.Start); Label textPhoneLabel = new Label("+7"); hBox.Add(textPhoneLabel); hBox.SetChildPacking(textPhoneLabel, false, false, 0, PackType.Start); var phoneDataEntry = new yValidatedEntry(); phoneDataEntry.ValidationMode = ValidationType.phone; phoneDataEntry.Tag = newPhone; phoneDataEntry.WidthRequest = 125; phoneDataEntry.WidthChars = 19; phoneDataEntry.Binding.AddBinding(newPhone, e => e.Number, w => w.Text).InitializeFromSource(); phoneDataEntry.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.IsEditable).InitializeFromSource(); hBox.Add(phoneDataEntry); hBox.SetChildPacking(phoneDataEntry, false, false, 0, PackType.Start); HandsetView handset = new HandsetView(newPhone.DigitsNumber); hBox.Add(handset); hBox.SetChildPacking(handset, false, false, 0, PackType.Start); var textAdditionalLabel = new Gtk.Label("доб."); hBox.Add(textAdditionalLabel); hBox.SetChildPacking(textAdditionalLabel, false, false, 0, PackType.Start); var additionalDataEntry = new yEntry(); additionalDataEntry.WidthRequest = 50; additionalDataEntry.MaxLength = 10; additionalDataEntry.Binding.AddBinding(newPhone, e => e.Additional, w => w.Text).InitializeFromSource(); additionalDataEntry.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.IsEditable).InitializeFromSource(); hBox.Add(additionalDataEntry); hBox.SetChildPacking(additionalDataEntry, false, false, 0, PackType.Start); var labelName = new Label("имя:"); hBox.Add(labelName); hBox.SetChildPacking(labelName, false, false, 0, PackType.Start); var entryName = new yEntry(); entryName.MaxLength = 150; entryName.Binding.AddBinding(newPhone, e => e.Name, w => w.Text).InitializeFromSource(); entryName.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.IsEditable).InitializeFromSource(); hBox.Add(entryName); hBox.SetChildPacking(entryName, true, true, 0, PackType.Start); yButton deleteButton = new yButton(); Image image = new Image(); image.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-delete", IconSize.Menu); deleteButton.Image = image; deleteButton.Clicked += (sender, e) => viewModel.DeleteItemCommand.Execute(hBox.Data["phone"] as Phone); deleteButton.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.Sensitive).InitializeFromSource(); hBox.Add(deleteButton); hBox.SetChildPacking(deleteButton, false, false, 0, PackType.Start); hBox.Data.Add("phone", newPhone); //Для свзяки виджета и телефона hBox.ShowAll(); vboxPhones.Add(hBox); vboxPhones.ShowAll(); hBoxList.Add(hBox); }