protected void BtnSave_Click(object sender, EventArgs e) { string missID = tbMissID.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()); CTMissedPetInfoComment comment = new CTMissedPetInfoComment(); comment.MissID = missID; comment.CommentContent = commentContent; comment.CommentID = commentID; comment.IP = commentIP; comment.UserID = commentUser; comment.CommentTime = commentTime; comment.IsVisible = isVisible; MissedPetComment missPetCommnet = new MissedPetComment(); int updateStatus = missPetCommnet.EditKnowledgeComment(comment); if (updateStatus == 1) { Response.Write("<script>alert('保存成功!')</script>"); } else { Response.Write("<script>alert('保存失败!')</script>"); } }
//增加一条评论 protected void BtnAddComment_Click(object sender, EventArgs e) { //获取本机IP IPHostEntry ipe = Dns.GetHostEntry(Dns.GetHostName()); IPAddress ipa = ipe.AddressList[0]; string user = ddUserList.SelectedValue.ToString(); string missID = ddMissList.SelectedValue.ToString(); string comment = tbComment.Text.Trim().ToString(); CTMissedPetInfoComment missPetComment = new CTMissedPetInfoComment(); missPetComment.CommentID = Guid.NewGuid().ToString(); missPetComment.CommentTime = DateTime.Now.ToShortDateString(); missPetComment.CommentWeiBoID = ""; missPetComment.UserID = user; missPetComment.MissID = missID; missPetComment.CommentContent = comment; missPetComment.IP = ipa.ToString(); MissedPetComment missComment = new MissedPetComment(); int insertStatus = missComment.InsertComment(missPetComment); if (insertStatus == 1) { Response.Write("<script>alert('添加成功!')</script>"); } else { Response.Write("<script>alert('添加失败!')</script>"); } }
protected void BtnEdit_Click(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; } } MissedPetComment petcomment = new MissedPetComment(); CTMissedPetInfoComment comment = new CTMissedPetInfoComment(); comment = petcomment.GetMissPetCommentByCommentID(commentID); tbMissID.Text = comment.MissID; tbCommentID.Text = comment.CommentID; tbCommentTime.Text = comment.CommentTime; tbContent.Text = comment.CommentContent; tbIP.Text = comment.IP; tbUserID.Text = comment.UserID; cbIsVisible.Checked = comment.IsVisible; }