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(); }
protected void RefreshSpinButtons() { int bottlesMax = BottlesRepository.GetBottlesAtDeliveryPoint(UoWGeneric, Entity.FromDeliveryPoint, Entity.TimeStamp); decimal depositsBottlesMax = DepositRepository.GetDepositsAtDeliveryPoint(UoWGeneric, Entity.FromDeliveryPoint, DepositType.Bottles, Entity.TimeStamp); decimal depositsEquipmentMax = DepositRepository.GetDepositsAtDeliveryPoint(UoWGeneric, Entity.FromDeliveryPoint, DepositType.Equipment, Entity.TimeStamp); if (Entity.OutBottlesOperation != null) { spinBottles.Value = Entity.OutBottlesOperation.Returned != 0 ? Entity.OutBottlesOperation.Returned : (Entity.OutBottlesOperation.Delivered * -1); } else { spinBottles.Value = 0; } if (Entity.OutBottlesDepositOperation != null) { spinDepositsBottles.Value = (double)(Entity.OutBottlesDepositOperation.RefundDeposit != 0 ? Entity.OutBottlesDepositOperation.RefundDeposit : (Entity.OutBottlesDepositOperation.ReceivedDeposit * -1)); } else { spinDepositsBottles.Value = 0; } if (Entity.OutEquipmentDepositOperation != null) { spinDepositsEquipment.Value = (double)(Entity.OutEquipmentDepositOperation.RefundDeposit != 0 ? Entity.OutEquipmentDepositOperation.RefundDeposit : (Entity.OutEquipmentDepositOperation.ReceivedDeposit * -1)); } else { spinDepositsEquipment.Value = 0; } if (Math.Abs(bottlesMax) < Math.Abs(spinBottles.Value) || Math.Abs(depositsBottlesMax) < Math.Abs((decimal)spinDepositsBottles.Value) || Math.Abs(depositsEquipmentMax) < Math.Abs((decimal)spinDepositsEquipment.Value)) { checkbuttonLock.Active = false; } spinBottles.Sensitive = referenceDeliveryPointFrom.Subject != null; labelBottlesMax.LabelProp = bottlesMax.ToString(); spinDepositsBottles.Sensitive = referenceDeliveryPointFrom.Subject != null; labelDepositsBottlesMax.LabelProp = depositsBottlesMax.ToString(); spinDepositsEquipment.Sensitive = referenceDeliveryPointFrom.Subject != null; labelDepositsEquipmentMax.LabelProp = depositsEquipmentMax.ToString(); if (checkbuttonLock.Active) { spinBottles.Adjustment.Upper = bottlesMax > 0 ? bottlesMax : 0; spinBottles.Adjustment.Lower = bottlesMax < 0 ? bottlesMax : 0; spinDepositsBottles.Adjustment.Upper = (double)(depositsBottlesMax > 0 ? depositsBottlesMax : 0); spinDepositsBottles.Adjustment.Lower = (double)(depositsBottlesMax < 0 ? depositsBottlesMax : 0); spinDepositsEquipment.Adjustment.Upper = (double)(depositsEquipmentMax > 0 ? depositsEquipmentMax : 0); spinDepositsEquipment.Adjustment.Lower = (double)(depositsEquipmentMax < 0 ? depositsEquipmentMax : 0); } else { spinBottles.Adjustment.Upper = 1000; spinBottles.Adjustment.Lower = -1000; spinDepositsBottles.Adjustment.Upper = 100000; spinDepositsBottles.Adjustment.Lower = -100000; spinDepositsEquipment.Adjustment.Upper = 100000; spinDepositsEquipment.Adjustment.Lower = -100000; } }