private bool ValidateForm()
        {
            if (!Regex.Match(FirstNameTextBox.Text, @"^\D{1,30}$").Success)
            {
                MessageBox.Show("First name must consist of at least 1 character and not exceed 30 characters!");
                FirstNameTextBox.Focus();
                return(false);
            }

            if (!Regex.Match(LastNameTextBox.Text, @"^\D{1,30}$").Success)
            {
                MessageBox.Show("Last name must consist of at least 1 character and not exceed 30 characters!");
                LastNameTextBox.Focus();
                return(false);
            }

            if (!Regex.Match(AddressTextBox.Text, @"^(Вул\.\s\D{1,40}\,\s\d{1,3})$").Success)
            {
                MessageBox.Show("Address must consist of at least 1 character and not exceed 50 characters!");
                AddressTextBox.Focus();
                return(false);
            }

            if (!Regex.Match(PhoneNumberTextBox.Text, @"^\d{10}$").Success)
            {
                MessageBox.Show("Phone number must consist of 10 digits!");
                PhoneNumberTextBox.Focus();
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
 // New Customer button clicked
 private void NewCustomerButton_Click(object sender, EventArgs e)
 {
     // if text fields are filled, show messagebox
     if (FirstNameTextBox.Text != "" || LastNameTextBox.Text != "" ||
         EmailTextBox.Text != "" || PhoneTextBox.Text != "" ||
         AddressTextBox.Text != "" || CityTextBox.Text != "" ||
         StateTextBox.Text != "" || ZipTextBox.Text != "")
     {
         DialogResult response = MessageBox.Show("Are you sure you want to discard all the changes?", "Discard Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
         if (response == DialogResult.Yes)
         {
             ResetAll();
             FirstNameTextBox.Focus();
             SaveButton.Enabled       = true;
             CustomerComboBox.Enabled = false;
             addNewCustomerMode       = true;
             updateCustomerMode       = false;
         }
     }
     else
     {
         ResetAll();
         FirstNameTextBox.Focus();
         SaveButton.Enabled       = true;
         CustomerComboBox.Enabled = false;
         addNewCustomerMode       = true;
         updateCustomerMode       = false;
     }
     EnableTextFields(true);
     CustomerCancelButton.Enabled = true;
 }
Exemplo n.º 3
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult result = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    // create writer
                    StreamWriter writer = new StreamWriter("Name2s.txt", true);
                    writer.WriteLine(FirstNameTextBox.Text + " " + LastNameTextBox.Text);

                    // close connections
                    writer.Close();

                    // reset the form fields
                    FirstNameTextBox.Clear();
                    LastNameTextBox.Clear();

                    FirstNameTextBox.Focus();
                }
                else
                {
                    FirstNameTextBox.Focus();
                    FirstNameTextBox.SelectAll();
                }
            } catch
            {
                Console.WriteLine("problems");
            }
        }
