Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MxWeiXinPF.Model.wx_sq_piclist model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_sq_piclist(");
            strSql.Append("aid,openid,picUrl,createDate,hasShenghe)");
            strSql.Append(" values (");
            strSql.Append("@aid,@openid,@picUrl,@createDate,@hasShenghe)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@aid",        SqlDbType.Int,         4),
                new SqlParameter("@openid",     SqlDbType.VarChar,   100),
                new SqlParameter("@picUrl",     SqlDbType.VarChar,   800),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@hasShenghe", SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.aid;
            parameters[1].Value = model.openid;
            parameters[2].Value = model.picUrl;
            parameters[3].Value = model.createDate;
            parameters[4].Value = model.hasShenghe;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_sq_piclist DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_sq_piclist model=new MxWeiXinPF.Model.wx_sq_piclist();
     if (row != null)
     {
         if(row["id"]!=null && row["id"].ToString()!="")
         {
             model.id=int.Parse(row["id"].ToString());
         }
         if(row["aid"]!=null && row["aid"].ToString()!="")
         {
             model.aid=int.Parse(row["aid"].ToString());
         }
         if(row["openid"]!=null)
         {
             model.openid=row["openid"].ToString();
         }
         if(row["picUrl"]!=null)
         {
             model.picUrl=row["picUrl"].ToString();
         }
         if(row["createDate"]!=null && row["createDate"].ToString()!="")
         {
             model.createDate=DateTime.Parse(row["createDate"].ToString());
         }
         if(row["hasShenghe"]!=null && row["hasShenghe"].ToString()!="")
         {
             if((row["hasShenghe"].ToString()=="1")||(row["hasShenghe"].ToString().ToLower()=="true"))
             {
                 model.hasShenghe=true;
             }
             else
             {
                 model.hasShenghe=false;
             }
         }
     }
     return model;
 }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_sq_piclist DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_sq_piclist model = new MxWeiXinPF.Model.wx_sq_piclist();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["aid"] != null && row["aid"].ToString() != "")
         {
             model.aid = int.Parse(row["aid"].ToString());
         }
         if (row["openid"] != null)
         {
             model.openid = row["openid"].ToString();
         }
         if (row["picUrl"] != null)
         {
             model.picUrl = row["picUrl"].ToString();
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
         if (row["hasShenghe"] != null && row["hasShenghe"].ToString() != "")
         {
             if ((row["hasShenghe"].ToString() == "1") || (row["hasShenghe"].ToString().ToLower() == "true"))
             {
                 model.hasShenghe = true;
             }
             else
             {
                 model.hasShenghe = false;
             }
         }
     }
     return(model);
 }
Пример #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MxWeiXinPF.Model.wx_sq_piclist model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_sq_piclist set ");
            strSql.Append("aid=@aid,");
            strSql.Append("openid=@openid,");
            strSql.Append("picUrl=@picUrl,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("hasShenghe=@hasShenghe");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@aid",        SqlDbType.Int,         4),
                new SqlParameter("@openid",     SqlDbType.VarChar,   100),
                new SqlParameter("@picUrl",     SqlDbType.VarChar,   800),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@hasShenghe", SqlDbType.Bit,         1),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.aid;
            parameters[1].Value = model.openid;
            parameters[2].Value = model.picUrl;
            parameters[3].Value = model.createDate;
            parameters[4].Value = model.hasShenghe;
            parameters[5].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_sq_piclist GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,aid,openid,picUrl,createDate,hasShenghe from wx_sq_piclist ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_sq_piclist GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,aid,openid,picUrl,createDate,hasShenghe from wx_sq_piclist ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

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