Cart.aspx.cs
资源名称:yjal.rar [点击查看]
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:5k
源码类别:
Email客户端
开发平台:
Visual C++
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using ShopCart;
- using System.Text.RegularExpressions;
- public partial class Cart : PageBase
- {
- UserInfoClass ucObj = new UserInfoClass();
- classDB dd = new classDB();
- protected void Page_Load(object sender, EventArgs e)
- {
- if (Session["Login"] == null)
- {
- Response.Write("<script>alert('对不起,你没有登陆,不能购买物品');</script>");
- Panel1.Visible = true;
- panel2.Visible = false;
- }
- else
- {
- Panel1.Visible = false;
- panel2.Visible = true;
- if (!IsPostBack)
- {
- ShopCartBind();
- TotalDs();
- }
- }
- }
- //绑定市场价
- public string GetMKPStr(string P_Str_MarketPrice)
- {
- return ucObj.VarStr(P_Str_MarketPrice, 1);
- }
- //绑定会员价
- public string GetMBPStr(string P_Str_MemberPrice)
- {
- return ucObj.VarStr(P_Str_MemberPrice, 1);
- }
- //绑定小计
- public string GetSPStr(string P_Str_SumPrice)
- {
- return ucObj.VarStr(P_Str_SumPrice, 1);
- }
- /// <summary>
- /// 获取购物车中的商品信息
- /// </summary>
- public void ShopCartBind()
- {
- ucObj.SCIBind("ShopCart", gvShopCart, Convert.ToInt32(Session["Login"].ToString()));
- }
- /// <summary>
- /// 显示购物车中的商品合计金额和商品数量
- /// </summary>
- public void TotalDs()
- {
- DataSet ds = ucObj.ReturnTotalDs(Convert.ToInt32(Session["Login"].ToString()), "TotalInfo");
- lbSumPrice.Text = ucObj.VarStr(ds.Tables["TotalInfo"].Rows[0][0].ToString(), 1);
- lbSumNum.Text = ucObj.VarStr(ds.Tables["TotalInfo"].Rows[0][2].ToString(), 1);
- Session["totalNumber"] = lbSumNum.Text;
- Session["totalPrice"] = lbSumPrice.Text;
- }
- protected void lnkbtnContinue_Click(object sender, EventArgs e)
- {
- Response.Redirect("produce.aspx");
- }
- protected void lnkbtnClear_Click(object sender, EventArgs e)
- {
- ucObj.DeleteShopCart(Convert.ToInt32(Session["Login"].ToString()));
- ShopCartBind();
- TotalDs();
- lbLag.Visible = true;
- }
- protected void gvShopCart_PageIndexChanging(object sender, GridViewPageEventArgs e)
- {
- gvShopCart.PageIndex = e.NewPageIndex;
- ShopCartBind();
- }
- protected void gvShopCart_RowDeleting(object sender, GridViewDeleteEventArgs e)
- {
- int P_Int_CartID = Convert.ToInt32(gvShopCart.DataKeys[e.RowIndex].Value.ToString());
- ucObj.DeleteShopCartByID(Convert.ToInt32(Session["Login"].ToString()), P_Int_CartID);
- ShopCartBind();
- TotalDs();
- }
- protected void gvShopCart_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
- {
- gvShopCart.EditIndex = -1;
- ShopCartBind();
- TotalDs();
- }
- protected void gvShopCart_RowUpdating(object sender, GridViewUpdateEventArgs e)
- {
- int P_Int_CartID = Convert.ToInt32(gvShopCart.DataKeys[e.RowIndex].Value.ToString());
- int P_Int_Num = Convert.ToInt32(((TextBox)(gvShopCart.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString());
- if (IsValidNum(P_Int_Num.ToString()) == true)
- {
- ucObj.UpdateSCI(Convert.ToInt32(Session["Login"].ToString()), P_Int_CartID, P_Int_Num);
- gvShopCart.EditIndex = -1;
- ShopCartBind();
- TotalDs();
- }
- else
- {
- gvShopCart.EditIndex = -1;
- ShopCartBind();
- TotalDs();
- }
- }
- protected void gvShopCart_RowEditing(object sender, GridViewEditEventArgs e)
- {
- gvShopCart.EditIndex = e.NewEditIndex;
- ShopCartBind();
- TotalDs();
- }
- //判断修改的数据是否为有效的数据
- public bool IsValidNum(string num)
- {
- return Regex.IsMatch(num, @"^+?[1-9][0-9]*$");
- }
- protected void LinkButton1_Click(object sender, EventArgs e)
- {
- String oid = Session["Login"].ToString();
- if (dd.IsCartNO(oid) != 0)
- {
- Response.Redirect("UserOrder.aspx");
- }
- else
- {
- Response.Write("<script>alert('购物车没有商品,不能提交!');</script>");
- }
- }
- }