private void InitializeSecondGrid () { if (secondGrid == null) { secondGrid = new ListView { Name = "secondGrid" }; ScrolledWindow sWindow = new ScrolledWindow { HscrollbarPolicy = PolicyType.Automatic, VscrollbarPolicy = PolicyType.Automatic }; sWindow.Add (secondGrid); algSecondGrid.Add (sWindow); sWindow.Show (); secondGrid.Show (); } ColumnController cc = new ColumnController (); CellText ct = new CellText ("ItemName"); colSecondItem = new Column (Translator.GetString ("Item"), ct, 1); cc.Add (colSecondItem); CellTextQuantity ctq = new CellTextQuantity ("Quantity"); colSecondQuantity = new Column (Translator.GetString ("Qtty"), ctq, 0.1) { MinWidth = 70 }; cc.Add (colSecondQuantity); if (!BusinessDomain.LoggedUser.HideItemsPurchasePrice) { CellTextCurrency ctc = new CellTextCurrency ("PriceIn", PriceType.Purchase); colSecondPurchaseValue = new Column (Translator.GetString ("Purchase price"), ctc, 0.1) {MinWidth = 70}; cc.Add (colSecondPurchaseValue); } if (BusinessDomain.AppConfiguration.AllowItemLotName) { ct = new CellText ("Lot"); colSecondLot = new Column (Translator.GetString ("Lot"), ct, 0.1) { MinWidth = 70 }; cc.Add (colSecondLot); } if (BusinessDomain.AppConfiguration.AllowItemSerialNumber) { ct = new CellText ("SerialNumber"); colSecondSerialNo = new Column (Translator.GetString ("Serial number"), ct, 0.1) { MinWidth = 80 }; cc.Add (colSecondSerialNo); } CellTextDate ctd; if (BusinessDomain.AppConfiguration.AllowItemExpirationDate) { ctd = new CellTextDate ("ExpirationDate"); colSecondExpirationDate = new Column (Translator.GetString ("Expiration date"), ctd, 0.1) { MinWidth = 70 }; cc.Add (colSecondExpirationDate); } if (BusinessDomain.AppConfiguration.AllowItemManufacturedDate) { ctd = new CellTextDate ("ProductionDate"); colSecondProductionDate = new Column (Translator.GetString ("Production date"), ctd, 0.1) { MinWidth = 70 }; cc.Add (colSecondProductionDate); } if (BusinessDomain.AppConfiguration.AllowItemLocation) { ct = new CellText ("LotLocation"); colSecondLotLocation = new Column (Translator.GetString ("Lot location"), ct, 0.1) { MinWidth = 70 }; cc.Add (colSecondLotLocation); } secondGrid.ColumnController = cc; secondGrid.AllowSelect = false; secondGrid.CellsFucusable = true; secondGrid.ManualFucusChange = true; secondGrid.RulesHint = true; }
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 RowData ToRow(uint rowNo) { if (rowNo == 0) { throw new ArgumentException("rowNo must be greater than 0."); } var retRowData = new RowData(); retRowData.Row.RowIndex = rowNo; var dataRowType = GetType(); var dataCellProperties = dataRowType.GetProperties().Where(prop => prop.IsDefined(typeof(CellDataAttribute), false)); foreach (var dataCell in dataCellProperties) { if (dataCell == null) { continue; } var target = dataCell.GetValue(this); if (target == null) { continue; } var dataCellAttr = dataCell.GetCustomAttributes(false).Where(atr => atr is CellDataAttribute).FirstOrDefault() as CellDataAttribute; if (dataCellAttr == null) { continue; } var cellColumnName = dataCellAttr.ColumnName; if (_propertyMappings.ContainsKey(dataCell.Name)) { cellColumnName = _propertyMappings[dataCell.Name]; } var cellDataType = ExcelHelper.ResolveCellType(target.GetType()); var cellDataValue = target.ToString(); var cellReference = cellColumnName + rowNo; var cell = new Cell() { CellReference = cellReference }; cell.CellValue = new CellValue(cellDataValue); cell.DataType = new EnumValue <CellValues>(cellDataType); var excelCell = new ExcelCell(); excelCell.Cell = cell; var cellFillAttr = dataCell.GetCustomAttributes(false).Where(atr => atr is CellFillAttribute).FirstOrDefault() as CellFillAttribute; var cellBorderAttr = dataCell.GetCustomAttributes(false).Where(atr => atr is CellBorderAttribute).FirstOrDefault() as CellBorderAttribute; var cellFontAttr = dataCell.GetCustomAttributes(false).Where(atr => atr is CellTextAttribute).FirstOrDefault() as CellTextAttribute; var cellStyleMappings = _propertyStylMappings.ContainsKey(dataCell.Name) ? _propertyStylMappings[dataCell.Name] : null; CellFill cellFillMap = null; CellBorder cellBorderMap = null; CellText cellFontMap = null; if (cellStyleMappings != null) { cellFillMap = cellStyleMappings.Where(x => x is CellFill).FirstOrDefault() as CellFill; cellBorderMap = cellStyleMappings.Where(x => x is CellBorder).FirstOrDefault() as CellBorder; cellFontMap = cellStyleMappings.Where(x => x is CellText).FirstOrDefault() as CellText; } if (cellFillMap == null) { if (cellFillAttr != null) { excelCell.Styles.Add(cellFillAttr.GetFill()); } } else { excelCell.Styles.Add(cellFillMap.GetFill()); } if (cellBorderMap == null) { if (cellBorderAttr != null) { excelCell.Styles.Add(cellBorderAttr.GetBorder()); } } else { excelCell.Styles.Add(cellBorderMap.GetBorder()); } if (cellFontMap == null) { if (cellFontAttr != null) { excelCell.Styles.Add(cellFontAttr.GetFont()); } } else { excelCell.Styles.Add(cellFontMap.GetFont()); } retRowData.Cells.Add(excelCell); } return(retRowData); }
public SelectCell(string name, bool isSelect) : this() { CellText.SetValue(Label.TextProperty, name); IsSelected = isSelect; }
private void InitializeSecondGrid() { if (secondGrid == null) { secondGrid = new ListView { Name = "secondGrid" }; ScrolledWindow sWindow = new ScrolledWindow { HscrollbarPolicy = PolicyType.Automatic, VscrollbarPolicy = PolicyType.Automatic }; sWindow.Add(secondGrid); algSecondGrid.Add(sWindow); sWindow.Show(); secondGrid.Show(); } ColumnController cc = new ColumnController(); if (BusinessDomain.AppConfiguration.EnableLineNumber) { CellTextEnumerator cte = new CellTextEnumerator(); colSecondLineNumber = new Column("№", cte, 0.01) { MinWidth = 25 }; cc.Add(colSecondLineNumber); } CellText ct; if (BusinessDomain.AppConfiguration.EnableItemCode) { ct = new CellText("ItemCode"); colSecondItemCode = new Column(Translator.GetString("Code"), ct, 0.1) { MinWidth = 70 }; cc.Add(colSecondItemCode); } ct = new CellText("ItemName") { IsEditable = true }; ct.CellEditBegin += CellEditBeginOnProdRecipe; colSecondItem = new Column(Translator.GetString("Item"), ct, 1); colSecondItem.ButtonPressEvent += SecondItemColumn_ButtonPressEvent; colSecondItem.KeyPressEvent += SecondItemColumn_KeyPress; cc.Add(colSecondItem); colSecondMeasure = new Column(Translator.GetString("Measure"), "MUnitName", 0.1) { MinWidth = 70 }; cc.Add(colSecondMeasure); CellTextQuantity ctq = new CellTextQuantity("Quantity") { IsEditable = true }; colSecondQuantity = new Column(Translator.GetString("Qtty"), ctq, 0.1) { MinWidth = 70 }; colSecondQuantity.ButtonPressEvent += SecondQtyColumn_ButtonPressEvent; colSecondQuantity.KeyPressEvent += SecondQtyColumn_KeyPress; cc.Add(colSecondQuantity); CellTextCurrency ctc = new CellTextCurrency("PriceIn", PriceType.Purchase); colSecondPurchaseValue = new Column(Translator.GetString("Purchase price"), ctc, 0.1) { MinWidth = 70 }; cc.Add(colSecondPurchaseValue); if (BusinessDomain.AppConfiguration.AllowItemLotName) { ct = new CellText("Lot") { IsEditable = true }; colSecondLot = new Column(Translator.GetString("Lot"), ct, 0.1) { MinWidth = 70 }; colSecondLot.ButtonPressEvent += SecondLotColumn_ButtonPressEvent; colSecondLot.KeyPressEvent += SecondLotColumn_KeyPress; cc.Add(colSecondLot); } if (BusinessDomain.AppConfiguration.AllowItemSerialNumber) { ct = new CellText("SerialNumber") { IsEditable = true }; colSecondSerialNo = new Column(Translator.GetString("Serial number"), ct, 0.1) { MinWidth = 80 }; colSecondSerialNo.ButtonPressEvent += SecondSerialNoColumn_ButtonPressEvent; colSecondSerialNo.KeyPressEvent += SecondSerialNoColumn_KeyPress; cc.Add(colSecondSerialNo); } CellTextDate ctd; if (BusinessDomain.AppConfiguration.AllowItemExpirationDate) { ctd = new CellTextDate("ExpirationDate") { IsEditable = true }; colSecondExpirationDate = new Column(Translator.GetString("Expiration date"), ctd, 0.1) { MinWidth = 70 }; colSecondExpirationDate.ButtonPressEvent += SecondExpirationDateColumn_ButtonPressEvent; colSecondExpirationDate.KeyPressEvent += SecondExpirationDateColumn_KeyPress; cc.Add(colSecondExpirationDate); } if (BusinessDomain.AppConfiguration.AllowItemManufacturedDate) { ctd = new CellTextDate("ProductionDate") { IsEditable = true }; colSecondProductionDate = new Column(Translator.GetString("Production date"), ctd, 0.1) { MinWidth = 70 }; colSecondProductionDate.ButtonPressEvent += SecondProductionDateColumn_ButtonPressEvent; colSecondProductionDate.KeyPressEvent += SecondProductionDateColumn_KeyPress; cc.Add(colSecondProductionDate); } if (BusinessDomain.AppConfiguration.AllowItemLocation) { ct = new CellText("LotLocation") { IsEditable = true }; colSecondLotLocation = new Column(Translator.GetString("Lot location"), ct, 0.1) { MinWidth = 70 }; colSecondLotLocation.ButtonPressEvent += SecondLotLocationColumn_ButtonPressEvent; colSecondLotLocation.KeyPressEvent += SecondLotLocationColumn_KeyPress; cc.Add(colSecondLotLocation); } if (BusinessDomain.AppConfiguration.EnableItemVatRate) { CellTextDouble ctf = new CellTextDouble("VatRate") { IsEditable = true, FixedFaction = BusinessDomain.AppConfiguration.PercentPrecision }; colSecondVatRate = new Column(BusinessDomain.AppConfiguration.UseSalesTaxInsteadOfVAT ? Translator.GetString("Tax %") : Translator.GetString("VAT %"), ctf, 0.1) { MinWidth = 70 }; colSecondVatRate.ButtonPressEvent += SecondVatRateColumn_ButtonPressEvent; colSecondVatRate.KeyPressEvent += SecondVatRateColumn_KeyPress; cc.Add(colSecondVatRate); } ctc = new CellTextCurrency("Total", PriceType.Purchase); colSecondTotal = new Column(Translator.GetString("Amount"), ctc, 0.1) { MinWidth = 70 }; cc.Add(colSecondTotal); secondGrid.ColumnController = cc; secondGrid.AllowSelect = false; secondGrid.CellsFucusable = true; secondGrid.ManualFucusChange = true; secondGrid.RulesHint = true; secondGrid.CellKeyPressEvent -= secondGrid_CellKeyPressEvent; secondGrid.CellKeyPressEvent += secondGrid_CellKeyPressEvent; secondGrid.CellStyleProvider = secondGrid_CellStyleProvider; }
private void InitializeProductsGrid() { if (grdProducts == null) { grdProducts = new ListView { Name = "grdProducts" }; ScrolledWindow sWindow = new ScrolledWindow { HscrollbarPolicy = PolicyType.Automatic, VscrollbarPolicy = PolicyType.Automatic }; sWindow.Add(grdProducts); algProducts.Add(sWindow); sWindow.Show(); grdProducts.Show(); } ColumnController cc = new ColumnController(); CellText ct = new CellText("ItemName") { IsEditable = true }; colSecondItem = new Column(Translator.GetString("Item"), ct, 1); colSecondItem.ButtonPressEvent += ProdItem_ButtonPressEvent; colSecondItem.KeyPressEvent += ProdItem_KeyPress; cc.Add(colSecondItem); colSecondMUnit = new Column(Translator.GetString("Measure"), "MUnitName", 0.1) { MinWidth = 70 }; cc.Add(colSecondMUnit); CellTextQuantity ctq = new CellTextQuantity("Quantity") { IsEditable = true }; colSecondQuantity = new Column(Translator.GetString("Qtty"), ctq, 0.1) { MinWidth = 70 }; colSecondQuantity.ButtonPressEvent += ProdQty_ButtonPressEvent; colSecondQuantity.KeyPressEvent += ProdQty_KeyPress; cc.Add(colSecondQuantity); CellTextCurrency ctc = new CellTextCurrency("PriceIn", PriceType.Purchase); colSecondPurchaseValue = new Column(Translator.GetString("Purchase price"), ctc, 0.1) { MinWidth = 70 }; cc.Add(colSecondPurchaseValue); ctc = new CellTextCurrency("Total", PriceType.Purchase); colSecondTotal = new Column(Translator.GetString("Amount"), ctc, 0.1) { MinWidth = 70 }; cc.Add(colSecondTotal); grdProducts.ColumnController = cc; grdProducts.Model = new BindingListModel(recipe.DetailsProd); grdProducts.Model.ListChanged += OperationModel_ListChanged; grdProducts.AllowSelect = false; grdProducts.CellsFucusable = true; grdProducts.ManualFucusChange = true; grdProducts.RulesHint = true; grdProducts.CellKeyPressEvent += grdProducts_CellKeyPressEvent; }