private void SetTableMapping() { if ((_projectManager.ActiveProject?.Columns.Count ?? 0) == 0) { return; } _mappingColumnsOffer.Clear(); VewActiveOfferSettings(_CurrentMapping); foreach (ColumnMapping col in _projectManager.ActiveProject.Columns) { OfferColumnMapping columnMapping = _CurrentMapping.Columns.Find(x => x.Name == col.Name); OfferColumnMapping cm = new OfferColumnMapping(); if (columnMapping != null) { cm.ColumnSymbol = columnMapping.ColumnSymbol; } cm.Name = col.Name; _mappingColumnsOffer.Add(cm); } UpdateTableSource(); if (_CurrentMapping != null) { TBoxSheetName.Text = _CurrentMapping.SheetName; TBoxFirstRowRangeValues.Text = _CurrentMapping.RowStart.ToString(); } SetTableColumns(); }
public OfferColumnMapping GetColumn(StaticColumns column) { OfferColumnMapping columnMapping = Columns.Find(x => x.Name == Project.ColumnsNames[column]); if (columnMapping is null) { throw new AddInException($"Не удалось найти столбец {Project.ColumnsNames[column]}"); } return(columnMapping); }
/// <summary> /// Получить столбцы из XML. /// </summary> /// <param name="xElement"></param> /// <returns></returns> private static List <OfferColumnMapping> LoadColumnsFromXElement(XElement xElement) { List <OfferColumnMapping> columns = new List <OfferColumnMapping>(); if (xElement != null) { foreach (XElement xcol in xElement.Elements()) { columns.Add(OfferColumnMapping.GetCellFromXElement(xcol)); } } return(columns); }
private void TableColumns_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (!(e.RowIndex >= 0 && e.RowIndex >= 0)) { return; } string name = TableColumns.Rows[e.RowIndex].Cells[0].Value?.ToString() ?? ""; OfferColumnMapping mapping = _mappingColumnsOffer.Find(f => f.Name == name); if (e.ColumnIndex == 1) { object value = TableColumns.Rows[e.RowIndex].Cells[1].Value; mapping.ColumnSymbol = value?.ToString() ?? ""; } }