Пример #1
0
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        BookBL   bookBL  = new BookBL();
        MemberBL memBL   = new MemberBL();
        string   orderID = bookBL.orderID(DateTime.Now.ToString("yyyyMM")).ToString();

        int orders = bookBL.orders_Add(orderID, Convert.ToInt32(HttpContext.Current.Server.UrlDecode(cookie.Values["mID"].ToString())), Label5.Text, DateTime.Now.ToString(), Convert.ToInt32(Label4.Text), Convert.ToInt32(Label1.Text));

        if (orders > 0)
        {
            for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
            {
                int orderDetails = bookBL.orderDetailes_Add(orderID, GridView1.Rows[i].Cells[0].Text, Convert.ToInt32(GridView1.Rows[i].Cells[3].Text), Convert.ToInt32(GridView1.Rows[i].Cells[2].Text));
            }
            //訂單成立後暢銷書+1與庫存-1
            for (int j = 0; j <= GridView1.Rows.Count - 1; j++)
            {
                bookBL.sel_hit_amonet(GridView1.Rows[j].Cells[0].Text);
                int hit    = bookBL.bookhit + 1;
                int amount = bookBL.bookAmonet - 1;
                bookBL.hit_amonet(GridView1.Rows[j].Cells[0].Text, amount, hit);
            }

            //購物完成寄送信件
            //string content = "<p>感謝您的光臨,您已經成功完成訂單程序。</p><p>您的訂單編號為:" + orderID.ToString() + ",您可使用此編號查詢您的訂購內容。";
            //memBL.send_mail(HttpContext.Current.Server.UrlDecode(cookie.Values["email"].ToString()), content);

            //清除購物車所有商品
            ht.Clear();
        }

        iPayPal paypal = new iPayPal();

        paypal.PayPal_Payment(GridView1, Label3.Text, orderID, "http://" + Request.ServerVariables["Server_Name"] + "/Bookstore/shopOK.aspx", "");
    }