示例#1
0
        private void Register_button_Click(object sender, EventArgs e)
        {
            bool flag = true;

            if (basicUser.EnterIntInput(FirstName_textBox.Text) == false || FirstName_textBox.Text.Length == 0)
            {
                FNameError_label.Show();
                flag = false;
            }
            if (basicUser.EnterIntInput(LastName_textBox.Text) == false || LastName_textBox.Text.Length == 0)
            {
                LNameError_label.Show();
                flag = false;
            }
            if (basicUser.EnterIDInput(textBox1.Text) == false)
            {
                IDError_label.Show();
                flag = false;
            }
            else if (isRegistration == true && HeadOfDepartmentSQL.DoesIdExists(textBox1.Text) == true)
            {
                IDError_label.Text = "ID already exists in the system";
                IDError_label.Show();
                flag = false;
            }

            int age;

            try
            {
                age = int.Parse(Age_textBox.Text);
                if (basicUser.EnterAgeInput(age) == false)
                {
                    AgeError_label.Show();
                    flag = false;
                }
            }
            catch (System.IO.IOException ex)
            {
                AgeError_label.Show();
                flag = false;
                ex.GetType();
            }
            catch (Exception ex)
            {
                AgeError_label.Show();
                flag = false;
                ex.GetType();
            }
            if (basicUser.EnterUsernamePassInput(Username_textBox.Text) == false ||
                Username_textBox.Text.Length == 0)    //username
            {
                UsernameError_label.Show();
                flag = false;
            }
            if (basicUser.EnterUsernamePassInput(Password_textBox.Text) == false ||
                Password_textBox.Text.Length == 0)    // pass
            {
                PassError_label.Show();
                flag = false;
            }

            if (flag == false)
            {
                MessageBox.Show("Wrong entery(ies), try again please.");
            }
            else
            {
                if (basicUser.Id != null)
                {
                    MessageBox.Show("Registered successfully.");
                }
                basicUser.FirstName = FirstName_textBox.Text;
                basicUser.LastName  = LastName_textBox.Text;
                basicUser.Id        = textBox1.Text;
                basicUser.Age       = int.Parse(Age_textBox.Text);
                basicUser.Username  = Username_textBox.Text;
                basicUser.Password  = Password_textBox.Text;
                this.Close();
            }
        }
        private void Register_button_Click(object sender, EventArgs e)
        {
            bool flag = true;

            if (basicUser.EnterIntInput(FirstName_textBox.Text) == false)
            {
                FNameError_label.Show();
                flag = false;
            }
            if (basicUser.EnterIntInput(LastName_textBox.Text) == false)
            {
                LNameError_label.Show();
                flag = false;
            }
            if (basicUser.EnterIDInput(textBox1.Text) == false)
            {
                IDError_label.Show();
                flag = false;
            }

            int age;

            try
            {
                age = int.Parse(Age_textBox.Text);
                if (basicUser.EnterAgeInput(age) == false)
                {
                    AgeError_label.Show();
                    flag = false;
                }
            }
            catch (System.IO.IOException ex)
            {
                //Console.WriteLine("Error, your input isn't an integer({0}), try again please.\n", ex.GetType().ToString());
                AgeError_label.Show();
                flag = false;
                ex.GetType();
            }
            catch (Exception ex)
            {
                AgeError_label.Show();
                flag = false;
                ex.GetType();
                //Console.WriteLine("Unknown error ({0}), try again please.\n", ex.GetType().ToString());
            }
            if (basicUser.EnterUsernamePassInput(Username_textBox.Text) == false) //username
            {
                UsernameError_label.Show();
                flag = false;
            }
            if (basicUser.EnterUsernamePassInput(Password_textBox.Text) == false) // pass
            {
                PassError_label.Show();
                flag = false;
            }

            if (flag == false)
            {
                MessageBox.Show("Wrong entery(ies), try again please.");
            }
            else
            {
                MessageBox.Show("Registered successfully.");
                basicUser.FirstName = FirstName_textBox.Text;
                basicUser.LastName  = LastName_textBox.Text;
                basicUser.Id        = textBox1.Text;
                basicUser.Age       = int.Parse(Age_textBox.Text);
                basicUser.Username  = Username_textBox.Text;
                basicUser.Password  = Password_textBox.Text;
                this.Close();
            }
        }