/// <summary> /// 编辑属性值 /// </summary> /// <param name="id"></param> /// <returns></returns> public string SaveValue(string id, string attributeId, string value) { //查看该属性值是否被使用 var ll = new Hi.BLL.BD_AttributeValues().GetList("", "id<>" + id + " and isnull(dr,0)=0 and attrvalue='" + value + "' and attributeId=" + attributeId, ""); if (ll.Count > 0) { return("ycz");//已存在 } string str = string.Empty; if (id != "" && id != null) { Hi.Model.BD_AttributeValues model = new Hi.BLL.BD_AttributeValues().GetModel(Convert.ToInt32(id)); if (model != null) { model.ts = DateTime.Now; model.modifyuser = this.UserID; model.AttrValue = value; model.CompID = this.CompID; bool bol = new Hi.BLL.BD_AttributeValues().Update(model); return("cg"); } } return(str); }
/// <summary> /// 属性值添加 /// </summary> /// <param name="value"></param> /// <returns></returns> public string AddAttributeValue(string value, string id) { value = Common.NoHTML(value); var num = new Hi.BLL.BD_AttributeValues().GetList("", "attributeid=" + id + " and attrvalue='" + value + "' and ISNULL(dr,0)=0 and compid=" + this.CompID, ""); if (num.Count > 0) { return("ycz");//已存在 } Hi.Model.BD_AttributeValues model = new Hi.Model.BD_AttributeValues(); model.AttrValue = value; model.AttributeID = Convert.ToInt32(id); model.CreateDate = DateTime.Now; model.CreateUserID = this.UserID; model.ts = DateTime.Now; model.CompID = this.CompID; model.modifyuser = this.UserID; model.IsEnabled = 1; int count = new Hi.BLL.BD_AttributeValues().Add(model); if (count > 0) { return(count.ToString()); } else { return(""); } }
/// <summary> /// 删除属性值 /// </summary> /// <param name="id"></param> /// <returns></returns> public string DelValue(string id) { //查看该属性值是否被使用 var ll = new Hi.BLL.BD_AttributeValues().GetModel(Convert.ToInt32(id)); if (ll != null) { string valueName = ll.AttrValue; var lll = new Hi.BLL.BD_GoodsAttrsInfo().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID + " and attrsInfoName='" + Common.NoHTML(valueName) + "'", ""); if (lll.Count > 0) { return("ycz"); } } string str = string.Empty; if (id != "" && id != null) { Hi.Model.BD_AttributeValues model = new Hi.BLL.BD_AttributeValues().GetModel(Convert.ToInt32(id)); if (model != null) { model.ts = DateTime.Now; model.modifyuser = this.UserID; model.dr = 1; model.CompID = this.CompID; bool bol = new Hi.BLL.BD_AttributeValues().Update(model); return("cg"); } } return(str); }
/// <summary> /// 验证属性值是否存在 /// </summary> /// <param name="s"></param> /// <returns></returns> public string CheckGoodsAttrValue(string attrlist, string value, string str, int index, SqlTransaction Tran, List <string[]> al) { string attrId = string.Empty; string strList = string.Empty; if (attrlist.IndexOf("@") != -1) { attrId = attrlist.Split('@')[1]; attrlist = attrlist.Split('@')[0]; } string[] valueList = value.Split(';'); //属性值组数组 string[] valueList2 = { }; //属性值数组 string strValue = string.Empty; //属性值拼接 bool bol = false; bool bol2 = false; for (int i = 0; i < valueList.Length; i++) { string strList2 = string.Empty; valueList2 = valueList[i].Split(','); for (int z = 0; z < valueList2.Length; z++) { // strValue += "'" + valueList2[z] + "',"; List <Hi.Model.BD_AttributeValues> l = new Hi.BLL.BD_AttributeValues().GetList("", "isnull(dr,0)=0 and isenabled=1 and compid=" + this.CompID + " and attributeid in(" + attrId + ") and attrvalue='" + valueList2[z] + "'", ""); if (l.Count == 0) { strValue = valueList2[z]; bol = true; break; } else { strList2 += l[0].ID + ","; strList += l[0].ID + ","; } } if (bol) { bol2 = true; break; } if (!Util.IsEmpty(strList2)) { strList2 = strList2.Substring(0, strList2.Length - 1); } al.Add(strList2.Split(',')); } if (bol2) { Eroor = true; throw new ApplicationException("Excel行号为: <i error>" + (index + 3) + " </i> 的数据有误。" + str + "不存在" + strValue + ",请修改后重新导入。"); } if (!Util.IsEmpty(strList)) { strList = strList.Substring(0, strList.Length - 1); } return(strList); }
/// <summary> /// 属性以及属性值添加 /// </summary> /// <param name="value"></param> /// <returns></returns> public string AddAttributeValue(string value, string id, string attrName) { value = Common.NoHTML(value); attrName = Common.NoHTML(attrName); int attrId = 0; if (id == "" || id == null) { if (IsExist("attributeName", attrName, "")) { return("sxycz"); } Hi.Model.BD_Attribute l = new Hi.Model.BD_Attribute(); l.AttributeName = attrName; l.CreateDate = DateTime.Now; l.CreateUserID = this.UserID; l.ts = DateTime.Now; l.CompID = this.CompID; l.modifyuser = this.UserID; l.IsEnabled = 1; attrId = new Hi.BLL.BD_Attribute().Add(l); } else { attrId = Convert.ToInt32(id); } var num = new Hi.BLL.BD_AttributeValues().GetList("", "attributeid=" + attrId + " and attrvalue='" + value + "' and ISNULL(dr,0)=0 and Compid=" + this.CompID, ""); if (num.Count > 0) { return("ycz");//已存在 } Hi.Model.BD_AttributeValues model = new Hi.Model.BD_AttributeValues(); model.AttrValue = value; model.AttributeID = Convert.ToInt32(attrId); model.CreateDate = DateTime.Now; model.CreateUserID = this.UserID; model.ts = DateTime.Now; model.CompID = this.CompID; model.modifyuser = this.UserID; model.IsEnabled = 1; int count = new Hi.BLL.BD_AttributeValues().Add(model); if (count > 0) { return(attrId.ToString()); } else { return(""); } }
/// <summary> /// 根据属性id得到属性值 /// </summary> /// <returns></returns> public string GetAttrValue(string str) { string list = string.Empty; List <Hi.Model.BD_AttributeValues> ll = new Hi.BLL.BD_AttributeValues().GetList("", "AttributeID=" + str + " and ISNULL(dr,0)=0 and ComPid=" + this.CompID + " and isenabled=1", ""); if (ll.Count > 0) { DataTable dt2 = Common.FillDataTable <Hi.Model.BD_AttributeValues>(ll); if (dt2.Rows.Count != 0) { return(ConvertJson.ToJson(dt2)); } } return("[{}]"); }
/// <summary> /// 取消删除最新插入 /// </summary> /// <param name="id"></param> /// <returns></returns> public string DelAttr(int id) { SqlTransaction Tran = Tran = DBUtility.SqlHelper.CreateStoreTranSaction(); try { Hi.Model.BD_Attribute model = new Hi.BLL.BD_Attribute().GetModel(id, Tran); model.dr = 1; model.modifyuser = this.UserID; model.ts = DateTime.Now; new Hi.BLL.BD_Attribute().Update(model, Tran); List <Hi.Model.BD_AttributeValues> l = new Hi.BLL.BD_AttributeValues().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID + " and attributeid=" + id, "", Tran); if (l.Count > 0) { foreach (Hi.Model.BD_AttributeValues item in l) { Hi.Model.BD_AttributeValues model2 = new Hi.BLL.BD_AttributeValues().GetModel(item.ID, Tran); model2.dr = 1; model2.modifyuser = this.UserID; model2.ts = DateTime.Now; new Hi.BLL.BD_AttributeValues().Update(model2, Tran); } } Tran.Commit(); return("cg"); } catch (Exception ex) { if (Tran != null) { if (Tran.Connection != null) { Tran.Rollback(); } } JScript.AlertMethod(this, "失败", JScript.IconOption.错误); return(""); } finally { DBUtility.SqlHelper.ConnectionClose(); } }
/// <summary> /// 根据属性ID得到属性值 /// </summary> /// <returns></returns> public string GetAttributeValueList(int str) { string list = string.Empty; List <Hi.Model.BD_AttributeValues> ll = new Hi.BLL.BD_AttributeValues().GetList("", "AttributeID=" + str + " and ISNULL(dr,0)=0 and ComPid=" + this.CompID, ""); if (ll.Count > 0) { foreach (Hi.Model.BD_AttributeValues item in ll) { string str2 = item.AttrValue; if (item.IsEnabled == 0)//如果禁用这灰色 { str2 = "<label style=\"color:#aaaaaa\">" + str2 + "</label>"; } list += str2 + ";"; } if (list.Length > 65) { list = list.Substring(0, list.Substring(0, 65).LastIndexOf(';')) + "<br> " + list.Substring(list.Substring(0, 65).LastIndexOf(';')); } } return(list != "" ? list.Substring(0, list.Length - 1) : list); }
/// <summary> /// 禁用属性值 /// </summary> /// <param name="id"></param> /// <returns></returns> public string EnableValue(string id) { string str = string.Empty; if (id != "" && id != null) { Hi.Model.BD_AttributeValues model = new Hi.BLL.BD_AttributeValues().GetModel(Convert.ToInt32(id)); if (model != null) { model.ts = DateTime.Now; model.modifyuser = this.UserID; model.CompID = this.CompID; var ll = new Hi.BLL.BD_AttributeValues().GetList("", "id=" + id + " and IsEnabled=1", ""); if (ll.Count > 0) { model.IsEnabled = 0; //if (new Hi.BLL.BD_AttributeValues().Updatess(this.UserID.ToString(), id, "0") > 0) //{ // Utils.EditLog("用户" + this.UserName + "禁用属性值成功", "禁用属性值成功", "商品属性管理模块", "Company/Goods/GoodsAttributeList.aspx", 1); str = "jycg";//禁用 // } } else { model.IsEnabled = 1; //if (new Hi.BLL.BD_AttributeValues().Updatess(this.UserID.ToString(), id, "1") > 0) //{ // Utils.EditLog("用户" + this.UserName + "启用属性值成功", "启用属性值成功", "商品属性管理模块", "Company/Goods/GoodsAttributeList.aspx", 1); str = "qycg";//启用 // } } bool bol = new Hi.BLL.BD_AttributeValues().Update(model); } } return(str); }
/// <summary> /// 属性绑定 /// </summary> private void BindAttribute(int type, string id) { int y = 0; StringBuilder html = new StringBuilder(); StringBuilder html2 = new StringBuilder(); html.Append("<ul class=\"ng-scope\">"); List <Hi.Model.BD_Attribute> ll = new Hi.BLL.BD_Attribute().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID, ""); if (ll.Count > 0) { if (type == 2) { List <Hi.Model.BD_TemplateAttribute> l = new Hi.BLL.BD_TemplateAttribute().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID + " and templateId=" + id, ""); foreach (Hi.Model.BD_Attribute item in ll) { string str = string.Empty; int attrId = 0; if (l.Count > 0) { foreach (Hi.Model.BD_TemplateAttribute item2 in l) { if (item2.AttributeID == item.ID) { attrId = item2.ID; str = "checked=\"checked\""; break; } } } html.Append("<li class=\"pointer proHover p-t-6 p-b-6 ng-scope\" tip=\"" + item.ID + "\"><span class=\"customerManager m-l-10\"><input class=\"ng-pristine ng-untouched ng-valid\" " + str + " type=\"checkbox\" name=\"chekAttr\" value=\"" + item.ID + "\"/></span><span class=\"ng-binding\">" + item.AttributeName + "</span>"); if (item.Memo != "") { html.Append("<span class=\"ng-binding\">(" + item.Memo + ")</span>"); } html.Append("</li>"); List <Hi.Model.BD_AttributeValues> lll = new Hi.BLL.BD_AttributeValues().GetList("", "isnull(dr,0)=0 and isenabled=1 and compId=" + this.CompID + " and attributeId=" + item.ID, ""); if (lll.Count > 0) { html2.Append("<ul class=\"ng-scope\" tip=\"" + item.ID + "\" " + (y != 0 ? "style=\"display:none;\"" : "") + ">"); foreach (Hi.Model.BD_AttributeValues item2 in lll) { string str2 = string.Empty; if (attrId != 0) { List <Hi.Model.BD_TemplateAttrValue> llll = new Hi.BLL.BD_TemplateAttrValue().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID + " and TemplateAttrID=" + attrId + " and attributevalueId=" + item2.ID, ""); if (llll.Count > 0) { str2 = "checked=\"checked\""; } List <Hi.Model.BD_TemplateAttrValue> lllll = new Hi.BLL.BD_TemplateAttrValue().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID + " and TemplateAttrID=" + attrId, ""); if (lllll.Count == 0) { str2 = "checked=\"checked\""; } } html2.Append("<li class=\"pointer proHover p-t-6 p-b-6 ng-scope\" tip=\"" + item2.ID + "\"><span class=\"customerManager m-l-10\"><input class=\"ng-pristine ng-untouched ng-valid\" " + str2 + " type=\"checkbox\" name=\"chekAttrValue" + item.ID + "\" value=\"" + item2.ID + "\"/></span><span class=\"ng-binding\">" + item2.AttrValue + "</span></li>"); y++; } html2.Append("</ul>"); } } } else { foreach (Hi.Model.BD_Attribute item in ll) { html.Append("<li class=\"pointer proHover p-t-6 p-b-6 ng-scope\" tip=\"" + item.ID + "\"><span class=\"customerManager m-l-10\"><input class=\"ng-pristine ng-untouched ng-valid\" type=\"checkbox\" name=\"chekAttr\" value=\"" + item.ID + "\"/></span><span class=\"ng-binding\">" + item.AttributeName + "</span>"); if (item.Memo != "") { html.Append("<span class=\"ng-binding\">(" + item.Memo + ")</span>"); } html.Append("</li>"); List <Hi.Model.BD_AttributeValues> l = new Hi.BLL.BD_AttributeValues().GetList("", "isnull(dr,0)=0 and isenabled=1 and compId=" + this.CompID + " and attributeId=" + item.ID, ""); if (l.Count > 0) { html2.Append("<ul class=\"ng-scope\" tip=\"" + item.ID + "\" style=\"display:none;\">"); foreach (Hi.Model.BD_AttributeValues item2 in l) { html2.Append("<li class=\"pointer proHover p-t-6 p-b-6 ng-scope\" tip=\"" + item2.ID + "\"><span class=\"customerManager m-l-10\"><input class=\"ng-pristine ng-untouched ng-valid\" type=\"checkbox\" name=\"chekAttrValue" + item.ID + "\" value=\"" + item2.ID + "\"/></span><span class=\"ng-binding\">" + item2.AttrValue + "</span></li>"); } html2.Append("</ul>"); } } } } html.Append("</ul>"); this.divAttr.InnerHtml = html.ToString(); this.divAttrValue.InnerHtml = html2.ToString(); }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { SqlTransaction Tran = Tran = DBUtility.SqlHelper.CreateStoreTranSaction(); try { List <int> l = new List <int>(); foreach (RepeaterItem row in this.rptAttribute.Items) { CheckBox cb = row.FindControl("CB_SelItem") as CheckBox; if (cb != null && cb.Checked) { HiddenField fld = row.FindControl("HF_Id") as HiddenField; if (fld != null) { int id = Convert.ToInt32(fld.Value); l.Add(id); Hi.Model.BD_Attribute model = new Hi.BLL.BD_Attribute().GetModel(id); if (model != null) { var lll = new Hi.BLL.BD_GoodsAttrs().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID + " and AttrsName ='" + model.AttributeName + "'", ""); if (lll.Count > 0) { JScript.AlertMethod(this, "属性已被使用,不能删除", JScript.IconOption.错误); break; } model.ts = DateTime.Now; model.modifyuser = this.UserID; model.dr = 1; model.CompID = this.CompID; bool bol = new Hi.BLL.BD_Attribute().Update(model); List <Hi.Model.BD_AttributeValues> ll = new Hi.BLL.BD_AttributeValues().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID + " and attributeid=" + id, "", Tran); if (ll.Count > 0) { foreach (Hi.Model.BD_AttributeValues item in ll) { Hi.Model.BD_AttributeValues model2 = new Hi.BLL.BD_AttributeValues().GetModel(item.ID, Tran); model2.dr = 1; model2.modifyuser = this.UserID; model2.ts = DateTime.Now; new Hi.BLL.BD_AttributeValues().Update(model2, Tran); } } } } } } Tran.Commit(); } catch (Exception ex) { if (Tran != null) { if (Tran.Connection != null) { Tran.Rollback(); } } JScript.AlertMethod(this, "失败", JScript.IconOption.错误); return; } finally { DBUtility.SqlHelper.ConnectionClose(); } // new Hi.BLL.BD_Attribute().Updates(this.UserID.ToString(), l, this.CompID.ToString()); Bind(); }