Exemplo n.º 1
0
        private bool isFormValidate()
        {
            if (BranchNametextBox.Text.Trim() == "")
            {
                MessageBox.Show("Branch Name is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BranchNametextBox.Clear();
                BranchNametextBox.Focus();
                return(false);
            }
            if (EmailAddressTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Email is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                EmailAddressTextBox.Clear();
                EmailAddressTextBox.Focus();
                return(false);
            }
            if (TelephoneTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Telephone is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TelephoneTextBox.Clear();
                TelephoneTextBox.Focus();
                return(false);
            }
            if (AddressLineTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Address is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                AddressLineTextBox.Clear();
                AddressLineTextBox.Focus();
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        private bool isFormValid()
        {
            if (BranchNameTextBox.Text.Trim() == string.Empty)
            {
                SMSMessageBox.ShowErrorMessage("Branch Name is required");
                BranchNameTextBox.Focus();
                return(false);
            }

            if (EmailAddressTextBox.Text.Trim() == string.Empty)
            {
                SMSMessageBox.ShowErrorMessage("Email is required");
                EmailAddressTextBox.Focus();
                return(false);
            }

            if (TelephoneTextBox.Text.Trim() == string.Empty)
            {
                SMSMessageBox.ShowErrorMessage("Telephone is required");
                TelephoneTextBox.Focus();
                return(false);
            }

            return(true);
        }
 private bool IsFormValid()
 {
     if (NameTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Name is required");
         NameTextBox.Clear();
         NameTextBox.Focus();
         return(false);
     }
     if (EmailTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Email is required");
         EmailTextBox.Clear();
         EmailTextBox.Focus();
         return(false);
     }
     if (TelephoneTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Telephone is required");
         TelephoneTextBox.Clear();
         TelephoneTextBox.Focus();
         return(false);
     }
     return(true);
 }
Exemplo n.º 4
0
 private void ClearText()
 {
     NameTextBox.Clear();
     AddressTextBox.Clear();
     PostalCodeTextBox.Clear();
     CityTextBox.Clear();
     TelephoneTextBox.Clear();
     EmailTextBox.Clear();
     ContactTypeComboBox.SelectedIndex = -1;
 }
Exemplo n.º 5
0
        private void TelephoneTextBox_Enter(object sender, EventArgs e)
        {
            TelephoneTextBox.ForeColor    = Color.FromArgb(78, 184, 206);
            TelephonePictureBox.Image     = Properties.Resources.phone_icon_colored;
            TelephoneFieldPanel.BackColor = Color.FromArgb(78, 184, 206);

            RegisterStatusLabel.Text = "";

            if (TelephoneTextBox.Text == "Телефон")
            {
                TelephoneTextBox.Clear();
            }
        }
Exemplo n.º 6
0
        private bool IsFormValidate()
        {
            if (FullNameTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Full Name is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FullNameTextBox.Clear();
                FullNameTextBox.Focus();
                return(false);
            }
            if (EmailAddressTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Email is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                EmailAddressTextBox.Clear();
                EmailAddressTextBox.Focus();
                return(false);
            }
            if ((TelephoneTextBox.Text.Trim() == "") && (MobileTextBox.Text.Trim() == ""))
            {
                MessageBox.Show("Mobile or Telephone Number is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TelephoneTextBox.Clear();
                TelephoneTextBox.Focus();
                return(false);
            }
            if (NICTextBox.Text.Trim() == "")
            {
                MessageBox.Show("NIC is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                NICTextBox.Clear();
                NICTextBox.Focus();
                return(false);
            }
            if (GenderComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("Gender is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            if (AddressLineTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Address is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                AddressLineTextBox.Clear();
                AddressLineTextBox.Focus();
                return(false);
            }
            if (CityComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("City is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            if (DistrictComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("District is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            if (PostCodeTextBox.Text.Trim() == "")
            {
                MessageBox.Show("PostCode is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                PostCodeTextBox.Clear();
                PostCodeTextBox.Focus();
                return(false);
            }
            if (JobTitleComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("Job Title is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            if (CurrentSalaryTextBox1.Text.Trim() == "")
            {
                MessageBox.Show("Current Salary is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                CurrentSalaryTextBox1.Clear();
                CurrentSalaryTextBox1.Focus();
                return(false);
            }
            else
            {
                if (Convert.ToDecimal(CurrentSalaryTextBox1.Text.Trim()) < 1)
                {
                    MessageBox.Show("Current Salary can not be Zero or less than zero");
                    CurrentSalaryTextBox1.Focus();
                    return(false);
                }
            }
            if (StartingSalaryTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Starting Salary is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                StartingSalaryTextBox.Clear();
                StartingSalaryTextBox.Focus();
                return(false);
            }
            else
            {
                if (Convert.ToDecimal(StartingSalaryTextBox.Text.Trim()) < 1)
                {
                    MessageBox.Show("Starting Salary can not be Zero or less than zero");
                    StartingSalaryTextBox.Focus();
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 7
0
        private void button2_Click(object sender, EventArgs e) //add guest
        {
            if ((myState == FormState.Add) || ((myState == FormState.WhileBooking) && button2.Text == "Add Guest") ||
                (myState == FormState.Edit))
            {
                Regex validateEmail = new Regex(@"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
                                                @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$");


                //https://msdn.microsoft.com/en-us/library/01escwtf(v=vs.110).aspx



                Regex testForNonNumeric = new Regex(@"\D");

                Regex testForLetters = new Regex(@"^[a-zA-Z ]+$"); // @"^[a-zA-Z ]+$" for space character



                if (FirstNameTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter First Name", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //https://msdn.microsoft.com/en-us/library/system.windows.forms.messageboxicon(v=vs.110).aspx
                    FirstNameTextBox.Focus(); //focuses on text box with error

                    return;
                }

                else if (LastNameTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter Last Name", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    LastNameTextBox.Focus();
                    return;
                }



                else if (TelephoneTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter Your Telephone Number", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TelephoneTextBox.Focus();
                    return;
                }

                else if (TelephoneTextBox.TextLength < 10)
                {
                    MessageBox.Show("Telephone number must contains 10 digits", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TelephoneTextBox.Focus();
                    return;
                }

                else if (TelephoneTextBox.TextLength > 10)
                {
                    MessageBox.Show("Telephone number must contains 10 digits", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TelephoneTextBox.Focus();
                    return;
                }

                else if (testForNonNumeric.IsMatch(TelephoneTextBox.Text))
                {
                    MessageBox.Show("Telephone number must contain digits only", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TelephoneTextBox.Focus();
                    return;
                }

                else if (EmailTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter An Email Address", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    EmailTextBox.Focus();
                    return;
                }

                else if (!validateEmail.IsMatch(EmailTextBox.Text))
                {
                    MessageBox.Show("Invalid Email Address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    EmailTextBox.Focus();
                    return;
                }


                else
                {
                    //go to next form
                    if (myState == FormState.Add)
                    {
                        guest = PopulateObject();
                        guestController.ADD(guest);
                        MessageBox.Show("Guest successfully added", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        ClearAll();
                        this.Hide();
                    }
                    if (myState == FormState.WhileBooking)
                    {
                        guest = PopulateObject();
                        aBooking.DepositPaid = "false";
                        aBooking.GuestID     = guest.GuestID;

                        bookingController.ADD(aBooking);
                        guestController.ADD(guest);
                        MessageBox.Show("Guest successfully added and booking successfully made", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);


                        //would they like to pay now
                        DialogResult result = MessageBox.Show("Would you like to pay now", "Pay now?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            PaymentDetailsForm paymentDetailsForm = new PaymentDetailsForm(paymentController,
                                                                                           aBooking, guest, bookingController);
                            paymentDetailsForm.MdiParent     = (Home)this.MdiParent;    // Setting the MDI Parent
                            paymentDetailsForm.StartPosition = FormStartPosition.CenterParent;
                            this.Hide();
                            paymentDetailsForm.Show();
                        }
                        else
                        {
                            //go straight to the email

                            ConfirmationForm cf = new ConfirmationForm(guest, aBooking);

                            cf.StartPosition = FormStartPosition.CenterParent;
                            cf.Show();
                            this.Hide();
                        }
                        ClearAll();
                    }
                    if (myState == FormState.Edit)
                    {
                        Guest g = new Guest();
                        g.GuestID   = textBox1.Text;
                        g.FirstName = FirstNameTextBox.Text;
                        g.Surname   = LastNameTextBox.Text;

                        g.TelephoneNumber = TelephoneTextBox.Text;
                        g.EmailAddress    = EmailTextBox.Text;


                        DialogResult result = MessageBox.Show("Are you sure you want to edit guest", "Edit Guest", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                        //populate the text boxes
                        if (result == DialogResult.Yes)
                        {
                            //we must delete the guest tell them guest has been successfully deleted
                            guestController.Edit(g);
                            MessageBox.Show("Guest successfully editted", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ClearAll();

                            this.Hide();
                        }
                        else
                        {
                            //reset the controls
                            showRequiredFields(FormState.Edit);
                        }
                    }
                }
            }

            else if (((myState == FormState.WhileBooking) && (button2.Text == "Verify Guest")) || (myState == FormState.Delete))
            {
                if (GuestIDTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter A Guest ID to search for", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    GuestIDTextBox.Focus();
                    return;
                }
                else if (guestController.FindByGuestID(GuestIDTextBox.Text) == null)
                {
                    MessageBox.Show("Guest not found", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    GuestIDTextBox.Focus();
                    return;
                }
                else
                {
                    Guest temp = guestController.FindByGuestID(GuestIDTextBox.Text);
                    FirstNameTextBox.Text = temp.FirstName;
                    LastNameTextBox.Text  = temp.Surname;

                    TelephoneTextBox.Text = temp.TelephoneNumber;

                    EmailTextBox.Text   = temp.EmailAddress;
                    GuestIDTextBox.Text = temp.GuestID;


                    if (myState == FormState.WhileBooking)
                    {
                        MessageBox.Show("Guest has been verified", "Verified", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //add the booking
                        aBooking.GuestID     = temp.GuestID;
                        aBooking.DepositPaid = "false";
                        bookingController.ADD(aBooking);
                        MessageBox.Show("Booking has been successfully made", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);


                        //populate the text boxes
                        DialogResult result = MessageBox.Show("Would you like to pay now", "Pay now?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            PaymentDetailsForm paymentDetailsForm = new PaymentDetailsForm(paymentController, aBooking, temp, bookingController);
                            paymentDetailsForm.MdiParent     = (Home)this.MdiParent;        // Setting the MDI Parent
                            paymentDetailsForm.StartPosition = FormStartPosition.CenterParent;
                            this.Hide();
                            paymentDetailsForm.Show();
                        }
                        else
                        {
                            //go straight to the email

                            ConfirmationForm cf = new ConfirmationForm(temp, aBooking);

                            cf.StartPosition = FormStartPosition.CenterParent;
                            cf.Show();
                            this.Hide();
                        }
                    }
                    if (myState == FormState.Delete)
                    {
                        DialogResult result = MessageBox.Show("Are you sure you want to delete guest", "Delete guest", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                        //populate the text boxes
                        if (result == DialogResult.Yes)
                        {
                            //we must delete the guest tell them guest has been successfully deleted
                            guestController.Delete(temp);
                            MessageBox.Show("Guest has been deleted", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Hide();
                        }
                        else
                        {
                            //reset the controls
                            showRequiredFields(FormState.Delete);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        /*
         * Event Handler for Confirm Button
         * -Validating FUll Name, Telephone Number, Email Address
         * -
         */
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            StreamWriter FileWriter;
            string       DynamicMessage;

            if (ProceedButton.Enabled == true)
            {
                MessageBox.Show("Please Confirm the Term by pressing Proceed button before confirming the membership");
            }
            else
            {
                if (NotNullValue(FullNameTextBox.Text, 1))
                {
                    //Full Name Regular Express Validation
                    //One Word is mandatory which includes Capital and small Letters
                    if (!Regex.IsMatch(FullNameTextBox.Text, @"^[A-Z a-z]*([A-Z a-z]*)+$"))
                    {
                        MessageBox.Show("Please enter valid name", "Invalid Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        FullNameTextBox.Focus();
                        FullNameTextBox.SelectAll();
                    }
                    else
                    {
                        if (NotNullValue(TelephoneTextBox.Text, 2))
                        {
                            //Telephone Number Reguar Expression Validation
                            //Grouping of 3 Number followed by space(not mandatory), then Next 3 numbers followed by space and then last 4 digits
                            if (!Regex.IsMatch(TelephoneTextBox.Text, @"^(\(?\d{3}\)*\s?\d{3}\s?\d{4})$"))
                            {
                                MessageBox.Show("Please enter valid telephone Number", "Invalid Number", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                TelephoneTextBox.Focus();
                                TelephoneTextBox.SelectAll();
                            }
                            else
                            {
                                if (NotNullValue(EmailTextBox.Text, 3))
                                {
                                    //Email Validation by Regular Expression
                                    bool CorrectEmail = Regex.IsMatch(EmailTextBox.Text, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);

                                    if (!CorrectEmail)
                                    {
                                        MessageBox.Show("Please enter valid email address", "Invalid Email Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        EmailTextBox.Focus();
                                        EmailTextBox.SelectAll();
                                    }
                                    else
                                    {
                                        //If all the detais are correct, providing popup
                                        DynamicMessage = "Provided Details are as below:";
                                        DynamicMessage = DynamicMessage + "\n\nMembership Details :";
                                        DynamicMessage = DynamicMessage + "\nMembership ID      : " + MembershipIDLabel.Text;
                                        DynamicMessage = DynamicMessage + "\nConfirmed Term     : " + ConfirmedTerm.ToString();
                                        DynamicMessage = DynamicMessage + "\nMembership Fees  : " + ConfirmedTermTotal.ToString();
                                        DynamicMessage = DynamicMessage + "\n\nPersonal Details :";
                                        DynamicMessage = DynamicMessage + "\nFull Name              : " + FullNameTextBox.Text;
                                        DynamicMessage = DynamicMessage + "\nTelephone No.      : " + TelephoneTextBox.Text;
                                        DynamicMessage = DynamicMessage + "\nEmail ID                 : " + EmailTextBox.Text;
                                        DynamicMessage = DynamicMessage + "\n\nDo you want to cofirm the Membership Details?";

                                        //Yes No Popup  Display decision
                                        DialogResult DR = MessageBox.Show(DynamicMessage, "Do you want to Continue?", MessageBoxButtons.YesNo);
                                        if (DR == DialogResult.Yes)
                                        {
                                            try
                                            {
                                                //Saving details of membership to the Database File
                                                FileWriter = File.AppendText(DatabaseFileName);
                                                FileWriter.WriteLine(MembershipIDLabel.Text);
                                                FileWriter.WriteLine(JoinDayLabel.Text);
                                                FileWriter.WriteLine(FullNameTextBox.Text);
                                                FileWriter.WriteLine(TelephoneTextBox.Text);
                                                FileWriter.WriteLine(EmailTextBox.Text);
                                                FileWriter.WriteLine(ConfirmedTerm.ToString());
                                                FileWriter.WriteLine(ConfirmedTermTotal.ToString("N2"));
                                                FileWriter.Close();
                                                //closing File Writer

                                                if (SummaryButton.Enabled == false)
                                                {
                                                    SummaryButton.Enabled = true;
                                                }
                                                if (SearchButton.Enabled == false)
                                                {
                                                    SearchButton.Enabled = true;
                                                }

                                                //Confirmation Message
                                                DynamicMessage = "Hello, " + FullNameTextBox.Text + "!. Welcome Aboard. :) \n Your Membership ID is : " + MembershipIDLabel.Text;
                                                MessageBox.Show(DynamicMessage, "Membership Confirmed", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                                MembershipDetailsGroupBox.Visible = false;
                                                //Clearing Fields
                                                TermTextBox.Text =
                                                    ClientConfirmedTextBox.Text               =
                                                        PricePerMonthLabel.Text               =
                                                            PriceFullTermLabel.Text           =
                                                                PriceNextTermLabel.Text       =
                                                                    FullNameTextBox.Text      =
                                                                        TelephoneTextBox.Text =
                                                                            EmailTextBox.Text = "";
                                                //Enabling Buttons
                                                SearchButton.Enabled        =
                                                    SummaryButton.Enabled   =
                                                        TermTextBox.Enabled =
                                                            ClientConfirmedTextBox.Enabled = true;
                                            }
                                            catch (Exception ex)
                                            {
                                                // Display an error message.
                                                MessageBox.Show(ex.Message);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }