public string DelType(string id) { string json = string.Empty; if (!string.IsNullOrEmpty(id)) { List <Hi.Model.BD_DisType> List = new Hi.BLL.BD_DisType().GetList(null, " CompID=" + CompID + " and isnull(dr,0)=0 and ParentId=" + id, null); if (List.Count > 0) { return("{\"result\":false,\"code\":\"此类别下还有子级类别,请先删除子级类别!\"}"); } List <Hi.Model.BD_Distributor> Dis = new Hi.BLL.BD_Distributor().GetList(null, " CompID=" + CompID + " and isnull(dr,0)=0 and DisTypeID=" + id, null); if (Dis.Count > 0) { return("{\"result\":false,\"code\":\"此分类已被使用,不允许删除!\"}"); } List <Hi.Model.BD_DisPrice> disp = new Hi.BLL.BD_DisPrice().GetList(null, " CompID=" + CompID + " and type=" + 1 + " and( One=" + id + " or two=" + id + " or three=" + id + ") and dr=0", null); if (disp.Count > 0) { return("{\"result\":false,\"code\":\"此区域下有代理商价格,不允许删除!\"}"); } Hi.Model.BD_DisType type = new Hi.BLL.BD_DisType().GetModel(id.ToInt(0)); type.dr = 1; type.ts = DateTime.Now; type.modifyuser = UserID; if (new Hi.BLL.BD_DisType().Update(type)) { return("{\"result\":true,\"code\":\"操作成功\"}"); } } return(json); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (KeyID != 0) { try { Hi.Model.BD_DisPrice model = new Hi.BLL.BD_DisPrice().GetModel(KeyID); if (model != null) { //this.lblDisTitle.InnerText = model.Title.ToString(); //this.lblDisID.InnerText = model.DisNames.ToString(); //this.txtRemark.Value = model.Remark; } Bind(KeyID.ToString()); } catch (Exception ex) { JScript.AlertMethod(this.Page, "数据有误", JScript.IconOption.错误, "function(){location.href='GoodsPriceList.aspx';}"); return; } } } }
/// <summary> /// 确定并生效按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnInsert_Click(object sender, EventArgs e) { SqlTransaction Tran = null; object obj = Session["GoodsPrice"]; if (obj != null) { try { Tran = DBUtility.SqlHelper.CreateStoreTranSaction(); string title = Common.NoHTML(this.txtDisTitle.Value.Trim()); //调价标题 string disNameList = Common.NoHTML(this.txtDisID1.Name.ToString()); //选择的代理商名称列表 string disIdList = Common.NoHTML(this.txtDisID1.Disid.ToString()); //选择的代理商Id列表 string remark = Common.NoHTML(this.txtRemark.Value.Trim()); //备注 if (Util.IsEmpty(title)) { JScript.AlertMethod(this.Page, "调价标题不能为空", JScript.IconOption.错误); return; } if (Util.IsEmpty(disNameList)) { JScript.AlertMethod(this.Page, "请选择代理商", JScript.IconOption.错误); return; } Hi.Model.BD_DisPrice model2 = new Hi.Model.BD_DisPrice(); //model2.Title = title; model2.CompID = this.CompID; model2.DisIDs = disIdList; //model2.DisNames = disNameList; //model2.Remark = remark; //model2.State = 0; model2.IsEnabled = true; model2.CreateUserID = this.UserID; model2.CreateDate = DateTime.Now; model2.dr = 0; model2.ts = DateTime.Now; model2.modifyuser = this.UserID; int disPriceId = new Hi.BLL.BD_DisPrice().Add(model2, Tran); int z = 0; List <Hi.Model.BD_GoodsPrice> llll = new List <Hi.Model.BD_GoodsPrice>(); //修改 List <Hi.Model.BD_GoodsPrice> llll2 = new List <Hi.Model.BD_GoodsPrice>(); //新增 List <Hi.Model.BD_DisPriceInfo> llll3 = new List <Hi.Model.BD_DisPriceInfo>(); //新增 // string disIdList = this.hidDisId.Value.Trim();//隐藏的选择代理商列表 List <Hi.Model.BD_GoodsInfo> ll = obj as List <Hi.Model.BD_GoodsInfo>; foreach (Hi.Model.BD_GoodsInfo item in ll) { List <Hi.Model.BD_GoodsPrice> lll = new Hi.BLL.BD_GoodsPrice().GetList("", "isnull(dr,0)=0 and isenabled=1 and disid in(" + disIdList + ") and compid=" + this.CompID + " and goodsinfoid=" + item.ID, "", Tran); if (lll.Count > 0) { foreach (Hi.Model.BD_GoodsPrice item2 in lll) { item2.IsEnabled = false; item2.modifyuser = this.UserID; item2.ts = DateTime.Now; item2.CompID = this.CompID; llll.Add(item2); //new Hi.BLL.BD_GoodsPrice().Update(llll); } } for (int i = 0; i < disIdList.Split(',').Length; i++) { Hi.Model.BD_GoodsPrice model = new Hi.Model.BD_GoodsPrice(); Hi.Model.BD_DisPriceInfo model3 = new Hi.Model.BD_DisPriceInfo(); //model.DisPriceID = 0; model.DisID = Convert.ToInt32(disIdList.Split(',')[i]); model.CompID = this.CompID; model.GoodsInfoID = item.ID; if (Request["txtPrice"] != null) { model.TinkerPrice = Convert.ToDecimal(Request["txtPrice"].Split(',')[z]); } model.IsEnabled = true; model.CreateUserID = this.UserID; model.CreateDate = DateTime.Now; model.ts = DateTime.Now; model.modifyuser = this.UserID; llll2.Add(model); model3.DisPriceID = disPriceId; //model3.DisID = Convert.ToInt32(disIdList.Split(',')[i]); model3.CompID = this.CompID; model3.GoodsInfoID = item.ID; if (Request["txtPrice"] != null) { model3.TinkerPrice = Convert.ToDecimal(Request["txtPrice"].Split(',')[z]); } model3.IsEnabled = true; model3.CreateUserID = this.UserID; model3.CreateDate = DateTime.Now; model3.ts = DateTime.Now; model3.modifyuser = this.UserID; llll3.Add(model3); } z++; } new Hi.BLL.BD_GoodsPrice().Update(llll, Tran); new Hi.BLL.BD_GoodsPrice().Add(llll2, Tran); new Hi.BLL.BD_DisPriceInfo().Add(llll3, Tran); Tran.Commit(); Response.Redirect("DispriceList.aspx"); // JScript.AlertMsg(this, "价格调整成功",); } catch (Exception) { if (Tran != null) { if (Tran.Connection != null) { Tran.Rollback(); } } JScript.AlertMethod(this, "价格调整失败", JScript.IconOption.错误, "function(){location.href='DispriceList.aspx';}"); return; } } else { JScript.AlertMethod(this.Page, "选择的商品数据有误", JScript.IconOption.错误); return; } }