/// <summary> /// 增加一条数据 /// </summary> public int Add(Hi.Model.BD_ShopImageList model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hi.Model.BD_ShopImageList model) { return(dal.Update(model)); }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { if (comPid == 0) { JScript.AlertMethod(this, "厂商Id有误", JScript.IconOption.错误, "function(){ window.location.href='../../admin/systems/CompList.aspx'; }"); return; } SqlTransaction Tran = DBUtility.SqlHelper.CreateStoreTranSaction(); try { new Hi.BLL.BD_ShopImageList().Delete(comPid, Tran); object url = Request["txtUrl"]; object hrImg = Request["hrImgPath"]; if (url != null) { for (int i = 0; i < url.ToString().Split(',').Length; i++) { Hi.Model.BD_ShopImageList model = new Hi.Model.BD_ShopImageList(); model.CompID = comPid; model.Type = 2; model.ImageUrl = hrImg.ToString().Split(',')[i]; string goodsUrl = url.ToString().Split(',')[i].Trim(); if (goodsUrl == "请输入商品网址") { model.ImageName = ""; model.GoodsUrl = ""; } else { model.GoodsUrl = url.ToString().Split(',')[i]; string id = goodsUrl.Substring(goodsUrl.IndexOf('=') + 1, goodsUrl.LastIndexOf('&') - goodsUrl.IndexOf('=') - 1); string str = goodsUrl.Substring(goodsUrl.IndexOf('?') + 1, goodsUrl.IndexOf('=') - goodsUrl.IndexOf('?') - 1).Trim();//判断是goodsid还是GoodsinfoId if (str.ToLowerInvariant() == "goodsid") { Hi.Model.BD_Goods model2 = new Hi.BLL.BD_Goods().GetModel(Convert.ToInt32(id.ToString()), Tran); if (model2 != null) { model.ImageName = model2.GoodsName; } else { model.ImageName = ""; } } else if (str.ToLowerInvariant() == "goodsinfoid") { Hi.Model.BD_GoodsInfo model3 = new Hi.BLL.BD_GoodsInfo().GetModel(Convert.ToInt32(id.ToString()), Tran); if (model3 != null) { Hi.Model.BD_Goods model4 = new Hi.BLL.BD_Goods().GetModel(model3.GoodsID, Tran); if (model4 != null) { model.ImageName = model4.GoodsName; } } else { model.ImageName = ""; } } } model.ImageTitle = ""; model.GoodsID = 0;// Convert.ToInt32(goodsId.ToString().Split(',')[i]); model.CreateDate = DateTime.Now; model.CreateUserID = this.UserID; model.ts = DateTime.Now; model.modifyuser = this.UserID; model.dr = 0; new Hi.BLL.BD_ShopImageList().Add(model, Tran); } } Tran.Commit(); Response.Redirect("RecommendGoodsPic2.aspx?KeyID=" + comPid); } catch (Exception ex) { if (Tran != null) { if (Tran.Connection != null) { Tran.Rollback(); } } JScript.AlertMsgOne(this, "编辑失败,出错原因" + ex.Message, JScript.IconOption.错误); return; } finally { DBUtility.SqlHelper.ConnectionClose(); } }