コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WechatBuilder.Model.wx_diancai_shoppic model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_diancai_shoppic set ");
            strSql.Append("shopid=@shopid,");
            strSql.Append("description=@description,");
            strSql.Append("sortid=@sortid,");
            strSql.Append("picUrl=@picUrl,");
            strSql.Append("pictzUrl=@pictzUrl,");
            strSql.Append("createDate=@createDate");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@shopid",      SqlDbType.Int,         4),
                new SqlParameter("@description", SqlDbType.VarChar,   200),
                new SqlParameter("@sortid",      SqlDbType.Int,         4),
                new SqlParameter("@picUrl",      SqlDbType.VarChar,   300),
                new SqlParameter("@pictzUrl",    SqlDbType.VarChar,   300),
                new SqlParameter("@createDate",  SqlDbType.DateTime),
                new SqlParameter("@id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.shopid;
            parameters[1].Value = model.description;
            parameters[2].Value = model.sortid;
            parameters[3].Value = model.picUrl;
            parameters[4].Value = model.pictzUrl;
            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);
            }
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WechatBuilder.Model.wx_diancai_shoppic model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_diancai_shoppic(");
            strSql.Append("shopid,description,sortid,picUrl,pictzUrl,createDate)");
            strSql.Append(" values (");
            strSql.Append("@shopid,@description,@sortid,@picUrl,@pictzUrl,@createDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@shopid",      SqlDbType.Int,       4),
                new SqlParameter("@description", SqlDbType.VarChar, 200),
                new SqlParameter("@sortid",      SqlDbType.Int,       4),
                new SqlParameter("@picUrl",      SqlDbType.VarChar, 300),
                new SqlParameter("@pictzUrl",    SqlDbType.VarChar, 300),
                new SqlParameter("@createDate",  SqlDbType.DateTime)
            };
            parameters[0].Value = model.shopid;
            parameters[1].Value = model.description;
            parameters[2].Value = model.sortid;
            parameters[3].Value = model.picUrl;
            parameters[4].Value = model.pictzUrl;
            parameters[5].Value = model.createDate;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WechatBuilder.Model.wx_diancai_shoppic DataRowToModel(DataRow row)
 {
     WechatBuilder.Model.wx_diancai_shoppic model = new WechatBuilder.Model.wx_diancai_shoppic();
     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["description"] != null)
         {
             model.description = row["description"].ToString();
         }
         if (row["sortid"] != null)
         {
             model.sortid = int.Parse(row["sortid"].ToString());
         }
         if (row["picUrl"] != null)
         {
             model.picUrl = row["picUrl"].ToString();
         }
         if (row["pictzUrl"] != null)
         {
             model.pictzUrl = row["pictzUrl"].ToString();
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
     }
     return(model);
 }
コード例 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WechatBuilder.Model.wx_diancai_shoppic GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,shopid,description,sortid,picUrl,pictzUrl,createDate from wx_diancai_shoppic ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #5
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public WechatBuilder.Model.wx_diancai_shoppic DataRowToModel(DataRow row)
		{
			WechatBuilder.Model.wx_diancai_shoppic model=new WechatBuilder.Model.wx_diancai_shoppic();
			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["description"]!=null)
				{
					model.description=row["description"].ToString();
				}
				if(row["sortid"]!=null)
				{
                    model.sortid = int.Parse(row["sortid"].ToString());
				}
				if(row["picUrl"]!=null)
				{
					model.picUrl=row["picUrl"].ToString();
				}
				if(row["pictzUrl"]!=null)
				{
					model.pictzUrl=row["pictzUrl"].ToString();
				}
				if(row["createDate"]!=null && row["createDate"].ToString()!="")
				{
					model.createDate=DateTime.Parse(row["createDate"].ToString());
				}
			}
			return model;
		}
コード例 #6
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public WechatBuilder.Model.wx_diancai_shoppic GetModel(int id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 id,shopid,description,sortid,picUrl,pictzUrl,createDate from wx_diancai_shoppic ");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)
			};
			parameters[0].Value = id;

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