Exemplo n.º 1
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            // deleting the reservation and resetting the ui
            Reservations cancel = new Reservations();

            cancel.getRes_ID();
            cancel.setRes_ID(Convert.ToInt32(txtResId.Text));
            cancel.deleteReservation();
            MessageBox.Show("A reservation has been successfully cancelled");
            cboRes_ID.SelectedIndex = -1;
            grpDeleteRes.Visible    = false;

            cboRes_ID.Items.Clear();

            DataSet ds = new DataSet();

            ds = Reservations.getValidReservationsForDeletion(ds);

            if (ds.Tables["ss"].Rows.Count == 0)
            {
                cboRes_ID.Focus();
                MessageBox.Show("There are no reservations available to be cancelled", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboRes_ID.TabStop = false;
            }
            else
            {
                for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++)
                {
                    cboRes_ID.Items.Add(String.Format("{0:000000}", ds.Tables[0].Rows[i][0]) + " " + ds.Tables[0].Rows[i][2].ToString());
                }
            }
        }
        private void cboRes_ID_SelectedIndexChanged(object sender, EventArgs e)
        {
            //this stops stops system from crashing after updating. so that when the box clears to not execute the rest of the code
            if (cboRes_ID.SelectedIndex == -1)
            {
                return;
            }



            Reservations myRes = new Reservations();

            myRes.getReservation(Convert.ToInt32(cboRes_ID.Text.Substring(0, 6)));

            //load form controls with data from myRes

            txtName.Text = myRes.getCust_Name();
            //formating date arrive text so that the secounds are cut from the date
            txtDateDep.Text = myRes.getDate_Depart().ToString().Substring(0, 10);
            //returning resid in the format 000001 etc
            txtResId.Text = myRes.getRes_ID().ToString("000000");



            //display reservation details
            grpCheckIn.Visible = true;
        }
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            //if the radio button is checked
            if (rbCheckIn.Checked)
            {
                //get the res id
                Reservations checkin = new Reservations();
                checkin.getRes_ID();
                checkin.setRes_ID(Convert.ToInt32(txtResId.Text));
                //invoke the checkin method
                checkin.checkIn();
                //confirmation message and reset the ui
                MessageBox.Show("A Customer has succesfully checkedIn");
                cboRes_ID.SelectedIndex = -1;
                rbCheckIn.Checked       = false;
                grpCheckIn.Visible      = false;

                // clear the res id box
                cboRes_ID.Items.Clear();
                // create and fill a new dataset that will allow the system to update on the fly you wont have to go in and out of the function in order for it to update
                DataSet ds = new DataSet();
                ds = Reservations.getCheckIns(ds, DateTime.Now.ToString("yyyy-MM-dd"));
                //if teres no check in display error message
                if (ds.Tables["ss"].Rows.Count == 0)
                {
                    cboRes_ID.Focus();
                    MessageBox.Show("There are no rooms available for check-In today", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cboRes_ID.TabStop = false;
                }
                else
                {
                    // if tere is populate the combo box
                    for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++)
                    {
                        cboRes_ID.Items.Add(String.Format("{0:000000}", ds.Tables[0].Rows[i][0]) + " " + ds.Tables[0].Rows[i][2].ToString());
                    }
                }
            }
            // validation that ensure that you actual select the check in
            else
            {
                MessageBox.Show("CheckIn must be Entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            rbCheckIn.Focus();
            return;
        }
Exemplo n.º 4
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (rbCheckOut.Checked)
            {
                // updateing db and resetting the ui
                Reservations checkOut = new Reservations();
                checkOut.getRes_ID();
                checkOut.setRes_ID(Convert.ToInt32(txtResID.Text));
                checkOut.checkOut();
                MessageBox.Show("A Customer has succesfully checkedOut");
                cboRes_ID.SelectedIndex = -1;
                rbCheckOut.Checked      = false;
                grpCheckOut.Visible     = false;
                //clearing cbo box
                cboRes_ID.Items.Clear();
                // repopulating the combobox with only relevant check outs. allows function to update while in the function
                DataSet ds = new DataSet();
                ds = Reservations.getCheckOuts(ds, DateTime.Now.ToString("yyyy-MM-dd"));

                if (ds.Tables["ss"].Rows.Count == 0)
                {
                    cboRes_ID.Focus();
                    MessageBox.Show("There are no rooms available for check-Out today", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cboRes_ID.TabStop = false;
                }
                else
                {
                    for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++)
                    {
                        cboRes_ID.Items.Add(String.Format("{0:000000}", ds.Tables[0].Rows[i][0]) + " " + ds.Tables[0].Rows[i][2].ToString());
                    }
                }
            }
            else
            {
                MessageBox.Show("CheckOut must be Entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            rbCheckOut.Focus();
            return;
        }
Exemplo n.º 5
0
        private void cboRes_ID_SelectedIndexChanged(object sender, EventArgs e)
        {
            // stops system from crashing when updating combo box
            if (cboRes_ID.SelectedIndex == -1)
            {
                return;
            }
            Reservations myRes = new Reservations();

            myRes.getReservation(Convert.ToInt32(cboRes_ID.Text.Substring(0, 6)));

            //load form controls with data from myRes

            txtName.Text    = myRes.getCust_Name();
            txtDateDep.Text = myRes.getDate_Depart().ToString().Substring(0, 10);
            txtDateArr.Text = myRes.getDate_Arrive().ToString().Substring(0, 10);
            txtResId.Text   = myRes.getRes_ID().ToString("000000");



            //display reservation details
            grpDeleteRes.Visible = true;
        }
Exemplo n.º 6
0
        private void cboRes_ID_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboRes_ID.SelectedIndex == -1)
            {
                return;
            }
            //retrieve reservation and display on UI
            Reservations myRes = new Reservations();

            myRes.getReservation(Convert.ToInt32(cboRes_ID.Text.Substring(0, 6)));

            //load form controls with data from myRes
            txtName.Text = myRes.getCust_Name();
            //formating date arrive text so that the secounds are cut from the date
            txtDateArr.Text = myRes.getDate_Arrive().ToString().Substring(0, 10);
            //returning resid in the format 000001 etc
            txtResID.Text = myRes.getRes_ID().ToString("000000");



            //display reservation details
            grpCheckOut.Visible = true;
        }