public ECCAMaterial GetMAterial(string searchquery) { ECCAMaterial result = null; result = MaterialCollection.Query(searchquery)[0]; return(result); }
public void CreateNewMaterial() { ECCAMaterial NewMaterial = new ECCAMaterial(); if (getMaterial(NewMaterial.MaterialName) == null) { MaterialList.Add(NewMaterial); } else { MessageBox.Show("The material you are trying to import or create allready exists"); } }
public ECCAMaterial getMaterial(string materialname) { ECCAMaterial result = null; if (MaterialList.Count > 0) { foreach (ECCAMaterial eccaMaterial in MaterialList) { if (eccaMaterial.MaterialName == materialname) { result = eccaMaterial; break; } } } return(result); }
private IList <ECCAMaterial> tryParseMaterial(DataTable dt) { //List<String> fieldNameList = new List<string>(); List <ECCAMaterial> result = new List <ECCAMaterial>(); //Reach row is one element //Loop through datatab;e foreach (DataRow dr in dt.Rows) { ECCAMaterial newMaterial = new ECCAMaterial(); //set the properties of the element per column newMaterial.CategoryName = txt_Category.Text; newMaterial.SubCategory = txt_SubCategory.Text; foreach (DataColumn dc in dt.Columns) { string columnName = dc.ToString(); string columnValue = dr[dc].ToString(); //check section fields columnName FieldInfo[] fieldValues = newMaterial.GetType().GetFields(); for (int i = 0; i < fieldValues.Length; i++) { FieldInfo field = fieldValues[i]; Type fieldType = field.FieldType; if (field.Name == columnName) { if (field.FieldType == typeof(string)) { field.SetValue(newMaterial, columnValue); } else if (field.FieldType == typeof(double)) { field.SetValue(newMaterial, Utils.ConvertMeToDouble(columnValue)); } } } } result.Add(newMaterial); } return(result); }
private void trv_DataTree_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode selectedNode = e.Node; MessageBox.Show(selectedNode.FullPath); string[] splittedSelection = selectedNode.FullPath.Split('\\'); string selectedElement = splittedSelection[splittedSelection.Length - 1]; string selectedElementType = splittedSelection[1]; if (selectedElementType == "Sections") { ECCASection selection = ECCalcAidData.GetSection(selectedElement) as ECCASection; dgv_Data.DataSource = selection.ToDataTable(); } else if (selectedElementType == "Materials") { ECCAMaterial selection = ECCalcAidData.GetMAterial(selectedElement) as ECCAMaterial; dgv_Data.DataSource = selection.ToDataTable(); } }