Exemplo n.º 4
0
        private void PerformSalutation()
        {
            _person.Salutation = String.Empty; // Reset
            personBindingSource.ResetBindings(false);
            if (_person.Name == String.Empty || _person.Firstname == String.Empty)
            {
                MessageBox.Show("Enter both the firstname and name of the person.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                FirstNameTextBox.Focus();
                FirstNameTextBox.SelectAll();
                return;
            }

            // Execute rules
            try
            {
                var ruleExecuter = new RuleSetInvoker();
                if (_settings.Source == RuleSource.CodedDynamic)
                {
                    ruleExecuter.PerformDynamicRules(_person, _settings.Rules);
                }
                else if (_settings.Source == RuleSource.CodedStatic)
                {
                    ruleExecuter.PerformCodedRules(_person);
                }
                else
                {
                    ruleExecuter.PerformDesignerRules(_person);
                }
                personBindingSource.ResetBindings(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 5
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.OKCancel);

            if (result == DialogResult.OK)
            {
                // Step 1 - Open a stream
                StreamWriter writer = new StreamWriter("Names.txt", true);

                // Step 2 - Write to the buffer
                writer.WriteLine(FirstNameTextBox.Text + " " + LastNameTextBox.Text);

                // Step 3 - Close the file
                writer.Close();

                //Step 4 - Reset the Form
                FirstNameTextBox.Clear();
                LastNameTextBox.Clear();
                FirstNameTextBox.Focus();
            }
            else
            {
                FirstNameTextBox.Focus();
                FirstNameTextBox.SelectAll();
            }
        }
Exemplo n.º 6
0
        private void addStudentItem_Click(object sender, EventArgs e)
        {
            if (Text_boxes_empty())
            {
                return;
            }

            if (students == null)
            {
                students = new StudentsCollection();
            }
            if (students.GetEnumerator().Position + 1 >= students.students_list.Count)
            {
                students.AddStudent(new Student(FirstNameTextBox.Text, SecondNameTextBox.Text, FacultyTextBox.Text));
                students.GetEnumerator().MoveEnd();
                deleteStudent.Enabled = true;
                SetButtonEnable(TypeAction.Next, false);
                SetButtonEnable(TypeAction.Prev, true);
                need_updated = true;
                FirstNameTextBox.Focus();

                MoveToAddForm();

                toolStripLabelnfo.Text = "Студент добавлен";
            }
            else
            {
                toolStripLabelnfo.Text = "Перейдите в поле для добавления";
            }
        }
Exemplo n.º 7
0
 private void addButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         bl.AddPrayer(prayer);
         prayer            = new BE.Prayer();
         Grid1.DataContext = prayer;
         prayersWindow.PrayerDataGrid.ItemsSource       = null;
         prayersWindow.PrayerDataGrid.ItemsSource       = bl.GetAllPrayers();
         prayersWindow.ChoosePrayerComboBox.ItemsSource = null;
         prayersWindow.ChoosePrayerComboBox.ItemsSource = bl.GetAllPrayers();
         string message = prayer.FirstName + " " + prayer.LastName + "נוסף לרשימת המתפללים";
         MessageBox.Show(message, "המתפלל נוסף לקהילה", MessageBoxButton.OK, MessageBoxImage.Information,
                         MessageBoxResult.OK, MessageBoxOptions.RightAlign);
         prayer            = new BE.Prayer();
         Grid1.DataContext = prayer;
         BMparashaComboBox.SelectedIndex        = -1;
         LastAliyaParashaComboBox.SelectedIndex = -1;
         TribeComboBox.SelectedIndex            = 2;
         FirstNameTextBox.Focus();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "אזהרה!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 private void FirstNameTextBox_Leave(object sender, EventArgs e)
 {
     if (FirstNameTextBox.TextLength < 2)
     {
         FirstNameTextBox.Focus();
         FirstNameTextBox.SelectAll();
     }
 }
Exemplo n.º 9
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     FirstNameTextBox.Focus(FocusState.Programmatic);
     // Setup date picker.
     dateTimeOnPageCreation = DateTime.Now;
     DobDatePicker.MaxYear  = dateTimeOnPageCreation;
     DobDatePicker.Date     = dateTimeOnPageCreation;
 }
Exemplo n.º 10
0
 private void ClearButton_Click(object sender, System.EventArgs e)
 {
     //Calling ClearBoxes method to clear textboxes
     ClearTextBoxes();
     //Setting focus back to SearchTextBox
     FirstNameTextBox.Focus();
     //Setting ADD button to enabled
     AddButton.Enabled = true;
 }
Exemplo n.º 11
0
        private void Add(object sender, RoutedEventArgs e)
        {
            string avatar = ((Icon)AvatarComboBox.SelectedValue).Icons;

            Contacts.Add(new Contact {
                FirstName = FirstNameTextBox.Text, LastName = LastnameTextBox.Text, Avatar = avatar
            });
            FirstNameTextBox.Text        = "";
            LastnameTextBox.Text         = "";
            AvatarComboBox.SelectedIndex = -1;
            FirstNameTextBox.Focus(FocusState.Programmatic);
        }
Exemplo n.º 12
0
        private void NewContactButton_Click(object sender, RoutedEventArgs e)
        {
            string avata = ((Icon)AvataComboBox.SelectedValue).IconPath;

            Contacts.Add(new Contact {
                FirstName = FirstNameTextBox.Text, LastName = LastNameTextBox.Text, AvataPath = avata
            });
            FirstNameTextBox.Text       = "";
            LastNameTextBox.Text        = "";
            AvataComboBox.SelectedIndex = -1;
            FirstNameTextBox.Focus(FocusState.Programmatic);
        }
Exemplo n.º 13
0
        // Checks imput fields.
        private bool CheckFields()
        {
            // First name.
            if (String.IsNullOrEmpty(FirstNameTextBox.Text))
            {
                ErrorFirstNameTextBlock.Visibility = Visibility.Visible;
                FirstNameTextBox.Focus(FocusState.Programmatic);
                return(false);
            }
            else
            {
                ErrorFirstNameTextBlock.Visibility = Visibility.Collapsed;
            }

            // Last name.
            if (String.IsNullOrEmpty(LastNameTextBox.Text))
            {
                ErrorLastNameTextBlock.Visibility = Visibility.Visible;
                LastNameTextBox.Focus(FocusState.Programmatic);
                return(false);
            }
            else
            {
                ErrorLastNameTextBlock.Visibility = Visibility.Collapsed;
            }

            // DOB.
            if (DobDatePicker.Date == null || DobDatePicker.Date >= dateTimeOnPageCreation)
            {
                ErrorDobDateTextBlock.Visibility = Visibility.Visible;
                DobDatePicker.Focus(FocusState.Programmatic);
                return(false);
            }
            else
            {
                ErrorDobDateTextBlock.Visibility = Visibility.Collapsed;
            }

            // Gender.
            if (GenderComboBox.SelectedItem == null)
            {
                ErrorGenderTextBlock.Visibility = Visibility.Visible;
                GenderComboBox.Focus(FocusState.Programmatic);
                return(false);
            }
            else
            {
                ErrorGenderTextBlock.Visibility = Visibility.Collapsed;
            }

            return(true);
        }
Exemplo n.º 14
0
        private const string BIO_TEXTBOX_DEFAULT = "(optional...)"; //default text to be displayed in BioTextBox

        /// <summary>
        /// Constructor for AddAuthorDialog
        /// Initializes fields and preps the Window for user interaction
        /// </summary>
        public AddAuthorDialog()
        {
            InitializeComponent();

            FirstNameTextBox.Text = string.Empty;
            LastNameTextBox.Text  = string.Empty;
            ErrorTextBlock.Text   = string.Empty;

            ResetBioBox();

            //ensure that FirstNameTextBox is focused
            FirstNameTextBox.Focus();
        }
Exemplo n.º 15
0
 public void ResetForm()
 {
     FirstNameTextBox.Text      = string.Empty;
     LastNameTextBox.Text       = string.Empty;
     MiddleTextBox.Text         = string.Empty;
     AddressTextBox.Text        = string.Empty;
     CityTextBox.Text           = string.Empty;
     StateTextBox.Text          = string.Empty;
     ZipCodeTextBox.Text        = string.Empty;
     PhoneNumTextBox.Text       = string.Empty;
     SecondaryPhoneTextBox.Text = string.Empty;
     LicenseNumTextBox.Text     = string.Empty;
     FirstNameTextBox.Focus();
 }
Exemplo n.º 16
0
        private void NewContactButton_Click_1(object sender, RoutedEventArgs e)
        {
            string avatar = ((Icon)AvatarComboBox.SelectedValue).IconPath;

            Contacts.Add(new Contact {
                FirstName = FirstNameTextBox.Text, LastName = LastNameTextBox.Text, AvatarPath = avatar
            });
            // sau khi an them contact
            FirstNameTextBox.Text        = "";
            LastNameTextBox.Text         = "";
            AvatarComboBox.SelectedIndex = 1;

            FirstNameTextBox.Focus(FocusState.Programmatic); // cho con tro chuot vao first name
        }
Exemplo n.º 17
0
        private void NewContactButton_Click(object sender, RoutedEventArgs e)
        {
            string avatar = ((Icon)Image.SelectedValue).IconPath;

            Products.Add(new Product {
                Name = FirstNameTextBox.Text, Description = LastNameTextBox.Text, Image = avatar
            });

            FirstNameTextBox.Text = "";
            LastNameTextBox.Text  = "";
            Image.SelectedIndex   = -1;

            FirstNameTextBox.Focus(FocusState.Programmatic);
        }
Exemplo n.º 18
0
        private void NewContactButton_Click(object sender, RoutedEventArgs e)
        {
            string avatar = ((IconSS)Images.SelectedValue).iconPath;

            //Thêm item mới
            Contacts.Add(new Contact {
                FirstName = FirstNameTextBox.Text, LastName = LastNameTextBox.Text, AvatarPath = avatar
            });

            //Reset data
            FirstNameTextBox.Text = "";
            LastNameTextBox.Text  = "";

            //AvatarComboBox.SelectedItem = -1;
            FirstNameTextBox.Focus(FocusState.Programmatic);
        }
Exemplo n.º 19
0
        public AddPrayerWindow()
        {
            InitializeComponent();
            bl                = BL.FactoryBl.getBL();
            prayer            = new BE.Prayer();
            Grid1.DataContext = prayer;


            BMparashaComboBox.CustomSource        = Enum.GetValues(typeof(BE.Parashot));
            LastAliyaParashaComboBox.CustomSource = Enum.GetValues(typeof(BE.Parashot));
            TribeComboBox.ItemsSource             = Enum.GetValues(typeof(BE.Lineage));

            BMparashaComboBox.SelectedIndex        = -1;
            LastAliyaParashaComboBox.SelectedIndex = -1;
            TribeComboBox.SelectedIndex            = 2;
            FirstNameTextBox.Focus();
        }
Exemplo n.º 20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (null == Session["LoggedUser"])
     {
         Response.Redirect("~/Login");
     }
     else
     {
         if (!IsPostBack)
         {
             FirstNameTextBox.Focus();
             User user = Session["LoggedUser"] as User;
             EmailTextBox.Text     = user.Email;
             FirstNameTextBox.Text = user.FirstName;
             LastNameTextBox.Text  = user.LastName;
         }
     }
 }
