Ejemplo n.º 1
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;
            }
        }