using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class CheckOut : System.Web.UI.Page
{
    BLL.UserInfo user = new BLL.UserInfo();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (user.IsLogin() == false)
        {
            this.Response.Redirect("Member_Login.aspx");
        }
    }

    /// <summary>
    /// 填写订单
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void addorderbt_Click(object sender, EventArgs e)
    {
        DateTime ordertime = DateTime.Now;
        string orderid = ordertime.ToString("yyyymmddhhmmss");
        string productid = Session["productids"].ToString();
        double orderprice = double.Parse(Session["price"].ToString());

        BLL.Order ord = new BLL.Order();

        if (ord.createorder(orderid, productid, user.getUserID(), this.acceptnametb.Text.Trim(),
            this.addorderbt.Text.Trim(), this.postalcodetb.Text.Trim(), this.phonetb.Text.Trim(),
            this.deliverylist.SelectedItem.Text, this.paymentlist.SelectedItem.Text, 1, ordertime, orderprice) == 1)
        {
            this.Response.Redirect("success.aspx");
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('订单出错!')</script>", false);
        }
    }
}
