public void initAddRentalComboBoxes() { cbxStudentID.Items.Clear(); cbxInstrumentID.Items.Clear(); StudentDBAccess sDb = new StudentDBAccess(Db); cbxStudentID.Items.Add("Please select"); cbxInstrumentID.Items.Add("Please select"); rentingStudents = new List <Student>(); rentingStudents = sDb.getStudentByRentalStatus("Y"); foreach (Student s in rentingStudents) { cbxStudentID.Items.Add(s.StudentID + " - " + s.StudentForename + " " + s.StudentSurname); } }
private void btnAddStudent_Click(object sender, EventArgs e) { StudentDBAccess a = new StudentDBAccess(Db); Student s = new Student(); bool ok = false; try { s.StudentForename = txtForename.Text; s.StudentSurname = txtSurname.Text; if (rbMale.Checked) { s.StudentGender = "M"; } if (rbFemale.Checked) { s.StudentGender = "F"; } s.StudentInstrument = cbxInstrument.SelectedItem.ToString(); if (rbYes.Checked) { s.StudentRequiresRental = "Y"; } if (rbNo.Checked) { s.StudentRequiresRental = "N"; } s.StudentAddressLine1 = txtAddress.Text; s.StudentAddressLine2 = txtAddress2.Text; s.StudentCity = txtCity.Text; bool postcodeValid = ValidationMethods.validPostcode(txtPostCode, 8, lblPostCode); if (postcodeValid == true) { ok = true; s.StudentPostCode = txtPostCode.Text; } else { ok = false; s.StudentPostCode = txtPostCode.Text; } s.StudentPhone = txtPhoneNumber.Text; if (ok == true) { a.insertStudent(s); MessageBox.Show("Student added", "Success"); } else { MessageBox.Show("Student not added", "Error"); } } catch { MessageBox.Show("Student not added", "Error"); } }
public StudentHandler() { studentInfoDb = new StudentDBAccess(); }