/// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_diancai_caipin_category DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_diancai_caipin_category model = new MxWeiXinPF.Model.wx_diancai_caipin_category();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["shopid"] != null && row["shopid"].ToString() != "")
         {
             model.shopid = int.Parse(row["shopid"].ToString());
         }
         if (row["sortid"] != null)
         {
             model.sortid = int.Parse(row["sortid"].ToString());
         }
         if (row["categoryName"] != null)
         {
             model.categoryName = row["categoryName"].ToString();
         }
         if (row["miaoshu"] != null)
         {
             model.miaoshu = row["miaoshu"].ToString();
         }
         if (row["isStart"] != null && row["isStart"].ToString() != "")
         {
             if ((row["isStart"].ToString() == "1") || (row["isStart"].ToString().ToLower() == "true"))
             {
                 model.isStart = true;
             }
             else
             {
                 model.isStart = false;
             }
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
     }
     return(model);
 }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_diancai_caipin_category DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_diancai_caipin_category model=new MxWeiXinPF.Model.wx_diancai_caipin_category();
     if (row != null)
     {
         if(row["id"]!=null && row["id"].ToString()!="")
         {
             model.id=int.Parse(row["id"].ToString());
         }
         if(row["shopid"]!=null && row["shopid"].ToString()!="")
         {
             model.shopid=int.Parse(row["shopid"].ToString());
         }
         if(row["sortid"]!=null)
         {
             model.sortid = int.Parse(row["sortid"].ToString());
         }
         if(row["categoryName"]!=null)
         {
             model.categoryName=row["categoryName"].ToString();
         }
         if(row["miaoshu"]!=null)
         {
             model.miaoshu=row["miaoshu"].ToString();
         }
         if(row["isStart"]!=null && row["isStart"].ToString()!="")
         {
             if((row["isStart"].ToString()=="1")||(row["isStart"].ToString().ToLower()=="true"))
             {
                 model.isStart=true;
             }
             else
             {
                 model.isStart=false;
             }
         }
         if(row["createDate"]!=null && row["createDate"].ToString()!="")
         {
             model.createDate=DateTime.Parse(row["createDate"].ToString());
         }
     }
     return model;
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MxWeiXinPF.Model.wx_diancai_caipin_category model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_diancai_caipin_category set ");
            strSql.Append("shopid=@shopid,");
            strSql.Append("sortid=@sortid,");
            strSql.Append("categoryName=@categoryName,");
            strSql.Append("miaoshu=@miaoshu,");
            strSql.Append("isStart=@isStart,");
            strSql.Append("createDate=@createDate");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@shopid",       SqlDbType.Int,         4),
                new SqlParameter("@sortid",       SqlDbType.Int,         4),
                new SqlParameter("@categoryName", SqlDbType.VarChar,   100),
                new SqlParameter("@miaoshu",      SqlDbType.VarChar,   100),
                new SqlParameter("@isStart",      SqlDbType.Bit,         1),
                new SqlParameter("@createDate",   SqlDbType.DateTime),
                new SqlParameter("@id",           SqlDbType.Int, 4)
            };
            parameters[0].Value = model.shopid;
            parameters[1].Value = model.sortid;
            parameters[2].Value = model.categoryName;
            parameters[3].Value = model.miaoshu;
            parameters[4].Value = model.isStart;
            parameters[5].Value = model.createDate;
            parameters[6].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MxWeiXinPF.Model.wx_diancai_caipin_category model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_diancai_caipin_category(");
            strSql.Append("shopid,sortid,categoryName,miaoshu,isStart,createDate)");
            strSql.Append(" values (");
            strSql.Append("@shopid,@sortid,@categoryName,@miaoshu,@isStart,@createDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@shopid",       SqlDbType.Int,       4),
                new SqlParameter("@sortid",       SqlDbType.Int,       4),
                new SqlParameter("@categoryName", SqlDbType.VarChar, 100),
                new SqlParameter("@miaoshu",      SqlDbType.VarChar, 100),
                new SqlParameter("@isStart",      SqlDbType.Bit,       1),
                new SqlParameter("@createDate",   SqlDbType.DateTime)
            };
            parameters[0].Value = model.shopid;
            parameters[1].Value = model.sortid;
            parameters[2].Value = model.categoryName;
            parameters[3].Value = model.miaoshu;
            parameters[4].Value = model.isStart;
            parameters[5].Value = model.createDate;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_diancai_caipin_category GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,shopid,sortid,categoryName,miaoshu,isStart,createDate from wx_diancai_caipin_category ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            MxWeiXinPF.Model.wx_diancai_caipin_category model = new MxWeiXinPF.Model.wx_diancai_caipin_category();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_diancai_caipin_category GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,shopid,sortid,categoryName,miaoshu,isStart,createDate from wx_diancai_caipin_category ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

            MxWeiXinPF.Model.wx_diancai_caipin_category model=new MxWeiXinPF.Model.wx_diancai_caipin_category();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }