Beispiel #1
0
    /// <summary>
    /// 绑定属性列表
    /// </summary>
    /// <param name="id"></param>
    private void Bind()
    {
        int    pageCount = 0;
        int    Counts    = 0;
        string strWhere  = "and ISNULL(dr,0)=0 and ComPid=" + this.CompID;

        if (ViewState["strWhere"] != null)
        {
            strWhere += ViewState["strWhere"].ToString();
        }
        //每页显示的数据设置
        if (this.txtPageSize.Value.Trim().ToString() != "" && this.txtPageSize.Value.Trim().ToString() != "0")
        {
            if (this.txtPageSize.Value.Trim().Length >= 5)
            {
                Pager.PageSize         = 100;
                this.txtPageSize.Value = "100";
            }
            else
            {
                this.Pager.PageSize = this.txtPageSize.Value.Trim().ToInt(0);
            }
        }
        List <Hi.Model.BD_Attribute> l = new Hi.BLL.BD_Attribute().GetList(Pager.PageSize, Pager.CurrentPageIndex, "id", false, strWhere, out pageCount, out Counts);

        this.rptAttribute.DataSource = l;
        this.rptAttribute.DataBind();
        Pager.RecordCount = Counts;
        page = Pager.CurrentPageIndex.ToString();
    }
Beispiel #2
0
    /// <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("");
        }
    }
Beispiel #3
0
    /// <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();
        }
    }
