Пример #1
0
        public static List<int> listOfGearIds(int materialID, List<int> shaftIds, Database1DataSet1TableAdapters.GearsTableAdapter gta)
        {
            List<int> gearIds = new List<int>();
            Database1DataSet1.GearsDataTable gearTable = new Database1DataSet1.GearsDataTable();

            // beacause of the Material
            gearTable = gta.GetDataByMaterialID(materialID);
            foreach (Database1DataSet1.GearsRow row in gearTable)
            {
                int id = row.ID;
                gearIds.Add(id);
            }

            // because of the shaft
            foreach (int shaft in shaftIds)
            {
                gearTable = gta.GetDataByShaftID(shaft);
                foreach (Database1DataSet1.GearsRow row in gearTable)
                {
                    int id = row.ID;
                    gearIds.Add(id);
                }
            }

            return gearIds;
        }
        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();
        }
Пример #3
0
        public static List<int> listOfGearIds(int shaftIds, Database1DataSet1TableAdapters.GearsTableAdapter gta)
        {
            List<int> gearIds = new List<int>();

            Database1DataSet1.GearsDataTable gearTable = new Database1DataSet1.GearsDataTable();
            gearTable = gta.GetDataByShaftID(shaftIds);
            foreach (Database1DataSet1.GearsRow row in gearTable)
            {
                int id = row.ID;
                gearIds.Add(id);
            }

            return gearIds;
        }