温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:明日网上商城购物系统源码
当前文件:
MingriNetShop/User/CheckOut.aspx.cs,打开代码结构图
MingriNetShop/User/CheckOut.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using System.Data.SqlClient; 12
13
public partial class User_CheckOut : System.Web.UI.Page 14
{ 15
UserInfoClass ucObj = new UserInfoClass(); 16
public static float P_Flt_TotalSF; 17
protected void Page_Load(object sender, EventArgs e) 18
{ 19
if (!IsPostBack) 20
{ 21
ddlCityBind(); 22
ddlShipBind(); 23
ddlPayBind(); 24
labKM.Text = ddlShipCity.SelectedValue.ToString(); 25
26
} 27
} 28
public void ddlCityBind() 29
{ 30
ucObj.ddlCityBind(ddlShipCity); 31
} 32
public void ddlShipBind() 33
{ 34
ucObj.ddlShipBind(ddlShipType); 35
} 36
public void ddlPayBind() 37
{ 38
ucObj.ddlPayBind(ddlPayType); 39
} 40
public float TotalGoodsPrice() 41
{ 42
DataSet ds = ucObj.ReturnTotalDs(Convert.ToInt32(Session["UID"].ToString()), "TotalInfo"); 43
float P_Flt_TotalGP = float.Parse(ds.Tables["TotalInfo"].Rows[0][0].ToString()); 44
return P_Flt_TotalGP; 45
} 46
/// <summary> 47
/// 所有商品运输费用 48
/// </summary> 49
/// <returns>返回商品运输费用</returns> 50
public float TotalShipFee() 51
{ 52
P_Flt_TotalSF = 0; 53
DataSet ds = ucObj.ReturnSCDs(Convert.ToInt32(Session["UID"].ToString()), "SCInfo"); 54
55
for (int i = 0; i < ds.Tables["SCInfo"].Rows.Count; i++) 56
{ 57
if (ucObj.GetSFValue(Convert.ToInt32(ds.Tables["SCInfo"].Rows[i][1].ToString()), ddlShipType.SelectedItem.Text.ToString()) ==100) 58
{ 59
60
Response.Write("<script>alert('添加失败,由于购买的商品运输费还没有添加,请重新购买!');location='index.aspx';</script>"); 61
return 100; 62
} 63
float P_Flt_SF = ucObj.GetSFValue(Convert.ToInt32(ds.Tables["SCInfo"].Rows[i][1].ToString()), ddlShipType.SelectedItem.Text.ToString()); 64
65
P_Flt_TotalSF =P_Flt_TotalSF +(float.Parse (ds.Tables["SCInfo"].Rows[i][5].ToString())) * P_Flt_SF*(Convert.ToInt32(ddlShipCity.SelectedItem.Value.ToString())); 66
} 67
return P_Flt_TotalSF; 68
69
70
} 71
protected void btnSave_Click(object sender, EventArgs e) 72
{ 73
if (txtReciverName.Text == "" || txtReceiverAddress.Text == "" || txtReceiverPhone.Text == "" || txtReceiverPostCode.Text == "" || txtReceiverEmails.Text == "") 74
{ 75
Response.Write("<script>alert('请输入完整的信息 !')</script>"); 76
return; 77
} 78
else 79
{ 80
float P_Flt_TotalSF=TotalShipFee(); 81
if (P_Flt_TotalSF <= 0 || P_Flt_TotalSF == 100) 82
{ 83
return; 84
} 85
float P_Flt_TotalGP=TotalGoodsPrice(); 86
int P_Int_Cart = ucObj.IsUserCart(Convert.ToInt32(Session["UID"].ToString()), P_Flt_TotalGP, P_Flt_TotalSF); 87
if (P_Int_Cart == -100 && ddlPayType.SelectedItem.Text.Trim() == "会员卡") 88
{ 89
Response.Write("<script>alert('您的会员卡中余额不足,不能购买商品,请充值!')</script>"); 90
return; 91
} 92
else 93
{ 94
int P_Int_OrderID = ucObj.AddOrderInfo(P_Flt_TotalGP, P_Flt_TotalSF, Convert.ToInt32(ddlShipType.SelectedItem.Value.ToString()), Convert.ToInt32(ddlPayType.SelectedItem.Value.ToString()), Convert.ToInt32(Session["UID"].ToString()), txtReciverName.Text.Trim(), txtReceiverPhone.Text.Trim(), txtReceiverPostCode.Text.Trim(), txtReceiverAddress.Text.Trim(), txtReceiverEmails.Text.Trim()); 95
DataSet ds = ucObj.ReturnSCDs(Convert.ToInt32(Session["UID"].ToString()), "SCInfo"); 96
for(int i = 0; i < ds.Tables["SCInfo"].Rows.Count; i++) 97
{ 98
ucObj.AddBuyInfo(Convert.ToInt32(ds.Tables["SCInfo"].Rows[i][1].ToString()), Convert.ToInt32(ds.Tables["SCInfo"].Rows[i][2].ToString()), P_Int_OrderID, float.Parse (ds.Tables["SCInfo"].Rows[i][3].ToString()), Convert.ToInt32(ds.Tables["SCInfo"].Rows[i][4].ToString())); 99
} 100
ucObj.DeleteSCInfo(Convert.ToInt32(Session["UID"].ToString())); 101
Response.Write("<script>alert('购物成功 !');location='index.aspx'</script>"); 102
return; 103
} 104
105
} 106
} 107
108
protected void btnReset_Click(object sender, EventArgs e) 109
{ 110
Response.Redirect("index.aspx"); 111
} 112
protected void lnkbtnSee_Click(object sender, EventArgs e) 113
{ 114
115
Response.Write("<script language=javascript>window.open('ShipFeeInfo.aspx','','width=640,height=640')</script>"); 116
} 117
protected void ddlShipCity_SelectedIndexChanged(object sender, EventArgs e) 118
{ 119
labKM.Text = ddlShipCity.SelectedItem.Value; 120
} 121
} 122




UserInfoClass ucObj 
}
}