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 admin_ad_add : Fm.Bussiness.BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Fm.Bussiness.public_select ps = new Fm.Bussiness.public_select();
            Drop_adclass.DataSource = ps.Getps("Fm_adclass","*","");
            Drop_adclass.DataTextField = "acname";
            Drop_adclass.DataValueField = "acid";
            Drop_adclass.DataBind();
        }
    }
    //保存广告信息
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (Drop_adclass.Items.Count > 0)
        {
            Fm.EntityClass.ad ad = new Fm.EntityClass.ad();
            ad.acid = int.Parse(Drop_adclass.SelectedValue);
            ad.adletter = txt_letter.Text;
            ad.adpic = txt_pic.Text;
            ad.adjs = txt_js.Text;
            ad.adurl = txt_url.Text;

            Fm.Bussiness.ad add = new Fm.Bussiness.ad();
            add.ADD(ad);

            Response.Redirect("Erro.aspx?eid=广告添加成功!&url=ad_add.aspx", false);
        }
        else
        {
            Response.Write("<script>alert('请先添加广告分类!');</script>");
        }
        
    }
    protected void btn_save_Click(object sender, EventArgs e)
    {
        string path = Server.MapPath("../");
        DateTime time = DateTime.Now;

        string newpath = "/upload/ad/" + time.Year.ToString() + time.Month.ToString() + time.Day.ToString() + time.Hour.ToString() + time.Minute.ToString()+ time.Second.ToString() + System.IO.Path.GetExtension(FileUpload1.FileName);
        FileUpload1.SaveAs(path + newpath);

        txt_pic.Text = newpath;
    }
}
