コード例 #1
0
ファイル: CancellForm.cs プロジェクト: desm01/Database_System
        private void button1_Click(object sender, EventArgs e)
        {
            //Creates a form to check if the user is sure they want to delete data or not
            using (var form = new DeleteValidate())
            {
                var result = form.ShowDialog();
                //If the user clicks 'Yes'
                if (result == DialogResult.Yes)
                {
                    //Make the form hide
                    this.Hide();
                    BookingDBAccess bdba = new BookingDBAccess(db);

                    //If the user hasn't selected a row
                    if (Results.SelectedRows.Count == 0)
                    {
                        MessageBox.Show("No Row Selected Was Selected", "Error");
                        this.Hide();
                        new MainApp(db).Show();
                    }
                    //If there's more than one row selected, show an error message
                    else if (Results.SelectedRows.Count > 1)
                    {
                        MessageBox.Show("There are too many rows selected. Only select one please.", "Error");
                    }
                    //If the user has selected one row delete that row from the booking table and populate it in the cancelation table with the entered reason
                    else if (Results.SelectedRows.Count == 1)
                    {
                        int            rowNum         = Results.SelectedRows[0].Index;
                        int            cancellationId = int.Parse(Results.Rows[rowNum].Cells[0].Value.ToString());
                        int            childId        = int.Parse(Results.Rows[rowNum].Cells[1].Value.ToString());
                        DateTime       date           = Convert.ToDateTime(Results.Rows[rowNum].Cells[4].Value.ToString());
                        string         reason         = reasonBox.Text;
                        List <Booking> results        = new List <Booking>();
                        results = bdba.getBookWithID(cancellationId);

                        CancellationDBAccess cdba = new CancellationDBAccess(db);
                        cdba.InsertCancell(cancellationId, childId, date, reason);



                        foreach (Booking book in results)
                        {
                            //When the entry is deleted show a message saying 'Success'
                            bdba.DeleteEntry(book.BookingId);
                            new SuccessForm(db, "Success, Booking Cancelled").Show();
                            this.Hide();
                            new MainApp(db).Show();
                        }
                    }

                    //If the user clicks 'No', make the form dissappear
                    else if (result == DialogResult.No)
                    {
                        this.Hide();
                        new CancellForm(db).Show();
                    }
                }
            }
        }
コード例 #2
0
 private void button3_Click(object sender, EventArgs e)
 {
     //Shows all the data for bookings when the 'View' button is clicked
     if (comboBox1.Text == "Show All")
     {
         BookingDBAccess bdba = new BookingDBAccess(db);
         createTable(bdba.getAllBook());
     }
     //Shows the data for the bookings which matches the searched for BookingId
     else if (comboBox1.Text == "Booking ID")
     {
         BookingDBAccess bdba   = new BookingDBAccess(db);
         int             BookNo = Convert.ToInt32(searchBox.Text);
         createTable(bdba.getBookWithID(BookNo));
     }
     //shows the data for the bookings which matches the searched for Childs name
     else if (comboBox1.Text == "Child Name")
     {
         ChildrenDBAccess cdba = new ChildrenDBAccess(db);
         string           name = searchBox.Text;
         createTableShowAllChild(cdba.GetChildByName(name));
         selectedTable = "Children";
     }
     //Shows the data for the bookings which matches the searched for childs age
     else if (comboBox1.Text == "Child Age")
     {
         ChildrenDBAccess cdba = new ChildrenDBAccess(db);
         int age = Convert.ToInt32(searchBox.Text);
         createTableShowAllChild(cdba.GetChildByAge("=", age.ToString()));
         selectedTable = "Children";
     }
 }
コード例 #3
0
ファイル: CancellForm.cs プロジェクト: desm01/Database_System
        private void InitalizeTable()
        {
            //Create new object of type BookingDBAccess. Update table to show all bookings
            BookingDBAccess bdba = new BookingDBAccess(db);

            createTable(bdba.getAllBook());
        }
