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 System.Data.SqlClient;

public partial class manage_Editleaveword : System.Web.UI.Page
{
    static int nResult = -1;
    protected void Page_Load(object sender, EventArgs e)
    {
        Loginjudge();
        if (!Page.IsPostBack)
        {
            if (Request.Params["ShowID"] != null)
            {
                if (Int32.TryParse(Request.Params["ShowID"].ToString(), out nResult) == false) { return; }
                Getleaveword(nResult);
                Getreply(nResult);
            }
        }
    }
    private void Getleaveword(int nLeavewordID)
    {
        INews shownews = new Mynews();
        SqlDataReader dr = shownews.SqlGetinfo("SELECT Content FROM Leaveword WHERE LeavewordID=" + nLeavewordID);
        if (dr.Read())
        {
            lblContent.Text = dr["Content"].ToString();
        }
    }
    private void Getreply(int nLeavewordID)
    {
        INews shownews = new Mynews();
        SqlDataReader dr = shownews.SqlGetinfo("SELECT Reply FROM Leaveword WHERE LeavewordID=" + nLeavewordID);
        if (dr.Read())
        {
            txtReply.Text = dr["Reply"].ToString();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        INews shownews = new Mynews();
        if (txtReply.Text.ToString().Trim().Length < 1)
        {
            return;
        }
        shownews.Executeinfo("UPDATE Leaveword SET Reply='" + txtReply.Text.ToString() + "',Replyshow=1,Replydate=GetDate() WHERE LeavewordID=" + nResult);
        lblError.Text = "回复成功！";
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        txtReply.Text = "";
    }
    private void Loginjudge()
    {
        if (Session["Login"] == null)
        {
            Response.Redirect("Error.aspx");
        }
        else
        {
            if (Session["Login"] != "pass")
            {
                Response.Redirect("Error.aspx");
            }

        }
    }
}
