Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Gear g = new Gear();
            g.Name = txtName.Text;
            g.Alpha = Convert.ToDouble(numAlpha.Value);
            g.GearModule = Convert.ToDouble(numGearModule.Value);
            g.Torque = Convert.ToDouble(numTorque.Value);
            g.WantedRadius = Convert.ToDouble(numWantedRadius.Value);
            g.Shaft = shaft;
            g.Material = material;

            if (g.Name != "" && g.Material != null && g.Shaft != null)
            {
                Database1DataSet1TableAdapters.GearsTableAdapter gta = new Database1DataSet1TableAdapters.GearsTableAdapter();
                gta.Insert(g.Name, g.Alpha, g.GearModule, g.Material.ID, g.Torque, g.Shaft.ID,g.WantedRadius, 0,0,0,0,0,0);
                g.ID = (int)gta.getID(g.Name, g.Alpha, g.GearModule, g.Material.ID, g.Torque, g.Shaft.ID, 0, 0, 0, 0, 0, 0, 0);

                Program.gearList.Add(g);
                DialogResult = DialogResult.OK;
            }
            else
            {
                if (g.Name == "")
                    MessageBox.Show("You have to add a Name to your gear", "Impossible to save the gear", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                else if (g.Shaft == null)
                    MessageBox.Show("You have to add a Shaft to your gear", "Impossible to save the gear", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                else
                    MessageBox.Show("You have to add a Material to your gear", "Impossible to save the gear", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            }
        }
Ejemplo n.º 2
0
        private void btnValidate_Click(object sender, EventArgs e)
        {
            Database1DataSet1TableAdapters.Shaft1TableAdapter sta = new Database1DataSet1TableAdapters.Shaft1TableAdapter();
            sta.Insert(inputGear.Shaft.Name, inputGear.Shaft.Diameter, inputGear.Shaft.Material.ID, inputGear.Shaft.KeyCutWidth, inputGear.Shaft.KeyCutHeigth, inputGear.Shaft.KeyCutLength);
            sta.Insert(outputGear.Shaft.Name, outputGear.Shaft.Diameter, outputGear.Shaft.Material.ID, outputGear.Shaft.KeyCutWidth, outputGear.Shaft.KeyCutHeigth, outputGear.Shaft.KeyCutLength);

            inputGear.Shaft.ID = (int)sta.getID(inputGear.Shaft.Name, inputGear.Shaft.Diameter, inputGear.Shaft.Material.ID, inputGear.Shaft.KeyCutWidth, inputGear.Shaft.KeyCutHeigth, inputGear.Shaft.KeyCutLength);
            outputGear.Shaft.ID = (int)sta.getID(outputGear.Shaft.Name, outputGear.Shaft.Diameter, outputGear.Shaft.Material.ID, outputGear.Shaft.KeyCutWidth, outputGear.Shaft.KeyCutHeigth, outputGear.Shaft.KeyCutLength);

            Database1DataSet1TableAdapters.GearsTableAdapter gta = new Database1DataSet1TableAdapters.GearsTableAdapter();
            gta.Insert(inputGear.Name, inputGear.Alpha,inputGear.GearModule, inputGear.Material.ID, inputGear.Torque, inputGear.Shaft.ID, inputGear.WantedRadius, inputGear.Z, inputGear.Phi, inputGear.R_base, inputGear.R_foot, inputGear.R_pitch, inputGear.R_top);
            gta.Insert(outputGear.Name, outputGear.Alpha, outputGear.GearModule, outputGear.Material.ID, outputGear.Torque, outputGear.Shaft.ID, outputGear.WantedRadius, outputGear.Z, outputGear.Phi, outputGear.R_base, outputGear.R_foot, outputGear.R_pitch, outputGear.R_top);

            inputGear.ID = (int)gta.getID(inputGear.Name, inputGear.Alpha, inputGear.GearModule, inputGear.Material.ID, inputGear.Torque, inputGear.Shaft.ID, inputGear.WantedRadius, inputGear.Z, inputGear.Phi, inputGear.R_base, inputGear.R_foot, inputGear.R_pitch, inputGear.R_top);
            outputGear.ID = (int)gta.getID(outputGear.Name, outputGear.Alpha, outputGear.GearModule, outputGear.Material.ID, outputGear.Torque, outputGear.Shaft.ID, outputGear.WantedRadius, outputGear.Z, outputGear.Phi, outputGear.R_base, outputGear.R_foot, outputGear.R_pitch, outputGear.R_top);

            Database1DataSet1TableAdapters.GearBoxTableAdapter gbta = new Database1DataSet1TableAdapters.GearBoxTableAdapter();
            gbta.Insert(gearBox.Name, gearBox.Alpha, gearBox.AxesDistance, gearBox.GearModule, gearBox.InputTorque, gearBox.OutputTorque, gearBox.TorqueRatio, gearBox.InputGear.ID, gearBox.OutputGear.ID);

            gearBox.ID = (int)gbta.getID(gearBox.Name, gearBox.Alpha, gearBox.AxesDistance, gearBox.GearModule, gearBox.InputTorque, gearBox.OutputTorque, gearBox.TorqueRatio, gearBox.InputGear.ID, gearBox.OutputGear.ID);

            Program.gearBoxList.Add(gearBox);
            Program.gearList.Add(inputGear);
            Program.gearList.Add(outputGear);
            Program.shaftList.Add(inputGear.Shaft);
            Program.shaftList.Add(outputGear.Shaft);

            tsStatusLabel.Text = "Gear Box saved !";
        }