//Constructor public Form4() { Current = this; InitializeComponent(); }
private void btn_next__form4_Click(object sender, EventArgs e) { //User is obliged to fill in all fields if (comboBx_BottmPanel.Text.Equals("") || comboBx_LPanel4.Text.Equals("") || comboBx_RearPanel4.Text.Equals("") || comboBx_Rpanel4.Text.Equals("") || comboBx_topPanel.Text.Equals("") || (comboBx_SteelCornerBr.Text.Equals("") && comboBx_SteelCornerBr.Enabled == true) || (comboBx_rackheight4.Text.Equals("") && comboBx_rackheight4.Enabled == true) || (comboBx_doorcolor4.Text.Equals("") && comboBx_doorcolor4.Enabled == true) || (comboBx_rightdoor.Text.Equals("") && comboBx_rightdoor.Enabled == true)) { // On ajoute une icône : celle d'une erreur. On change aussi les boutons... MessageBox.Show("Please define all fields !", "Titre", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Create Elements for Rack InsertRackElements(); //test to see if not in update mode if (updateMode_flag == false) { cabinetkit.List_of_racks.Add(rack); } else { try { int indx = rackcounter; cabinetkit.List_of_racks[indx - 1] = rack; //Client has decided to reduce number of racks in edit mode if (numberOfracks > cabinetkit.Nbr_racks) { int indx_racks_delete = indx; int nbr_racks_delete = numberOfracks - cabinetkit.Nbr_racks; //Remove/delete old racks cabinetkit.List_of_racks.RemoveRange(indx_racks_delete, nbr_racks_delete); } } //Client has decided to add racks in edit mode catch (ArgumentOutOfRangeException) { cabinetkit.List_of_racks.Add(rack); } } //Test to see if all racks have been created if (rackcounter + 1 <= cabinetkit.Nbr_racks) { this.Dispose(); this.Close(); //this.Hide(); if (updateMode_flag == true) { Form4 update_rack = new Form4(db, cabinetkit, rackcounter, list_of_cabinetkits, updateMode_flag, cabinet_index); update_rack.ShowDialog(); } else { Form4 new_rack = new Form4(db, cabinetkit, rackcounter, list_of_cabinetkits); new_rack.ShowDialog(); } } else { //Try to find Steel corner bars that match current cabinet conditions AddSteelCornerbars(); //Set price cabinetkit.CalculatePrice(); if (updateMode_flag == false) { //Add cabinetkit list_of_cabinetkits.Add(cabinetkit); } else { //Replace cabinet list_of_cabinetkits[cabinet_index] = cabinetkit; } this.Dispose(); this.Close(); Form3.Current.Dispose(); Form3.Current.Close(); Form2 form2 = new Form2(db, list_of_cabinetkits); form2.ShowDialog(); } } }