コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand(@"insert into clients (first_name , last_name , client_email , password , client_address , credit_card) 
            values (@FirstName , @LastName , @email , @password , @Address , @CreditCard)", con);

            cmd.Parameters.AddWithValue("@FirstName", textBox1.Text);
            cmd.Parameters.AddWithValue("@LastName", textBox2.Text);
            cmd.Parameters.AddWithValue("@email", textBox3.Text);
            cmd.Parameters.AddWithValue("@password", textBox4.Text);
            cmd.Parameters.AddWithValue("@Address", textBox5.Text);
            cmd.Parameters.AddWithValue("@CreditCard", textBox6.Text);
            cmd.ExecuteNonQuery(); //executes without returning a value

            SqlCommand cmd2 = new SqlCommand(@"insert into client_phone (country_code , carrier , number)
            values (@CountryCode , @Carrier , @Number)", con);

            cmd2.Parameters.AddWithValue("@CountryCode", textBoxPhone1.Text);
            cmd2.Parameters.AddWithValue("@Carrier", textBoxPhone2.Text);
            cmd2.Parameters.AddWithValue("@Number", textBoxPhone3.Text);
            cmd2.ExecuteNonQuery();
            SqlCommand cmd3 = new SqlCommand("select client_id from clients where client_email='" + textBox3.Text + "'", con);

            Global.Globalvar = (int)cmd3.ExecuteScalar();

            con.Close();

            MessageBox.Show("Your account was created successfully!");

            this.Hide();
            PlaceOrder frm = new PlaceOrder();

            frm.Show();
        }
コード例 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            this.Hide();
            PlaceOrder frm = new PlaceOrder();

            frm.Show();
        }
コード例 #3
0
        private void button2_Click(object sender, EventArgs e) //Log in button
        {
            SqlConnection con = new SqlConnection(@"Data Source=SARAH-PC\SQLEXPRESS;Initial Catalog=Food_Ordering_System;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;");

            con.Open();
            SqlCommand cmd   = new SqlCommand(" select count(*) from Clients where client_email='" + textBox1.Text + "'and password='******'", con);
            int        count = (int)cmd.ExecuteScalar();

            if (count.ToString() == "1")
            {
                this.Hide();                                 //hides this form and opens the placeOrder form.
                PlaceOrder frm = new PlaceOrder();
                frm.Show();
                SqlCommand cmd2 = new SqlCommand("select client_id from clients where client_email='" + textBox1.Text + "'", con);
                Global.Globalvar = (int)cmd2.ExecuteScalar(); //execute scalar as it returns one value only.
            }


            else
            {
                MessageBox.Show("Please enter a correct E-mail and Password.");
            }
            con.Close();
        }