private void cbStaffID_SelectedIndexChanged(object sender, EventArgs e) { //Call the getStaffForename and pass across the data. List <string> forenames = StaffClass.getStaffForename(Convert.ToInt32(cbStaffID.Text)); if (forenames.Count > 0) { //Create a new instance of the stringbuilder class. StringBuilder sb = new StringBuilder(); foreach (string fname in forenames) { sb.AppendLine(fname); //Save the forename to the variable staff_fname. staff_fname = fname; } } //Call the getStaffSurname and pass across the data. List <string> surnames = StaffClass.getStaffSurname(Convert.ToInt32(cbStaffID.Text)); if (surnames.Count > 0) { //Create a new instance of the stringbuilder class. StringBuilder s_b = new StringBuilder(); foreach (string sname in surnames) { s_b.AppendLine(sname); //Display the forename and surname in lblDisplayName. lblDisplayName.Text = staff_fname + " " + sname; } } }
private void AddStaffClass() { //If the StaffID and the SupportingStaffID are not the same... if (_staffClass._main != _staffClass._supporting) { //Try to... try { //Call the AddStaffClass method from the StaffClass and pass across the data. int rowsAffected = StaffClass.AddStaffClass(lblID.Text, cbStaffID.Text, cbStaffRole.Text); if (rowsAffected > 0) { //If the StaffClass has been added successfully, display the message below. MessageBox.Show("Staff member has been allocated successfully."); //Call the Back method. Back(); } } //Catch any exceptions that may occur and display an error message. catch (Exception ex) { MessageBox.Show(ex.Message); } } //Otherwise, display the message below. else { MessageBox.Show("The Main staff Member and the Supporting Staff Member cannot be the same."); } }
public void StaffIds() { //Call the getStaffID method and save it to a list. List <int> ids = StaffClass.getStaffID(); { foreach (int id in ids) { //Add each ID to the list. cbStaffID.Items.Add(id); } } }
private void ClassSearch() { //This method will check that the ClassID enter is valid. using (SqlConnection connection = new SqlConnection(_connectionString)) { using (SqlCommand sqlCommand = new SqlCommand("SELECT COUNT(*) FROM Class WHERE (ClassID = @ClassID)", connection)) { connection.Open(); sqlCommand.Parameters.AddWithValue("@ClassID", txtClassID.Text); int _class = (int)sqlCommand.ExecuteScalar(); bool classExist = false; if (_class > 0) { classExist = true; //If classExist is true... if (classExist) { //Call the changeDataGridView... changeDataGridView(); //Call the getClassName method from the Class class and pass the text in txtClassID. List <string> names = Class.getClassName(txtClassID.Text); { //If the amount of names is greater than 0... if (names.Count > 0) { //Create a new instance of the stringbuilder class. StringBuilder sb = new StringBuilder(); foreach (string name in names) { sb.AppendLine(name); //Display the class name in txtClassName. txtClassName.Text = name; } } } //Call the getClassDay method from the Class class and pass the text in txtClassID List <string> days = Class.getClassDay(txtClassID.Text); { //If the amount of days is greater than 0... if (days.Count > 0) { //Create a new instance of the stringbuilder class. StringBuilder sb = new StringBuilder(); foreach (string day in days) { sb.AppendLine(day); //Display the day in cbDay. cbDay.Text = day; } } } //Call the getClassTime method from the Class class and pass the text in txtClassID List <string> times = Class.getClassTime(txtClassID.Text); { //If the amount of times is greater than 0... if (times.Count > 0) { //Create a new instance of the stringbuilder class. StringBuilder sb = new StringBuilder(); foreach (string time in times) { sb.AppendLine(time); //Display the time in cbTime. cbTime.Text = time; } } } //Call the getClassLevel method from the Class class and pass the text in txtClassID List <string> levels = Class.getClassLevel(txtClassID.Text); { //If the amount of levels is greater than 0... if (levels.Count > 0) { //Create a new instance of the stringbuilder class. StringBuilder sb = new StringBuilder(); foreach (string level in levels) { sb.AppendLine(level); //Display the level in cbLevel. cbLevel.Text = level; } } } //Call the displayStaffID method from the StaffClass class and pass the text in txtClassID List <int> ids = StaffClass.displayStaffID(txtClassID.Text); { //If the amount of IDs is greater than 0... if (ids.Count > 0) { //Create a new instance of the stringbuilder class. StringBuilder _sb = new StringBuilder(); foreach (int id in ids) { _sb.AppendLine(Convert.ToString(id)); //Display the ID in txtStaffID. txtStaffID.Text = Convert.ToString(id); } } } //Call the displaysupportingStaffID method from the StaffClass class and pass the text in txtClassID List <int> supportids = StaffClass.displaySupportingStaffID(txtClassID.Text); { //If the amount of IDs is greater than 0... if (ids.Count > 0) { //Create a new instance of the stringbuilder class. StringBuilder _sb1 = new StringBuilder(); foreach (int id in supportids) { _sb1.AppendLine(Convert.ToString(id)); //Display the ID in txtSupportingID. txtSupportingID.Text = Convert.ToString(id); } } } } //Otherwise display the message below. else { MessageBox.Show("Class does not exist."); } } //Otherwise display the message below. else { MessageBox.Show("Class does not exist."); } } } }