Beispiel #4
0
 /// <summary>
 /// 编辑属性
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnEdit_Click(object sender, EventArgs e)
 {
     try
     {
         //赋值
         string attributeName            = Common.NoHTML(txtAttributeNames.Value.Trim()); //属性名称
         string memo                     = Common.NoHTML(txtMemos.Value.Trim());          //属性备注
         Hi.Model.BD_Attribute attribute = new Hi.BLL.BD_Attribute().GetModel(Convert.ToInt32(hideAttrId.Value));
         var list = new Hi.BLL.BD_Attribute().GetList("", "id<>" + hideAttrId.Value + " and attributename='" + attributeName + "' and ISNULL(dr,0)=0 and compid=" + this.CompID, "");
         if (list.Count > 0)
         {
             JScript.AlertMethod(this, "属性名称已存在", JScript.IconOption.错误);
             return;
         }
         else
         {
             attribute.AttributeName = attributeName;
         }
         attribute.AttributeName = attributeName;
         attribute.Memo          = memo;
         attribute.CreateUserID  = this.UserID;
         attribute.ts            = DateTime.Now;
         attribute.CompID        = this.CompID;
         attribute.modifyuser    = this.UserID;
         attribute.IsEnabled     = 1;
         /*****执行*****/
         bool k = new Hi.BLL.BD_Attribute().Update(attribute);
         if (k)
         {
             Bind();
             txtAttributeNames.Value = string.Empty;
         }
         else
         {
             JScript.AlertMethod(this, "属性编辑失败", JScript.IconOption.错误);
             return;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #5
0
    /// <summary>
    /// 判断某属性某值是否存在
    /// </summary>
    /// <param name="Id">ID</param>
    /// <returns></returns>
    public bool IsExist(string value, string text, string id)
    {
        string where = string.Empty;
        if (!Util.IsEmpty(id))
        {
            where = " and id!=" + id;
        }
        bool bfg = false;

        if (!string.IsNullOrEmpty(text))
        {
            List <Hi.Model.BD_Attribute> List = new Hi.BLL.BD_Attribute().GetList(" top 1 *", value + "='" + text + "' and ISNULL(dr,0)=0 and compid=" + this.CompID + where, null);
            if (List.Count > 0)
            {
                bfg = true;
            }
        }
        return(bfg);
    }
Beispiel #6
0
    /// <summary>
    /// 判断某属性某值是否存在
    /// </summary>
    /// <param name="Id">ID</param>
    /// <returns></returns>
    public bool IsExist(int id, string value)
    {
        bool bfg = false;

        if (id != 0)
        {
            var list = new Hi.BLL.BD_Attribute().GetList("", "id<>" + id + " and attributename='" + value + "' and ISNULL(dr,0)=0 and compid=" + this.CompID, "");
            if (list.Count > 0)
            {
                bfg = true;
            }
        }
        else
        {
            if (IsExist("attributeName", value, ""))
            {
                bfg = true;
            }
        }
        return(bfg);
    }
Beispiel #7
0
    /// <summary>
    /// 绑定
    /// </summary>
    /// <param name="id"></param>
    public string Bind2(string id)
    {
        DataTable dt = new Hi.BLL.BD_Attribute().GetAttributrList(id, this.CompID.ToString());//获取属性以及属性值

        if (dt.Rows.Count != 0)
        {
            return(ConvertJson.ToJson(dt));
        }
        else
        {
            Hi.Model.BD_Attribute        model = new Hi.BLL.BD_Attribute().GetModel(Convert.ToInt32(id));
            List <Hi.Model.BD_Attribute> lsit  = new List <Hi.Model.BD_Attribute>();
            lsit.Add(model);
            DataTable dt2 = Common.FillDataTable <Hi.Model.BD_Attribute>(lsit);
            if (dt2.Rows.Count != 0)
            {
                return(ConvertJson.ToJson(dt2));
            }
            return("[{}]");
        }
    }
Beispiel #8
0
    /// <summary>
    /// 根据属性
    /// </summary>
    /// <returns></returns>
    public string GetTemplateList(int str)
    {
        string list = string.Empty;
        List <Hi.Model.BD_TemplateAttribute> ll = new Hi.BLL.BD_TemplateAttribute().GetList("", "TemplateID=" + str + " and ISNULL(dr,0)=0 and ComPid=" + this.CompID, "");

        if (ll.Count > 0)
        {
            foreach (Hi.Model.BD_TemplateAttribute item in ll)
            {
                Hi.Model.BD_Attribute model = new Hi.BLL.BD_Attribute().GetModel(item.AttributeID);
                string str2 = model.AttributeName;
                if (model.Memo != "")
                {
                    str2 += "(" + model.Memo + ")";
                }
                list += str2 + ";";
            }
            if (list.Length > 65)
            {
                list = list.Substring(0, list.Substring(0, 65).LastIndexOf(';')) + "<br>&nbsp;&nbsp;&nbsp;" + list.Substring(list.Substring(0, 65).LastIndexOf(';'));
            }
        }
        return(list != "" ? list.Substring(0, list.Length - 1) : list);
    }
Beispiel #9
0
    /// <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();
    }
Beispiel #10
0
    /// <summary>
    /// 添加属性
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            if (bolNum(hideadd.Value))
            {
                Hi.Model.BD_Attribute attribute = new Hi.BLL.BD_Attribute().GetModel(Convert.ToInt32(hideadd.Value));
                if (IsExist("attributeName", this.txtAttributeName.Value.Trim(), hideadd.Value))
                {
                    JScript.AlertMethod(this, "属性已存在", JScript.IconOption.错误);
                    return;
                }
                attribute.AttributeName = Common.NoHTML(this.txtAttributeName.Value.Trim());
                attribute.Memo          = Common.NoHTML(this.txtMemo.Value.Trim());
                attribute.CreateUserID  = this.UserID;
                attribute.ID            = Convert.ToInt32(hideadd.Value);
                attribute.ts            = DateTime.Now;
                attribute.CompID        = this.CompID;
                attribute.modifyuser    = this.UserID;
                bool k = new Hi.BLL.BD_Attribute().Update(attribute);

                Bind();
                txtAttributeName.Value = string.Empty;
                txtMemo.Value          = string.Empty;
                hideadd.Value          = "";
            }
            else
            {
                //赋值
                string attributeName = Common.NoHTML(txtAttributeName.Value.Trim()); //属性名称
                string memo          = Common.NoHTML(txtMemo.Value.Trim());          //排序编号
                if (IsExist("attributeName", attributeName, ""))
                {
                    JScript.AlertMethod(this, "属性已存在", JScript.IconOption.错误);
                    return;
                }
                Hi.Model.BD_Attribute attribute = new Hi.Model.BD_Attribute();
                attribute.AttributeName = attributeName;
                attribute.Memo          = memo;
                attribute.CreateUserID  = this.UserID;
                attribute.CreateDate    = DateTime.Now;
                attribute.CreateDate    = DateTime.Now;//创建时间
                attribute.ts            = DateTime.Now;
                attribute.CompID        = this.CompID;
                attribute.modifyuser    = this.UserID;
                attribute.IsEnabled     = 1;
                /*****执行*****/
                int k = new Hi.BLL.BD_Attribute().Add(attribute);
                if (k > 0)
                {
                    Bind();
                    txtAttributeName.Value = string.Empty;
                    hideadd.Value          = "";
                }
                else
                {
                    JScript.AlertMethod(this, "属性添加失败", JScript.IconOption.错误);
                    return;
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Beispiel #11
0
    /// <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();
    }
Beispiel #12
0
    /// <summary>
    /// 验证规格属性是否存在一、二、三级分类
    /// </summary>
    /// <returns></returns>
    public string CheckGoodsAttr(string goodsTypeId, string goodsCate3, string value, string str, int index, SqlTransaction Tran)
    {
        string goodsCateId = string.Empty;

        if (goodsCate3.IndexOf("@") != -1)
        {
            categoryId  = goodsCate3.Split('@')[1];
            goodsCateId = goodsCate3.Split('@')[1];
            goodsCate3  = goodsCate3.Split('@')[0];
        }
        else
        {
            List <Hi.Model.BD_GoodsCategory> ll = new Hi.BLL.BD_GoodsCategory().GetList("", "isnull(dr,0)=0 and isenabled=1 and goodstypeid=" + goodsTypeId + "   and categoryname='" + goodsCate3 + "' and compid=" + this.CompID, "", Tran);
            if (ll.Count > 0)
            {
                goodsCateId = ll[0].ID.ToString();
            }
        }
        string[] valueList = value.Split(','); //规格属性以逗号分隔
        bool     bol       = false;            //如果有不存在的规格属性,则跳出for
        string   strValue  = string.Empty;     //保存属性
        string   listId    = string.Empty;     //attrId

        for (int i = 0; i < valueList.Length; i++)
        {
            if (!Util.IsEmpty(valueList[i]))
            {
                List <Hi.Model.BD_Attribute> l = new Hi.BLL.BD_Attribute().GetList("", "isnull(dr,0)=0 and isenabled=1 and compId=" + this.CompID + " and attributename='" + valueList[i] + "'", "", Tran);
                if (l.Count == 0)
                {
                    strValue = valueList[i];
                    bol      = true;
                    break;
                }
                else
                {
                    foreach (Hi.Model.BD_Attribute item in l)
                    {
                        listId += item.ID + ",";
                        // strValue += item.AttributeName + ",";
                    }
                }
            }
        }
        if (bol)
        {
            Eroor = true;
            throw new ApplicationException("Excel行号为:&nbsp;<i error>" + (index + 3) + " </i>  &nbsp;&nbsp;的数据有误。" + str + "不存在" + strValue + ",请修改后重新导入。");
        }
        else
        {
            if (!Util.IsEmpty(listId))
            {
                listId   = listId.Substring(0, listId.Length - 1);
                strValue = value.Replace(',', ',');
            }
            List <Hi.Model.BD_CategoryAttribute> lll = new Hi.BLL.BD_CategoryAttribute().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID + "  and attributeid in(" + listId + ") and categoryId=" + goodsCateId, "", Tran);
            if (lll.Count == 0)
            {
                Eroor = true;
                throw new ApplicationException("Excel行号为:&nbsp;<i error>" + (index + 3) + " </i>  &nbsp;&nbsp;的数据有误。" + str + "不存在" + strValue + ",请修改后重新导入。");
            }
            else
            {
                string liststr = string.Empty;
                foreach (Hi.Model.BD_CategoryAttribute item in lll)
                {
                    liststr += item.ID + ",";
                }
                if (!Util.IsEmpty(liststr))
                {
                    liststr = liststr.Substring(0, liststr.Length - 1);
                }
                return(listId + "@" + liststr);
            }
        }
        return(listId);
    }