/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { try { List <int> l = new List <int>(); List <int> ll = new List <int>(); foreach (RepeaterItem row in this.rptGoods.Items) { CheckBox cb = row.FindControl("CB_SelItem") as CheckBox; if (cb != null && cb.Checked) { HiddenField fld = row.FindControl("HF_Id") as HiddenField; HiddenField fld2 = row.FindControl("HF_CateID") as HiddenField; if (fld != null) { int id = Convert.ToInt32(fld.Value); l.Add(id); int cateid = Convert.ToInt32(fld2.Value); ll.Add(cateid); } } } if (l.Count == 0) { JScript.AlertMethod(this, "请勾商品", JScript.IconOption.错误); return; } int areaid = 0; if (!Util.IsEmpty(txtDisAreaBox.areaId)) { areaid = Convert.ToInt32(txtDisAreaBox.areaId); } else { JScript.AlertMethod(this, "区域选择有误", JScript.IconOption.错误); return; } for (int i = 0; i < l.Count; i++) { Hi.Model.BD_GoodsAreas model = new Hi.Model.BD_GoodsAreas(); model.CompID = this.CompID; model.areaID = areaid; model.GoodsID = l[i]; model.CategoryID = ll[i]; model.ts = DateTime.Now; model.modifyuser = this.UserID; new Hi.BLL.BD_GoodsAreas().Add(model); } // new Hi.BLL.BD_CategoryAttribute().Updates(this.UserID.ToString(), l, this.CompID.ToString()); JScript.AlertMethod(this, "商品不可售区域设置成功", JScript.IconOption.正确, "function(){location.href='GoodsAreasList.aspx';}"); } catch (Exception ex) { JScript.AlertMethod(this, "出错了", JScript.IconOption.错误); return; } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { SqlTransaction Tran = null; try { Tran = DBUtility.SqlHelper.CreateStoreTranSaction(); object disId = Request["disId"]; //代理商id object goodsId = Request["goodsId"]; //商品Id if (disId != null && goodsId != null) { for (int i = 0; i < disId.ToString().Split(',').Length; i++) { for (int z = 0; z < goodsId.ToString().Split(',').Length; z++) { List <Hi.Model.BD_GoodsAreas> l = new Hi.BLL.BD_GoodsAreas().GetList("", "isnull(dr,0)=0 and compId=" + this.CompID + " and disId=" + disId.ToString().Split(',')[i] + " and goodsId=" + goodsId.ToString().Split(',')[z], "", Tran); if (l.Count == 0) { Hi.Model.BD_GoodsAreas model = new Hi.Model.BD_GoodsAreas(); Hi.Model.BD_Distributor model2 = new Hi.BLL.BD_Distributor().GetModel(Convert.ToInt32(disId.ToString().Split(',')[i]), Tran); Hi.Model.BD_Goods model3 = new Hi.BLL.BD_Goods().GetModel(Convert.ToInt32(goodsId.ToString().Split(',')[z]), Tran); model.CompID = this.CompID; model.areaID = model2.AreaID; model.GoodsID = Convert.ToInt32(goodsId.ToString().Split(',')[z]); model.CategoryID = model3.CategoryID; model.ts = DateTime.Now; model.dr = 0; model.modifyuser = this.UserID; model.DisID = Convert.ToInt32(disId.ToString().Split(',')[i]); new Hi.BLL.BD_GoodsAreas().Add(model, Tran); } else { continue; } } } } Tran.Commit(); Response.Redirect("GoodsAreaList.aspx"); } catch (Exception ex) { if (Tran != null) { if (Tran.Connection != null) { Tran.Rollback(); } } JScript.AlertMethod(this, "保存失败了", JScript.IconOption.错误, "function(){location.href='GoodsAreaList.aspx';}"); return; } finally { DBUtility.SqlHelper.ConnectionClose(); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hi.Model.BD_GoodsAreas model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hi.Model.BD_GoodsAreas model) { return(dal.Add(model)); }