Files
g.hnyhua.cn/Mtxfw.shop/Sell/Order.aspx.cs
2026-02-07 15:48:27 +08:00

142 lines
6.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
{
/// <summary>
/// index 的摘要说明。
/// </summary>
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("<script language='javascript'>alert('您的收货信息不完整,请先完善您的资料!');location.replace('/Member_Info.aspx');</script>");
}
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("<script language='javascript'>alert('兑换成功!');location.replace('/Member_Orders_List.aspx');</script>");
}
else
{
Response.Write("<script language='javascript'>alert('您的积分余额不足!');location.replace('/Member_JiangLi_List.aspx');</script>");
}
}
else
{
Response.Write("<script language='javascript'>alert('商品已售完" + Pmodel.P_Inventory + "');location.replace('/');</script>");
}
}
else
{
Response.Write("<script language='javascript'>alert('商品不存在!');location.replace('/');</script>");
}
}
}
}
else
{
string RUrl = "/view-" + ProductID + ".html";
Session["returnurl"] = RUrl;
Response.Redirect("/login.aspx");
}
}
else
{
Response.Write("<script language='javascript'>alert('参数为空!');location.replace('/');</script>");
}
}
#region Web
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
#endregion
}
}