コード例 #4
0
        //Inserts data into the table
        private void button1_Click(object sender, EventArgs e)
        {
            //Initalizes cancelled to 0 as it hasnt been cancelled
            int canclled     = 0;
            int ChildId      = Convert.ToInt32(childId.Text);
            int BusBookingId = Convert.ToInt32(busBookingId.Text);

            //If the user hasn't paid, they're assigned 0
            if (cancelled.Text == "Not Paid")
            {
                canclled = 0;
            }
            //If the user has paid, they're assigned a 1
            else if (cancelled.Text == "Paid")
            {
                canclled = 1;
            }
            try
            {
                //Inserts the entered data into the Booking table
                string time = date.Value.ToShortDateString();

                BookingDBAccess bdba = new BookingDBAccess(db);
                bdba.InsertBooking(ChildId, BusBookingId, canclled, time);
                this.Hide();
                new SuccessForm(db, "Booking Successfully Registered").Show();
            }
            catch (Exception ex) {  }
        }
コード例 #5
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)
        {
            BookingDBAccess bbdba = new BookingDBAccess(db);

            bbdba.UpdateBooking(BookingId, ChildId, BusBookingId, Paid, Date);
            MessageBox.Show("The row in the database has been updated.", "Success");
            bookResults.DataSource = null;
        }
コード例 #6
0
ファイル: frmShowBooking.cs プロジェクト: OliwiaM/Repository
        private void frmShowBooking_Load(object sender, EventArgs e)
        {
            BookingDBAccess    BDBAccess = new BookingDBAccess(db);
            InstrumentDBAccess IDBAccess = new InstrumentDBAccess(db);
            PupilDBAccess      PDBAccess = new PupilDBAccess(db);

            selection         = cBox.SelectedIndex;
            lbl1.Visible      = false;
            lbl2.Visible      = false;
            btnSearch.Visible = false;
            txtBox1.Visible   = false;
            txtBox2.Visible   = false;
        }
コード例 #7
0
ファイル: frmShowPupils.cs プロジェクト: OliwiaM/Repository
        private void frmShowPupils_Load(object sender, EventArgs e)
        {
            PupilDBAccess      PDBAccess = new PupilDBAccess(db);
            BookingDBAccess    BDBAccess = new BookingDBAccess(db);
            InstrumentDBAccess IDBAccess = new InstrumentDBAccess(db);

            selection          = cBox.SelectedIndex;
            lbl1.Visible       = false;
            lbl2.Visible       = false;
            txtBoxID.Visible   = false;
            txtBoxName.Visible = false;
            btn1.Visible       = false;
        }
コード例 #8
0
ファイル: frmShowBooking.cs プロジェクト: OliwiaM/Repository
        private void cBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            PupilDBAccess      PDBAccess = new PupilDBAccess(db);
            BookingDBAccess    BDBAccess = new BookingDBAccess(db);
            InstrumentDBAccess IDBAccess = new InstrumentDBAccess(db);

            switch (cBox.SelectedIndex)
            {
            case 0: CreateTableResults(BDBAccess.getAllBookings(), IDBAccess.getAllInstruments(), PDBAccess.getAllPupils()); break;

            case 1:     lbl1.Visible = true;
                lbl2.Visible         = true;
                btnSearch.Visible    = true;
                txtBox1.Visible      = true;
                txtBox2.Visible      = true; break;
            }
        }
コード例 #9
0
ファイル: frmShowPupils.cs プロジェクト: OliwiaM/Repository
        private void btn1_Click(object sender, EventArgs e)
        {
            PupilDBAccess      PDBAccess = new PupilDBAccess(db);
            BookingDBAccess    BDBAccess = new BookingDBAccess(db);
            InstrumentDBAccess IDBAccess = new InstrumentDBAccess(db);
            List <Pupil>       pupils    = new List <Pupil>();
            Pupil Selected = new Pupil();

            if (string.IsNullOrWhiteSpace(txtBoxID.Text))
            {
                pupils = PDBAccess.getPupilByPupilName(txtBoxName.Text);
            }

            else
            {
                Selected = PDBAccess.getPupilByPupilNo(Convert.ToInt32(txtBoxID.Text));
                pupils.Add(Selected);
            }

            CreateTableResults(pupils);
        }
