private void btnSave_Click(object sender, EventArgs e)
        {
            Shaft s = new Shaft();
            s.Name = txtName.Text;
            s.Diameter = Convert.ToDouble(numDiameter.Value);
            s.KeyCutWidth = Convert.ToDouble(numKeyCutWidth.Value);
            s.KeyCutHeigth = Convert.ToDouble(numKeyCutHeight.Value);
            s.KeyCutLength = Convert.ToDouble(numKeyCutLength.Value);
            s.Material = material;

            if (s.Name != "" && s.Material != null)
            {
                Database1DataSet1TableAdapters.Shaft1TableAdapter sta = new Database1DataSet1TableAdapters.Shaft1TableAdapter();
                sta.Insert(s.Name, s.Diameter, s.Material.ID, s.KeyCutWidth, s.KeyCutHeigth, s.KeyCutLength);
                s.ID = (int)sta.getID(s.Name, s.Diameter, s.Material.ID, s.KeyCutWidth, s.KeyCutHeigth, s.KeyCutLength);
                Program.shaftList.Add(s);
                DialogResult = DialogResult.OK;
            }
            else
            {
                if (s.Name == "")
                    MessageBox.Show("You have to add a Name to your shaft", "Impossible to save the gear", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                else
                    MessageBox.Show("You have to add a Material to your shaft", "Impossible to save the gear", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            }
        }
        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 !";
        }