示例#1
0
        private void button4_Click(object sender, EventArgs e)
        {
            Form1Login obj = new Form1Login();

            this.Hide();
            obj.ShowDialog();
            this.Close();
        }
示例#2
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            //this.button2.BackgroundImage = NameSpace1.Properties.Resources.UntitledImage2;

            pictureBox1.BackColor = Color.Red;



            CheckBox bold = new CheckBox();

            bold.Appearance = Appearance.Button;
            bold.Size       = new Size(16, 16);
            bold.Image      = Properties.Resources.back;

            Form1Login obj1 = new Form1Login();

            this.Hide();
            obj1.ShowDialog();
            this.Close();
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Validation



            if (textBox1.Text == "FullName" && textBox2.Text == "0333-XXXXXXX" && textBox3.Text == "" && textBox4.Text == "*****@*****.**")
            {
                // txtEmptyString_Validated("",e);

                textBox1.BackColor = Color.Red;
                textBox2.BackColor = Color.Red;
                textBox3.BackColor = Color.Red;
                textBox4.BackColor = Color.Red;
                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);



                textBox1.Focus();
                textBox1.BackColor = Color.White;



                textBox2.Focus();
                textBox2.BackColor = Color.White;
                textBox3.Focus();
                textBox3.BackColor = Color.White;
                textBox4.Focus();
                textBox4.BackColor = Color.White;


                this.errorProvider1.SetError(textBox1, "This field must contain text");
                this.errorProvider3.SetError(textBox2, "This field must contain text");
                this.errorProvider2.SetError(textBox3, "This field must contain text");
                this.errorProvider4.SetError(textBox4, "This field must contain text");
            }



            else if (textBox1.Text != "FullName" && textBox2.Text == "0333-XXXXXXX" && textBox3.Text == "" && textBox4.Text == "*****@*****.**")
            {
                textBox3.BackColor = Color.Red;
                textBox2.BackColor = Color.Red;
                textBox4.BackColor = Color.Red;
                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                textBox1.BackColor = Color.White;

                textBox2.BackColor = Color.White;
                textBox3.Focus();
                textBox3.BackColor = Color.White;
                textBox4.Focus();
                textBox4.BackColor = Color.White;
                this.errorProvider3.SetError(textBox2, "");
            }

            else if (textBox1.Text != "FullName" && textBox2.Text != "0333-XXXXXXX" && textBox3.Text == "" && textBox4.Text == "*****@*****.**")
            {
                if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text == "" && textBox4.Text == "")
                {
                    textBox3.BackColor = Color.Red;
                    textBox4.BackColor = Color.Red;
                    MessageBox.Show(this,
                                    "Invalid Data",
                                    "Exit",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    textBox1.Focus();
                    textBox1.BackColor = Color.White;
                    textBox2.BackColor = Color.White;


                    textBox3.Focus();
                    textBox3.BackColor = Color.White;
                    textBox4.Focus();
                    textBox4.BackColor = Color.White;
                }
            }


            else if (textBox1.Text != "FullName" && textBox2.Text != "0333-XXXXXXX" && textBox3.Text != "" && textBox4.Text == "*****@*****.**")
            {
                textBox4.BackColor = Color.Red;
                MessageBox.Show(this,
                                "Invalid Data ",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);


                textBox1.Focus();
                textBox1.BackColor = Color.White;
                textBox2.BackColor = Color.White;
                textBox3.BackColor = Color.White;


                textBox4.Focus();
                textBox4.BackColor = Color.White;


                // code
            }



            else if (textBox1.Text != "FullName" && textBox2.Text != "0333-XXXXXXX" && textBox3.Text != "" && textBox4.Text != "*****@*****.**")
            {
                textBox1.Focus();
                textBox1.BackColor = Color.White;
                textBox2.BackColor = Color.White;
                textBox3.BackColor = Color.White;
                textBox4.BackColor = Color.White;
                MessageBox.Show("OK! ");


                //Insert data

                SqlConnection sqlcon = new SqlConnection(@"Data Source=DESKTOP-4DB2DSO;Initial Catalog=Connection;Integrated Security=True");
                SqlCommand    cmd    = new SqlCommand(@"INSERT INTO[dbo].[tbl_Login]

                           (
                           [username]
                           ,[password]
                           ,[repassword]
                        ,[email])

                    

                     VALUES
                           ('" + textBox1.Text + "'  , ' " + textBox2.Text + "' ,'" + textBox3.Text + "'  ,  '" + textBox4.Text + "' )", sqlcon);

                sqlcon.Open();
                cmd.ExecuteNonQuery();
                sqlcon.Close();



                MessageBox.Show("Register Successfully");

                DialogResult dialogResult = MessageBox.Show("Do you want to Sign up", "Some Title", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    this.Show();
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                    Form1Login obj = new Form1Login();
                    this.Hide();
                    obj.Show();
                }

                //end insertion



                // code
            }



            else if (textBox1.Text != "FullName" && textBox2.Text == "0333-XXXXXXX" && textBox3.Text != "" && textBox4.Text == "*****@*****.**")
            {
                textBox2.BackColor = Color.Red;
                textBox4.BackColor = Color.Red;
                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                textBox1.BackColor = Color.White;

                textBox2.BackColor = Color.White;
                textBox3.Focus();
                textBox3.BackColor = Color.White;
                textBox4.Focus();
                textBox4.BackColor = Color.White;


                // code
            }
            else if (textBox1.Text == "FullName" && textBox2.Text != "0333-XXXXXXX" && textBox3.Text == "" && textBox4.Text != "*****@*****.**")
            {
                textBox1.BackColor = Color.Red;
                textBox3.BackColor = Color.Red;

                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                textBox1.BackColor = Color.White;

                textBox2.BackColor = Color.White;
                textBox3.Focus();
                textBox3.BackColor = Color.White;
                textBox4.Focus();
                textBox4.BackColor = Color.White;
            }
            else if (textBox1.Text != "FullName" && textBox2.Text == "0333-XXXXXXX" && textBox3.Text == "" && textBox4.Text != "*****@*****.**")
            {
                textBox2.BackColor = Color.Red;
                textBox3.BackColor = Color.Red;
                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                textBox1.BackColor = Color.White;

                textBox2.BackColor = Color.White;
                textBox3.Focus();
                textBox3.BackColor = Color.White;
                textBox4.Focus();
                textBox4.BackColor = Color.White;
            }
            else if (textBox1.Text != "FullName" && textBox2.Text != "0333-XXXXXXX" && textBox3.Text == "" && textBox4.Text != "*****@*****.**")
            {
                textBox3.BackColor = Color.Red;
                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                textBox1.BackColor = Color.White;
                textBox2.BackColor = Color.White;
                textBox3.BackColor = Color.White;


                textBox4.Focus();
                textBox4.BackColor = Color.White;
            }
            else if (textBox1.Text != "FullName" && textBox2.Text == "0333-XXXXXXX" && textBox3.Text != "" && textBox4.Text != "*****@*****.**")
            {
                textBox2.BackColor = Color.Red;

                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                textBox1.BackColor = Color.White;
                textBox2.BackColor = Color.White;
                textBox3.BackColor = Color.White;


                textBox4.Focus();
                textBox4.BackColor = Color.White;


                // code
            }
            else if (textBox1.Text == "FullName" && textBox2.Text != "0333-XXXXXXX" && textBox3.Text != "" && textBox4.Text != "*****@*****.**")
            {
                textBox1.BackColor = Color.Red;

                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                textBox1.BackColor = Color.White;

                textBox2.BackColor = Color.White;
                textBox3.Focus();
                textBox3.BackColor = Color.White;
                textBox4.Focus();
                textBox4.BackColor = Color.White;


                // code
            }
            else if (textBox1.Text == "FullName" && textBox2.Text == "0333-XXXXXXX" && textBox3.Text != "" && textBox4.Text != "*****@*****.**")
            {
                textBox1.BackColor = Color.Red;
                textBox2.BackColor = Color.Red;

                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                textBox1.BackColor = Color.White;

                textBox2.BackColor = Color.White;
                textBox3.Focus();
                textBox3.BackColor = Color.White;
                textBox4.Focus();
                textBox4.BackColor = Color.White;



                // code
            }
            else if (textBox1.Text == "FullName" && textBox2.Text != "" && textBox3.Text == "" && textBox4.Text == "*****@*****.**")
            {
                textBox1.BackColor = Color.Red;
                textBox3.BackColor = Color.Red;
                textBox4.BackColor = Color.Red;
                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                textBox1.BackColor = Color.White;

                textBox2.BackColor = Color.White;
                textBox3.Focus();
                textBox3.BackColor = Color.White;
                textBox4.Focus();
                textBox4.BackColor = Color.White;
            }

            else if (textBox1.Text == "FullName" && textBox2.Text == "0333-XXXXXXX" && textBox3.Text != "" && textBox4.Text == "*****@*****.**")
            {
                textBox1.BackColor = Color.Red;
                textBox2.BackColor = Color.Red;
                textBox4.BackColor = Color.Red;
                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                textBox1.BackColor = Color.White;

                textBox2.BackColor = Color.White;
                textBox3.Focus();
                textBox3.BackColor = Color.White;
                textBox4.Focus();
                textBox4.BackColor = Color.White;
            }
            else if (textBox1.Text == "FullName" && textBox2.Text == "0333-XXXXXXX" && textBox3.Text == "" && textBox4.Text != "*****@*****.**")
            {
                textBox1.BackColor = Color.Red;
                textBox2.BackColor = Color.Red;
                textBox3.BackColor = Color.Red;
                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                textBox1.BackColor = Color.White;

                textBox2.BackColor = Color.White;
                textBox3.Focus();
                textBox3.BackColor = Color.White;
                textBox4.Focus();
                textBox4.BackColor = Color.White;
            }



            //Validation End



            else if (textBox1.Text != "" && textBox2.Text != "")
            {
                MessageBox.Show("OK! ");



                SqlConnection sqlcon = new SqlConnection(@"Data Source=DESKTOP-4DB2DSO;Initial Catalog=Connection;Integrated Security=True");
                SqlCommand    cmd    = new SqlCommand(@"INSERT INTO[dbo].[tbl_Login]

                           (
                           [username]
                           ,[password]
                           ,[repassword]
                        ,[email])

                    

                     VALUES
                           ('" + textBox1.Text + "'  , ' " + textBox2.Text + "' ,'" + textBox3.Text + "'  ,  '" + textBox4.Text + "' )", sqlcon);

                sqlcon.Open();
                cmd.ExecuteNonQuery();
                sqlcon.Close();



                MessageBox.Show("Register Successfully");

                DialogResult dialogResult = MessageBox.Show("Do you want to Sign up", "Some Title", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    this.Show();
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                    Form1Login obj = new Form1Login();
                    this.Hide();
                    obj.Show();
                }
            }
        }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" && textBox2.Text == "")
            {
                // txtEmptyString_Validated("",e);

                textBox1.BackColor = Color.Red;
                textBox2.BackColor = Color.Red;

                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);



                textBox1.Focus();
                textBox1.BackColor = Color.White;



                textBox2.Focus();
                textBox2.BackColor = Color.White;
            }
            else if (textBox1.Text != "" && textBox2.Text == "")
            {
                // txtEmptyString_Validated("",e);


                textBox2.BackColor = Color.Red;

                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);



                textBox1.Focus();
                textBox1.BackColor = Color.White;



                textBox2.Focus();
                textBox2.BackColor = Color.White;
            }
            else if (textBox1.Text == "" && textBox2.Text != "")
            {
                // txtEmptyString_Validated("",e);


                textBox1.BackColor = Color.Red;

                MessageBox.Show(this,
                                "Invalid Data",
                                "Exit",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);



                textBox1.Focus();
                textBox1.BackColor = Color.White;



                textBox2.Focus();
                textBox2.BackColor = Color.White;
            }
            else if (textBox1.Text != "" && textBox2.Text != "")
            {
                MessageBox.Show("OK! ");



                SqlConnection sqlcon = new SqlConnection(@"Data Source=DESKTOP-4DB2DSO;Initial Catalog=Connection;Integrated Security=True");
                SqlCommand    cmd    = new SqlCommand(@"INSERT INTO[dbo].[tbl_Login]

                           (
                           [username]
                           ,[password])
                     VALUES
                           ('" + textBox1.Text + "'  , ' " + textBox2.Text + "')", sqlcon);

                sqlcon.Open();
                cmd.ExecuteNonQuery();
                sqlcon.Close();



                MessageBox.Show("Register Successfully");

                DialogResult dialogResult = MessageBox.Show("Do you want to Sign up", "Some Title", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    this.Show();
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                    Form1Login obj = new Form1Login();
                    this.Hide();
                    obj.Show();
                }
            }
        }