コード例 #10
0
ファイル: frmAddBooking.cs プロジェクト: OliwiaM/Repository
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {   // populates the labels with information about pupil
         if (DataGrid.SelectedRows.Count == 1)
         {
             BookingDBAccess BA     = new BookingDBAccess(db);
             List <Booking>  Booked = new List <Booking>();
             Booked = BA.getAllBookings();
             int           rowNum      = DataGrid.SelectedRows[0].Index;
             int           id          = int.Parse(DataGrid.Rows[rowNum].Cells[0].Value.ToString());
             PupilDBAccess pupilAccess = new PupilDBAccess(db);
             Selected          = pupilAccess.getPupilByPupilNo(id);
             lblPupilNo.Text   = Selected.PupilNo.ToString();
             lblTitle.Text     = Selected.PupilTitle;
             lblFirstName.Text = Selected.PupilFirstName;
             lblLastName.Text  = Selected.PupilLastName;
             lblDOB.Text       = Selected.PupilDOB.ToString("d/MM/yyyy");
             int    now  = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
             string date = DateTime.Now.ToShortDateString();
             int    dob  = int.Parse(Selected.PupilDOB.ToString("yyyyMMdd"));
             int    age  = (now - dob) / 10000;
             lblAge.Text = age.ToString();
             //fix this to autoNumber
             lblBookingNo.Text = Convert.ToString(Booked[Booked.Count() - 1].bookingNo + 1);
             timer1.Start();
             lblDate.Text      = date;
             groupBox4.Enabled = false;
             groupBox5.Enabled = false;
             groupBox6.Enabled = false;
             groupBox1.Enabled = true;
             groupBox2.Enabled = true;
             groupBox3.Enabled = true;
         }
     }
     catch (NullReferenceException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #11
0
ファイル: frmShowBooking.cs プロジェクト: OliwiaM/Repository
        private void btn1_Click(object sender, EventArgs e)
        {
            //Searches pupil by either pupilNo or LastName
            PupilDBAccess     pupilAccess   = new PupilDBAccess(db);
            BookingDBAccess   BookingAccess = new BookingDBAccess(db);
            List <Pupil>      pupils        = new List <Pupil>();
            List <Booking>    bookings      = new List <Booking>();
            List <Instrument> instruments   = new List <Instrument>();
            Booking           Selected      = new Booking();

            if (string.IsNullOrWhiteSpace(txtBox1.Text))
            {
                Selected = BookingAccess.getBookingByPupilID(Convert.ToInt32(txtBox2.Text));
                bookings.Add(Selected);
            }

            else
            {
                Selected = BookingAccess.getBookingByID(Convert.ToInt32(txtBox1.Text));
                bookings.Add(Selected);
            }

            CreateTableResults(bookings, instruments, pupils);
        }
コード例 #12
0
ファイル: frmAddBooking.cs プロジェクト: OliwiaM/Repository
        private void btn2_Click_1(object sender, EventArgs e)
        {
            //Validates if all of the required options were selected
            if (comboBox1.SelectedIndex == -1 || comboBox2.SelectedIndex == -1 || comboBox3.SelectedIndex == -1)
            {
                MessageBox.Show("To proceed you must select tuition type, lesson level and duration. ");
            }
            else
            {
                try
                {   //Inserts booking
                    int BookingNo    = Convert.ToInt32(lblBookingNo.Text);
                    int NoOfLessons  = lessons;
                    int instrumentNo = comboBox1.SelectedIndex;

                    newBooking.BookingNo = BookingNo;
                    newBooking.Duration  = Duration;
                    newBooking.PupilNo   = int.Parse(lblPupilNo.Text);
                    BookingDBAccess BookingAccess = new BookingDBAccess(db);
                    BookingAccess.insertBooking(BookingNo, int.Parse(lblPupilNo.Text), instrumentNo, NoOfLessons, level, Duration, fee);

                    //Informs the user that booking was created and checks if user wants to block book instantly
                    DialogResult dialogResult = MessageBox.Show("Would you like to Block Book your lessons now?", "Booking Created.", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        // Enables groupboxes related to block booking lessons
                        groupBox4.Enabled = true;
                        groupBox5.Enabled = true;
                        groupBox6.Enabled = true;

                        //Disables buttons related to booking
                        btnSearch.Enabled      = false;
                        btnSelectPupil.Enabled = false;
                        btn2.Enabled           = false;
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                        this.Hide();
                        frmPrivateTuition PTuition = new frmPrivateTuition(db);
                        PTuition.Show();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                cBoxTimeSlot.Items.Clear();
                cBoxTimeSlot.Items.Add("9:00am to 9:30am");
                cBoxTimeSlot.Items.Add("9:30am to 10:00am");
                cBoxTimeSlot.Items.Add("10:00am to 10:30am");
                cBoxTimeSlot.Items.Add("10:30am to 11:00am");
                cBoxTimeSlot.Items.Add("11:00am to 11:30am");
                cBoxTimeSlot.Items.Add("11:30am to 12:00pm");
                cBoxTimeSlot.Items.Add("12:00pm to 12:30pm");
                cBoxTimeSlot.Items.Add("12:30pm to 1:00pm");
                cBoxTimeSlot.Items.Add("1:00pm to 1:30pm");
                cBoxTimeSlot.Items.Add("1:30pm to 2:00pm");
                cBoxTimeSlot.Items.Add("2:00pm to 2:30pm");
                cBoxTimeSlot.Items.Add("2:30pm to 3:00pm");
                cBoxTimeSlot.Items.Add("3:00pm to 3:30pm");
                cBoxTimeSlot.Items.Add("3:30pm to 4:00pm");
                cBoxTimeSlot.Items.Add("4:00pm to 4:30pm");
                cBoxTimeSlot.Items.Add("4:30pm to 5:00pm");
                cBoxTimeSlot.Items.Add("5:00pm to 5:30pm");
                cBoxTimeSlot.Items.Add("5:30pm to 6:00pm");
                cBoxTimeSlot.Items.Add("6:00pm to 6:30pm");
                cBoxTimeSlot.Items.Add("6:30pm to 7:00pm");
                cBoxTimeSlot.Items.Add("7:00pm to 7:30pm");
                cBoxTimeSlot.Items.Add("7:30pm to 8:00pm");
                cBoxTimeSlot.Items.Add("8:00pm to 8:30pm");
                cBoxTimeSlot.Items.Add("8:30pm to 9:00pm");

                /*else
                 * {
                 *  cBoxTimeSlot.Items.Clear();
                 *  cBoxTimeSlot.Items.Add("9:00am to 10:00am");
                 *  cBoxTimeSlot.Items.Add("10:00am to 11:00am");
                 *  cBoxTimeSlot.Items.Add("11:00am to 12:00pm");
                 *  cBoxTimeSlot.Items.Add("12:00pm to 1:00pm");
                 *  cBoxTimeSlot.Items.Add("1:00pm to 2:00pm");
                 *  cBoxTimeSlot.Items.Add("2:00pm to 3:00pm");
                 *  cBoxTimeSlot.Items.Add("3:00pm to 4:00pm");
                 *  cBoxTimeSlot.Items.Add("4:00pm to 5:00pm");
                 *  cBoxTimeSlot.Items.Add("5:00pm to 6:00pm");
                 *  cBoxTimeSlot.Items.Add("6:00pm to 7:00pm");
                 *  cBoxTimeSlot.Items.Add("7:00pm to 8:00pm");
                 *  cBoxTimeSlot.Items.Add("8:00pm to 9:00pm");
                 * }*/
                // catch (Exception ex)
                //{
                // MessageBox.Show(ex.Message);
                // }
            }
        }