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 member_article : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //获取栏目值
            Fm.Bussiness.public_select ps = new Fm.Bussiness.public_select();
            //Drop_column.DataSource = ps.Getps("Fm_column", "cl_id,cl_name", "cl_xs=1 and cl_tg=1 and cl_attribute<>2 and cl_attribute<>1 order by cl_px asc");
            //Drop_column.DataTextField = "cl_name";
            //Drop_column.DataValueField = "cl_id";
            //Drop_column.DataBind();

            //绑定栏目信息
            Fm.Bussiness.Column cn = new Fm.Bussiness.Column();
            cn.GetColumns(Drop_column);

            //添加第一个栏目
            ListItem item = new ListItem();
            item.Text = "请选择投稿栏目";
            item.Value = "0";

            Drop_column.Items.Insert(0, item);
        }
    }
    protected void bt_save_Click(object sender, ImageClickEventArgs e)
    {
        if (Check_code.Text == Session["CheckCode"].ToString())
        {
             //判断栏目是否能够投稿
            Fm.Bussiness.Column col = new Fm.Bussiness.Column();
            if (col.Doc(int.Parse(Drop_column.SelectedValue)))
            {
                //模型基表数据处理
                Fm.EntityClass.model_main model = new Fm.EntityClass.model_main();
                model.title = doctitle.Text;

                model.head = false;

                model.map = false;

                model.flash = false;

                model.commend = false;


                model.bold = false;

                model.colid = int.Parse(Drop_column.SelectedValue);
                //model.mid = 1;
                model.thumbnail = thumbnail.Value;
                model.writertime = DateTime.Now;
                if (Session["membername"] != null)
                {
                    model.username = Session["membername"].ToString();
                }
                else
                {
                    model.username = "";
                }
                model.click = 1;
                model.audit = false;

                model.comment = true;

                model.color = "";
                model.keyword = "";
                model.intro = intro.Text;
                model.html = false;
                model.topclick = 0;
                model.tread = 0;
                //主表数据的添加
                Fm.Bussiness.model_main buss = new Fm.Bussiness.model_main();
                int docid = buss.model_main_add(model);
                // Fm.Bussiness.public_select ps = new Fm.Bussiness.public_select();
                //内容处理
                //内容处理
                Fm.EntityClass.model_article article = new Fm.EntityClass.model_article();
                article.docid = docid;
                article.content = FCKeditor1.Value;
                article.author = author.Text;
                article.source = source.Text;
                if (buss.model_article_add(article))
                {
                    Response.Redirect("Erro.aspx?eid=新文章发布成功!&url=article.aspx", true);
                }
                else
                {
                    Response.Write("<script>alert('文档发布出错 !');</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('你所选择的栏目不允许投稿 !');</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('请输入正确的验证码!');</script>");
        }
    }
}