Exemplo n.º 21
0
 private void ClearForm()
 {
     // Clear input fields.
     FirstNameTextBox.Text       = String.Empty;
     LastNameTextBox.Text        = String.Empty;
     DobDatePicker.Date          = dateTimeOnPageCreation;
     GenderComboBox.SelectedItem = null;
     EmailTextBox.Text           = String.Empty;
     PhoneTextBox.Text           = String.Empty;
     // Clear error fields.
     ErrorFirstNameTextBlock.Visibility = Visibility.Collapsed;
     ErrorLastNameTextBlock.Visibility  = Visibility.Collapsed;
     ErrorDobDateTextBlock.Visibility   = Visibility.Collapsed;
     ErrorGenderTextBlock.Visibility    = Visibility.Collapsed;
     // Clear edit buttons.
     ButtonsStackPanel.Visibility = Visibility.Collapsed;
     // Set focus to the first input.
     FirstNameTextBox.Focus(FocusState.Programmatic);
 }
Exemplo n.º 22
0
        /// <summary>
        /// Creates a new author based on the user inputs
        /// </summary>
        private void CreateAuthor()
        {
            //if nothing was inputted to FirstNameTextBox, show error message and return
            if (FirstNameTextBox.Text.Length == 0)
            {
                ErrorTextBlock.Text = "Please enter a first name.";
                FirstNameTextBox.Focus();
                return;
            }

            //if nothing was entered in LastNameTextBox, show error message and return
            if (LastNameTextBox.Text.Length == 0)
            {
                ErrorTextBlock.Text = "Please enter a last name.";
                LastNameTextBox.Focus();
                return;
            }

            //Show confirmation messagebox, if the messagebox result is Yes, set the dialog result to true and close this window.
            if (MessageBox.Show("Are you sure you want to create this author?", "Confirm", MessageBoxButton.YesNo,
                                MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
            {
                FirstNameResult = FirstNameTextBox.Text;
                LastNameResult  = LastNameTextBox.Text;

                if (BioTextBox.Text == BIO_TEXTBOX_DEFAULT)
                {
                    BioResult = string.Empty;
                }
                else
                {
                    BioResult = BioTextBox.Text;
                }


                DialogResult = true;
                this.Close();
            }
        }
Exemplo n.º 23
0
        private void FirstNameTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            string namePattern      = @"[а-я]";
            var    firstNameIsMatch = Regex.IsMatch(FirstNameTextBox.Text, namePattern);

            if (String.IsNullOrEmpty(FirstNameTextBox.Text))
            {
                e.Cancel = true;
                FirstNameTextBox.Focus();
                ErrorProvider.SetError(FirstNameTextBox, "Укажите имя");
            }
            else if (firstNameIsMatch == false)
            {
                e.Cancel = true;
                FirstNameTextBox.Focus();
                ErrorProvider.SetError(FirstNameTextBox, "Недопустимый формат");
            }
            else
            {
                e.Cancel = false;
                ErrorProvider.SetError(FirstNameTextBox, null);
            }
        }
Exemplo n.º 24
0
 /// <summary>
 /// When the page loads first the page checks if the user is logged in, and is redirected to the login page if not.
 /// Then the method checks if the user has has proper authentication (Master Administrator role) to access this page.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["securityID"] == null) // Redirect Administrator to login if not logged in
     {
         Response.Redirect("~/Admin/Login.aspx");
     }
     else if ((int)Session["securityID"] != 2) // Return HTTP Code 403 if not Master Administrator
     {
         Context.Response.StatusCode = 403;
     }
     else
     {
         if (!IsPostBack)
         {
             // Set focus on the First Name text box
             FirstNameTextBox.Focus();
             // Hide the success message field
             SuccessMessage.Visible = false;
             // Clear all text box fields
             ClearFields();
         }
     }
 }
