コード例 #1
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        try
        {
            string temp = "";
            temp = Label6.Text;
            con  = new SqlDbConnect();
            //Inserting information into purchase table
            con.SqlQuery("INSERT INTO Purchase_Table (Purchase_Date, Purchase_Price, Purchase_Desc, Cust_ID) VALUES(@Date,@Price,@Desc, @ID)");
            con.cmd.Parameters.Add("@Date", DateTime.Today);
            con.cmd.Parameters.Add("@Price", float.Parse(TextBox5.Text));
            con.cmd.Parameters.Add("@Desc", temp);
            con.cmd.Parameters.Add("@ID", this.id);
            con.NonQuery();

            //resets textboxes incase user wants to purcahse more goods
            TextBox1.Text = "";
            TextBox2.Text = "";
            ListBox1.Items.Clear();
            TextBox5.Text = "";
        }
        catch {
            Response.Write("<script>alert('An error has occured')</script>"); 
        }
        Response.Write("<script>alert('Your order has been recieved - Thank you')</script>"); //successful request
    }
コード例 #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            Boolean proceed = false;
            string  Email   = "";
            //validation cell number


            //validation email
            con = new SqlDbConnect();
            con.SqlQuery("SELECT Customer_Email FROM Cust_Table ");//selecting email from customer table for validation
            Email = con.ExecuteScalar();
            if (TextBox3.Text == Email)
            {
                Label2.Visible = true;
                proceed        = false;
            }
            else
            {
                Label2.Visible = false;
                proceed        = true;
            }

            if (proceed == true)
            {
                con = new SqlDbConnect();
                con.SqlQuery("INSERT INTO Cust_Table (Customer_Name, Customer_Surname, Customer_Email, Customer_Cell, Customer_Username, Customer_Password) VALUES(@NameP,@SurnameP,@EmailP, @CellP,@UserP,@PassP )");
                con.cmd.Parameters.Add("@NameP", TextBox1.Text.Trim());
                con.cmd.Parameters.Add("@SurnameP", TextBox2.Text.Trim());
                con.cmd.Parameters.Add("@EmailP", TextBox3.Text.Trim());
                con.cmd.Parameters.Add("@CellP", TextBox4.Text.Trim());
                con.cmd.Parameters.Add("@UserP", TextBox5.Text.Trim());
                con.cmd.Parameters.Add("@PassP", TextBox6.Text.Trim());
                con.NonQuery();
                //inserting new details into db


                Response.Redirect("~/Pages/LoginPage.aspx");
            }
        }
        catch {
        }
    }