private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            New_Reservation CreateNewReservation = new New_Reservation();

            CreateNewReservation.Show();
            this.Close();
        }
예제 #2
0
        //When the Create Reservation is Click
        private void btnNewReservation_Click(object sender, RoutedEventArgs e)
        {
            New_Reservation CreateQuote = new New_Reservation();

            CreateQuote.Show();
            this.Close();
        }
예제 #3
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.winNewReservation = ((Group03.New_Reservation)(target));
                return;

            case 2:
                this.lblInstructions = ((System.Windows.Controls.Label)(target));
                return;

            case 3:
                this.lblTitle = ((System.Windows.Controls.Label)(target));
                return;

            case 4:
                this.lblRoomType = ((System.Windows.Controls.Label)(target));
                return;

            case 5:
                this.lblNoRooms = ((System.Windows.Controls.Label)(target));
                return;

            case 6:
                this.lblCheckIn = ((System.Windows.Controls.Label)(target));
                return;

            case 7:
                this.txtNoOfRoom = ((System.Windows.Controls.TextBox)(target));
                return;

            case 8:
                this.lblCheckOut = ((System.Windows.Controls.Label)(target));
                return;

            case 9:
                this.txtQuote = ((System.Windows.Controls.TextBox)(target));
                return;

            case 10:
                this.btnQuote = ((System.Windows.Controls.Button)(target));
                return;

            case 11:
                this.btnReservation = ((System.Windows.Controls.Button)(target));
                return;

            case 12:
                this.btnMainMenu = ((System.Windows.Controls.Button)(target));
                return;
            }
            this._contentLoaded = true;
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.winNewReservation = ((Group03.New_Reservation)(target));
                return;

            case 2:
                this.grpReservationInfo = ((System.Windows.Controls.GroupBox)(target));
                return;

            case 3:
                this.lblTitle = ((System.Windows.Controls.Label)(target));
                return;

            case 4:
                this.lblRoomType = ((System.Windows.Controls.Label)(target));
                return;

            case 5:
                this.cbxRoomType = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 6:
                this.lblNoRooms = ((System.Windows.Controls.Label)(target));
                return;

            case 7:
                this.dtpCheckIn = ((System.Windows.Controls.DatePicker)(target));

            #line 34 "..\..\New Reservation.xaml"
                this.dtpCheckIn.SelectedDateChanged += new System.EventHandler <System.Windows.Controls.SelectionChangedEventArgs>(this.dtpCheckIn_SelectedDateChange);

            #line default
            #line hidden
                return;

            case 8:
                this.lblCheckIn = ((System.Windows.Controls.Label)(target));
                return;

            case 9:
                this.txtNoOfRooms = ((System.Windows.Controls.TextBox)(target));
                return;

            case 10:
                this.lblCheckOut = ((System.Windows.Controls.Label)(target));
                return;

            case 11:
                this.dtpCheckOut = ((System.Windows.Controls.DatePicker)(target));

            #line 38 "..\..\New Reservation.xaml"
                this.dtpCheckOut.SelectedDateChanged += new System.EventHandler <System.Windows.Controls.SelectionChangedEventArgs>(this.dtpCheckOut_SelectedDateChanged);

            #line default
            #line hidden
                return;

            case 12:
                this.txtQuote = ((System.Windows.Controls.TextBox)(target));
                return;

            case 13:
                this.btnQuote = ((System.Windows.Controls.Button)(target));

            #line 40 "..\..\New Reservation.xaml"
                this.btnQuote.Click += new System.Windows.RoutedEventHandler(this.btnQuote_Click);

            #line default
            #line hidden
                return;

            case 14:
                this.btnReservation = ((System.Windows.Controls.Button)(target));

            #line 41 "..\..\New Reservation.xaml"
                this.btnReservation.Click += new System.Windows.RoutedEventHandler(this.btnReservation_Click);

            #line default
            #line hidden
                return;

            case 15:
                this.btnMainMenu = ((System.Windows.Controls.Button)(target));

            #line 42 "..\..\New Reservation.xaml"
                this.btnMainMenu.Click += new System.Windows.RoutedEventHandler(this.btnMainMenu_Click);

            #line default
            #line hidden
                return;

            case 16:
                this.lblQuote = ((System.Windows.Controls.Label)(target));
                return;
            }
            this._contentLoaded = true;
        }
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            string   strCardNum = txtCardNo.Text.Trim().Replace(" ", "");
            string   FirstName;
            string   LastName;
            string   CardNo;
            string   PhoneNumber;
            string   Email;
            DateTime CheckInDate;
            DateTime CheckOutDate;

            //Validate card number
            long lngOut;
            int  i;
            int  intCheckDigit;
            int  intCheckSum = 0;

            DateTime CheckIn  = new DateTime();
            DateTime CheckOut = new DateTime();

            //Parse Variable
            double dblNum;

            // variables to check empty fields
            bool   bolEmpty = false; // boolean that is set to true whenever there is an unselected/empty field
            string strEmpty = "";    // string used to add fields that will be displayed whenever they are empty

            // check for empty fields
            if (txtFirstName.Text.Trim() == "")
            {
                bolEmpty = true;
                strEmpty = "first name";
            }

            if (txtLastName.Text.Trim() == "")
            {
                if (bolEmpty == true)
                {
                    strEmpty = strEmpty + ", last name";
                }

                else
                {
                    bolEmpty = true;
                    strEmpty = "last name";
                }
            }

            if (txtCardNo.Text.Trim() == "")
            {
                if (bolEmpty == true)
                {
                    strEmpty = strEmpty + ", credit card no";
                }

                else
                {
                    bolEmpty = true;
                    strEmpty = "credit card no";
                }
            }

            if (txtPhone.Text.Trim() == "")
            {
                if (bolEmpty == true)
                {
                    strEmpty = strEmpty + ", phone no";
                }

                else
                {
                    bolEmpty = true;
                    strEmpty = strEmpty + "phone no";
                }
            }

            // if bolEmpty is true, display message showing all empty fields that needs to be sorted out
            if (bolEmpty == true)
            {
                MessageBox.Show("The field(s) " + strEmpty + " cannot be empty.");
                return;
            }

            //Check whether first name contains numbers, show error if true
            if (double.TryParse(txtFirstName.Text.Trim(), out dblNum))
            {
                MessageBox.Show("First name cannot contain numbers.");
                return;
            }

            //Check whether last name contains numbers, show error if true
            if (double.TryParse(txtLastName.Text.Trim(), out dblNum))
            {
                MessageBox.Show("Last name cannot contain numbers.");
                return;
            }

            //Check that credit card only contains numbers
            if (!Int64.TryParse(strCardNum, out lngOut))
            {
                MessageBox.Show("Credit card can only contain numeric values.");
                return;
            }

            //Validate the card number length
            if (strCardNum.Length != 13 && strCardNum.Length != 15 && strCardNum.Length != 16)
            {
                MessageBox.Show("Credit card numbers must be either 13, 15, or 16 digits.");
                return;
            }

            //Validate the card number
            strCardNum = ReverseString(strCardNum);

            for (i = 0; i < strCardNum.Length; i++)
            {
                intCheckDigit = Convert.ToInt32(strCardNum.Substring(i, 1));

                if ((i + 1) % 2 == 0)
                {
                    intCheckDigit *= 2;

                    if (intCheckDigit > 9)
                    {
                        intCheckDigit -= 9;
                    }
                }

                intCheckSum += intCheckDigit;
            }

            // show error if the checksum is not valid
            if (intCheckSum % 10 != 0)
            {
                MessageBox.Show("Credit card number is not valid.");
                return;
            }

            // validate that phone number only contain numbers
            if (!Int64.TryParse(txtPhone.Text, out lngOut))
            {
                MessageBox.Show("Phone number can only contain numeric values.");
                return;
            }

            if (txtPhone.Text.Trim().Length != 10)
            {
                MessageBox.Show("Phone number must be 10 digits.");
                return;
            }

            // if email is not empty, validate it
            if (txtEmail.Text.Trim() != "")
            {
                if (IsValidEmail(txtEmail.Text.Trim()) == false)
                {
                    MessageBox.Show("Email must be in valid format.");
                    return;
                }
            }

            //Store the inputed value
            FirstName   = txtFirstName.Text.Trim();
            LastName    = txtLastName.Text.Trim();
            CardNo      = txtCardNo.Text.Trim();
            PhoneNumber = txtPhone.Text.Trim();
            Email       = txtEmail.Text.Trim();

            CheckIn     = Convert.ToDateTime(lblCheckInOut.Content).Date;
            CheckInDate = CheckIn.Date;

            CheckOut     = Convert.ToDateTime(lblCheckOutOut.Content).Date;
            CheckOutDate = CheckOut.Date;


            //Add the reservation to the reservation list
            newReservation = new Reservation(CheckInDate.Date, CheckOutDate.Date,
                                             FirstName, LastName, PhoneNumber, Email, lblRoomTypeOut.Content.ToString(), CurrentQuote.NoOfRoom,
                                             lblTotalPriceOut.Content.ToString());

            //Save to json file
            SaveToJson();

            //Return to new reservation 1
            New_Reservation mw = new New_Reservation();

            mw.Show();
            this.Close();
        }