Example #1
0
File: Comment.cs Project: CSBOY/Web
 //根据外键进行查询
 public IList<CommentEntity> GetAllCommentByresource_id(int t_resource_id)
 {
     IList<CommentEntity> t_Comments = new List<CommentEntity>();
        SqlDataReader sdr = null;
        using(sdr=SqlDBHelp.GetReader("select * from Comment where resource_id="+t_resource_id))
        {
       while(sdr.Read())
         {
             CommentEntity t_Comment= new CommentEntity();
             t_Comment.Comment_id=(int)sdr.GetValue(0);
             t_Comment.Resource_id=(int)sdr.GetValue(1);
             t_Comment.User_id=(int)sdr.GetValue(2);
             t_Comment.Comment_text=(string)sdr.GetValue(3);
             t_Comments.Add(t_Comment);
         }
         sdr.Close();
     }
     return t_Comments;
 }
Example #2
0
File: Comment.cs Project: CSBOY/Web
 public static int UpdateComment(CommentEntity t_Comment)
 {
     int i=-1;
     //定义插入数据的参数数组
     try
     {
         i=dal.UpdateComment(t_Comment);
     }
     catch(Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return i;
 }
Example #3
0
File: Comment.cs Project: CSBOY/Web
 public CommentEntity SelectCommentByID(int t_comment_id)
 {
     CommentEntity t_Comment= new CommentEntity();
     SqlDataReader sdr=null;
     using(sdr=SqlDBHelp.GetReader("select * from Comment where comment_id="+t_comment_id))
     {
         if(sdr.Read())
         {
             t_Comment.Comment_id=(int)sdr.GetValue(0);
             t_Comment.Resource_id=(int)sdr.GetValue(1);
             t_Comment.User_id=(int)sdr.GetValue(2);
             t_Comment.Comment_text=(string)sdr.GetValue(3);
         }
     }
     sdr.Close();
     return t_Comment;
 }
Example #4
0
File: Comment.cs Project: CSBOY/Web
 public int UpdateComment(CommentEntity t_Comment)
 {
     SqlParameter[] p=new SqlParameter[]{
     new SqlParameter("@Comment_id",t_Comment.Comment_id),
     new SqlParameter("@Resource_id",t_Comment.Resource_id),
     new SqlParameter("@User_id",t_Comment.User_id),
     new SqlParameter("@Comment_text",t_Comment.Comment_text)
     };
     int i=SqlDBHelp.GetExecute("update Comment set comment_id=@Comment_id,comment_text=@Comment_text where comment_id=@Comment_id", p) ;
     return i;
 }
Example #5
0
File: Comment.cs Project: CSBOY/Web
 //插入操作
 public int InsertComment(CommentEntity t_Comment)
 {
     //定义插入数据的参数数组
       SqlParameter[] p=new SqlParameter[]{
       new SqlParameter("@Comment_id",t_Comment.Comment_id),
       new SqlParameter("@Resource_id",t_Comment.Resource_id),
       new SqlParameter("@User_id",t_Comment.User_id),
       new SqlParameter("@Comment_text",t_Comment.Comment_text)
        };
        int i=SqlDBHelp.GetExecute("insert into Comment values (@Comment_id,@Resource_id,@User_id,@Comment_text)", p) ;
        return i;
 }