Exemplo n.º 25
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            string letterList = "ABCDEFGHIJKLMNOPRSTUVWXYZabcdefghijklmnoprstuvwxyzАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя";
            string numList    = "1234567890";

            if (!String.IsNullOrWhiteSpace(LastNameTextBox.Text) && !String.IsNullOrWhiteSpace(FirstNameTextBox.Text) && !String.IsNullOrWhiteSpace(MiddleNameTextBox.Text) && !String.IsNullOrWhiteSpace(PhoneNumberTextBox.Text) && !String.IsNullOrWhiteSpace(PassportTextBox.Text) && !String.IsNullOrWhiteSpace(IssuedByWhomTextBox.Text) && !String.IsNullOrWhiteSpace(AreaTextBox.Text) && !String.IsNullOrWhiteSpace(CityTextBox.Text) && !String.IsNullOrWhiteSpace(StreetTextBox.Text) && !String.IsNullOrWhiteSpace(HouseTextBox.Text) && DateOfBirthDatePicker.SelectedDate != null && GroupComboBox.SelectedItem != null && EducationComboBox.SelectedItem != null && DateOfIssueDatePicker.SelectedDate != null && BasicOfLearningComboBox.SelectedItem != null)
            {
                if (LastNameTextBox.Text.IndexOfAny(numList.ToCharArray()) <= -1)
                {
                    if (FirstNameTextBox.Text.IndexOfAny(numList.ToCharArray()) <= -1)
                    {
                        if (MiddleNameTextBox.Text.IndexOfAny(numList.ToCharArray()) <= -1)
                        {
                            if (PhoneNumberTextBox.Text.Length == 18 && (PhoneNumberTextBox.Text.IndexOfAny(letterList.ToCharArray()) <= -1) && !PhoneNumberTextBox.Text.Contains('_'))
                            {
                                if (AreaTextBox.Text.IndexOfAny(numList.ToCharArray()) <= -1)
                                {
                                    if (CityTextBox.Text.IndexOfAny(numList.ToCharArray()) <= -1)
                                    {
                                        if (DateOfBirthDatePicker.SelectedDate < DateTime.Today)
                                        {
                                            if (!PassportTextBox.Text.Contains('_'))
                                            {
                                                if (DateOfIssueDatePicker.SelectedDate < DateTime.Today)
                                                {
                                                    if (CurrentStudent == null)
                                                    {
                                                        //if (AppData.Context.Passport.Where(c => c.Serial == PassportTextBox.Text.Remove(5, 7) && c.Number == PassportTextBox.Text.Remove(0, 6)).FirstOrDefault() == null)
                                                        //{
                                                        CurrentPassport = new Passport()
                                                        {
                                                            Serial       = PassportTextBox.Text.Remove(5, 7).Replace(" ", ""),
                                                            Number       = PassportTextBox.Text.Remove(0, 6),
                                                            DateOfIssue  = DateOfIssueDatePicker.SelectedDate,
                                                            IssuedByWhom = IssuedByWhomTextBox.Text,
                                                        };
                                                        AppData.Context.Passport.Add(CurrentPassport);

                                                        CurrentAddress = new Address()
                                                        {
                                                            Region    = AreaTextBox.Text,
                                                            City      = CityTextBox.Text,
                                                            Street    = StreetTextBox.Text,
                                                            House     = HouseTextBox.Text,
                                                            Apartment = ApartmentTextBox.Text,
                                                        };
                                                        AppData.Context.Address.Add(CurrentAddress);

                                                        CurrentStudent = new Student()
                                                        {
                                                            LastName        = LastNameTextBox.Text,
                                                            FirstName       = FirstNameTextBox.Text,
                                                            MiddleName      = MiddleNameTextBox.Text,
                                                            PhoneNumber     = PhoneNumberTextBox.Text,
                                                            DateOfBirth     = DateOfBirthDatePicker.SelectedDate,
                                                            Group           = GroupComboBox.SelectedItem as Group,
                                                            Education       = EducationComboBox.SelectedItem as Education,
                                                            IdPassport      = CurrentPassport.Id,
                                                            IdAddress       = CurrentAddress.Id,
                                                            BasicOfLearning = BasicOfLearningComboBox.SelectedItem as BasicOfLearning,
                                                        };
                                                        AppData.Context.Student.Add(CurrentStudent);
                                                        AppData.Context.SaveChanges();
                                                        MessageBox.Show("Обучающийся успешно добавлен!", "Внимание", MessageBoxButton.OK, MessageBoxImage.Information);
                                                        NavigationService.GoBack();
                                                    }
                                                }
                                                else
                                                {
                                                    CurrentStudent.LastName    = LastNameTextBox.Text;
                                                    CurrentStudent.FirstName   = FirstNameTextBox.Text;
                                                    CurrentStudent.MiddleName  = MiddleNameTextBox.Text;
                                                    CurrentStudent.PhoneNumber = PhoneNumberTextBox.Text;
                                                    CurrentStudent.DateOfBirth = DateOfBirthDatePicker.SelectedDate;
                                                    CurrentGroup                 = GroupComboBox.SelectedItem as Group;
                                                    CurrentBasicOfLearning       = BasicOfLearningComboBox.SelectedItem as BasicOfLearning;
                                                    CurrentEducation             = EducationComboBox.SelectedItem as Education;
                                                    CurrentPassport.Serial       = PassportTextBox.Text.Remove(5, 7).Replace(" ", "");
                                                    CurrentPassport.Number       = PassportTextBox.Text.Remove(0, 6);
                                                    CurrentPassport.DateOfIssue  = DateOfIssueDatePicker.SelectedDate;
                                                    CurrentPassport.IssuedByWhom = IssuedByWhomTextBox.Text;
                                                    CurrentAddress.Region        = AreaTextBox.Text;
                                                    CurrentAddress.City          = CityTextBox.Text;
                                                    CurrentAddress.Street        = StreetTextBox.Text;
                                                    CurrentAddress.House         = HouseTextBox.Text;
                                                    CurrentAddress.Apartment     = ApartmentTextBox.Text;
                                                    AppData.Context.SaveChanges();
                                                    MessageBox.Show("Информация обновлена!", "Внимание", MessageBoxButton.OK, MessageBoxImage.Information);
                                                    NavigationService.GoBack();
                                                }
                                            }
                                            else
                                            {
                                                MessageBox.Show("Дата выдачи паспорта указаны некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                                DateOfIssueDatePicker.Focus();
                                            }
                                            //}
                                            //else
                                            //{
                                            //    MessageBox.Show("Серия и номер паспорта указаны некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                            //    PassportTextBox.Focus();
                                            //}
                                        }
                                        else
                                        {
                                            MessageBox.Show("Дата рождения указана некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                            DateOfBirthDatePicker.Focus();
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Город указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                        CityTextBox.Focus();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Область указана некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                    AreaTextBox.Focus();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Номер телефона указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                LastNameTextBox.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Отчество указано некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                            MiddleNameTextBox.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Имя указано некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                        FirstNameTextBox.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Фамилия указана некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                    LastNameTextBox.Focus();
                }
            }
            else
            {
                MessageBox.Show("Не все поля заполнены!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 26
0
        private void button3_Click(object sender, EventArgs e)
        {
            //check if the field is empty
            if (GuestIDTextBox.Text == "")
            {
                MessageBox.Show("Please input a guestID", "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;
            }
            //if the guest doesnt exist
            else if (guestController.FindByGuestID(GuestIDTextBox.Text) == null)
            {
                MessageBox.Show("Guest not found", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                GuestIDTextBox.Focus();
                return;
            }
            //if the guest exists
            else
            {
                Guest temp = guestController.FindByGuestID(GuestIDTextBox.Text);
                label10.Visible = true;
                label11.Visible = true;
                label12.Visible = true;
                label17.Visible = true;
                label18.Visible = true;
                label19.Visible = false;

                FirstNameTextBox.Visible = true;
                LastNameTextBox.Visible  = true;

                TelephoneTextBox.Visible = true;

                EmailTextBox.Visible = true;



                GuestIDTextBox.Visible = false;
                button3.Visible        = false;

                FirstNameTextBox.Text = temp.FirstName;
                LastNameTextBox.Text  = temp.Surname;

                TelephoneTextBox.Text = temp.TelephoneNumber;

                EmailTextBox.Text = temp.EmailAddress;

                if (myState == FormState.Edit)
                {
                    label10.Text             = "Edit Guest with ID:";
                    FirstNameTextBox.Enabled = true;
                    LastNameTextBox.Enabled  = true;

                    TelephoneTextBox.Enabled = true;

                    EmailTextBox.Enabled = true;

                    button2.Text    = "Save Changes";
                    button2.Visible = true;

                    textBox1.Text    = temp.GuestID;
                    textBox1.Enabled = false;
                    textBox1.Visible = true;
                }
                if (myState == FormState.Delete)
                {
                    label10.Text             = "Delete Guest with ID:";
                    FirstNameTextBox.Enabled = false;
                    LastNameTextBox.Enabled  = false;

                    TelephoneTextBox.Enabled = false;

                    EmailTextBox.Enabled = false;
                    button2.Text         = "Delete";
                    button2.Visible      = true;
                    textBox1.Text        = temp.GuestID;
                    textBox1.Enabled     = false;
                    textBox1.Visible     = true;
                }
            }
        }
Exemplo n.º 27
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.º 28
0
        private bool ValidateForm()
        {
            if (!Regex.Match(FirstNameTextBox.Text, @"^\D{1,30}$").Success)
            {
                MessageBox.Show("First name must consist of at least 1 character and not exceed 30 characters!");
                FirstNameTextBox.Focus();
                return(false);
            }

            if (!Regex.Match(LastNameTextBox.Text, @"^\D{1,30}$").Success)
            {
                MessageBox.Show("Last name must consist of at least 1 character and not exceed 30 characters!");
                LastNameTextBox.Focus();
                return(false);
            }

            if (!Regex.Match(PhoneNumberTextBox.Text, @"^\d{10}$").Success)
            {
                MessageBox.Show("Phone number must consist of 10 digits!");
                PhoneNumberTextBox.Focus();
                return(false);
            }

            if (!Regex.Match(ExperienceTextBox.Text, @"^[0-9]+$").Success)
            {
                MessageBox.Show("Invalid work experience number! It must contain only digits");
                ExperienceTextBox.Focus();
                return(false);
            }

            if (!Regex.Match(AddressTextBox.Text, @"^(Вул\.\s\D{1,40}\,\s\d{1,3})$").Success)
            {
                MessageBox.Show("Address must consist of at least 1 character and not exceed 50 characters!");
                AddressTextBox.Focus();
                return(false);
            }

            if (RoleComboBox.SelectedItem == null)
            {
                MessageBox.Show("Please select role");
                return(false);
            }

            if (MarketComboBox.SelectedItem == null)
            {
                MessageBox.Show("Please select market");
                return(false);
            }

            if (CityComboBox.SelectedItem == null)
            {
                MessageBox.Show("Please select city");
                return(false);
            }

            if (!Regex.Match(LoginTextBox.Text, @"^\D{6,20}$").Success)
            {
                MessageBox.Show("Login must consist of at least 6 character and not exceed 20 characters!");
                LoginTextBox.Focus();
                return(false);
            }

            if (!Regex.Match(PasswordTextBox.Text, @"^\D{6,20}$").Success)
            {
                MessageBox.Show("Login must consist of at least 6 character and not exceed 20 characters!");
                PasswordTextBox.Focus();
                return(false);
            }

            return(true);
        }
Exemplo n.º 29
0
 protected void Page_Load(object sender, EventArgs e)
 {
     FirstNameTextBox.Focus();
 }
Exemplo n.º 30
0
        private string TextBoxValidation()
        {
            string errorMessage = string.Empty;

            if (FirstNameTextBox.Text.Length > 0 && FirstNameTextBox.Text != null)
            {
                this.FirstName = FirstNameTextBox.Text;
            }
            else
            {
                errorMessage = "Invalid entry for first name. Please enter a valid first name";

                FirstNameTextBox.Focus();
            }

            if (MiddleNameTextBox.Text != null)
            {
                this.MiddleName = MiddleNameTextBox.Text;
            }
            else
            {
                errorMessage = "Invalid entry for middle name. Please enter a valid middle name";

                MiddleNameTextBox.Focus();
            }

            if (LastNameTextBox.Text.Length > 0 && LastNameTextBox.Text != null)
            {
                this.LastName = LastNameTextBox.Text;
            }
            else
            {
                errorMessage = "Invalid entry for last name. Please enter a valid last name";

                LastNameTextBox.Focus();
            }

            if (CityTextBox.Text.Length > 0 && CityTextBox.Text != null)
            {
                this.City = CityTextBox.Text;
            }
            else
            {
                errorMessage = "Invalid entry for city. Please enter a valid city";

                CityTextBox.Focus();
            }

            if (StateTextBox.Text.Length > 0 && StateTextBox.Text != null)
            {
                this.State = StateTextBox.Text;
            }
            else
            {
                errorMessage = "Invalid entry for state. Please enter a valid state";

                StateTextBox.Focus();
            }

            if (CountryTextBox.Text.Length > 0 && CountryTextBox.Text != null)
            {
                this.Country = CountryTextBox.Text;
            }
            else
            {
                errorMessage = "Invalid entry for Country. Please enter a valid country";

                CountryTextBox.Focus();
            }

            if (PhoneNumberTextBox.Text.Length > 0 && PhoneNumberTextBox.Text != null)
            {
                this.PhoneNumber = PhoneNumberTextBox.Text;
            }
            else
            {
                errorMessage = "Invalid entry for phone number. Please enter a valid phone number";

                PhoneNumberTextBox.Focus();
            }

            if (EmailAddressTextBox.Text.Length > 0 && EmailAddressTextBox.Text != null)
            {
                this.EmailAddress = EmailAddressTextBox.Text;
            }
            else
            {
                errorMessage = "Invalid entry for email address. Please enter a valid email address";

                EmailAddressTextBox.Focus();
            }

            return(errorMessage);
        }