Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebApi_Model.T_Photo_Store model)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebApi_Model.T_Photo_Store model)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebApi_Model.T_Photo_Store DataRowToModel(DataRow row)
 {
     WebApi_Model.T_Photo_Store model = new WebApi_Model.T_Photo_Store();
     if (row != null)
     {
         if (row["StoreID"] != null && row["StoreID"].ToString() != "")
         {
             model.StoreID = int.Parse(row["StoreID"].ToString());
         }
         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["CreatDate"] != null && row["CreatDate"].ToString() != "")
         {
             model.CreatDate = DateTime.Parse(row["CreatDate"].ToString());
         }
     }
     return(model);
 }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebApi_Model.T_Photo_Store GetModel(int StoreID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 StoreID,UID,PhotoCollectionID,CreatDate from T_Photo_Store ");
            strSql.Append(" where StoreID=@StoreID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StoreID", SqlDbType.Int, 4)
            };
            parameters[0].Value = StoreID;

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

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