Пример #1
0
        private bool isFormValid()
        {
            if (StudentNameTextBox.Text.Trim() == string.Empty)
            {
                SMSMessageBox.ShowErrorMessage("Name is required");
                StudentNameTextBox.Focus();
                return(false);
            }

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

            if (DepartmentComboBox.SelectedIndex == -1)
            {
                SMSMessageBox.ShowErrorMessage("Department is required");
                DepartmentComboBox.Focus();
                return(false);
            }

            return(true);
        }
        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);
        }
Пример #3
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);
        }
Пример #4
0
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            string Str = TransactionNumberTextBox.Text;
            double Num;
            bool   isNum = double.TryParse(Str, out Num);

            string Str2 = PhoneNumberTextBox.Text;
            double Num2;
            bool   isNum2 = double.TryParse(Str2, out Num2);

            if (isNum)
            {
                if (NameTextBox.Text != "")
                {
                    if (isNum2)
                    {
                        if (EmailTextBox.Text != "")
                        {
                            Message = ("Details of your transaction below\n" +
                                       "Transaction id: " + TransactionNumberTextBox.Text + "\n" +
                                       "Name: " + NameTextBox.Text + "\n" +
                                       "Phone Number: " + PhoneNumberTextBox.Text + "\n" +
                                       "Email: " + EmailTextBox.Text + "\n" + "Principal+interest: " +
                                       value + "\n" +
                                       "If the details above are correct and you wish to proceed click OK ");
                            Heading = "Confirmation";
                            MessageBoxButtons buttons     = MessageBoxButtons.OKCancel;
                            MessageBoxIcon    messageIcon = MessageBoxIcon.Question;
                            DialogResult      result;
                            result = MessageBox.Show(Message, Heading, buttons, messageIcon);
                            if (result == DialogResult.OK)
                            {
                                FileWriter();

                                MessageBox.Show("Clients details have been saved ", "Details Saved", MessageBoxButtons.OK);

                                TransCount     += TransactionNumberTextBox.Text + "\n";
                                InvestedAmount += decimal.Parse(InvestAmountTextBox.Text);
                                NumberOfTransactions++;

                                SummaryGB.Visible     = true;
                                SummaryButton.Visible = true;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please enter your email address");
                            EmailTextBox.Focus();
                            EmailTextBox.SelectAll();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter a phone number, Only numeric Input accepted");
                        PhoneNumberTextBox.Focus();
                        PhoneNumberTextBox.SelectAll();
                    }
                }
                else
                {
                    MessageBox.Show("Please enter your name");
                    NameTextBox.Focus();
                    NameTextBox.SelectAll();
                }
            }
            else
            {
                MessageBox.Show("Please enter a SIX digit unique key");
                TransactionNumberTextBox.Focus();
                TransactionNumberTextBox.SelectAll();
            }
        }
Пример #5
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);
        }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            string letterList = "ABCDEFGHIJKLMNOPRSTUVWXYZabcdefghijklmnoprstuvwxyzАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя";
            string numList    = "1234567890";

            if (!String.IsNullOrWhiteSpace(NameTextBox.Text) && !String.IsNullOrWhiteSpace(PhoneNumberTextBox.Text) && !String.IsNullOrWhiteSpace(InnTextBox.Text) && !String.IsNullOrWhiteSpace(OgrnTextBox.Text) && !String.IsNullOrWhiteSpace(KPPTextBox.Text) && !String.IsNullOrWhiteSpace(LastNameTextBox.Text) && !String.IsNullOrWhiteSpace(FirstNameTextBox.Text) && !String.IsNullOrWhiteSpace(MiddleNameTextBox.Text) && !String.IsNullOrWhiteSpace(AreaTextBox.Text) && !String.IsNullOrWhiteSpace(CityTextBox.Text) && !String.IsNullOrWhiteSpace(StreetTextBox.Text) && !String.IsNullOrWhiteSpace(HouseTextBox.Text) && !String.IsNullOrWhiteSpace(BankNameTextBox.Text) && !String.IsNullOrWhiteSpace(PaymentAccountTextBox.Text) && !String.IsNullOrWhiteSpace(CorrespondentAccountTextBox.Text) && !String.IsNullOrWhiteSpace(BIKTextBox.Text))
            {
                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 (!InnTextBox.Text.Contains('_'))
                                        {
                                            if (!OgrnTextBox.Text.Contains('_'))
                                            {
                                                if (!KPPTextBox.Text.Contains('_'))
                                                {
                                                    if (!PaymentAccountTextBox.Text.Contains('_'))
                                                    {
                                                        if (!CorrespondentAccountTextBox.Text.Contains('_'))
                                                        {
                                                            if (!BIKTextBox.Text.Contains('_'))
                                                            {
                                                                if (CurrentOrganization == null)
                                                                {
                                                                    if (AppData.Context.Organization.Where(c => c.Name == NameTextBox.Text).FirstOrDefault() == null)
                                                                    {
                                                                        Address CurrentAddress = new Address()
                                                                        {
                                                                            Region = AreaTextBox.Text,
                                                                            City   = CityTextBox.Text,
                                                                            Street = StreetTextBox.Text,
                                                                            House  = HouseTextBox.Text,
                                                                        };
                                                                        AppData.Context.Address.Add(CurrentAddress);
                                                                        BankDetail CurrentBankDetail = new BankDetail()
                                                                        {
                                                                            BankName             = BankNameTextBox.Text,
                                                                            PaymentAccount       = PaymentAccountTextBox.Text,
                                                                            CorrespondentAccount = CorrespondentAccountTextBox.Text,
                                                                            BIK = BIKTextBox.Text,
                                                                        };
                                                                        AppData.Context.BankDetail.Add(CurrentBankDetail);
                                                                        CurrentOrganization = new Organization()
                                                                        {
                                                                            Name         = NameTextBox.Text,
                                                                            IdAddress    = CurrentAddress.Id,
                                                                            OGRN         = OgrnTextBox.Text,
                                                                            INN          = InnTextBox.Text,
                                                                            KPP          = KPPTextBox.Text,
                                                                            IdBankDetail = CurrentBankDetail.Id,
                                                                            PhoneNumber  = PhoneNumberTextBox.Text,
                                                                            LastName     = LastNameTextBox.Text,
                                                                            FirstName    = FirstNameTextBox.Text,
                                                                            MiddleName   = MiddleNameTextBox.Text,
                                                                        };
                                                                        AppData.Context.Organization.Add(CurrentOrganization);
                                                                        AppData.Context.SaveChanges();
                                                                        MessageBox.Show("Организация успешно добавлена!", "Внимание", MessageBoxButton.OK, MessageBoxImage.Information);
                                                                        NavigationService.GoBack();
                                                                    }
                                                                    else
                                                                    {
                                                                        MessageBox.Show("Организация с таким названием уже существует!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                                                        NameTextBox.Focus();
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    CurrentOrganization.Name        = NameTextBox.Text;
                                                                    CurrentOrganization.OGRN        = OgrnTextBox.Text;
                                                                    CurrentOrganization.INN         = InnTextBox.Text;
                                                                    CurrentOrganization.KPP         = KPPTextBox.Text;
                                                                    CurrentOrganization.PhoneNumber = PhoneNumberTextBox.Text;
                                                                    CurrentOrganization.LastName    = LastNameTextBox.Text;
                                                                    CurrentOrganization.FirstName   = FirstNameTextBox.Text;
                                                                    CurrentOrganization.MiddleName  = MiddleNameTextBox.Text;

                                                                    CurrentAddress.Region = AreaTextBox.Text;
                                                                    CurrentAddress.City   = CityTextBox.Text;
                                                                    CurrentAddress.Street = StreetTextBox.Text;
                                                                    CurrentAddress.House  = HouseTextBox.Text;

                                                                    CurrentBankDetail.BankName             = BankNameTextBox.Text;
                                                                    CurrentBankDetail.PaymentAccount       = PaymentAccountTextBox.Text;
                                                                    CurrentBankDetail.CorrespondentAccount = CorrespondentAccountTextBox.Text;
                                                                    CurrentBankDetail.BIK = BIKTextBox.Text;

                                                                    AppData.Context.SaveChanges();
                                                                    MessageBox.Show("Информация обновлена!", "Внимание", MessageBoxButton.OK, MessageBoxImage.Information);
                                                                    NavigationService.GoBack();
                                                                }
                                                            }
                                                            else
                                                            {
                                                                MessageBox.Show("БИК указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                                                BIKTextBox.Focus();
                                                            }
                                                        }
                                                        else
                                                        {
                                                            MessageBox.Show("Корреспондентский счёт указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                                            CorrespondentAccountTextBox.Focus();
                                                        }
                                                    }
                                                    else
                                                    {
                                                        MessageBox.Show("Расчётный счёт указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                                        PaymentAccountTextBox.Focus();
                                                    }
                                                }
                                                else
                                                {
                                                    MessageBox.Show("КПП указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                                    KPPTextBox.Focus();
                                                }
                                            }
                                            else
                                            {
                                                MessageBox.Show("ОГРН указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                                OgrnTextBox.Focus();
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("ИНН указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                                            InnTextBox.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);
                                PhoneNumberTextBox.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);
            }
        }