private void button3_Click(object sender, EventArgs e) { //Shows all the data for the parent table which matches the searched for parent name if (comboBox1.Text == "Parent Name") { ParentDBAccess pdba = new ParentDBAccess(db); string name = searchBox.Text; createTable(pdba.SelectAllParentsWhereName(name)); } //Shows all the data for the parent table which matches the searched for parent town else if (comboBox1.Text == "Town") { ParentDBAccess pdba = new ParentDBAccess(db); string townName = searchBox.Text; createTable(pdba.SelectAllParentsWhereTown(townName)); } //Shows all the data for the parent table when the 'View' button is clicked else if (comboBox1.Text == "Show All") { ParentDBAccess pdba = new ParentDBAccess(db); createTable(pdba.SelectAllParents()); } //If a problem arises, display this error message else { MessageBox.Show("ERROR"); this.Hide(); new MainApp(db).Show(); } }
private void button1_Click(object sender, EventArgs e) { string SearchedName = textBox1.Text; ParentDBAccess pdba = new ParentDBAccess(db); SelectAllWhereName(pdba.SelectAllParentsWhereName(SearchedName)); }
private void button1_Click_1(object sender, EventArgs e) { //Take the entered text and pass it into a variable string SearchedName = textBox1.Text; //Create a new ParentDBAcccess, giving access to the methods in that class ParentDBAccess pdba = new ParentDBAccess(db); //If the textbox is left empty diplay an error message if (SearchedName == "") { MessageBox.Show("Error, SearchBox Must Not Be Left Blank "); } //If it's not empty, update the table to show all the names in the database that match the searched for parents name else { SelectAllWhereName(pdba.SelectAllParentsWhereName(SearchedName)); } }
//When the 'Search' button is clicked private void button1_Click(object sender, EventArgs e) { //The searched for name goes into the searcher variable string searcher = textBox1.Text; //If the user is searching for a child name in the Parent & Child table if (comboBox2.Text == "Child Name" && comboBox1.Text == "Parent & Child") { //display the data which matches the searched for childs name InnerJoinDBAccess injdba = new InnerJoinDBAccess(db); CreateTableToShowChildAndParent(injdba.GetChildrenAndParentWhereChildName(searcher)); } //If the user is searching for the Parents name in the parent & child table if (comboBox2.Text == "Parent Name" && comboBox1.Text == "Parent & Child") { //diaplay the data which matches the searched for parents name InnerJoinDBAccess injdba = new InnerJoinDBAccess(db); CreateTableToShowChildAndParent(injdba.GetChildrenAndParentWhereParentName(searcher)); } //If the user is searching for Driver if (comboBox2.Text == "Driver") { //display the data which matches the searched for Bus drivers name BusDBAccess bdba = new BusDBAccess(db); createTableToShowBus(bdba.getWhereDriverIs(searcher)); } // This repeats for the rest of the IF statements, the program will update the grid to show where the data in the table matches the value that the user is searching for if (comboBox2.Text == "Route") { BusDBAccess bdba = new BusDBAccess(db); createTableToShowBus(bdba.getWhereRouteIs(searcher)); } if (comboBox2.Text == "Time") { BusDBAccess bdba = new BusDBAccess(db); createTableToShowBus(bdba.getWhereTimeIs(comboBox3.Text, searcher)); } if (comboBox2.Text == "Reason") { CancellationDBAccess cdba = new CancellationDBAccess(db); CreateTableToShowCancellation(cdba.GetCancellByName(searcher)); } if (comboBox2.Text == "Child Name") { ChildrenDBAccess cdba = new ChildrenDBAccess(db); CreateTableToShowChildren(cdba.GetChildByName(searcher)); } if (comboBox2.Text == "Age") { ChildrenDBAccess cdba = new ChildrenDBAccess(db); CreateTableToShowChildren(cdba.GetChildByAge(comboBox3.Text, searcher)); } if (comboBox2.Text == "Medical Problems") { ChildrenDBAccess cdba = new ChildrenDBAccess(db); CreateTableToShowChildren(cdba.getChildByMedicalDetails()); } if (comboBox2.Text == "Parent Name") { ParentDBAccess pdba = new ParentDBAccess(db); CreateTableToShowParent(pdba.SelectAllParentsWhereName(searcher)); } if (comboBox2.Text == "Parent Phone") { ParentDBAccess pdba = new ParentDBAccess(db); CreateTableToShowParent(pdba.getParentWithPhone(searcher)); } if (comboBox2.Text == "Parent Email") { ParentDBAccess pdba = new ParentDBAccess(db); CreateTableToShowParent(pdba.getAllParentByEmail(searcher)); } if (comboBox2.Text == "Parent Address") { ParentDBAccess pdba = new ParentDBAccess(db); CreateTableToShowParent(pdba.getParentByAddress(searcher)); } if (comboBox2.Text == "Parent Occupation") { ParentDBAccess pdba = new ParentDBAccess(db); CreateTableToShowParent(pdba.getParentByOccupation(searcher)); } if (comboBox2.Text == "School Name") { SchoolDBAccess sdba = new SchoolDBAccess(db); CreateTableToShowSchools(sdba.getSchoolByName(searcher)); } if (comboBox2.Text == "School Location") { SchoolDBAccess sdba = new SchoolDBAccess(db); CreateTableToShowSchools(sdba.getSchoolByLocation(searcher)); } if (comboBox2.Text == "School Number") { SchoolDBAccess sdba = new SchoolDBAccess(db); CreateTableToShowSchools(sdba.getSchoolByNumber(searcher)); } if (comboBox2.Text == "Paid") { string reason = textBox1.Text.ToLower(); int num = 0; //If the user types in false or true, the program creates a variable called num which stores 0/1 depeneding on if the user has typed true or false switch (reason) { case "false": num = 0; break; case "true": num = 1; break; } InnerJoinDBAccess injdba = new InnerJoinDBAccess(db); createTableToShowBookings(injdba.GetBookingWithPaid(num)); } if (comboBox2.Text == "Name") { string name = textBox1.Text; InnerJoinDBAccess injdba = new InnerJoinDBAccess(db); createTableToShowBookings(injdba.GetBookingWithName(name)); } }