protected void BtnAddComment_Click(object sender, EventArgs e)
 {
     //获取本机IP
     IPHostEntry ipe = Dns.GetHostEntry(Dns.GetHostName());
     IPAddress ipa = ipe.AddressList[0];
     string comment = TextBoxComment.Text.Trim().ToString();
     string userID = ddUser11.SelectedValue.ToString();
     string adoptID = ddAdopt1.SelectedValue.ToString();
     CTAdoptPetComment adoptComment = new CTAdoptPetComment();
     adoptComment.AdoptID = adoptID;
     adoptComment.CommentContent = comment;
     adoptComment.CommentID = Guid.NewGuid().ToString();
     adoptComment.CommentTime = DateTime.Now.ToString();
     adoptComment.IsVisible = true;
     adoptComment.UserID = userID;
     adoptComment.IP = ipa.ToString();
     AdoptPetComment ado = new AdoptPetComment();
     int insertStatus = 0;
     insertStatus = ado.InsertComment(adoptComment);
     if (insertStatus == 1)
     {
         Response.Write("<script>alert('添加成功!')</script>");
     }
     else
     {
         Response.Write("<script>alert('添加失败!')</script>");
     }
 }
Example #2
0
        //根据CommentID获取相应的comment信息
        public CTAdoptPetComment GetAdoptPetCommentByCommentID(string commentID)
        {
            CTAdoptPetComment adoptPetCommnet = new CTAdoptPetComment();

               SqlParameter parm = new SqlParameter();
               parm.Value = commentID;
               parm.ParameterName = PARAM_COMMENTID;

               //execute the query
               using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_ADOPTComment, parm))
               {
               while (rdr.Read())
               {

                   adoptPetCommnet.CommentID = rdr["CommentID"].ToString();
                   adoptPetCommnet.AdoptID = rdr["AdoptID"].ToString();
                   adoptPetCommnet.CommentContent = rdr["CommentContent"].ToString();
                   adoptPetCommnet.CommentTime = rdr["CommentTime"].ToString();
                   adoptPetCommnet.IP = rdr["IP"].ToString();
                   adoptPetCommnet.UserID = rdr["UserID"].ToString();
                   adoptPetCommnet.IsVisible = bool.Parse(rdr["IsVisible"].ToString());
                   break;

               }
               rdr.Close();
               rdr.Dispose();
               }

               return adoptPetCommnet;
        }
Example #3
0
        //编辑评论信息
        public int EditAdoptPetComment(CTAdoptPetComment adoptComment)
        {
            int editStatus = 0;

               SqlParameter[] parms = null;
               parms = new SqlParameter[]
                            {
                                new SqlParameter("@CommentID",SqlDbType.NVarChar,20),
                                new SqlParameter("@CommentContent",SqlDbType.NVarChar,100),
                                new SqlParameter("@IsVisible",SqlDbType.Bit),
                            };

               parms[0].Value = adoptComment.CommentID;
               parms[1].Value = adoptComment.CommentContent;
               parms[2].Value = adoptComment.IsVisible;

               using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringOrderDistributedTransaction))
               {
               editStatus = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, SQL_EDIT_AdoptComment, parms);
               }

               return editStatus;
        }
Example #4
0
 //增加一条adopt文章的评论
 public int InsertComment(CTAdoptPetComment adoptComment)
 {
     return dal.InsertAdoptPetComment(adoptComment);
 }
Example #5
0
 //编辑adopt的评论
 public int EditAdoptComment(CTAdoptPetComment adoptPetComment)
 {
     return dal.EditAdoptPetComment(adoptPetComment);
 }
 //编辑
 protected void BtnEdit_Click1(object sender, EventArgs e)
 {
     string commentID=string.Empty;
     for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
     {
         CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox");
         if (cbox.Checked == true)
         {
              commentID = GridView1.DataKeys[i].Value.ToString();
             break;
         }
     }
     AdoptPetComment petcomment = new AdoptPetComment();
     CTAdoptPetComment comment = new CTAdoptPetComment();
     comment = petcomment.GetAdoptCommentByCommentID(commentID);
     tbAdoptID.Text = comment.AdoptID;
     tbCommentID.Text = comment.CommentID;
     tbCommentTime.Text = comment.CommentTime;
     tbContent.Text = comment.CommentContent;
     tbIP.Text = comment.IP;
     tbUserID.Text = comment.UserID;
     cbIsVisible.Checked = comment.IsVisible;
 }
 protected void BtnSave_Click(object sender, EventArgs e)
 {
     string adoptID = tbAdoptID.Text.Trim().ToString();
     string commentID = tbCommentID.Text.Trim().ToString();
     string commentTime = tbCommentTime.Text.Trim().ToString();
     string commentIP = tbIP.Text.Trim().ToString();
     string commentContent = tbContent.Text.Trim().ToString();
     string commentUser=tbUserID.Text.Trim().ToString();
     bool isVisible= bool.Parse(cbIsVisible.Checked.ToString());
     CTAdoptPetComment comment = new CTAdoptPetComment();
     comment.AdoptID = adoptID;
     comment.CommentContent = commentContent;
     comment.CommentID = commentID;
     comment.IP = commentIP;
     comment.UserID = commentUser;
     comment.CommentTime = commentTime;
     comment.IsVisible = isVisible;
     AdoptPetComment adoptpetCommnet = new AdoptPetComment();
     int updateStatus = adoptpetCommnet.EditAdoptComment(comment);
     if (updateStatus == 1)
     {
         Response.Write("<script>alert('保存成功!')</script>");
     }
     else
     {
         Response.Write("<script>alert('保存失败!')</script>");
     }
 }
Example #8
0
        //插入评论信息
        public int InsertAdoptPetComment(CTAdoptPetComment adoptComment)
        {
            int insertStatus = 0;
               SqlParameter[] parms = null;
               parms = new SqlParameter[]
                            {
                                new SqlParameter("@CommentID",SqlDbType.NVarChar,20),
                                new SqlParameter("@UserID",SqlDbType.NVarChar,20),
                                new SqlParameter("@AdoptID",SqlDbType.NVarChar,20),
                                new SqlParameter("@CommentTime",SqlDbType.DateTime ),
                                new SqlParameter("@IP",SqlDbType.NVarChar,20),
                                new SqlParameter("@CommentContent",SqlDbType.NVarChar,100),
                                new SqlParameter("@IsVisible",SqlDbType.Bit),
                            };

               parms[0].Value = adoptComment.CommentID;
               parms[1].Value = adoptComment.UserID;
               parms[2].Value = adoptComment.AdoptID;
               parms[3].Value = adoptComment.CommentTime;
               parms[4].Value = adoptComment.IP;
               parms[5].Value = adoptComment.CommentContent;
               parms[6].Value = adoptComment.IsVisible;

               using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringOrderDistributedTransaction))
               {
               insertStatus = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, SQL_INSERT_AdoptComment, parms);
               }
               return insertStatus;
        }