using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TopWinCMS.Model;
using TopWinCMS.BLL;
using TopWinCMS.Common;
namespace TopWinCMS.WebUI.Member
{
    public partial class Question : TopWinCMS.BLL.PageFactory.Pages.ClientPublicPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Page.Title = "提问";
                new ClassManage().BindDDL(this.DDL_ClassID, TopWinCMS.Model.Enum.Class_BindOption.NoLink, "<请选择栏目>", 5);
            }
        }

        #region 添加或修改
        private void Add()
        {
            AskInfo model = new AskInfo();

            model.ModelID = 5;
            model.ClassID = int.Parse(DDL_ClassID.SelectedValue);
            model.Title = TB_Title.Text.Trim();
            model.Content = TB_Content.Text.Trim();
            model.UserName = MemberLoginInfo.UserName ;
            model.Key = TB_Key.Text.Trim();
            model.IP = TopWinCMS.Common.HttpClient.GetIP();
            model.TemplateFileName = BLL.HTMLBuilder.Templates.DefaultTemplate.AskShow_aspx;
            model.Pass = ModelManage.GetPass(5);

            if (Request["ID"] == null)
            {
                model.ID = 0;
            }
            else
            {
                model.ID = int.Parse(Request["ID"]);
            }

            string strErr = null;

            new Public_Ask().Add(model, new List<string>(), new List<object>(), ref strErr);

            if (string.IsNullOrEmpty(strErr) == false)
            {
                MsgBox.Alert(strErr);
                return;
            }
            else
            {
                MsgBox.Alert("添加成功！", this.Request.Url.ToString());
            }

        }
        #endregion

        protected void BT_OK_Click(object sender, EventArgs e)
        {
            Add();
        }
    }
}