Example #1
0
        private void button5_Click_1(object sender, EventArgs e)
        {
            bunifuMaterialTextbox1.Text.Trim(' ');
            bunifuMaterialTextbox2.Text.Trim(' ');
            bunifuMaterialTextbox4.Text.Trim(' ');
            if (bunifuMaterialTextbox1.Text.Length == 0 || bunifuMaterialTextbox2.Text.Length == 0 || bunifuMaterialTextbox4.Text.Length == 0)
            {
                MessageBox.Show("Enter All Information First");
            }
            else
            {
                try
                {
                    double Number = double.Parse(bunifuMaterialTextbox2.Text);
                    if (bunifuMaterialTextbox2.Text.Length < 11 || bunifuMaterialTextbox2.Text.Length > 13)
                    {
                        MessageBox.Show("Enter Full Phone Number");
                    }

                    else
                    {
                        if (bunifuMaterialTextbox4.Text.Contains("@") && bunifuMaterialTextbox4.Text.Contains(".com"))
                        {
                            int cc = 0, ac = 0;
                            foreach (Match m in Regex.Matches(bunifuMaterialTextbox4.Text, ".com"))
                            {
                                cc++;
                            }
                            foreach (Match m in Regex.Matches(bunifuMaterialTextbox4.Text, "@"))
                            {
                                ac++;
                            }
                            if (cc == 1 && ac == 1)
                            {
                                bool accepetName = true;

                                string name = bunifuMaterialTextbox1.Text;
                                foreach (char c in name)
                                {
                                    if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '.' || c == ' '))
                                    {
                                        accepetName = false;
                                        break;
                                    }
                                }
                                if (accepetName == true)
                                {
                                    bool result = emp.SaveUser(bunifuMaterialTextbox1.Text, bunifuMaterialTextbox2.Text, bunifuMaterialTextbox4.Text);

                                    SeekHelpForm sh = new SeekHelpForm();
                                    this.Hide();
                                    sh.Show();
                                }
                                else
                                {
                                    MessageBox.Show("Only letters and '.' are accepted");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Enter Correct Email Address");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Enter A valid Email Address");
                        }
                    }
                }
                catch (FormatException)
                {
                    MessageBox.Show("Enter A valid Phone Number");
                }
            }
        }