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;

public partial class admini_AddArticle : BasePage
{
    SiteInfo si = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CheckLogin()) return;
        si = base.getSiteInfo();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //if (Session["admin"] == null)
        //{
        //    this.RegisterStartupScript("", "<script>alert('您无权进行此操作');</script>");
        //}
        //else
        //{
        //51aspx
            string title =Server.HtmlEncode( this.txtTitle.Value);
            string text =this.FreeTextBox1.Text.Trim();
            string desc = this.txtzaiy.Text;
            string f = this.txtFrom.Text;
            if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(text) || string.IsNullOrEmpty(desc) || string.IsNullOrEmpty(f))
            {
                this.RegisterStartupScript("", "<script>alert('不能为空！');</script>");
                return;
            }
            string sql =string.Format( "INSERT INTO ARTICLE (ARTTITLE,ARTDESC,ARTTIME,ARTSTATUS,ARTAUTHOR,ARTTOP,ARTTEXT,ARTHIT,ARTFROM) values ('{0}','{1}',now(),true,'{2}',true,'{3}',0,'{4}')",title,desc,si.TName,text,f);
            try
            {
                int k = SqlHelper.ExecuteSql(sql);
                if (k > 0)
                {
                    this.RegisterStartupScript("", "<script>alert('发布成功');</script>");
                    WebClass.ReMoveCacheByKey("NewArticle");
                }
                else
                    this.RegisterStartupScript("", "<script>alert('发布失败');</script>");
            }
            catch (Exception ex)
            {
                this.RegisterStartupScript("", "<script>alert(\"发布失败!"+ex.Message+"\");</script>");
            }
        //}
    }
}
