Esempio n. 1
0
    private void insert()
    {
        HXD.SQLServerDAL.tb_U_Advertisement dal   = new HXD.SQLServerDAL.tb_U_Advertisement();
        HXD.Model.tb_U_Advertisement        model = new HXD.Model.tb_U_Advertisement();
        model.type        = int.Parse(this.DropDownList1.SelectedValue);
        model.AdName      = this.TextBox1.Text.Trim();
        model.Width       = this.TextBox2.Text.Trim() != "" ? int.Parse(this.TextBox2.Text) : 0;
        model.Height      = this.TextBox3.Text.Trim() != "" ? int.Parse(this.TextBox3.Text) : 0;
        model.href        = this.TextBox4.Text.Trim();
        model.Elucidation = this.TextBox5.Text.Trim();
        model.scripttext  = this.TextBox6.Text.Trim();
        model.CloseTime   = Convert.ToDateTime(this.Text1.Value);
        model.isqiyong    = this.CheckBox1.Checked;

        if (this.DropDownList1.SelectedValue == "2" || this.DropDownList1.SelectedValue == "5")//图片
        {
            //if (this.Radio1.Checked)
            //{
            //    model.Files = Request.Form["FileStr"].Trim();
            //    model.FileType = 1;
            //}
            //else
            //{
            string type = Web.Model.PublicModel.UpLoadFileImage;
            string k    = string.Empty;
            if (upfileui.SaveFile(this.File1, Web.Model.PublicModel.ADUpLoadFileImages, type, Web.Model.PublicModel.filesizes, out k))    //上传文件并且返回信息
            {
                model.Files = Web.Model.PublicModel.XADUpLoadFileImages + upfileui.file_name;
            }
            else
            {
                Jscript.Alert(k, this.Page); return;
            }
            model.FileType = 2;
            //}
        }
        else if (this.DropDownList1.SelectedValue == "3")//Flash
        {
            string k = string.Empty;
            if (upfileui.SaveFile(this.File2, Web.Model.PublicModel.ADUpLoadFileImages, "swf", Web.Model.PublicModel.filesizes, out k))//上传文件并且返回信息
            {
                model.Files = Web.Model.PublicModel.XADUpLoadFileImages + upfileui.file_name;
            }
            else
            {
                Jscript.Alert(k, this.Page); return;
            }
        }
        else
        {
            model.Files = ""; model.FileType = 0;
        }
        if (dal.Add(model))
        {
            Jscript.AlertAndRedirect("广告添加成功!", "AdvertisementList.aspx?Page=" + Pages);
        }
        else
        {
            Jscript.Alert("广告添加失败!", this.Page);
        }
    }
Esempio n. 2
0
    private void binder()
    {
        HXD.SQLServerDAL.tb_U_Advertisement dal   = new HXD.SQLServerDAL.tb_U_Advertisement();
        HXD.Model.tb_U_Advertisement        model = new HXD.Model.tb_U_Advertisement();
        model = dal.GetModel(id);
        this.ViewState["Files"]          = model.Files;
        this.ViewState["FilesType"]      = model.FileType;
        this.DropDownList1.SelectedIndex = this.DropDownList1.Items.IndexOf(this.DropDownList1.Items.FindByValue(model.type.ToString())); //类型
        this.TextBox1.Text     = model.AdName;                                                                                            //名称
        this.TextBox2.Text     = model.Width.ToString();
        this.TextBox3.Text     = model.Height.ToString();
        this.TextBox4.Text     = model.href;
        this.TextBox5.Text     = model.Elucidation;
        this.TextBox6.Text     = model.scripttext;
        this.Text1.Value       = model.CloseTime.ToString("yyyy-MM-dd");
        this.CheckBox1.Checked = model.isqiyong;
        this.Literal2.Text     = model.submittime.ToString();
        //if (model.FileType == 1)
        //{
        //    this.Radio1.Checked = true;
        //    this.Radio2.Checked = false;
        //    this.FileStr.Text = model.Files;
        //    this.filetable1.Style.Add("display", "block");
        //    this.filetable2.Style.Add("display", "none");
        //}
        //else if (model.FileType == 2)
        //{
        //    this.Radio1.Checked = false;
        //    this.Radio2.Checked = true;
        //    this.filetable1.Style.Add("display", "none");
        //    this.filetable2.Style.Add("display", "block");
        //}

        if (model.type == 2)//图片
        {
            this.adsize.Style.Add("display", "block");
            this.adfile.Style.Add("display", "block");
            this.adflash.Style.Add("display", "none");
            this.adlink.Style.Add("display", "block");
            this.adlinkstr.Style.Add("display", "block");
            this.adjs.Style.Add("display", "none");
        }
        else if (model.type == 3)//Flash
        {
            this.adsize.Style.Add("display", "block");
            this.adfile.Style.Add("display", "none");
            this.adflash.Style.Add("display", "block");
            this.adlink.Style.Add("display", "none");
            this.adlinkstr.Style.Add("display", "none");
            this.adjs.Style.Add("display", "none");
        }
        else if (model.type == 4)//脚本
        {
            this.adsize.Style.Add("display", "none");
            this.adfile.Style.Add("display", "none");
            this.adflash.Style.Add("display", "none");
            this.adlink.Style.Add("display", "none");
            this.adlinkstr.Style.Add("display", "none");
            this.adjs.Style.Add("display", "block");
        }
        else if (model.type == 5)//漂浮
        {
            this.adsize.Style.Add("display", "block");
            this.adfile.Style.Add("display", "block");
            this.adflash.Style.Add("display", "none");
            this.adlink.Style.Add("display", "block");
            this.adlinkstr.Style.Add("display", "block");
            this.adjs.Style.Add("display", "none");
        }
    }