Beispiel #1
0
    protected void ButtonCheckout_Click(object sender, EventArgs e)
    {
        utility.LoginCheck();

        //1.將shoppingcart 的資料轉到order orderdetails資料表
        //2.將shoppingcart的資料清除
        //3.告知使用者訂單編號,轉到訂單頁面

        using (SqlConnection conn = new SqlConnection(strConn))
        {
            using (SqlCommand cmd = new SqlCommand("OrderCreate", conn))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@CartID", Session["CartID"].ToString());
                cmd.Parameters.AddWithValue("@CustomerID", Convert.ToInt32(Session["CartID"]));
                cmd.Parameters.AddWithValue("@OrderDate", DateTime.Now.ToShortDateString());
                cmd.Parameters.AddWithValue("@ShipDate", DateTime.Now.AddDays(1));

                cmd.Parameters.AddWithValue("@OrderID", SqlDbType.Int);
                cmd.Parameters["@OrderID"].Direction = ParameterDirection.Output;

                conn.Open();
                cmd.ExecuteNonQuery();
                string orderID = cmd.Parameters["@OrderID"].Value.ToString();

                string strJS = "alert('訂單編號" + orderID + " !!');location.href='Order.aspx?OrderID=" + orderID + "'";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", strJS, true);
                conn.Close();
            }
        }
    }
Beispiel #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //if (Request.Cookies["name"] == null)
     //{
     //    string strPath = Request.Url.PathAndQuery;
     //    Response.Redirect("~/Login.aspx?returnUrl=" + strPath);
     //}
     utility.LoginCheck();
 }
Beispiel #3
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        MsitUtility.LoginCheck();

        using (SqlConnection conn = new SqlConnection(connStr))
        {
            using (SqlCommand cmd = new SqlCommand("OrderCreate", conn))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@CartID", Session["CartID"].ToString());
                cmd.Parameters.AddWithValue("@CustomerID", Convert.ToInt32(Session["CartID"]));
                cmd.Parameters.AddWithValue("@OrderDate", DateTime.Now.ToShortDateString());
                cmd.Parameters.AddWithValue("@ShipDate", DateTime.Now.AddHours(6).ToShortDateString());
                cmd.Parameters.Add("@OrderID", SqlDbType.Int);
                cmd.Parameters["@OrderID"].Direction = ParameterDirection.Output;

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

                Response.Redirect("~/Orders.aspx?OrderID=" + cmd.Parameters["@OrderID"].Value);
            }
        }
    }
Beispiel #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     utility.LoginCheck();
 }