public void SetSelectedPaymentType(BasePaymentType paymentType) { bool includePrinterPayments = false; DeviceManagerBase dManager = BusinessDomain.DeviceManager; if (dManager.CashReceiptPrinterConnected && dManager.CashReceiptPrinterDriver.SupportedCommands.Contains(DeviceCommands.GetPaymentName)) { includePrinterPayments = true; } List <KeyValuePair <long, string> > paymentPairs = new List <KeyValuePair <long, string> > (); foreach (PaymentType paymentMethod in PaymentType.GetAll()) { string paymentName; if (includePrinterPayments) { dManager.CashReceiptPrinterDriver.GetPaymentName(paymentMethod.BaseType, out paymentName); paymentName = string.IsNullOrEmpty(paymentName) ? paymentMethod.Name : string.Format("{0} ({1})", paymentMethod.Name, paymentName); } else { paymentName = paymentMethod.Name; } paymentPairs.Add(new KeyValuePair <long, string> (paymentMethod.Id, paymentName)); } cboPaymentMethod.Load(paymentPairs, "Key", "Value", (long)paymentType); }
private void InitializeEntries() { txtNumber.Text = document.NumberString; List <KeyValuePair <long, string> > paymentPairs = PaymentType.GetAll().Select(p => new KeyValuePair <long, string> (p.Id, p.Name)).ToList(); if (IsEditable) { cboPaymentType.Load(paymentPairs, "Key", "Value", BusinessDomain.AppConfiguration.LastDocumentPaymentMethodId); Operation operation = operations.Last(); cbeRecipient.Load(DocumentBase.GetRecipientSuggestions(operation.PartnerId), null, null); cbeEGN.Load(DocumentBase.GetEGNSuggestions(operation.PartnerId), null, null); cbeProvider.Load(DocumentBase.GetProviderSuggestions(), null, null); cbeReason.Load(DocumentBase.GetReasonSuggestions(), null, null); cbeDescription.Load(DocumentBase.GetDescriptionSuggestions(), null, null); cbeLocation.Load(DocumentBase.GetLocationSuggestions(), null, null); txtDate.Text = BusinessDomain.GetFormattedDate(BusinessDomain.Today); txtTaxDate.Text = BusinessDomain.GetFormattedDate(operation.Date); Partner partner = Partner.GetById(partnerId); if (partner != null) { lblPartnerValue.SetText(partner.Name); } txtNumber.GrabFocus(); } else { txtRefNumber.Text = document.ReferenceNumberString; txtRefDate.Text = document.ReferenceDateString; cboPaymentType.Load(paymentPairs, "Key", "Value", document.PaymentMethod); cbeRecipient.Entry.Text = document.Recipient; cbeEGN.Entry.Text = document.RecipientEGN; cbeProvider.Entry.Text = document.Provider; cbeReason.Entry.Text = document.Reason; cbeDescription.Entry.Text = document.Description; lblPartnerValue.SetText(document.RecipientName); cbeLocation.Entry.Text = document.Location; txtDate.Text = document.DateString; txtTaxDate.Text = document.TaxDateString; hboPartner.Sensitive = false; fraMain.Sensitive = false; fraAdditional.Sensitive = false; } }
private void InitializeGrid() { try { if (initialized) { return; } ColumnController cc = new ColumnController(); supportsSumming = false; for (int i = 0; i < dataQueryResult.Result.Columns.Count; i++) { DbField field = dataQueryResult.Columns [i].Field; DataType fieldType = ReportProvider.GetDataFieldType(field); string columnName = dataQueryResult.Result.Columns [i]; string columnHeaderText = ReportProvider.GetReportFieldColumnName(dataQueryResult, i); CellText cell; bool thisColumnSummable = false; switch (fieldType) { case DataType.Date: cell = new CellTextDate(columnName); break; case DataType.DateTime: cell = new CellTextDateTime(columnName); break; case DataType.Quantity: cell = new CellTextQuantity(columnName); thisColumnSummable = true; break; case DataType.CurrencyIn: cell = new CellTextCurrency(columnName, PriceType.Purchase); thisColumnSummable = true; break; case DataType.CurrencyOut: cell = new CellTextCurrency(columnName); thisColumnSummable = true; break; case DataType.Currency: cell = new CellTextCurrency(columnName, PriceType.Unknown); thisColumnSummable = true; break; case DataType.Percent: cell = new CellTextDouble(columnName) { FixedFaction = BusinessDomain.AppConfiguration.PercentPrecision }; break; case DataType.Id: case DataType.UserId: cell = new CellTextNumber(columnName); break; case DataType.DocumentNumber: cell = new CellTextNumber(columnName) { FixedDigits = BusinessDomain.AppConfiguration.DocumentNumberLength }; break; case DataType.OperationType: cell = new CellTextLookup <int> (columnName); CellTextLookup <int> cellOperationType = (CellTextLookup <int>)cell; foreach (OperationType operationType in Enum.GetValues(typeof(OperationType))) { if (operationType > 0) { cellOperationType.Lookup.Add((int)operationType, Translator.GetOperationTypeName(operationType)); } } break; case DataType.DocumentType: cell = new CellTextLookup <int> (columnName).Load(DocumentBase.GetAllDocumentTypes()); break; case DataType.BasePaymentType: cell = new CellTextLookup <int> (columnName).Load(PaymentType.GetAllBaseTypePairs()); break; case DataType.PaymentType: cell = new CellTextLookup <long> (columnName); CellTextLookup <long> cellPaymentType = (CellTextLookup <long>)cell; foreach (PaymentType paymentType in PaymentType.GetAll()) { cellPaymentType.Lookup.Add(paymentType.Id, paymentType.Name); } break; case DataType.PriceGroupType: cell = new CellTextLookup <int> (columnName).Load(Currency.GetAllPriceGroups()); break; case DataType.PartnerType: cell = new CellTextLookup <int> (columnName).Load(Partner.GetAllTypes()); break; case DataType.ItemType: cell = new CellTextLookup <int> (columnName).Load(Item.GetAllTypes()); break; case DataType.UserAccessLevel: cell = new CellTextLookup <int> (columnName).Load(User.GetAllAccessLevels()); break; case DataType.TurnoverType: cell = new CellTextLookup <int> (columnName).Load(CashBookEntry.GetAllTurnoverTypes()); break; case DataType.TurnoverDirection: cell = new CellTextLookup <int> (columnName).Load(CashBookEntry.GetAllTurnoverDirections()); break; case DataType.TaxGroupCode: cell = new CellTextLookup <string> (columnName).Load(VATGroup.AllCodes); break; case DataType.Sign: cell = new CellTextLookup <int> (columnName).Load(Payment.GetAllSignTypes()); break; case DataType.PaymentMode: cell = new CellTextLookup <int> (columnName).Load(Payment.GetAllModeTypes()); break; case DataType.Text: cell = new CellText(columnName); break; default: continue; } Column col = new Column(columnHeaderText, cell, 0.1, columnName) { MinWidth = 100, Visible = !skip.Contains(field) && CheckColumnVisible(dataQueryResult, i) }; cc.Add(col); supportsSumming |= thisColumnSummable && col.Visible; } grid.ColumnController = cc; // Prevent the grid from reapplying the old sort grid.Model = null; grid.Model = model; grid.AllowSelect = true; grid.AllowMultipleSelect = true; grid.CellsFucusable = true; grid.RulesHint = true; grid.SortColumnsHint = true; grid.RowActivated -= grid_RowActivated; grid.RowActivated += grid_RowActivated; initialized = true; } finally { EventHandler onInitialized = Initialized; if (onInitialized != null) { onInitialized(this, EventArgs.Empty); } } }
public void RefreshGrid(bool?amountEdited = null) { for (int i = tblPayments.Children.Length - 1; i >= 0; i--) { Widget child = tblPayments.Children [i]; tblPayments.Remove(child); child.Destroy(); } if (payments.Count > 3) { scwPayments.HeightRequest = 100; scwPayments.VscrollbarPolicy = PolicyType.Automatic; } else { scwPayments.HeightRequest = -1; scwPayments.VscrollbarPolicy = PolicyType.Never; } uint rows = 0; foreach (Payment payment in payments) { if (ReferenceEquals(selectedPayment, payment)) { cboSelectedType = new ComboBox(); cboSelectedType.Load(PaymentType.GetAll(), "Id", "Name", payment.Type.Id); tblPayments.Attach(cboSelectedType, 0, 1, rows, rows + 1, AttachOptions.Fill | AttachOptions.Expand, 0, 0, 1); cboSelectedType.Changed += cboSelectedType_Changed; txtSelectedAmount = new Entry { Text = Currency.ToEditString(payment.Quantity, priceType), WidthRequest = 100, Xalign = 1f }; txtSelectedAmount.Changed += OnSelectedValueChanged; tblPayments.Attach(txtSelectedAmount, 1, 2, rows, rows + 1, AttachOptions.Fill, AttachOptions.Fill, 0, 1); if (amountEdited == true) { txtSelectedAmount.GrabFocus(); } if (amountEdited == false) { cboSelectedType.GrabFocus(); } } else { Label lblType = new Label(payment.Type.Name) { Xalign = 0f, Ellipsize = EllipsizeMode.End }; Button btnType = new Button(lblType) { Relief = ReliefStyle.None }; btnType.Data.Add("Payment", payment); btnType.Clicked += btnEditType_Clicked; tblPayments.Attach(btnType, 0, 1, rows, rows + 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 1); Label lblAmount = new Label(Currency.ToString(payment.Quantity, priceType)) { Xalign = 1f }; Button btnAmount = new Button(lblAmount) { Relief = ReliefStyle.None, WidthRequest = 100 }; btnAmount.Data.Add("Payment", payment); btnAmount.Clicked += btnEditAmount_Clicked; tblPayments.Attach(btnAmount, 1, 2, rows, rows + 1, AttachOptions.Fill, AttachOptions.Fill, 0, 1); } Button btnDelete = new Button(FormHelper.LoadImage("Icons.Delete16.png")); btnDelete.Data.Add("Payment", payment); btnDelete.Clicked += btnDelete_Clicked; tblPayments.Attach(btnDelete, tblPayments.NColumns - 1, tblPayments.NColumns, rows, rows + 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 1); rows++; } tblPayments.ShowAll(); if (payments.Count > 0) { lblPayments.Visible = true; lblPayments.HeightRequest = -1; frmPayments.ShadowType = ShadowType.EtchedIn; algPayments.LeftPadding = 4; algPayments.RightPadding = 4; } else { lblPayments.Visible = false; lblPayments.HeightRequest = 1; frmPayments.ShadowType = ShadowType.None; algPayments.LeftPadding = 0; algPayments.RightPadding = 0; } RefreshChooseMoneyPanel(); }