Exemple #1
0
        //If the show all busbooking label is clicked, the grid will update to show all the current bus bookings in the database
        private void label6_Click(object sender, EventArgs e)
        {
            BusBookingDBAccess bdba = new BusBookingDBAccess(db);

            createTableShowAllBusBooking(bdba.getAllBusBooking());
            selectedTable = "Bus";
        }
Exemple #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            //When the button has been hit change the data in the database depending on what has been entered into the gird
            //Create access to the BusBooking table
            BusBookingDBAccess bbdba = new BusBookingDBAccess(db);

            //Call the UpdateBooking method and pass in the values you want to change
            bbdba.UpdateBooking(BusBookingId, BusId, StaffId);
            //Display an error message and make the grid empty
            MessageBox.Show("The row in the database has been updated.", "Success");
            busResults.DataSource = null;
        }
Exemple #3
0
        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 { }
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //This adds the new entry to the database

                //Creates acces to the BusBooking table
                BusBookingDBAccess bbda = new BusBookingDBAccess(db);

                int _staffId = Convert.ToInt32(StaffBox.Text);
                int _busId   = Convert.ToInt32(BusBox.Text);

                //Calls the InsertBusBook method and passes in the changed variables
                bbda.InsertBusBook(_busId, _staffId);
                //The succesform appears
                this.Hide();
                new SuccessForm(db, "Success, BusBooking Registered").Show();
            }
            //If there's a problem, show an error
            catch
            {
                new ErrorBox(null).Show();
            }
        }