/// <summary> /// 绑定信息 /// </summary> private void BindData() { UserInfo user = Session["user"] as UserInfo; if (user != null) { DataSet ds = CartTempService.GetList("addUser = "******"lblTotal") as Label; total += Convert.ToDouble(lbl.Text.Trim()); } ViewState["carTotal"] = total.ToString("0.00"); }
/// <summary> /// 获取购物车中产品的Quantity /// </summary> /// <param name="id"></param> /// <returns></returns> protected string GetProductCount(object id) { UserInfo user = Session["user"] as UserInfo; if (user == null) { List <CartTemp> cartlist = Session["nologinCart"] as List <CartTemp>; if (cartlist != null) { if (cartlist.Count > 0) { foreach (CartTemp ct in cartlist) { if (ct.productId == Convert.ToInt32(id)) { return(ct.productCount.ToString()); } } } } } else { Session["nologinCart"] = null; CartTemp item = CartTempService.GetModelByProductId(user.id, Convert.ToInt32(id)); if (item != null) { return(item.productCount.ToString()); } } return(""); }
/// <summary> /// 获取产品Quantity /// </summary> /// <returns></returns> protected int GetProductCount() { UserInfo user = Session["user"] as UserInfo; if (user != null) { return(CartTempService.GetProductCount(user.id)); } return(0); }
/// <summary> /// 获取购物车产品Quantity /// </summary> /// <returns></returns> protected string GetCarTotal() { StringBuilder sb = new StringBuilder(); UserInfo user = Session["user"] as UserInfo; if (user != null) { int count = CartTempService.GetProductCount(user.id); if (count > 0) { sb.Append("<span class=\"num totleNum\" id=\"carttotal\">" + count + "</span>"); } else { sb.Append("<span class=\"num hideNum\" id=\"carttotal\"></span>"); } } else { List <CartTemp> list = Session["nologinCart"] as List <CartTemp>; if (list != null) { int count = list.Count; if (count > 0) { int total = 0; foreach (CartTemp ct in list) { total += ct.productCount; } sb.Append("<span class=\"num totleNum\" id=\"carttotal\">" + total + "</span>"); } else { sb.Append("<span class=\"num\" id=\"carttotal\"></span>"); } } else { sb.Append("<span class=\"\" id=\"carttotal\"></span>"); } } return(sb.ToString()); }
protected void LinkButton1_Click(object sender, EventArgs e) { string ids = selInfo(); int num = 0; if (ids.Length == 0) { Jscript.Alert("请选择要Delete的记录!", this.Page); return; } string[] arr = ids.TrimEnd(',').Split(','); for (int i = 0; i < arr.Length; i++) { if (CartTempService.Delete(Convert.ToInt32(arr[i]))) { num++; } } BindData(); }
/// <summary> /// 控件行命令事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void repInfo_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("add")) { int id = Convert.ToInt32(e.CommandArgument); CartTemp ct = CartTempService.GetModel(id); if (ct != null) { ct.productCount++; Product p = ProductService.GetModel(ct.productId); if (p != null) { ct.remark = (ct.productCount * p.price1).ToString("0.00"); } CartTempService.UpdateCart(ct); } } if (e.CommandName.Equals("del")) { CartTempService.Delete(Convert.ToInt32(e.CommandArgument)); } if (e.CommandName.Equals("reduce")) { int id = Convert.ToInt32(e.CommandArgument); CartTemp ct = CartTempService.GetModel(id); if (ct != null) { if (ct.productCount > 1) { ct.productCount--; Product p = ProductService.GetModel(ct.productId); if (p != null) { ct.remark = (ct.productCount * p.price1).ToString("0.00"); } CartTempService.UpdateCart(ct); } } } BindData(); }
/// <summary> /// 绑定信息 /// </summary> private void BindData() { UserInfo user = Session["user"] as UserInfo; if (user != null) { ViewState["nologinImg"] = "images/hasproduct.png"; #region Log In状态下 DataSet ds = CartTempService.GetList("addUser = "******"productCount"] = ds.Tables[0].Rows.Count; repInfo.DataSource = ds; repInfo.DataBind(); double total = 0; foreach (DataRow dr in ds.Tables[0].Rows) { if (Convert.ToInt32(dr["sel"]) == 1) { total += Convert.ToDouble(dr["remark"]); } } ViewState["carTotal"] = total.ToString("0.00"); } else { repInfo.DataSource = null; repInfo.DataBind(); this.cartButton.Visible = false; this.noList.Visible = true; } #endregion } else { Response.Redirect("login.html"); } }
/// <summary> /// 绑定数据 /// </summary> private void BindData() { #region 生成订单 UserInfo user = Session["user"] as UserInfo; if (user != null) { OrderInfo order = new OrderInfo(); order.orderNo = ""; order.orderName = user.relName + "在Plate-X订单"; order.proTotal = 0; order.sendTotal = 0; order.orderTotal = 0; double total = 0; DataSet ds = CartTempService.GetList("addUser = "******"remark"]); } } order.orderTotal = Math.Round(total, 2); order.orderDesc = ""; order.remark = order.orderName + ",订单日期:" + DateTime.Now.ToString("yyyy-MM-dd"); order.recieveUser = user.relName; order.pid = 0; order.cid = 0; order.regionId = 0; order.PName = ""; order.CName = ""; order.ReginName = ""; order.address = ""; order.mobile = user.mobile; order.tel = ""; order.status = 0; order.addTime = DateTime.Now; order.infoType = 0; order.addUser = user.id; int maxId = OrderService.Add(order); order.orderNo = maxId + DateTime.Now.ToString("yyyyMd") + DateTime.Now.ToString("hhmmss"); int rows = OrderService.UpdateOrderNo(maxId, order.orderNo, order.orderDesc); if (rows > 0) { #region 订单详细 if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int pid = Convert.ToInt32(ds.Tables[0].Rows[i]["productId"]); int count = Convert.ToInt32(ds.Tables[0].Rows[i]["productCount"]); #region 订单详细 Product item = ProductService.GetModel(pid); if (item != null) { #region 订单详细表 OrderDetail od = new OrderDetail(); od.orderId = maxId; od.orderNo = order.orderNo; od.productId = pid; od.productCount = count; od.isActive = 0; od.activeCode = ""; od.activeMoney = 0; od.total = Convert.ToDouble(ds.Tables[0].Rows[i]["remark"]); od.satus = 0; od.remark = ""; od.infoType = 0; OrderDetailService.Add(od); #endregion //清空临时表信息 CartTempService.DeleteByUserId(user.id, pid); } #endregion } } #endregion } Response.Redirect("/zhifu_" + maxId + ".html"); } #endregion }
/// <summary> /// 绑定数据 /// </summary> private void BindData() { #region 生成订单 UserInfo user = Session["user"] as UserInfo; if (user != null) { OrderInfo order = new OrderInfo(); order.orderNo = ""; order.orderName = user.relName + "在Plate-X订单"; order.proTotal = 0; order.sendTotal = 0; order.orderTotal = 0; double total = 0; DataSet ds = CartTempService.GetList("addUser = "******"remark"]); } } order.orderTotal = Math.Round(total, 2); order.orderDesc = ""; order.remark = order.orderName + ",订单日期:" + DateTime.Now.ToString("yyyy-MM-dd"); order.recieveUser = user.relName; order.pid = 0; order.cid = 0; order.regionId = 0; order.PName = ""; order.CName = ""; order.ReginName = ""; order.address = ""; order.mobile = user.mobile; order.tel = ""; order.status = 0; order.addTime = DateTime.Now; order.infoType = 0; order.addUser = user.id; int maxId = OrderService.Add(order); //生成二维码: //string ranStr = Rand.GetMixPwd(10); //string websiteUrl = BaseConfigService.GetById(12); //string userUrlStr = ""; // websiteUrl + "/mychat.aspx?orderId=" + maxId; //weixin://wxpay/bizpayurl?appid=wx8a02513b182f68af&mch_id=1372977102&nonce_str=" + ranStr + "&product_id=" + maxId + "&time_stamp=" + DateTime.Now.ToString("yyyyMMddhhmm") + "&sign= string url = "";// create_two(userUrlStr, maxId); order.orderDesc = url; order.orderNo = maxId + DateTime.Now.ToString("yyyyMMdd") + user.id + DateTime.Now.ToString("hhmmss"); int rows = OrderService.UpdateOrderNo(maxId, order.orderNo, order.orderDesc); if (rows > 0) { #region 订单详细 if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { int productId = Convert.ToInt32(dr["productId"]); Product item = ProductService.GetModel(productId); if (item != null) { #region 订单详细表 OrderDetail od = new OrderDetail(); od.orderId = maxId; od.orderNo = order.orderNo; od.productId = productId; od.productCount = Convert.ToInt32(dr["productCount"]); od.isActive = 0; od.activeCode = ""; od.activeMoney = 0; od.total = Convert.ToDouble(dr["remark"]); od.satus = 0; od.remark = ""; od.infoType = 0; OrderDetailService.Add(od); #endregion //清空临时表信息 CartTempService.DeleteByUserId(user.id, productId); } } } #endregion } Response.Redirect("orders_99.html"); } #endregion }