using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Globalization;
namespace PeiXun
{
///
/// index 的摘要说明。
///
public partial class OrderBook : System.Web.UI.Page
{
public Mtxfw.DAL.user_info daoUser = new Mtxfw.DAL.user_info();
Mtxfw.DAL.order_info daoorder = new Mtxfw.DAL.order_info();
Mtxfw.Model.order_info Modelorder = new Mtxfw.Model.order_info();
Mtxfw.DAL.P_Product daoProduct = new Mtxfw.DAL.P_Product();
protected void Page_Load(object sender, System.EventArgs e)
{
if (!String.IsNullOrEmpty(Request.QueryString["ID"]))
{
int ProductID = int.Parse(Request.QueryString["ID"].ToString());
if (Session["MemberId"] != null)
{
int MemberId = Convert.ToInt32(Session["MemberId"].ToString());
Mtxfw.Model.user_info model = daoUser.GetModel(MemberId);
if (model != null)
{
string Contactname = "", Contacttel = "", Address = "", Zipcode = "", strProvince = "", strCity = "", strCounty = "", OrdersID = "";
if (model.RealName == "" || model.Phone == "" || model.MailingAddress == "")
{
Response.Write("");
}
else
{
Contactname = model.RealName;
Contacttel = model.Phone;
Address = model.MailingAddress;
Zipcode = model.PostalCode;
strProvince = model.Province;
strCity = model.City;
strCounty = model.County;
Mtxfw.Model.P_Product Pmodel = daoProduct.GetModel(ProductID);
if (Pmodel != null)
{
if (Pmodel.P_Inventory > 0)
{
string prodNum = "1";
Double SubTotal = Pmodel.P_VIP_P;
DateTime dt = DateTime.Now;
string OID = dt.ToString("yyyMMddhhmmssffff", DateTimeFormatInfo.InvariantInfo);
if (Convert.ToDouble(SubTotal.ToString("f2")) <= Convert.ToDouble(model.umoney0.ToString("f2")))
{
Modelorder.pid = ProductID;
Modelorder.orderid = OID;
Modelorder.Contactname = Contactname;
Modelorder.Contacttel = Contacttel;
Modelorder.Province = strProvince;
Modelorder.City = strCity;
Modelorder.County = strCounty;
Modelorder.Address = Address;
Modelorder.Zipcode = Zipcode;
Modelorder.Guests = "";
Modelorder.Totalprice = SubTotal;
Modelorder.Totalnum = int.Parse(prodNum);
Modelorder.O_Submit = "1";
Modelorder.UserID = MemberId;
Modelorder.utype = "2";
int OrderID = daoorder.Add(Modelorder);
daoProduct.UpdateInventory(ProductID, -1);
//更新订单为已付款状态
daoorder.UpdateqyState(0, "1", DateTime.Now, OrderID);
//减少买家余额
daoUser.UpdateMoney("umoney0", -SubTotal, MemberId);
Response.Write("");
}
else
{
Response.Write("");
}
}
else
{
Response.Write("");
}
}
else
{
Response.Write("");
}
}
}
}
else
{
string RUrl = "/view-" + ProductID + ".html";
Session["returnurl"] = RUrl;
Response.Redirect("/login.aspx");
}
}
else
{
Response.Write("");
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
}
#endregion
}
}