private int ItemPropertyToDatagridColumnIndex(InventoryItem.ItemProperty property) { var columnName = property.ToString(); var columnIndex = dataGridViewItems.Columns[columnName].Index; return(columnIndex); }
/// <summary> /// Creates a new form to select transformation in. /// The form needs to know what kind of Inventory Item Property it will work on, /// in ordet to create a 'transformer' object for the selected data. /// </summary> /// <param name="property">The Item Property to transform</param> public FormTransformValue(InventoryItem.ItemProperty property) { _property = property; InitializeComponent(); PopulateComboBoxOperation(); }
/// <summary> /// Validate value 'x' against property 'property' /// </summary> /// <param name="x"></param> /// <param name="property"></param> /// <returns></returns> public static string Validate(string text, InventoryItem.ItemProperty property) { var targetType = InventoryItem.ItemPropertyType(property);; decimal lowerBound = 0; // Todo: possibly change this according to rules // (BL seem to accept -1 in some properties, what does that mean? // https://www.bricklink.com/help.asp?helpID=207 nothing here about -1....) if (targetType == typeof(int)) { try { int x = int.Parse(text); return(x >= lowerBound ? string.Empty : $"Must be {(int)lowerBound} or greater"); } catch //(Exception ex) { return("Not an integer value"); } } else if (targetType == typeof(decimal)) { try { decimal x = decimal.Parse(text); return(x >= lowerBound ? string.Empty : $"Must be {lowerBound} or greater"); } catch //(Exception ex) { return("Not a decimal value."); } } return(string.Empty); }
/// <summary> /// Creates a new form to enter new values in /// </summary> public FormSetValue(InventoryItem.ItemProperty property) { _property = property; InitializeComponent(); }