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 Base;
using System.Data.SqlClient;
public partial class AdPlaceEdit : BasePage
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckRights("Basic", "B1");
        if (!IsPostBack)
        {
            string id= Session["id"] as string;
            int tid = Convert.ToInt32(id);
            DAL.Ad.AdPlaceManage adi = new DAL.Ad.AdPlaceManage();
            Model.Ad.AdItiem adt = adi.SelectInfo(tid);
            this.TxB_ID.Text = id.ToString();
            this.TxB_name.Text = adt.Name;
            this.DDL_Adtype.Text = adt.Type;
            this.DDL_Place.Text = adt.Page;
            //this.TxB_adrees.Text = adt.Adrees; ;
            //this.TxB_ImageAdrees.Text = adt.IamgeAdress;
            this.TxB_Width.Text = adt.AdWidth.ToString();
            this.TxB_Length.Text = adt.AdHeight.ToString();
            this.TxB_mark.Text = adt.Mark.ToString().Remove(adt.Mark.ToString().Trim().Length -5,5);
           
        }
        btn_decided.Attributes.Add("onclick", "return check();");
        //Btn_upload.Attributes.Add("onclick","return di();");
    }

    /// <summary>
    /// 更新广告位信息
    /// </summary>
    protected void btn_decided_Click(object sender, EventArgs e)
    {
        string tid = Session["id"] as string;
        int id = Convert.ToInt32(tid);
        Model.Ad.AdItiem adi = new Model.Ad.AdItiem();
        adi.Name = this.TxB_name.Text.Trim();
        adi.Type = this.DDL_Adtype.SelectedValue.Trim();
        adi.Page = this.DDL_Place.SelectedValue.Trim();
        adi.IamgeAdress = "";// this.TxB_ImageAdrees.Text.Trim();
        adi.Adrees = ""; //this.TxB_adrees.Text.Trim();
        adi.AdWidth =Convert.ToInt32(this.TxB_Width.Text.Trim());
        adi.AdHeight =Convert.ToInt32(this.TxB_Length.Text.Trim());
        adi.Mark = decimal.Parse((this.TxB_mark.Text.Trim()));

        DAL.Ad.AdPlaceManage adp = new DAL.Ad.AdPlaceManage();
        adp.UpAdInfo(id,adi);

        Response.Write("<script>alert('编辑成功');location.href='AdPlaceList.aspx';</script>");
    }
    #region //上传事件
    //protected void Btn_Up_Click(object sender, EventArgs e)
    //{
    //    Base.Core.WebConfig web = new Base.Core.WebConfig();
    //    string imgsFolder = web.ImgFolder;
    //    string datatime = System.DateTime.Now.ToString("yyyyMMddHHmmssffff");
    //    if (this.FileUploadAdrees.HasFile)
    //    {
    //        string fileName = this.FileUploadAdrees.FileName;
    //        string fileExition = System.IO.Path.GetExtension(fileName).ToLower();
    //        string de = "|.gif|.png|.jpeg|.jpg";
    //        string path = HttpContext.Current.Server.MapPath("~/" + imgsFolder);
    //        if (!System.IO.Directory.Exists(path)) 
    //        {
    //            System.IO.Directory.CreateDirectory(path);
    //        }
    //        if (fileName == "")
    //        {
    //            Response.Write("<script>alert('请选择上传的图片');</script>");
    //            return;
    //        }
    //        if (de.IndexOf(fileExition) > 0)
    //        {
    //         string NewFileName ="/"+datatime + fileExition;
    //         this.FileUploadAdrees.PostedFile.SaveAs(path + NewFileName);
    //         this.TxB_ImageAdrees.Text = Base.BasePage.Config.WebURL + imgsFolder + NewFileName;
    //         }
    //         else
    //         {
    //          Response.Write("<script>alert('上传图片格式错误');</script>");
    //         }

    //     }
    #endregion
     //}
}
