/// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WeiXinPF.Model.wx_diancai_shop_advertisement DataRowToModel(DataRow row)
 {
     WeiXinPF.Model.wx_diancai_shop_advertisement model = new WeiXinPF.Model.wx_diancai_shop_advertisement();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["setupid"] != null && row["setupid"].ToString() != "")
         {
             model.setupid = int.Parse(row["setupid"].ToString());
         }
         if (row["advertisementName"] != null)
         {
             model.advertisementName = row["advertisementName"].ToString();
         }
         if (row["sortid"] != null)
         {
             model.sortid = int.Parse(row["sortid"].ToString());
         }
         if (row["picUrl"] != null)
         {
             model.picUrl = row["picUrl"].ToString();
         }
         if (row["websetUrl"] != null)
         {
             model.websetUrl = row["websetUrl"].ToString();
         }
         if (row["isdisplay"] != null && row["isdisplay"].ToString() != "")
         {
             if ((row["isdisplay"].ToString() == "1") || (row["isdisplay"].ToString().ToLower() == "true"))
             {
                 model.isdisplay = true;
             }
             else
             {
                 model.isdisplay = false;
             }
         }
         if (row["createDate"] != null)
         {
             model.createDate = row["createDate"].ToString();
         }
     }
     return(model);
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WeiXinPF.Model.wx_diancai_shop_advertisement model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_diancai_shop_advertisement set ");
            strSql.Append("setupid=@setupid,");
            strSql.Append("advertisementName=@advertisementName,");
            strSql.Append("sortid=@sortid,");
            strSql.Append("picUrl=@picUrl,");
            strSql.Append("websetUrl=@websetUrl,");
            strSql.Append("isdisplay=@isdisplay,");
            strSql.Append("createDate=@createDate");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@setupid",           SqlDbType.Int,        4),
                new SqlParameter("@advertisementName", SqlDbType.VarChar,  300),
                new SqlParameter("@sortid",            SqlDbType.Int,        4),
                new SqlParameter("@picUrl",            SqlDbType.VarChar,  300),
                new SqlParameter("@websetUrl",         SqlDbType.VarChar,  300),
                new SqlParameter("@isdisplay",         SqlDbType.Bit,        1),
                new SqlParameter("@createDate",        SqlDbType.VarChar, 4000),
                new SqlParameter("@id",                SqlDbType.Int, 4)
            };
            parameters[0].Value = model.setupid;
            parameters[1].Value = model.advertisementName;
            parameters[2].Value = model.sortid;
            parameters[3].Value = model.picUrl;
            parameters[4].Value = model.websetUrl;
            parameters[5].Value = model.isdisplay;
            parameters[6].Value = model.createDate;
            parameters[7].Value = model.id;

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

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

            strSql.Append("insert into wx_diancai_shop_advertisement(");
            strSql.Append("setupid,advertisementName,sortid,picUrl,websetUrl,isdisplay,createDate)");
            strSql.Append(" values (");
            strSql.Append("@setupid,@advertisementName,@sortid,@picUrl,@websetUrl,@isdisplay,@createDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@setupid",           SqlDbType.Int,       4),
                new SqlParameter("@advertisementName", SqlDbType.VarChar, 300),
                new SqlParameter("@sortid",            SqlDbType.Int,       4),
                new SqlParameter("@picUrl",            SqlDbType.VarChar, 300),
                new SqlParameter("@websetUrl",         SqlDbType.VarChar, 300),
                new SqlParameter("@isdisplay",         SqlDbType.Bit,       1),
                new SqlParameter("@createDate",        SqlDbType.VarChar, 4000)
            };
            parameters[0].Value = model.setupid;
            parameters[1].Value = model.advertisementName;
            parameters[2].Value = model.sortid;
            parameters[3].Value = model.picUrl;
            parameters[4].Value = model.websetUrl;
            parameters[5].Value = model.isdisplay;
            parameters[6].Value = model.createDate;

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

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

            strSql.Append("select  top 1 id,setupid,advertisementName,sortid,picUrl,websetUrl,isdisplay,createDate from wx_diancai_shop_advertisement ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }