Beispiel #1
0
        private void submit_btn_Click(object sender, EventArgs e)       //Submit button
        {
            if (string.IsNullOrEmpty(full_name_txb.Text) == true)
            {
                e1.SetError(this.full_name_txb, "Enter full name");
            }

            else if (gender_cmb.SelectedItem == null)
            {
                e2.SetError(this.gender_cmb, "Please Select Gender");
            }

            else if (string.IsNullOrEmpty(Phone_txb.Text) == true)
            {
                e3.SetError(this.Phone_txb, "Enter Vallid phone number");
            }
            else if (Phone_txb.Text.Length != Phone_txb.MaxLength)
            {
                e3.SetError(this.Phone_txb, "Enter valid phone number");
            }

            else if (string.IsNullOrEmpty(email_txb.Text) == true)
            {
                e4.SetError(this.email_txb, "Enter an email");
            }

            else if (Regex.IsMatch(email_txb.Text, patt) == false)
            {
                e4.SetError(this.email_txb, "Email is Not valid");
            }
            else if (rs.IsemailAva(email_txb.Text) == 1)
            {
                e4.SetError(this.email_txb, "Email is Allready registered");
            }

            else if (string.IsNullOrEmpty(address_txb.Text) == true)
            {
                errorProvider4.SetError(this.address_txb, "address is emty");
            }



            else if (user_type_cmb.SelectedItem == null)
            {
                e10.SetError(this.user_type_cmb, "Please Select usertype");
            }



            else if (user_type_cmb.SelectedIndex != 2 && string.IsNullOrEmpty(user_name_txb.Text) == true)
            {
                errorProvider3.SetError(this.user_name_txb, "Enter a Username");
            }

            else if (user_type_cmb.SelectedIndex != 2 && string.IsNullOrEmpty(pass_txb.Text) == true)
            {
                errorProvider1.SetError(this.pass_txb, "Enter a password");
            }



            else if (user_type_cmb.SelectedIndex != 2 && string.IsNullOrEmpty(confirm_pass_txb.Text) == true)
            {
                errorProvider2.SetError(this.confirm_pass_txb, "Enter Confirm password");
            }
            else if (user_type_cmb.SelectedIndex != 2 && pass_txb.Text != confirm_pass_txb.Text)
            {
                errorProvider2.SetError(this.confirm_pass_txb, "Password not match");
            }

            else if (pictureBox1.ImageLocation == null)
            {
                errorProvider6.SetError(this.pictureBox1, "Add a Photo");
            }

            //End of valiidation



            else
            {
                errorProvider6.Clear();


                if (user_type_cmb.SelectedIndex != 2)
                {
                    int result = rs.LeadRegistration(full_name_txb.Text, gender_cmb.Text, dateTimePicker1.Value, Phone_txb.Text, email_txb.Text, address_txb.Text, index, img, user_name_txb.Text, pass_txb.Text);


                    if (result == 3)
                    {
                        MessageBox.Show("User Inserted succesfully ");
                        //services Here
                    }
                    else
                    {
                        MessageBox.Show("User not Inserted succesfully ");
                    }
                }
                else
                {
                    int result = rs.ChefRegistration(full_name_txb.Text, gender_cmb.Text, dateTimePicker1.Value, Phone_txb.Text, email_txb.Text, address_txb.Text, index, img);
                    if (result == 1)
                    {
                        MessageBox.Show("User Inserted succesfully ");
                        //services Here
                    }
                    else
                    {
                        MessageBox.Show("User not Inserted succesfully ");
                    }
                }



                Allclear();
            }
        }