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_Inputproduct : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Loginjudge();
        if (!Page.IsPostBack)
        {
            Getglory();
        }
    }
    //读新闻
    private void Getglory()
    {
        INews shownews = new Mynews();
        SqlDataReader dr = shownews.SqlGetinfo("SELECT Content FROM Corp");
        if (dr.Read())
        {
            FreeTextBox1.Text = dr["Content"].ToString();
        }
    }
    //插入新闻
    public int Insertglory(string sContent)
    {
        INews shownews = new Mynews();
        int nResult = shownews.Executeinfo("UPDATE Corp SET Content='" + sContent + "'");
        return nResult;
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int nResult = -1;
        string content = FreeTextBox1.Text.ToString();
        if (content.Length > 10)
        {
            nResult = Insertglory(content);
        }
        if (nResult == 1)
        {
            lblError.Text = "更新成功！";
        }
        else
        {
            lblError.Text = "更新失败！";
        }
        
    }
    private void Loginjudge()
    {
        if (Session["Login"] == null)
        {
            Response.Redirect("Error.aspx");
        }
        else
        {
            if (Session["Login"] != "pass")
            {
                Response.Redirect("Error.aspx");
            }

        }
    }
}
