public static PassengerDetails4 GetInstance(Form1 form) { if (instance == null) { instance = new PassengerDetails4(form); return(instance); } else { return(instance); } }
private void btn_NEXT_Click(object sender, EventArgs e) { try { if (Form1.OWorRT.Equals("One Way")) { if (dataGridViewOutbound.GetCellCount(DataGridViewElementStates.Selected) == 0) { throw new Exception("Please choose Train"); } } else { if (dataGridViewOutbound.GetCellCount(DataGridViewElementStates.Selected) == 0) { throw new Exception("Please choose Outbound Train"); } if (dataGridViewInbound.GetCellCount(DataGridViewElementStates.Selected) == 0) { throw new Exception("Please choose Inbound Train"); } } form1.panel3.BackColor = Color.ForestGreen; switch (Form1.adult + Form1.children) { case 1: { var PassengerDetailsControl = PassengerDetails4.GetInstance(form1); Controls.Add(PassengerDetailsControl); PassengerDetailsControl.BringToFront(); break; } case 2: { var PassengerDetailsControl = PassengerDetails4.GetInstance(form1); Controls.Add(PassengerDetailsControl); PassengerDetailsControl.BringToFront(); break; } case 3: { var PassengerDetailsControl = PassengerDetails4.GetInstance(form1); Controls.Add(PassengerDetailsControl); PassengerDetailsControl.BringToFront(); break; } case 4: { var PassengerDetailsControl = PassengerDetails4.GetInstance(form1); Controls.Add(PassengerDetailsControl); PassengerDetailsControl.BringToFront(); break; } default: break; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }