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;
        }
        private void SalesAnalysis_Load(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            ds = Reservations.getYear(ds);


            for (int i = 0; i < ds.Tables["Year"].Rows.Count; i++)
            {
                var val = ds.Tables[0].Rows[i][0].ToString().PadLeft(3, '0');

                if (!cmbYear.Items.Contains(val))
                {
                    cmbYear.Items.Add(val);
                }
            }
        }
Example #3
0
        private void CancelReservation_Load(object sender, EventArgs e)
        {
            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());
                }
            }
        }
Example #4
0
        private void CheckOut_Load(object sender, EventArgs e)
        {
            //populate the combobox on load
            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());
                }
            }
        }
Example #5
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;
        }
Example #6
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;
        }
Example #7
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;
        }
Example #8
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (cboTypes.SelectedIndex == -1)//Nothing selected
            {
                MessageBox.Show("A Room Type must be selected", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboTypes.Focus();
                return;
            }

            if (dtpFrom.Text == dtpTo.Text)// makes sure the users arrival and depature date are not the same
            {
                MessageBox.Show("You cannot make a resrvation for the same day", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (dtpTo.MinDate < dtpFrom.Value)//makes sure that the depature date isnt before date of arrival
            {
                MessageBox.Show("You cannot make a resrvation for a date before the date of arrival", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dtpTo.Focus();
                return;
            }

            else
            {
                //if it passes the validation create a dataset. call the method get available rooms. This method checks to confirm a booking has not been made on that date for that room
                DataSet ds = new DataSet();


                ds = Reservations.getAvailableRooms(ds, dtpFrom.Value.ToString("yyyy-MM-dd"), dtpTo.Value.ToString("yyyy-MM-dd"), cboTypes.Text.Substring(0, 3));
                // if no rooms pass that validation displays approiate error message otherwise fills the room no box with the available rooms
                if (ds.Tables["ss"].Rows.Count == 0)
                {
                    MessageBox.Show("Sorry there are no available rooms for the period selected. Please select another Date/Type", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cboTypes.SelectedIndex = -1;
                    cboTypes.Focus();
                }
                else
                {
                    cmbRoomNo.Items.Clear();
                    for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++)
                    {
                        cmbRoomNo.Items.Add(ds.Tables[0].Rows[i][0].ToString());
                    }

                    Reservations makeRes = new Reservations();

                    //res id to string
                    txtResID.Text = Reservations.nextResId().ToString("000000");
                    //calculating the cost of the reservation giving the user a price be4 confirming reservation
                    // finding days between storing in p
                    double p = (Convert.ToDateTime(dtpTo.Text) - Convert.ToDateTime(dtpFrom.Text)).TotalDays;
                    // finding the rate
                    decimal x = Reservations.findRateprov(cboTypes.Text);
                    // making x a double so that it can be multiplied by totaldays between
                    double dbl = Convert.ToDouble(x);



                    double ans = Convert.ToDouble(p * dbl);
                    txtCost.Text = Convert.ToString(ans);



                    grpReservaion.Visible = true;
                }
            }
        }
Example #9
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (txtCustName.Text == String.Empty)
            {
                //Checking if customersname has been entered correctly and putting cursor there if it isnt
                MessageBox.Show("Customers Name must be Entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtCustName.Focus();
                return;
            }

            if (txtEmail.Text == String.Empty)
            {
                //Checking if E-mail has been entered correctly and putting cursor there if it isnt
                MessageBox.Show("E-mail must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmail.Focus();
                return;
            }

            if (txtCustName.Text.Any(Char.IsDigit))
            {
                MessageBox.Show("CustName only accepts letters");
                txtCustName.Focus();
                return;
            }
            //Checking if RoomNo has been selected correctly and putting cursor there if it isnt
            if (cmbRoomNo.SelectedIndex == -1)//Nothing selected
            {
                MessageBox.Show("A Room No must be selected", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbRoomNo.Focus();
                return;
            }


            else
            {
                //adding details to reservation and calculating total cost of stay

                Reservations makeRes = new Reservations();
                makeRes.setRes_ID(Reservations.nextResId());
                makeRes.setRoom_No(Convert.ToInt32(cmbRoomNo.Text));
                makeRes.setCust_Name(txtCustName.Text.ToUpper());
                makeRes.setE_Mail(txtEmail.Text.ToUpper());
                makeRes.setDate_Arrive(dtpFrom.Value.ToString("yyyy-MM-dd"));
                makeRes.setDate_Depart(dtpTo.Value.ToString("yyyy-MM-dd"));
                makeRes.setTotal_Cost((Convert.ToDateTime(dtpTo.Text) - Convert.ToDateTime(dtpFrom.Text)).TotalDays * Reservations.findRate(makeRes.getRoom_No(Convert.ToInt32(cmbRoomNo.Text))));
                makeRes.setCheck_In("A");
                makeRes.setCheck_Out("A");
                makeRes.setRes_Status("A");
                makeRes.makeReservation();


                //Clearing the ui
                MessageBox.Show("A Reservation has been successfully made");
                txtCustName.Clear();
                txtEmail.Clear();
                cmbRoomNo.SelectedIndex = -1;
                cboTypes.SelectedIndex  = -1;
                grpReservaion.Visible   = false;
            }
        }