Ejemplo n.º 1
0
 private void button3_Click(object sender, EventArgs e)
 {
     //shows the data for the School table which matches the searched for School name
     if (comboBox1.Text == "School Name")
     {
         SchoolDBAccess sdba = new SchoolDBAccess(db);
         string         name = searchBox.Text;
         createTableShowAll(sdba.getSchoolByName(name));
     }
     //shows the data for the School table which matches the searched for School Location
     else if (comboBox1.Text == "Location")
     {
         SchoolDBAccess sdba     = new SchoolDBAccess(db);
         string         location = searchBox.Text;
         createTableShowAll(sdba.getSchoolByLocation(location));
     }
     //Shows all the data for the School table when the 'View' button is clicked
     else if (comboBox1.Text == "Show All")
     {
         SchoolDBAccess sdba = new SchoolDBAccess(db);
         createTableShowAll(sdba.getAllSchools());
     }
     //If there's a problem. Display an error message and return to the main menu
     else
     {
         MessageBox.Show("ERROR");
         this.Hide();
         new MainApp(db).Show();
     }
 }
Ejemplo n.º 2
0
 private void button3_Click(object sender, EventArgs e)
 {
     //shows the data for the Child table which matches the searched for Child name
     if (comboBox1.Text == "Child Name")
     {
         ChildrenDBAccess cdba = new ChildrenDBAccess(db);
         string           name = searchBox.Text;
         createTableShowAll(cdba.GetChildByName(name));
     }
     //shows the data for the Child table which matches the searched for child age
     else if (comboBox1.Text == "Age")
     {
         ChildrenDBAccess cdba = new ChildrenDBAccess(db);
         string           name = searchBox.Text;
         createTableShowAll(cdba.GetChildByAge("=", name));
     }
     //Shows all the data for the Child table when the 'View' button is clicked
     else if (comboBox1.Text == "Show All")
     {
         ChildrenDBAccess cdba = new ChildrenDBAccess(db);
         createTableShowAll(cdba.GetAllChildren());
         SelectedTable = "Child";
     }
     //Shows all the data for the School table which matches the searched for school name
     else if (comboBox1.Text == "School Name")
     {
         string         name  = searchBox.Text;
         SchoolDBAccess scdba = new SchoolDBAccess(db);
         createTableShowAllSchools(scdba.getSchoolByName(name));
     }
 }
Ejemplo n.º 3
0
        //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)
        {
            SchoolDBAccess sdba = new SchoolDBAccess(db);

            sdba.updateProject(schoolId, schoolName, schoolLocation, schoolAddress, schoolNumber, schoolEmail);
            MessageBox.Show("The row in the database has been updated.", "Success");
            schoolTable.DataSource = null;
        }
Ejemplo n.º 4
0
        //Create a new entry in the table using the entered data
        private void button1_Click(object sender, EventArgs e)
        {
            //Add whatever is in the textboxes to these variables
            string Name           = schoolNameTXT.Text;
            string SchoolLocation = schoolLocationTXT.Text;
            string SchoolAddress  = schoolAddressTXT.Text;
            int    SchoolNumber   = Convert.ToInt32(schoolNumberTXT.Text);
            string SchoolEmail    = schoolEmailTXT.Text;


            //Populate a new entry using this data
            SchoolDBAccess sdba = new SchoolDBAccess(db);


            sdba.InsertSchool(Name, SchoolLocation, SchoolAddress, SchoolNumber, SchoolEmail);

            //If it works, display the success form with the childs name
            this.Hide();
            new SuccessForm(db, "New School: " + Name + "\nRegistered").Show();
        }
Ejemplo n.º 5
0
        //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;
            }
        }
Ejemplo n.º 6
0
        //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;
            }
        }
Ejemplo n.º 7
0
        //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));
            }
        }
Ejemplo n.º 8
0
        //When the label is clicked, the table will update to show all the data for schools
        private void label1_Click(object sender, EventArgs e)
        {
            SchoolDBAccess sdba = new SchoolDBAccess(db);

            createTableShowAllSchools(sdba.getAllSchools());
        }