private void button3_Click(object sender, EventArgs e) { //shows the data for the staff table which matches the searched for staff name if (comboBox1.Text == "Staff Name") { StaffDBAccess sdba = new StaffDBAccess(db); string selectedName = searchBox.Text; createTable(sdba.GetStaffByName(selectedName)); } //Shows all the data for the staff table when the 'View' button is clicked if (comboBox1.Text == "Show All") { StaffDBAccess sdba = new StaffDBAccess(db); createTable(sdba.getAllStaff()); } //Shows the data for the staff table which mathes whether the the user is searching for voluntary or non-voluntary staff if (comboBox1.Text == "Voluntary") { bool decider = false; StaffDBAccess sdba = new StaffDBAccess(db); switch (searchBox.Text) { case "False": decider = false; break; case "True": decider = true; break; } createTable(sdba.getStaffByVoluntary(decider)); } }
private void label4_Click(object sender, EventArgs e) { //If the label is clicked, fill the table with all the data in the staff table StaffDBAccess sdba = new StaffDBAccess(db); createTableToShowStaff(sdba.getAllStaff()); SelectedTable = "Staff"; }
//when the modify data button is clicked, the highlighted entry will be changed in the database to whatever the user has entered into the grid private void button4_Click(object sender, EventArgs e) { StaffDBAccess sdba = new StaffDBAccess(db); sdba.updateProject(_staffId, _staffName, _staffNumber, _staffAddress, _staffEmail, _staffVoluntary); MessageBox.Show("The row in the database has been updated.", "Success"); staffResults.DataSource = null; }
private void button4_Click(object sender, EventArgs e) { try { //If the user selects show all, display all the entries for the Bus Booking if (comboBox1.Text == "Show All") { BusBookingDBAccess bdba = new BusBookingDBAccess(db); createTableToShowAllBusBooking(bdba.getAllBusBooking()); SelectedTable = ""; } //If the user searchs for a Booking ID, Show all the entries where their entered ID matches ones in the database else if (comboBox1.Text == "Booking ID") { BusBookingDBAccess bdba = new BusBookingDBAccess(db); createTableToShowAllBusBooking(bdba.SelectWhereBookingID(Convert.ToInt32(textBox1.Text))); SelectedTable = "BusBooking"; } //If the user searchs for a Driver Name, Show all the entries where their entered name matches the one stored in the database else if (comboBox1.Text == "Driver Name") { BusDBAccess bdba = new BusDBAccess(db); string driverName = textBox1.Text; createTableToShowBus(bdba.getWhereDriverIs(driverName)); SelectedTable = "Bus"; } //If the user searchs for a Staff Name, Show all the entries where their entered name matches the one stored in the database else if (comboBox1.Text == "Staff Name") { StaffDBAccess sdba = new StaffDBAccess(db); string staffName = textBox1.Text; createTableToShowStaff(sdba.GetStaffByName(staffName)); SelectedTable = "Staff"; } } catch { } }
//The constrcutor has the database and selected table passed in public SearchForm(Database db, string WhichTable) { InitializeComponent(); this.db = db; //Assign which table is being selected Table = WhichTable; //Makes border disappear and the form curved this.FormBorderStyle = FormBorderStyle.None; Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20)); CenterToScreen(); //Fill the combo boxes InitComboBox(); comboBox3.Items.Add("="); comboBox3.Items.Add(">"); comboBox3.Items.Add("<"); comboBox1.Text = Table; //Check the selected table switch (Table) { //If it's this table. Fill the grid with data from the chosen database table case "Parent & Child": InnerJoinDBAccess parentChild = new InnerJoinDBAccess(db); CreateTableToShowChildAndParent(parentChild.GetChildAndParent()); break; case "Bookings": InnerJoinDBAccess booking = new InnerJoinDBAccess(db); createTableToShowBookings(booking.GetAllBooking()); break; case "Bus": BusDBAccess BusdbAcess = new BusDBAccess(db); createTableToShowBus(BusdbAcess.getAllBus()); break; case "Cancellation": CancellationDBAccess cdba = new CancellationDBAccess(db); CreateTableToShowCancellation(cdba.getAllCancellation()); break; case "Children": ChildrenDBAccess chdba = new ChildrenDBAccess(db); CreateTableToShowChildren(chdba.GetAllChildren()); break; case "Parent": ParentDBAccess pdba = new ParentDBAccess(db); CreateTableToShowParent(pdba.SelectAllParents()); break; case "Schools": SchoolDBAccess sdba = new SchoolDBAccess(db); CreateTableToShowSchools(sdba.getAllSchools()); break; case "Staff": StaffDBAccess stdba = new StaffDBAccess(db); CreateTableToShowStaff(stdba.getAllStaff()); break; } }
//Creates a new entry in the table using the entered data private void button1_Click(object sender, EventArgs e) { string StaffName = staffName.Text; string StaffNumber = staffNumber.Text; string StaffAddress = staffAddress.Text; string StaffEmail = staffEmail.Text; string StaffVoluntary = comboBox2.Text; int voluntary = 0;; //Switch the string switch (StaffVoluntary) { //If it's false make voluntary = 0 OR if it's true make voluntary = 1 case "False": voluntary = 0; break; case "True": voluntary = 1; break; } StaffDBAccess sdba = new StaffDBAccess(db); sdba.InsertStaff(StaffName, StaffNumber, StaffAddress, StaffEmail, voluntary); //Display a message saying succes new SuccessForm(db, StaffName).Show(); }
//When the user changes the selected combobox index private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { //Clear the data in the second combobox comboBox2.Items.Clear(); //Switch the selected table switch (comboBox1.Text) { //If the selected table is this value: populate the second combobox with these values case "Bookings": comboBox2.Items.Add("Name"); comboBox2.Items.Add("Paid"); InnerJoinDBAccess booking = new InnerJoinDBAccess(db); createTableToShowBookings(booking.GetAllBooking()); break; case "Bus": comboBox2.Items.Add("Driver"); comboBox2.Items.Add("Route"); comboBox2.Items.Add("Time"); BusDBAccess BusdbAcess = new BusDBAccess(db); createTableToShowBus(BusdbAcess.getAllBus()); break; case "Cancellation": comboBox2.Items.Add("Reason"); CancellationDBAccess cdba = new CancellationDBAccess(db); CreateTableToShowCancellation(cdba.getAllCancellation()); break; case "Children": comboBox2.Items.Add("Child Name"); comboBox2.Items.Add("Age"); comboBox2.Items.Add("Medical Problems"); ChildrenDBAccess chdba = new ChildrenDBAccess(db); CreateTableToShowChildren(chdba.GetAllChildren()); break; break; case "Parent": comboBox2.Items.Add("Parent Name"); comboBox2.Items.Add("Parent Phone"); comboBox2.Items.Add("Parent Email"); comboBox2.Items.Add("Parent Address"); comboBox2.Items.Add("Parent Occupation"); ParentDBAccess pdba = new ParentDBAccess(db); CreateTableToShowParent(pdba.SelectAllParents()); break; case "Schools": comboBox2.Items.Add("School Name"); comboBox2.Items.Add("School Location"); comboBox2.Items.Add("School Number"); SchoolDBAccess sdba = new SchoolDBAccess(db); CreateTableToShowSchools(sdba.getAllSchools()); break; case "Staff": comboBox2.Items.Add("Staff Name"); comboBox2.Items.Add("Staff Voluntary"); StaffDBAccess stdba = new StaffDBAccess(db); CreateTableToShowStaff(stdba.getAllStaff()); break; case "Parent & Child": comboBox2.Items.Add("Parent Name"); comboBox2.Items.Add("Child Name"); InnerJoinDBAccess injdba = new InnerJoinDBAccess(db); CreateTableToShowChildAndParent(injdba.GetChildAndParent()); break; } }