//推荐设置 protected void ButtonVouchSet_Click(object sender, EventArgs e) { foreach (RepeaterItem ri in RepList.Items) { CheckBox cb = ((CheckBox)ri.FindControl("CheckBoxChoose")); int ID = Convert.ToInt32(((HiddenField)ri.FindControl("HiddenFieldID")).Value); if (cb.Checked == true) { TB_Product_Group model = ProductService.GroupService.Get(ID); model.VouchType = DDLVouchType.SelectedValue.ToInt(); ProductService.GroupService.Update(model); } } //重新加载 LoadDataBind(); }
//保存 protected void BtnSave_Click(object sender, EventArgs e) { TB_Product_Group model = new TB_Product_Group(); if (ViewState["id"] != null) { model = ProductService.GroupService.Get(ViewState["id"]); } model.GroupName = TbName.Text; model.Price = TbPrice.Text.ToDecimal(); model.GroupPrice = TbGroupPrice.Text.ToDecimal(); model.StartDate = TbStartDate.Text.ToDateTime(); model.StopDate = TbStopDate.Text.ToDateTime(); model.ImgUrl = ProImg.Url; model.GroupDesc = FckDes.Value; model.VouchType = DDLVouchType.SelectedValue.ToInt(); model.IsHidden = CheckBoxIsHidden.Checked; model.OrderBy = TbOrderBy.Text.ToInt(); model.AddDate = DateTime.Now; model.Creater = AdminUserName; if (ViewState["id"] == null) { if (ProductService.GroupService.Insert(model) == 1) { MessageDiv.InnerHtml = CommonClass.Reload("数据添加成功"); } else { MessageDiv.InnerHtml = CommonClass.Alert("数据添加失败"); } } else { if (ProductService.GroupService.Update(model) == 1) { MessageDiv.InnerHtml = CommonClass.Reload("数据修改成功"); } else { MessageDiv.InnerHtml = CommonClass.Alert("数据修改失败"); } } }
//加载 public void LoadDataBind() { int ID = CommonClass.ReturnRequestInt("id", 0); if (ID > 0) { TB_Product_Group model = ProductService.GroupService.Get(ID); if (model.ID.ToInt() > 0) { TbName.Text = model.GroupName; TbPrice.Text = model.Price.ToStr(); TbGroupPrice.Text = model.GroupPrice.ToStr(); TbStartDate.Text = model.StartDate.ToStr(); TbStopDate.Text = model.StopDate.ToStr(); ProImg.Url = model.ImgUrl; FckDes.Value = model.GroupDesc; DDLVouchType.SelectedValue = model.VouchType.ToStr(); CheckBoxIsHidden.Checked = model.IsHidden; TbDate.Text = model.AddDate.ToString(); TbOrderBy.Text = model.OrderBy.ToStr(); ViewState["id"] = model.ID; } } }
protected void Page_Load(object sender, EventArgs e) { int id = CommonClass.ReturnRequestInt("id", 0); entity = ProductService.GroupService.Get(id); }
/// <summary> /// 添加购物车 /// </summary> /// <param name="type">商品类型,0为普通商品,1为团购商品</param> /// <param name="proId">商品编号</param> /// <param name="count">商品数量</param> /// <returns></returns> public static bool AddCart(int type, int proId, int count) { if (!File.Exists(path)) { CreateXMLFile(path); } decimal marketPrice = 0; //获取购物车里面的数据 TB_Order_OrderDetails model = new TB_Order_OrderDetails(); switch (type) { case 0: TB_Product_Products entity = ProductService.ProductsService.Get(proId); model.ProductID = entity.ID; model.ProNumber = entity.ProNumber; model.ProName = entity.ProName; model.Price = entity.SalesPrice; model.Picture = entity.ImgUrl; marketPrice = entity.MarketPrice; break; case 1: TB_Product_Group entity2 = ProductService.GroupService.Get(proId); model.ProductID = entity2.ID; model.ProName = entity2.GroupName; model.Price = entity2.Price; model.Picture = entity2.ImgUrl; break; } DataSet ds = new DataSet(); ds.ReadXml(path); if (ds.Tables.Count > 0) { DataTable dt = ds.Tables[0]; //当前商品是否存在 bool isExist = false; foreach (DataRow dr in dt.Rows) { if (dr["id"].ToInt() == proId && dr["type"].ToInt() == type) { isExist = true; dr["count"] = dr["count"].ToInt() + count; dr["amount"] = model.Price * dr["count"].ToInt(); } } //当不存在 if (isExist == false) { DataRow dr = dt.NewRow(); dr["type"] = type.ToStr(); dr["id"] = model.ProductID; dr["proNumber"] = model.ProNumber; dr["name"] = model.ProName; dr["img"] = model.Picture; dr["marketPrice"] = marketPrice; dr["count"] = count; dr["price"] = model.Price; dr["amount"] = model.Price * count; dt.Rows.Add(dr); } //保存到购物车 ds.WriteXml(path); } else { AddProductInfo(type, model, count); } return(true); }