using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Base;
using nspKnow;

public partial class Admin_Know_ProblemView : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ProblemBind();
            AnswerBind();
        }
    }
    private void ProblemBind()
    {
        if (GetRequest.GetQueryStringValue("ID") != "")
        {
            int id = int.Parse(Request.QueryString["ID"].ToString());
            KnowProblem pro = new KnowProblem().GetItem(id);
            lblCaption.Text = pro.Caption;
            lblDetail.Text = pro.Detail;
            if (pro.State.ToString() == "True")
                lblState.Text = "等待解决的问题";

            else
                lblState.Text = "已经解决的问题";
            lblCount.Text = pro.AnswerCount.ToString();
            lblUserName.Text = pro.UserName;
        }
    }
    private void AnswerBind()
    {
        string strURl = Request.RawUrl;
        strURl = strURl.Substring(0, strURl.IndexOf(".aspx")) + ".aspx";
        PageNo1.Strurl = strURl;
        PageNo1.Table = "W_KnowAnswer";
        PageNo1.FldName = "AddDate";
        PageNo1.StrGetFields = "ID,UserName,Detail,IP,AddDate";
        PageNo1.PageSize = 12;
        string strWhere = "1=1";
        if (Request.QueryString["page"] != "" && Request.QueryString["page"] != null)
        {
            PageNo1.Pageindex = Convert.ToInt32(Request.QueryString["page"].ToString());
            if (Session["strWhere"] != null)
                strWhere = Session["strWhere"].ToString();
            PageNo1.Where = strWhere;
            DataTable dt = PageNo1.BindViewDesc();
            if (dt.DefaultView.Count == 0)
            {
                lblMessage.Visible = true;
                lblMessage.Text = "暂无人回答";
            }
            else
                lblMessage.Visible = false;
            dlstAnswer.DataSource = dt.DefaultView;
            dlstAnswer.DataBind();
        }
        else
        {
            if (GetRequest.GetQueryStringValue("ID") != "")
            {
                string id = Request.QueryString["ID"].ToString();
                strWhere += " and W_KnowAnswer.ProblemsID=" + id;
                PageNo1.Where = strWhere;
                PageNo1.Pageindex = 1;
                Session["strWhere"] = strWhere;
                DataTable dt = PageNo1.BindViewDesc();
                if (dt.DefaultView.Count == 0)
                {
                    lblMessage.Visible = true;
                    lblMessage.Text = "暂无人回答";
                }
                else
                    lblMessage.Visible = false;
                dlstAnswer.DataSource = dt.DefaultView;
                dlstAnswer.DataBind();
            }
        }

    }
}
