Ejemplo n.º 1
0
        public virtual ProductTypeInfo GetProductTypeByID(int ID)
        {
            ProductTypeInfo entity  = null;
            SqlDataReader   RdrList = null;

            try
            {
                string SqlList;
                SqlList = "SELECT * FROM ProductType WHERE ProductType_ID = " + ID;
                RdrList = DBHelper.ExecuteReader(SqlList);
                if (RdrList.Read())
                {
                    entity = new ProductTypeInfo();

                    entity.ProductType_ID       = Tools.NullInt(RdrList["ProductType_ID"]);
                    entity.ProductType_Name     = Tools.NullStr(RdrList["ProductType_Name"]);
                    entity.ProductType_Sort     = Tools.NullInt(RdrList["ProductType_Sort"]);
                    entity.ProductType_IsActive = Tools.NullInt(RdrList["ProductType_IsActive"]);
                    entity.ProductType_Site     = Tools.NullStr(RdrList["ProductType_Site"]);
                }
                RdrList.Close();
                RdrList = null;
                if (entity != null)
                {
                    entity.BrandInfos             = GetProductBrands(entity.ProductType_ID);
                    entity.ProductTypeExtendInfos = MyProductTypeExtend.GetProductTypeExtends(entity.ProductType_ID);
                }
                return(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (RdrList != null)
                {
                    RdrList.Close();
                    RdrList = null;
                }
            }
        }
Ejemplo n.º 2
0
    //获取产品类型所属扩展属性
    public string GetProductTypeExtends(int ID)
    {
        IList <ProductTypeExtendInfo> ProductTypeExtends = MyBLL.GetProductTypeExtends(ID);

        if (ProductTypeExtends != null)
        {
            StringBuilder jsonBuilder = new StringBuilder();
            jsonBuilder.Append("{\"page\":1,\"total\":" + ProductTypeExtends.Count + ",\"records\":" + ProductTypeExtends.Count + ",\"rows\"");
            jsonBuilder.Append(":[");
            foreach (ProductTypeExtendInfo entity in ProductTypeExtends)
            {
                jsonBuilder.Append("{\"ProductType.ProductType_ID\":" + entity.ProductType_Extend_ID + ",\"cell\":[");
                //各字段
                jsonBuilder.Append("\"");
                jsonBuilder.Append(entity.ProductType_Extend_ID);
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                jsonBuilder.Append(entity.ProductType_Extend_Name);
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                switch (entity.ProductType_Extend_Display.ToLower())
                {
                case "select":
                    jsonBuilder.Append("下拉菜单");
                    break;

                case "text":
                    jsonBuilder.Append("文本框");
                    break;

                case "html":
                    jsonBuilder.Append("HTML");
                    break;

                default:
                    jsonBuilder.Append("--");
                    break;
                }
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                if (entity.ProductType_Extend_IsSearch == 0)
                {
                    jsonBuilder.Append("否");
                }
                else
                {
                    jsonBuilder.Append("是");
                }
                jsonBuilder.Append("\",");


                jsonBuilder.Append("\"");
                jsonBuilder.Append(entity.ProductType_Extend_Sort);
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                jsonBuilder.Append("<img src=\\\"/images/icon_edit.gif\\\"> <a href=\\\"producttypeExtend_edit.aspx?extend_id=" + entity.ProductType_Extend_ID + "\\\" title=\\\"修改\\\">修改</a> <img src=\\\"/images/icon_del.gif\\\"> <a href=\\\"javascript:void(0);\\\" onclick=\\\"confirmdelete('producttypeextend_do.aspx?action=move&extend_id=" + entity.ProductType_Extend_ID + "')\\\" title=\\\"删除\\\">删除</a>");
                jsonBuilder.Append("\",");

                jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
                jsonBuilder.Append("]},");
            }
            jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
            jsonBuilder.Append("]");
            jsonBuilder.Append("}");
            return(jsonBuilder.ToString());
        }
        else
        {
            return(null);
        }
    }