private void AddParticipants_Click(object sender, EventArgs e) { addParticipant_form Form_ap = new addParticipant_form(); this.Hide(); Form_ap.Show(); }
private void AddParbtn_Click(object sender, EventArgs e) { ArrayList errors = new ArrayList(); Boolean eventID = true; Boolean parName = true; Boolean category = true; if (comboBoxpar1.SelectedIndex == -1) { eventID = false; errors.Add("please Add EventID"); } if (namePartextbox.Text.Equals("")) { parName = false; errors.Add("please add Participant Name"); } if (Category.Equals("")) { category = false; errors.Add("please enter Category"); } string ErrorArr = ""; foreach (Object ob in errors) { ErrorArr = ErrorArr + "\n" + ob; } if (eventID && parName && category) { OpenConnection(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = ("set IDENTITY_INSERT ON"); cmd.CommandText = ("insert into Participants([Event ID],[Name],[Category]) values ('" + comboBoxpar1.SelectedItem + "','" + namePartextbox.Text + "','" + Category + "')"); cmd.ExecuteNonQuery(); CloseConnection(); this.ResetRecords(); DialogResult dResult = MessageBox.Show("Add more Participants", "Record Inserted Successfully", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dResult == DialogResult.Yes) { addParticipant_form AddPar = new addParticipant_form(); this.Hide(); AddPar.Show(); } } else { MessageBox.Show(ErrorArr); } }