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 DAL;

public partial class admin_Addflash : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack && Request.QueryString["id"] != null)
        {
            int id = int.Parse(Request.QueryString["id"]);
            string sql = string.Format("select top 1 * from flash where id={0}", id);
            DataTable dt = DataProvider.ExecuteSql(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                txtTitle.Text = dt.Rows[0]["title"].ToString();
                txtContent.Text = dt.Rows[0]["content"].ToString().Replace("<br />", "\r");
                ddlClass.SelectedValue = dt.Rows[0]["class"].ToString();
                ddlStatus.SelectedValue = dt.Rows[0]["status"].ToString();

            }
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int id = Request.QueryString["id"] == null? 0:int.Parse(Request.QueryString["id"]);
        DataProvider.FlashManage(id, txtTitle.Text, txtContent.Text.Replace("\r", "<br />"), int.Parse(ddlClass.SelectedValue), int.Parse(ddlStatus.SelectedValue));
        Response.Redirect("flash.aspx");

    }
}
