📄 quecommentmanage.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace Service
{
/// <summary>
/// Summary description for QueCommentManage.
/// </summary>
public partial class QueCommentManage : System.Web.UI.Page
{
public String sOperation = "";
public String sLinkName = "";
protected void Page_Load(object sender, System.EventArgs e)
{
if(Session["UserID"] == null)
{
Response.Redirect("~/Default.aspx");
}
else
{
String sUserRoleName = UserDB.GetUserLoginRole(Int32.Parse(Session["UserID"].ToString()));
if(sUserRoleName.IndexOf("Monitor") == -1)
{
Response.Redirect("~/Default.aspx");
}
}
if(!Page.IsPostBack)
{
BindQuestionData();
if(QuestionList.Items.Count > 0)
{
BindCommentData(Int32.Parse(QuestionList.SelectedValue));
}
}
deleteBtn.Attributes.Add("onclick","return confirm('你确定要删除所选择的问题吗?');");
if(Request.Params["LinkID"] != null)
{
GetLinkName(Request.Params["LinkID"].ToString());
}
}
private void GetLinkName(String sLinkID)
{
String[] aName = new String[2];
aName = GlobalVarables.GetLinkName(sLinkID);
sOperation = aName[0].ToString();
sLinkName = aName[1].ToString();
}
private void BindQuestionData()
{
QuestionList.Items.Clear();
QuestionDB question = new QuestionDB();
SqlDataReader recq = question.GetQuestionByUser(Int32.Parse(Session["UserID"].ToString()));
for(int i = 0; i < GlobalVarables.DEGREE; i++)
{
while(recq.Read())
{
ListItem listTtem = new ListItem(recq["Title"].ToString(),recq["QuestionID"].ToString());
QuestionList.Items.Add(listTtem);
}
recq.NextResult();
}
recq.Close();
}
private void BindCommentData(int nQuestionID)
{
CommentList.Items.Clear();
// CommentDB comment = new CommentDB();
// SqlDataReader rece = comment.GetCommentByQuestion(nQuestionID);
//
// CommentList.DataSource = rece;
// CommentList.DataTextField = "Comment";
// CommentList.DataValueField = "ID";
// CommentList.DataBind();
//
// rece.Close();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
protected void QuestionList_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(QuestionList.Items.Count > 0)
{
BindCommentData(Int32.Parse(QuestionList.SelectedValue));
}
}
protected void deleteBtn_Click(object sender, System.EventArgs e)
{
if(CommentList.SelectedIndex > -1)
{
CommentDB comment = new CommentDB();
try
{
comment.DeleteComment(Int32.Parse(CommentList.SelectedValue));
}
catch(Exception ex)
{
string sRawURL = Request.RawUrl;
if(sRawURL.IndexOf("?") > -1)
{
sRawURL = sRawURL.Substring(0,sRawURL.IndexOf("?"));
}
Response.Redirect("~/ManageSystem/ErrorPage.aspx?ErrorUrl=" + sRawURL + "&ErrorMessage=" + ex.Message.Replace("\n"," "));
}
BindCommentData(Int32.Parse(QuestionList.SelectedValue));
}
else
{
Response.Write("<script>alert(\"请选择你的数据项!\")</script>");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -