protected void imgbtnSubmit_Click1(object sender, ImageClickEventArgs e) { if (Session["Addr"] != null && Session["TelPhone"] != null && Session["RevName"] != null) { BuyerDSTableAdapters.View_ChartDetailTableAdapter chartDA = new BuyerDSTableAdapters.View_ChartDetailTableAdapter(); DataTable chartDT = chartDA.GetDataByPid(System.Guid.Parse(Session["BuyerId"].ToString()), long.Parse(ddlSelectId.SelectedValue.ToString()), "是"); if (chartDT.Rows.Count != 0) { int store = int.Parse(chartDT.Rows[0][21].ToString()); int want = int.Parse(chartDT.Rows[0][4].ToString()); lblAddr.Text = System.Guid.Parse(chartDT.Rows[0][2].ToString()).ToString(); int money = int.Parse(chartDT.Rows[0][5].ToString()); BuyerDSTableAdapters.OrderInfoTableAdapter orderDA = new BuyerDSTableAdapters.OrderInfoTableAdapter(); int orderDT = orderDA.InsertOrder(System.Guid.Parse(chartDT.Rows[0][2].ToString()), System.Guid.Parse(Session["BuyerId"].ToString()), long.Parse(ddlSelectId.SelectedValue.ToString()), want, DateTime.Now, "1", DateTime.Now, DateTime.Now, Session["Addr"].ToString(), Session["TelPhone"].ToString(), Session["RevName"].ToString() ); if (orderDT != 0) { BuyerDSTableAdapters.PhoneInfoTableAdapter storeDA = new BuyerDSTableAdapters.PhoneInfoTableAdapter(); int storeDT = storeDA.UpdateStore(store - want, long.Parse(ddlSelectId.SelectedValue.ToString())); BuyerDSTableAdapters.ShopCartTableAdapter delDA = new BuyerDSTableAdapters.ShopCartTableAdapter(); int delDT = delDA.DeleteShopChart(long.Parse(chartDT.Rows[0][0].ToString())); if (storeDT != 0 && delDT != 0) { BuyerDSTableAdapters.OrderInfoTableAdapter SearchOrderDA = new BuyerDSTableAdapters.OrderInfoTableAdapter(); DataTable SearchDT = SearchOrderDA.GetOrderId(System.Guid.Parse(Session["BuyerId"].ToString()), long.Parse(ddlSelectId.SelectedValue.ToString()), "1"); if (SearchDT.Rows.Count != 0) { string OrderId = SearchDT.Rows[0][0].ToString(); Response.Redirect("~/Buyer/Pay.aspx?OrderId=" + OrderId + "&OrderName=" + ddlSelectId.SelectedValue.ToString() + "&Money=" + money + "&RevName=" + Session["RevName"].ToString() + "&RevAddr=" + Session["Addr"].ToString() + "&RevTel=" + Session["TelPhone"].ToString()); } } else { Response.Write("<Script>alert('订单未能提交!')</Script>"); //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('订单未能提交!');", true); } } } } else { Response.Write("<Script>alert('收货人信息不完整!')</Script>"); } }
protected void imgbtnInCart_Click(object sender, ImageClickEventArgs e) { string PhoneId = ((ImageButton)sender).CommandArgument.ToString(); if (PhoneId != "") { BuyerDSTableAdapters.PhoneInfoTableAdapter phoneDA = new BuyerDSTableAdapters.PhoneInfoTableAdapter(); DataTable phoneDT = phoneDA.GetDataByPhoneId(long.Parse(PhoneId)); if (phoneDT.Rows.Count != 0) { BuyerDSTableAdapters.ShopCartTableAdapter chartDA = new BuyerDSTableAdapters.ShopCartTableAdapter(); int chartDT = chartDA.InsertShopChart(System.Guid.Parse(Session["Uid"].ToString()), System.Guid.Parse(phoneDT.Rows[0][2].ToString()), long.Parse(PhoneId), 1, int.Parse(phoneDT.Rows[0][14].ToString()), DateTime.Now, "否"); if (chartDT != 0) { Response.Redirect("~/Buyer/ShoppingCart.aspx?PhoneId=" + PhoneId); } } } }