private void store(OleDbConnection cn, string material, MaterialDesignProps props) { if (props is ConcreteDesignProps) { store(cn, material, (ConcreteDesignProps)props); } else if (props is NoDesignProps) { store(cn, material, (NoDesignProps)props); } else if (props is RebarDesignProps) { store(cn, material, (RebarDesignProps)props); } else if (props is AluminumDesignProps) { store(cn, material, (AluminumDesignProps)props); } else if (props is ColdFormedDesignProps) { store(cn, material, (ColdFormedDesignProps)props); } else if (props is SteelDesignProps) { store(cn, material, (SteelDesignProps)props); // Se tiene que checar al final porque tiene herencia. } else { throw new NotSupportedException("Only specific DesignProps are supported, this method should not be called"); } }
public void UpdatePage2() { if (material != null) { material.Name = material.Name; // Checks that material name is valid nameTextBox.Text = material.Name; densityTextBox.Text = material.Density.ToString(); densityLabel.Text = Culture.Get("Density") + " (" + Canguro.Model.Model.Instance.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.Density) + ")"; MaterialTypeProps typeProps = material.TypeProperties; MaterialDesignProps designProps = material.DesignProperties; for (int i = 0; i < typeList.Count; i++) { if (typeList[i].ToString().Equals(typeProps.ToString())) { typeComboBox.SelectedIndex = i; } } typePropertyGrid.SelectedObject = typeProps; for (int i = 0; i < designPropList.Count; i++) { if (designPropList[i].ToString().Equals(designProps.ToString())) { designComboBox.SelectedIndex = i; } } designPropertyGrid.SelectedObject = designProps; } else { wizardControl.SelectTab(0); } }
private void store(OleDbConnection cn, Material obj) { MaterialTypeProps tProps = obj.TypeProperties; MaterialDesignProps dProps = obj.DesignProperties; double e, u, a; string type = ""; string design = (dProps is RebarDesignProps) ? "Rebar" : (dProps is ColdFormedDesignProps) ? "ColdFormed" : (dProps is SteelDesignProps) ? "Steel" : (dProps is ConcreteDesignProps) ? "Concrete" : (dProps is AluminumDesignProps) ? "Aluminum" : "None"; if (tProps is IsotropicTypeProps) { IsotropicTypeProps iProps = tProps as IsotropicTypeProps; type = "Isotropic"; e = iProps.E; u = iProps.Nu; a = iProps.Alpha; } else if (tProps is UniaxialTypeProps) { UniaxialTypeProps uProps = tProps as UniaxialTypeProps; type = "Uniaxial"; e = uProps.E; u = 0.0; a = uProps.A; } else { e = u = a = 0.0; type = (tProps is OrthotropicTypeProps) ? "Orthotropic" : "Anisotropic"; } string sql = "INSERT INTO [Material Properties 01 - General] " + "(Material,Type,DesignType,UnitMass,UnitWeight,E,U,A,MDampRatio,VDampMass,VDampStiff,HDampMass,HDampStiff,NumAdvance,Color) " + "VALUES (\"" + obj.Name + "\",\"" + type + "\",\"" + design + "\"," + obj.Density + "," + obj.UnitWeight + "," + e + "," + u + "," + a + ",0,0,0,0,0,0,\"Yellow\");"; new OleDbCommand(sql, cn).ExecuteNonQuery(); store(cn, obj.Name, dProps); }