//保存广告内容
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        wgiAdUnionSystem.BLL.wgi_adv badv = new wgiAdUnionSystem.BLL.wgi_adv();
        wgiAdUnionSystem.Model.wgi_adv madv = new wgiAdUnionSystem.Model.wgi_adv();
        madv.companyid = base.companyid;
        //广告参数
        madv.advname = txtname.Text;//关键描述
        madv.advstart = Helper.HelperDateTime.InputDateTime(txtbegin.Text);//开始时间
        madv.advend = Helper.HelperDateTime.InputDateTime(txtend.Text);//截止时间
        madv.advuptime = DateTime.Now;//添加时间
        madv.advpaytype = Helper.HelperDigit.ConvertToInt32(ddlPayType.SelectedValue, 1);//付费类型
        madv.advtype = Helper.HelperDigit.ConvertToInt32(ddlDisplayType.SelectedValue, 1);//显示类型

        madv.advstatus = 1;//默认审核通过
        madv.advinvalid = 1;//默认投放状态

        switch (madv.advtype)
        {
            case 1://文字广告
                madv.advlink = txtUrl.Text;
                madv.advcont = txtTilte.Text;
                break;
            case 2://图片广告
                madv.advlink = txtPicUrl.Text;
                if (ddlChange.SelectedIndex == 0)//外部地址
                {
                    madv.advcont = txtRemotePic.Text;
                }
                else
                {
                    //madv.advcont =fupload.s //上传图片地址
                }
                break;
            case 3://FLASH广告
                madv.advlink = txtSwfUrl.Text;

                if (ddlFlash.SelectedIndex == 0)//外部地址
                {
                    madv.advcont = txtRemoteSwf.Text;
                }
                else
                {
                    //madv.advcont =fupload.s //上传FLASH地址
                }

                break;
        }
        try
        {
            //新增一条广告资源
            int advid = badv.Add(madv);

            if (advid > 0)
            {
                Response.Redirect("adlist.aspx");
            }
            else
            {
                lblmsg.Text = "保存操作失败!";
            }
        }
        catch (Exception E)
        {
            lblmsg.Text = E.Message;
        }
    }
Exemple #2
0
 /// <summary>
 /// ��������б�
 /// </summary>
 public List<wgiAdUnionSystem.Model.wgi_adv> DataTableToList(DataTable dt)
 {
     List<wgiAdUnionSystem.Model.wgi_adv> modelList = new List<wgiAdUnionSystem.Model.wgi_adv>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         wgiAdUnionSystem.Model.wgi_adv model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new wgiAdUnionSystem.Model.wgi_adv();
             if (dt.Rows[n]["advid"].ToString() != "")
             {
                 model.advid = int.Parse(dt.Rows[n]["advid"].ToString());
             }
             if (dt.Rows[n]["companyid"].ToString() != "")
             {
                 model.companyid = int.Parse(dt.Rows[n]["companyid"].ToString());
             }
             model.advname = dt.Rows[n]["advname"].ToString();
             if (dt.Rows[n]["advtype"].ToString() != "")
             {
                 model.advtype = int.Parse(dt.Rows[n]["advtype"].ToString());
             }
             model.advcont = dt.Rows[n]["advcont"].ToString();
             model.advlink = dt.Rows[n]["advlink"].ToString();
             if (dt.Rows[n]["advwidth"].ToString() != "")
             {
                 model.advwidth = int.Parse(dt.Rows[n]["advwidth"].ToString());
             }
             if (dt.Rows[n]["advheight"].ToString() != "")
             {
                 model.advheight = int.Parse(dt.Rows[n]["advheight"].ToString());
             }
             if (dt.Rows[n]["advuptime"].ToString() != "")
             {
                 model.advuptime = DateTime.Parse(dt.Rows[n]["advuptime"].ToString());
             }
             if (dt.Rows[n]["advstatus"].ToString() != "")
             {
                 model.advstatus = int.Parse(dt.Rows[n]["advstatus"].ToString());
             }
             if (dt.Rows[n]["advstart"].ToString() != "")
             {
                 model.advstart = DateTime.Parse(dt.Rows[n]["advstart"].ToString());
             }
             if (dt.Rows[n]["advend"].ToString() != "")
             {
                 model.advend = DateTime.Parse(dt.Rows[n]["advend"].ToString());
             }
             if (dt.Rows[n]["advinvalid"].ToString() != "")
             {
                 model.advinvalid = int.Parse(dt.Rows[n]["advinvalid"].ToString());
             }
             if (dt.Rows[n]["advpaytype"].ToString() != "")
             {
                 model.advpaytype = int.Parse(dt.Rows[n]["advpaytype"].ToString());
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }