Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebApi_Model.T_Photo_Likes model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Photo_Likes set ");
            strSql.Append("UID=@UID,");
            strSql.Append("PhotoCollectionID=@PhotoCollectionID,");
            strSql.Append("CreateTime=@CreateTime");
            strSql.Append(" where UID=@UID and PhotoCollectionID=@PhotoCollectionID and CreateTime=@CreateTime ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UID",               SqlDbType.Int, 4),
                new SqlParameter("@PhotoCollectionID", SqlDbType.Int, 4),
                new SqlParameter("@CreateTime",        SqlDbType.DateTime)
            };
            parameters[0].Value = model.UID;
            parameters[1].Value = model.PhotoCollectionID;
            parameters[2].Value = model.CreateTime;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WebApi_Model.T_Photo_Likes model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Photo_Likes(");
            strSql.Append("UID,PhotoCollectionID,CreateTime)");
            strSql.Append(" values (");
            strSql.Append("@UID,@PhotoCollectionID,@CreateTime)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UID",               SqlDbType.Int, 4),
                new SqlParameter("@PhotoCollectionID", SqlDbType.Int, 4),
                new SqlParameter("@CreateTime",        SqlDbType.DateTime)
            };
            parameters[0].Value = model.UID;
            parameters[1].Value = model.PhotoCollectionID;
            parameters[2].Value = DateTime.Now;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebApi_Model.T_Photo_Likes GetModel(int UID, int PhotoCollectionID, DateTime CreateTime)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 UID,PhotoCollectionID,CreateTime from T_Photo_Likes ");
            strSql.Append(" where UID=@UID and PhotoCollectionID=@PhotoCollectionID and CreateTime=@CreateTime ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UID",               SqlDbType.Int, 4),
                new SqlParameter("@PhotoCollectionID", SqlDbType.Int, 4),
                new SqlParameter("@CreateTime",        SqlDbType.DateTime)
            };
            parameters[0].Value = UID;
            parameters[1].Value = PhotoCollectionID;
            parameters[2].Value = CreateTime;

            WebApi_Model.T_Photo_Likes model = new WebApi_Model.T_Photo_Likes();
            DataSet ds = DBHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebApi_Model.T_Photo_Likes DataRowToModel(DataRow row)
 {
     WebApi_Model.T_Photo_Likes model = new WebApi_Model.T_Photo_Likes();
     if (row != null)
     {
         if (row["UID"] != null && row["UID"].ToString() != "")
         {
             model.UID = int.Parse(row["UID"].ToString());
         }
         if (row["PhotoCollectionID"] != null && row["PhotoCollectionID"].ToString() != "")
         {
             model.PhotoCollectionID = int.Parse(row["PhotoCollectionID"].ToString());
         }
         if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
         {
             model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
         }
     }
     return(model);
 }