Exemple #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Thumb DataRowToModel(DataRow row)
 {
     Thumb model=new Thumb();
     if (row != null)
     {
         if(row["Id"]!=null && row["Id"].ToString()!="")
         {
             model.Id=long.Parse(row["Id"].ToString());
         }
         if(row["TravelPartId"]!=null && row["TravelPartId"].ToString()!="")
         {
             model.TravelPartId=int.Parse(row["TravelPartId"].ToString());
         }
         if(row["UserId"]!=null && row["UserId"].ToString()!="")
         {
             model.UserId=int.Parse(row["UserId"].ToString());
         }
         if(row["IsDelete"]!=null && row["IsDelete"].ToString()!="")
         {
             if((row["IsDelete"].ToString()=="1")||(row["IsDelete"].ToString().ToLower()=="true"))
             {
                 model.IsDelete=true;
             }
             else
             {
                 model.IsDelete=false;
             }
         }
         if(row["CreateTime"]!=null && row["CreateTime"].ToString()!="")
         {
             model.CreateTime=DateTime.Parse(row["CreateTime"].ToString());
         }
     }
     return model;
 }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(Thumb model)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("insert into Thumb(");
            strSql.Append("TravelPartId,UserId,IsDelete,CreateTime)");
            strSql.Append(" values (");
            strSql.Append("@TravelPartId,@UserId,@IsDelete,@CreateTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@TravelPartId", SqlDbType.Int,4),
                    new SqlParameter("@UserId", SqlDbType.Int,4),
                    new SqlParameter("@IsDelete", SqlDbType.Bit,1),
                    new SqlParameter("@CreateTime", SqlDbType.DateTime)};
            parameters[0].Value = model.TravelPartId;
            parameters[1].Value = model.UserId;
            parameters[2].Value = model.IsDelete;
            parameters[3].Value = model.CreateTime;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt64(obj);
            }
        }
Exemple #3
0
 public string Create(int travelPartId,int userId)
 {
     if (travelPartId>0&&userId>0)
     {
         var model = new Thumb
         {
             TravelPartId = travelPartId,
             UserId = userId,
             IsDelete = false,
             CreateTime = DateTime.Now
         };
         var flag = _thumbBll.Add(model);
         if (flag>0)
         {
             return HttpRequestResult.StateOk;
         }
     }
     return HttpRequestResult.StateError;
 }
Exemple #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Thumb model)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("update Thumb set ");
            strSql.Append("TravelPartId=@TravelPartId,");
            strSql.Append("UserId=@UserId,");
            strSql.Append("IsDelete=@IsDelete,");
            strSql.Append("CreateTime=@CreateTime");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@TravelPartId", SqlDbType.Int,4),
                    new SqlParameter("@UserId", SqlDbType.Int,4),
                    new SqlParameter("@IsDelete", SqlDbType.Bit,1),
                    new SqlParameter("@CreateTime", SqlDbType.DateTime),
                    new SqlParameter("@Id", SqlDbType.BigInt,8)};
            parameters[0].Value = model.TravelPartId;
            parameters[1].Value = model.UserId;
            parameters[2].Value = model.IsDelete;
            parameters[3].Value = model.CreateTime;
            parameters[4].Value = model.Id;

            int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Exemple #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Thumb GetModel(long Id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 Id,TravelPartId,UserId,IsDelete,CreateTime from Thumb ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.BigInt)
            };
            parameters[0].Value = Id;

            Thumb model=new Thumb();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Exemple #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public long Add(Thumb model)
 {
     return dal.Add(model);
 }
Exemple #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Thumb model)
 {
     return dal.Update(model);
 }