private void GearBoxGenerator_Load(object sender, EventArgs e)
        {
            // Get the Materials
            Database1DataSet1TableAdapters.MaterialsTableAdapter mta = new Database1DataSet1TableAdapters.MaterialsTableAdapter();
            Database1DataSet1.MaterialsDataTable MaterialsFromDB = new Database1DataSet1.MaterialsDataTable();
            mta.Fill(MaterialsFromDB);

            foreach(Database1DataSet1.MaterialsRow row in MaterialsFromDB.Rows){
                Material mat = new Material();
                mat.ID = row.ID;
                mat.Name = row.MaterialName;
                mat.Density = row.Density;
                mat.yieldStress = row.YieldStress;
                mat.youngsModulus = row.YoungsModulus;

                Program.materialList.Add(mat);

            }

            // Get the Shafts
            Database1DataSet1TableAdapters.Shaft1TableAdapter sta = new Database1DataSet1TableAdapters.Shaft1TableAdapter();
            Database1DataSet1.Shaft1DataTable ShaftsFromDB = new Database1DataSet1.Shaft1DataTable();
            sta.Fill(ShaftsFromDB);

            foreach (Database1DataSet1.Shaft1Row row in ShaftsFromDB.Rows) {
                Shaft shaft = new Shaft();
                shaft.ID = row.ID;
                shaft.Name = row.ShaftName;
                shaft.Diameter = row.Diameter;
                shaft.KeyCutHeigth = row.KeyCutHeight;
                shaft.KeyCutLength = row.KeyCutLenght;
                shaft.KeyCutWidth = row.KeyCutWidth;
                shaft.Material = Util.getMaterialById(row.MaterialID);

                Program.shaftList.Add(shaft);
            }

            Database1DataSet1TableAdapters.GearsTableAdapter gta = new Database1DataSet1TableAdapters.GearsTableAdapter();
            Database1DataSet1.GearsDataTable GearsFromDB = new Database1DataSet1.GearsDataTable();
            gta.Fill(GearsFromDB);

            foreach (Database1DataSet1.GearsRow row in GearsFromDB.Rows)
            {
                Gear gear = new Gear();
                gear.ID = row.ID;
                gear.Alpha = row.Alpha;
                gear.GearModule = row.GearModule;
                gear.Torque = row.Torque;
                gear.WantedRadius = row.WantedRadius;
                gear.Name = row.GearName;
                gear.Z = row.Z;
                gear.Phi = row.Phi;
                gear.R_base = row.RBase;
                gear.R_foot = row.RFoot;
                gear.R_pitch = row.RPitch;
                gear.R_top = row.RTop;
                gear.Material = Util.getMaterialById(row.MaterialID);
                gear.Shaft = Util.getShaftById(row.ShaftID);

                Program.gearList.Add(gear);
            }

            Util.refreshGearBoxList();
        }
Beispiel #2
0
        public static List<int> listOfShaftIds(int materialID, Database1DataSet1TableAdapters.Shaft1TableAdapter sta)
        {
            List<int> shaftIds = new List<int>();

            Database1DataSet1.Shaft1DataTable shaftTable = new Database1DataSet1.Shaft1DataTable();
            shaftTable = sta.GetDataByMaterialID(materialID);
            foreach (Database1DataSet1.Shaft1Row row in shaftTable)
            {
                int id = row.ID;
                shaftIds.Add(id);
            }

            return shaftIds;
        }