protected void btnSave_Click(object sender, EventArgs e) { if (this.Action == "add") { LinkModel info = new LinkModel(); info.possymbol = possymbol; info.includepic = this.txtincludepic.Text.Trim(); info.linkurl = this.txtlinkurl.Text.Trim(); info.orderno = Int32.Parse(this.txtorderno.Text.Trim()); info.linkname = this.txttitle.Text.Trim(); info.createtime = DateTime.Now; LinkFactory.Add(info); ClientScript.RegisterStartupScript(this.GetType(), "AddEditTips", "<script language=\"javascript\">alert('添加成功!');window.location='linklist.aspx?pb=" + possymbol + "';</script>"); } else if (this.Action == "edit") { int linkid = HYRequest.GetInt("linkid", 0); LinkModel info = LinkFactory.Get(linkid); info.includepic = this.txtincludepic.Text.Trim(); info.linkurl = this.txtlinkurl.Text.Trim(); info.orderno = Int32.Parse(this.txtorderno.Text.Trim()); info.linkname = this.txttitle.Text.Trim(); LinkFactory.Update(info); ClientScript.RegisterStartupScript(this.GetType(), "AddEditTips", "<script language=\"javascript\">alert('修改成功!');window.location='linklist.aspx?pb=" + possymbol + "';</script>"); } }
private void LoadData() { if (this.Action == "edit") { int linkid = HYRequest.GetInt("linkid", 0); LinkModel info = LinkFactory.Get(linkid); this.txtincludepic.Text = info.includepic; this.txtlinkurl.Text = info.linkurl; this.txtorderno.Text = info.orderno.ToString(); this.txttitle.Text = info.linkname; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int totalcount = 0; int pagesize = 12; int cid = HYRequest.GetQueryInt("cid", 0); int pageindex = HYRequest.GetQueryInt("p", 1); int od = HYRequest.GetQueryInt("od", 0); string whereSql = " where productcode=1 "; string orderby = " order by productid desc "; string url = "productlist.aspx?p={0}"; if (cid > 0) { whereSql = " where productcode=1 and categoryid=" + cid; url += "&cid=" + cid; } if (od == 1) { orderby = " order by salecount desc "; } else if (od == 2) { orderby = " order by price desc "; } listProducts = ProductFactory.GetList(pagesize, pageindex, whereSql, orderby, out totalcount); //this.rptProducts.DataSource = list; //this.rptProducts.DataBind(); //this.rptAddToCarPopWin.DataSource = list; //this.rptAddToCarPopWin.DataBind(); pagerHtml = Utils.BuildProductListPager(totalcount, pagesize, pageindex, url); if (cid == 0) { this.CategoryName = "全部商品"; } else { ProductCategoryModel pcm = ProductCategoryFactory.Get(cid); if (pcm != null) { this.CategoryName = pcm.categoryname; } } } string action = HYRequest.GetQueryString("action"); if (action == "ajaxloadlist") { int cid = HYRequest.GetInt("cid", 0); int pageindex = HYRequest.GetInt("p", 1); int pagesize = 12; int totalcount = 0; string wheresql = " where productcode=1 "; if (cid > 0) { wheresql = string.Format(" where productcode=1 and categoryid={0} ", cid.ToString()); } List <ProductModel> list = ProductFactory.GetList(pagesize, pageindex, wheresql, string.Empty, out totalcount); StringBuilder sbhtml = new StringBuilder(); foreach (ProductModel pm in list) { sbhtml.AppendLine("<li class=\"item\">"); sbhtml.AppendLine(string.Format("<a href=\"productshow.aspx?id={0}\"><img src=\"{1}\" alt=\"item\" /></a>", pm.productid, pm.includepicpath)); sbhtml.AppendLine(string.Format("<h4><a href=\"productshow.aspx?id={0}\">{1}</a></h4>", pm.productid, pm.productname)); sbhtml.AppendLine(string.Format("<span>¥{0}</span><del style=\"display:none\">¥{0}</del><em>库存:{1} 销量:{2}</em>", pm.price.ToString(), pm.productcount, pm.salecount)); sbhtml.AppendLine(string.Format("<p class=\"add-to-cart\" onClick=\"toshare({0})\"><span>添加到购物车</span></p>", pm.productid)); sbhtml.AppendLine("</li>"); } Response.Write(sbhtml.ToString()); Response.Flush(); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { UserModel userInfo = this.LoginUser; OrderModel myorder = OrderFactory.GetCartOrder(userInfo.uid); int pid = HYRequest.GetQueryInt("pid", 0); int itemflag = HYRequest.GetQueryInt("itemflag", 0); string action = HYRequest.GetQueryString("action"); if (action == "add") //添加商品 { OrderModel myof = myorder; if (myof == null) { myof = new OrderModel(); myof.orderno = Utils.GenerateOutTradeNo(userInfo.uid); //Utils.GetRandomOrderNo(); myof.uid = userInfo.uid; myof.customername = userInfo.fullname; myof.tel = userInfo.tel; myof.address = userInfo.address; } ProductModel p = ProductFactory.Get(pid); OrderProduct op = new OrderProduct(); op.count = 1; op.productinfo = p; op.price = p.price; //判断是否有属性 if (itemflag > 0) { int tmpflag = 1; foreach (KeyValuePair <string, decimal> kvp in p.itempricelist) { if (itemflag == tmpflag) { op.item = kvp.Key; op.price = kvp.Value; break; } tmpflag++; } } CheckIsAdd(myof.productlist, op); if (myorder == null) { OrderFactory.Add(myof); } else { OrderFactory.Update(myof); } Response.Redirect("cart.aspx"); } else if (action == "del") { OrderModel myof = myorder; ProductModel p = ProductFactory.Get(pid); OrderProduct op = new OrderProduct(); op.productinfo = p; op.item = HYRequest.GetQueryString("item"); CheckIsDel(myof.productlist, op); OrderFactory.Update(myof); Response.Redirect("cart.aspx"); } else if (action == "ajaxupdate") //更新数量 { int goods_selected = HYRequest.GetInt("goods_selected", 1); int goods_number = HYRequest.GetInt("goods_number", 1); int rec_id = HYRequest.GetInt("rec_id", 0); string item = HYRequest.GetString("item"); OrderModel myof = myorder; ProductModel p = ProductFactory.Get(rec_id); OrderProduct op = new OrderProduct(); op.isselected = (goods_selected == 1) ? true : false; op.count = goods_number; op.item = item; op.productinfo = p; CheckIsUpdate(myof.productlist, op); OrderFactory.Update(myof); string json = "{\"rec_id\":" + rec_id + ",\"goods_number\":" + goods_number + ",\"total_number\":" + myof.productcount + ",\"total_desc\":" + myof.productprice.ToString() + ",\"postage\":" + myof.postage.ToString() + ",\"error\":0}"; Response.Write(json); Response.Flush(); Response.End(); return; } else if (action == "ajaxupdateall") //全选状态处理 { int goods_selected = HYRequest.GetInt("goods_selected", 1); int rec_id = HYRequest.GetInt("rec_id", 0); OrderModel myof = myorder; foreach (OrderProduct o in myof.productlist) { o.isselected = (goods_selected == 1) ? true : false; } OrderFactory.Update(myof); string json = "{\"rec_id\":" + rec_id + ",\"total_number\":" + myof.productcount + ",\"total_desc\":" + myof.productprice.ToString() + ",\"postage\":" + myof.postage.ToString() + ",\"error\":0}"; Response.Write(json); Response.Flush(); Response.End(); return; } if (myorder != null && myorder.productcount > 0) { this.phNoProduct.Visible = false; CartOrder = myorder; } else { this.phNoProduct.Visible = true; } } }