protected void Save()
        {
            ShowShop.Common.SysParameter sp=new ShowShop.Common.SysParameter();
            ShowShop.BLL.Accessories.AdvertiseManage bll = new ShowShop.BLL.Accessories.AdvertiseManage();
            ShowShop.Model.Accessories.AdvertiseManage model = new ShowShop.Model.Accessories.AdvertiseManage();
            string typeId = this.hfAdTypeId.Value;
            string adId = this.hfAdId.Value;
            switch (typeId)
            {
                case "0"://图片
                    model.Name = this.txt_image_Add_Name.Text.Trim();
                    model.Power = this.txt_images_Power.Text.Trim() == "" ? 0 : Convert.ToInt32(this.txt_images_Power.Text.Trim());
                    model.BrowseCount = this.txt_images_BrowseCount.Text.Trim() == "" ? 0 : Convert.ToInt32(this.txt_images_BrowseCount.Text.Trim());
                    model.ClickCount = this.txt_images_ClickCount.Text.Trim() == "" ? 0 : Convert.ToInt32(this.txt_images_ClickCount.Text.Trim());
                    model.OverdueTime = Convert.ToDateTime(this.dpStart_images.Text.Trim());
                    model.Examine = this.chx_images_Examine.Checked ? 1 : 0;
                    model.StatClick = this.chx_images_ClickCount.Checked ? 1 : 0;
                    model.StatBrowse = this.chx_images_BorwsCount.Checked ? 1 : 0;

                    model.SizeBreadth = txt_images_Width.Text.Trim();
                    model.Hight = txt_images_Height.Text.Trim();
                    model.LinkAddress = txt_images_LinkAddress.Text.Trim();
                    model.Hint = txt_images_Hint.Text.Trim();
                    //打开方式
                    model.BackgorTarget = Convert.ToInt32(this.rdolstTarget1.SelectedValue);
                    model.Advertisecont = txtContent1.Text.Trim();
                    model.Adtype = 0;
                    string images_path = "";
                    if (fu_images.PostedFile.ContentLength > 1)
                    {
                        ChangeHope.Common.UploadFile uf = new ChangeHope.Common.UploadFile();
                        uf.ExtensionLim = ".gif,.jpg,.jpeg,.dmp";
                        uf.FileLengthLim = sp.ImageSize;
                        uf.PostedFile = this.fu_images;
                        uf.SavePath = "/yxuploadfile/accessories/advertise";
                        string errorInfo = "";

                        if (uf.Upload())
                        {
                            if (uf.HaveLoad)
                            {
                                if (!string.IsNullOrEmpty(adId) && ViewState["Images"] != null)
                                {
                                    ChangeHope.Common.FileHelper fh = new ChangeHope.Common.FileHelper();
                                    fh.DeleteFile(Server.MapPath("~\\" + ViewState["Images"].ToString()));
                                }
                                images_path = uf.FilePath;
                            }
                            else
                            {

                                errorInfo = uf.Message;
                            }
                        }
                        else
                        {
                            errorInfo = uf.Message;
                        }
                        if (images_path == "")
                        {
                            this.ltlMsg.Text = "操作失败," + errorInfo + "";
                            this.pnlMsg.Visible = true;
                            this.pnlMsg.CssClass = "actionErr";
                            return;
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(adId) && ViewState["Images"] != null)
                        {
                            images_path = ViewState["Images"].ToString();
                        }
                    }

                    model.UpspreadAdd = images_path;
                    if (string.IsNullOrEmpty(adId))
                    {
                        if (bll.Add(model) > 0)
                        {
                            ChangeHope.WebPage.BasePage.PageRight("图片广告已保存。", "advertise_info_edit.aspx");
                        }
                    }
                    else
                    {
                        model.ID = Convert.ToInt32(adId);
                        bll.Amend(model);
                        ChangeHope.WebPage.BasePage.PageRight("图片广告修改成功。", "advertise_list.aspx");
                    }
                    break;
                case "1"://动画

                    model.Name = this.txt_flash_Add_Name.Text.Trim();
                    model.Power = this.txt_flash_Power.Text.Trim() == "" ? 0 : Convert.ToInt32(this.txt_flash_Power.Text.Trim());
                    model.BrowseCount = this.txt_flash_BrowseCount.Text.Trim() == "" ? 0 : Convert.ToInt32(this.txt_flash_BrowseCount.Text.Trim());
                    model.ClickCount = this.txt_flash_ClickCount.Text.Trim() == "" ? 0 : Convert.ToInt32(this.txt_flash_ClickCount.Text.Trim());
                    model.OverdueTime = Convert.ToDateTime(this.dpStart_flash.Text.Trim());
                    model.Examine = this.chx_flash_Examine.Checked ? 1 : 0;
                    model.StatClick = this.chx_flash_ClickCount.Checked ? 1 : 0;
                    model.StatBrowse = this.chx_flash_BorwsCount.Checked ? 1 : 0;
                    string flash_path = string.Empty;
                    if (this.fu_flash.PostedFile.ContentLength > 0)
                    {
                        ChangeHope.Common.UploadFile uf_falsh = new ChangeHope.Common.UploadFile();
                        uf_falsh.ExtensionLim = ".gif,.swf";
                        uf_falsh.FileLengthLim = sp.ImageSize;
                        uf_falsh.PostedFile = this.fu_flash;
                        uf_falsh.SavePath = "/yxuploadfile/accessories/advertise";
                        if (uf_falsh.Upload())
                        {
                            if (uf_falsh.HaveLoad)
                            {
                                if (!string.IsNullOrEmpty(adId) && ViewState["Images"] != null)
                                {
                                    ChangeHope.Common.FileHelper fh = new ChangeHope.Common.FileHelper();
                                    fh.DeleteFile(Server.MapPath("~\\" + ViewState["Images"].ToString()));
                                }
                                flash_path = uf_falsh.FilePath;
                            }
                            else
                            {

                                this.ltlMsg.Text = "操作失败," + uf_falsh.Message + "";
                                this.pnlMsg.Visible = true;
                                this.pnlMsg.CssClass = "actionErr";
                                return;
                            }
                        }
                        else
                        {
                            this.ltlMsg.Text = "操作失败," + uf_falsh.Message + "";
                            this.pnlMsg.Visible = true;
                            this.pnlMsg.CssClass = "actionErr";
                            return;
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(adId) && ViewState["Images"] != null)
                        {
                            flash_path = ViewState["Images"].ToString();
                        }
                    }
                    model.SizeBreadth = this.txt_flash_Width.Text.Trim();
                    model.Hight = this.txt_flash_Height.Text.Trim();
                    model.LinkAddress = "";
                    model.Hint = "";
                    model.BackgorTarget = Convert.ToInt32(this.rlistTarget2.SelectedValue);
                    model.Advertisecont = "";
                    model.UpspreadAdd = flash_path;
                    model.Adtype = 1;
                    if (string.IsNullOrEmpty(adId))
                    {
                        if (bll.Add(model) > 0)
                        {
                            ChangeHope.WebPage.BasePage.PageRight("动画广告已保存。", "advertise_info_edit.aspx");
                        }
                    }
                    else
                    {
                        model.ID = Convert.ToInt32(adId);
                        bll.Amend(model);
                        ChangeHope.WebPage.BasePage.PageRight("动画广告修改成功。", "advertise_list.aspx");
                    }
                    break;
                case "2"://文本
                    model.Name = this.txt_text_Add_Name.Text.Trim();
                    model.Power = this.txt_text_Power.Text.Trim() == "" ? 0 : Convert.ToInt32(this.txt_text_Power.Text.Trim());
                    model.BrowseCount = this.txt_text_BrowseCount.Text.Trim() == "" ? 0 : Convert.ToInt32(this.txt_text_BrowseCount.Text.Trim());
                    model.ClickCount = this.txt_text_ClickCount.Text.Trim() == "" ? 0 : Convert.ToInt32(this.txt_text_ClickCount.Text.Trim());
                    model.OverdueTime = Convert.ToDateTime(this.dpStart_text.Text.Trim());
                    model.Examine = this.chx_text_Examine.Checked ? 1 : 0;
                    model.StatClick = this.chx_text_ClickCount.Checked ? 1 : 0;
                    model.StatBrowse = this.chx_text_BorwsCount.Checked ? 1 : 0;
                    model.LinkAddress = "";
                    model.Hint = "";
                    model.SizeBreadth = "";
                    model.Hight = "";
                    model.BackgorTarget = 0;
                    model.UpspreadAdd = "";
                    model.Adtype = 2;
                    model.Advertisecont = this.txtContent3.Text.Trim();
                    if (string.IsNullOrEmpty(adId))
                    {
                        if (bll.Add(model) > 0)
                        {
                            ChangeHope.WebPage.BasePage.PageRight("文本广告已保存。", "advertise_info_edit.aspx");
                        }
                    }
                    else
                    {
                        model.ID = Convert.ToInt32(adId);
                        bll.Amend(model);
                        ChangeHope.WebPage.BasePage.PageRight("文本广告修改成功。", "advertise_list.aspx");
                    }
                    break;
                case "3"://幻灯片
                    model.Name = this.txt_Slide_Add_Name.Text.Trim();
                    model.Power = this.txt_Slide_Power.Text.Trim() == "" ? 0 : Convert.ToInt32(this.txt_Slide_Power.Text.Trim());
                    model.BrowseCount = this.txt_Slide_BrowseCount.Text.Trim() == "" ? 0 : Convert.ToInt32(this.txt_Slide_BrowseCount.Text.Trim());
                    model.ClickCount = this.txt_Slide_ClickCount.Text.Trim() == "" ? 0 : Convert.ToInt32(this.txt_Slide_ClickCount.Text.Trim());
                    model.OverdueTime = Convert.ToDateTime(this.dpStart_Slide.Text.Trim());
                    model.Examine = this.chx_Slide_Examine.Checked ? 1 : 0;
                    model.StatClick = this.chx_Slide_ClickCount.Checked ? 1 : 0;
                    model.StatBrowse = this.chx_Slide_BorwsCount.Checked ? 1 : 0;

                    model.SizeBreadth = this.txt_Slide_Width.Text.Trim();
                    model.Hight = this.txt_Slide_Height.Text.Trim();
                    model.LinkAddress = this.txtLinkAddress4.Text.Trim();
                    model.Hint = this.txtHint4.Text.Trim();
                    model.BackgorTarget = Convert.ToInt32(this.rlistTarget4.SelectedValue);
                    model.Advertisecont = this.txtContent4.Text.Trim();
                    System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
                    string slide_path = "";
                    string slide_error_info = "";
                    if (files.Count > 1)//说明图片大小和格式都没问题
                    {
                        ChangeHope.Common.UploadFile slide_uf = new ChangeHope.Common.UploadFile();
                        slide_uf.ExtensionLim = ".gif,.jpg,.jpeg,.dmp";
                        slide_uf.FileLengthLim = sp.ImageSize;
                        for (int i = 2; i < files.Count; i++)
                        {
                            slide_uf.MyFile = files[i];
                            slide_uf.SavePath = "/yxuploadfile/accessories/advertise";
                            if (slide_uf.HTMLUpLoad())
                            {
                                if (slide_uf.HaveLoad)
                                {
                                    if (slide_path == "")
                                    {

                                        slide_path = slide_uf.FilePath;
                                    }
                                    else
                                    {
                                        slide_path += "|" + slide_uf.FilePath;
                                    }
                                }
                                else
                                {
                                    slide_error_info += slide_uf.Message + "</br>";
                                    break;
                                }
                            }
                            else
                            {
                                slide_error_info += slide_uf.Message + "</br>";
                                break;
                            }
                        }
                        if (!string.IsNullOrEmpty(adId) && ChangeHope.WebPage.PageRequest.GetFormString("hfImagesAddress") != "")
                        {
                            slide_path += "|" + ChangeHope.WebPage.PageRequest.GetFormString("hfImagesAddress");
                        }
                        if (slide_error_info != "")
                        {
                            this.ltlMsg.Text = "操作失败," + slide_error_info + "";
                            this.pnlMsg.Visible = true;
                            this.pnlMsg.CssClass = "actionErr";
                            return;
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(adId) && ChangeHope.WebPage.PageRequest.GetFormString("hfImagesAddress") != "")
                        {
                            slide_path = ChangeHope.WebPage.PageRequest.GetFormString("hfImagesAddress");
                        }
                    }

                    model.UpspreadAdd = slide_path;
                    model.Adtype = 3;
                    if (string.IsNullOrEmpty(adId))
                    {
                        if (bll.Add(model) > 0)
                        {
                            ChangeHope.WebPage.BasePage.PageRight("幻灯片广告已保存。", "advertise_info_edit.aspx");
                        }
                    }
                    else
                    {
                        model.ID = Convert.ToInt32(adId);
                        bll.Amend(model);
                        ChangeHope.WebPage.BasePage.PageRight("幻灯片广告修改成功。", "advertise_list.aspx");
                    }
                    this.ltlMsg.Text = "操作成功,已保存该信息";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionOk";
                    break;
            }
        }
Example #2
0
 /// <summary>
 /// 得到一个实体
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ShowShop.Model.Accessories.AdvertiseManage GetModelByID(int id)
 {
     ShowShop.Model.Accessories.AdvertiseManage model = new ShowShop.Model.Accessories.AdvertiseManage();
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select  top 1 [id],[name],[power],[statbrowse],[statclick],[overduetime],[examine],[upspreadadd],[sizebreadth],[hight],[linkaddress],[hint],[backgortarget],[advertisecont],[browsecount],[clickcount],[adtype] from yxs_advertisemanage ");
     strSql.Append(" where [id]=@id ");
     SqlParameter[] parameters = (SqlParameter[])this.ValueIDPara(id);
     using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString(),parameters))
     {
         if (reader.Read())
         {
             model.ID = reader.GetInt32(0);
             model.Name = reader.GetString(1);
             model.Power = reader.GetInt32(2);
             model.StatBrowse = reader.GetInt32(3);
             model.StatClick = reader.GetInt32(4);
             model.OverdueTime = reader.GetDateTime(5);
             model.Examine = reader.GetInt32(6);
             model.UpspreadAdd = reader.GetString(7);
             model.SizeBreadth = reader.GetString(8);
             model.Hight = reader.GetString(9);
             model.LinkAddress = reader.GetString(10);
             model.Hint = reader.GetString(11);
             model.BackgorTarget = reader.GetInt32(12);
             model.Advertisecont = reader.GetString(13);
             model.BrowseCount = reader.GetInt32(14);
             model.ClickCount = reader.GetInt32(15);
             model.Adtype = reader.GetInt32(16);
         }
     }
     return model;
 }
        private void Save()
        {
            ShowShop.BLL.Accessories.AdvertiseManage bll = new ShowShop.BLL.Accessories.AdvertiseManage();
            ShowShop.Model.Accessories.AdvertiseManage model = new ShowShop.Model.Accessories.AdvertiseManage();
            model.Name = this.txtName.Text.Trim();
            model.Power = this.txtPower.Text.Length == 0 ? 0 : Convert.ToInt32(this.txtPower.Text.Trim());
            model.BrowseCount = this.txtBrowseCount.Text.Length == 0 ? 0 : Convert.ToInt32(this.txtBrowseCount.Text.Trim());
            model.ClickCount = this.txtClickCount.Text.Length == 0 ? 0 : Convert.ToInt32(this.txtClickCount.Text.Trim());
            try
            {
                model.OverdueTime = Convert.ToDateTime(this.dpStart.Text.Trim());
            }
            catch
            {
                this.ltlMsg.Text = "请输入正确的时间格式,最好通过选择器选择日期";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionErr";
                return;
            }

            model.Examine = this.chxExamine.Checked ? 1 : 0;
            model.StatClick = this.chxClickCount.Checked ? 1 : 0;
            model.StatBrowse = this.chxBorwsCount.Checked ? 1 : 0;

            #region 修改操作
            if (Request["Ads_ID"] != null)
            {
                int id = Convert.ToInt32(Request["Ads_ID"].ToString());
                if (ViewState["adtype"] != null)
                {
                    //图片
                    if (ViewState["adtype"].ToString() == "0")
                    {
                        model.SizeBreadth = txtWidth1.Text.Trim();
                        model.Hight = txtHeight1.Text.Trim();
                        model.LinkAddress = txtLinkAddress.Text.Trim();
                        model.Hint = txtHint1.Text.Trim();
                        //打开方式
                        model.BackgorTarget = Convert.ToInt32(this.rdolstTarget1.SelectedValue);
                        model.Advertisecont = txtContent1.Text.Trim();
                        model.Adtype = 0;
                        model.ID = id;
                        if (txtUpspread1.Text != "")
                        {
                            model.UpspreadAdd = this.txtUpspread1.Text.ToString();
                        }
                        else
                        {
                            model.UpspreadAdd = ViewState["picAddress"].ToString();
                        }
                        bll.Amend(model);
                        this.ltlMsg.Text = "操作成功,已保存该信息";
                        this.pnlMsg.Visible = true;
                        this.pnlMsg.CssClass = "actionOk";
                    }
                    //动画
                    else if (ViewState["adtype"].ToString() == "1")
                    {
                        ViewState["adtype2"] = "1";
                        string Upspread = string.Empty;

                        if (FileUpload2.HasFile)
                        {
                            ChangeHope.Common.UploadFile uf = new ChangeHope.Common.UploadFile();
                            uf.ExtensionLim = ".gif,.swf";
                            uf.FileLengthLim = 4000;
                            uf.PostedFile = this.FileUpload2;
                            uf.SavePath = "/yxuploadfile/accessories/advertise";
                            if (uf.Upload())
                            {
                                if (uf.HaveLoad)
                                {
                                    Upspread = uf.FilePath;
                                }
                                else
                                {
                                    this.ltlMsg.Text = "操作失败," + uf.Message + "";
                                    this.pnlMsg.Visible = true;
                                    this.pnlMsg.CssClass = "actionErr";
                                    return;
                                }
                            }
                            else
                            {
                                this.ltlMsg.Text = "操作失败," + uf.Message + "";
                                this.pnlMsg.Visible = true;
                                this.pnlMsg.CssClass = "actionErr";
                                return;
                            }
                        }
                        model.SizeBreadth = this.txtWidth2.Text.Trim();
                        model.Hight = this.txtHeight2.Text.Trim();
                        model.LinkAddress = "";
                        model.Hint = "";
                        model.BackgorTarget = Convert.ToInt32(this.rlistTarget2.SelectedValue);
                        model.Advertisecont = "";
                        model.UpspreadAdd = Upspread;
                        model.Adtype = 1;
                        model.ID = id;
                        bll.Amend(model);
                        this.ltlMsg.Text = "操作成功,已保存该信息";
                        this.pnlMsg.Visible = true;
                        this.pnlMsg.CssClass = "actionOk";
                    }
                    //文本
                    else if (ViewState["adtype"].ToString() == "2")
                    {
                        model.LinkAddress = "";
                        model.Hint = "";
                        model.SizeBreadth = "";
                        model.Hight = "";
                        model.BackgorTarget = 0;
                        model.UpspreadAdd = "";
                        model.Adtype = 2;
                        model.Advertisecont = this.txtContent3.Text.Trim();
                        model.ID = id;
                        bll.Amend(model);
                        this.ltlMsg.Text = "操作成功,已保存该信息";
                        this.pnlMsg.Visible = true;
                        this.pnlMsg.CssClass = "actionOk";
                    }
                    //幻灯片
                    else if (ViewState["adtype"].ToString() == "3")
                    {
                        model.SizeBreadth = this.txtWidth4.Text.Trim();
                        model.Hight = this.txtHeight4.Text.Trim();
                        model.LinkAddress = this.txtLinkAddress4.Text.Trim();
                        model.Hint = this.txtHint4.Text.Trim();
                        model.BackgorTarget = Convert.ToInt32(this.rlistTarget4.SelectedValue);
                        model.Advertisecont = this.txtContent4.Text.Trim();
                        if (this.txtUpspread1.Text != "")
                        {
                            model.UpspreadAdd = this.txtUpspread4.Text.ToString();
                        }
                        else
                        {
                            model.UpspreadAdd = ViewState["picAddress"].ToString();
                        }
                        model.Adtype = 3;
                        model.ID = id;
                        bll.Amend(model);
                        this.ltlMsg.Text = "操作成功,已保存该信息";
                        this.pnlMsg.Visible = true;
                        this.pnlMsg.CssClass = "actionOk";
                    }
                }

            }
            #endregion
            #region 增加操作
            else
            {
                #region 图片类型广告
                if (ViewState["adtype"] == null || ViewState["adtype"].ToString() == "0")
                {
                    model.SizeBreadth = this.txtWidth1.Text.Trim();
                    model.Hight = this.txtHeight1.Text.Trim();
                    model.LinkAddress = this.txtLinkAddress.Text.Trim();
                    model.Hint = this.txtHint1.Text.Trim();
                    //打开方式
                    model.BackgorTarget = Convert.ToInt32(this.rdolstTarget1.SelectedValue);
                    model.Advertisecont = this.txtContent1.Text.Trim();
                    model.UpspreadAdd = this.txtUpspread1.Text.ToString();
                    model.Adtype = 0;
                    bll.Add(model);
                    this.ltlMsg.Text = "操作成功,已保存该信息";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionOk";
                }
                #endregion

                #region 动画类型广告
                else if (ViewState["adtype"].ToString() == "1")
                {
                    string Upspread = string.Empty;
                    if (FileUpload2.HasFile)
                    {
                        ChangeHope.Common.UploadFile uf = new ChangeHope.Common.UploadFile();
                        uf.ExtensionLim = ".gif,.swf";
                        uf.FileLengthLim = 4000;
                        uf.PostedFile = this.FileUpload2;
                        uf.SavePath = "/yxuploadfile/accessories/advertise";
                        if (uf.Upload())
                        {
                            if (uf.HaveLoad)
                            {
                                Upspread = uf.FilePath;
                            }
                            else
                            {
                                this.ltlMsg.Text = "操作失败," + uf.Message + "";
                                this.pnlMsg.Visible = true;
                                this.pnlMsg.CssClass = "actionErr";
                                return;
                            }
                        }
                        else
                        {
                            this.ltlMsg.Text = "操作失败," + uf.Message + "";
                            this.pnlMsg.Visible = true;
                            this.pnlMsg.CssClass = "actionErr";
                            return;
                        }
                    }
                    model.SizeBreadth = this.txtWidth2.Text.Trim();
                    model.Hight = this.txtHeight2.Text.Trim();
                    model.LinkAddress = "";
                    model.Hint = "";
                    model.BackgorTarget = Convert.ToInt32(this.rlistTarget2.SelectedValue);
                    model.Advertisecont = "";
                    model.UpspreadAdd = Upspread;
                    model.Adtype = 1;
                    bll.Add(model);
                    this.ltlMsg.Text = "操作成功,已保存该信息";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionOk";
                }
                #endregion

                #region 文本类型广告
                else if (ViewState["adtype"].ToString() == "2")
                {
                    model.LinkAddress = "";
                    model.Hint = "";
                    model.SizeBreadth = "";
                    model.Hight = "";
                    model.BackgorTarget = 0;
                    model.UpspreadAdd = "";
                    model.Adtype = 2;
                    model.Advertisecont = this.txtContent3.Text.Trim();
                    bll.Add(model);
                    this.ltlMsg.Text = "操作成功,已保存该信息";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionOk";
                }
                #endregion

                #region 幻灯片类型广告
                else if (ViewState["adtype"].ToString() == "3")
                {
                    model.SizeBreadth = this.txtWidth4.Text.Trim();
                    model.Hight = this.txtHeight4.Text.Trim();
                    model.LinkAddress = this.txtLinkAddress4.Text.Trim();
                    model.Hint = this.txtHint4.Text.Trim();
                    model.BackgorTarget = Convert.ToInt32(this.rlistTarget4.SelectedValue);
                    model.Advertisecont = this.txtContent4.Text.Trim();
                    model.UpspreadAdd = this.txtUpspread4.Text.ToString();
                    model.Adtype = 3;
                    bll.Add(model);
                    this.ltlMsg.Text = "操作成功,已保存该信息";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionOk";
                }
                #endregion
            }
            #endregion
        }
Example #4
0
 /// <summary>
 /// 所有数据集合
 /// </summary>
 /// <returns></returns>
 public List<ShowShop.Model.Accessories.AdvertiseManage> GetAll()
 {
     List<ShowShop.Model.Accessories.AdvertiseManage> list = new List<ShowShop.Model.Accessories.AdvertiseManage>();
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select  [id],[name],[power],[statbrowse],[statclick],[overduetime],[examine],[upspreadadd],[sizebreadth],[hight],[linkaddress],[hint],[backgortarget],[advertisecont],[browsecount],[clickcount],[adtype] from yxs_advertisemanage ");
     strSql.Append(" where 1=1");
     using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString()))
     {
         while (reader.Read())
         {
             ShowShop.Model.Accessories.AdvertiseManage model = new ShowShop.Model.Accessories.AdvertiseManage();
             model.ID = reader.GetInt32(0);
             model.Name = reader.GetString(1);
             model.Power = reader.GetInt32(2);
             model.StatBrowse = reader.GetInt32(3);
             model.StatClick = reader.GetInt32(4);
             model.OverdueTime = reader.GetDateTime(5);
             model.Examine = reader.GetInt32(6);
             model.UpspreadAdd = reader.GetString(7);
             model.SizeBreadth = reader.GetString(8);
             model.Hight = reader.GetString(9);
             model.LinkAddress = reader.GetString(10);
             model.Hint = reader.GetString(11);
             model.BackgorTarget = reader.GetInt32(12);
             model.Advertisecont = reader.GetString(13);
             model.BrowseCount = reader.GetInt32(14);
             model.ClickCount = reader.GetInt32(15);
             model.Adtype = reader.GetInt32(16);
             list.Add(model);
         }
     }
     return list;
 }
        protected void GetModel()
        {
            #region 显示要编辑的数据
            if (ChangeHope.WebPage.PageRequest.GetQueryInt("Ads_ID") > 0)
            {
                ShowShop.BLL.Accessories.AdvertiseManage bll = new ShowShop.BLL.Accessories.AdvertiseManage();
                ShowShop.Model.Accessories.AdvertiseManage model = new ShowShop.Model.Accessories.AdvertiseManage();
                model = bll.GetModelByID(Convert.ToInt32(Request["Ads_ID"].ToString()));
                this.txtName.Text = model.Name;
                this.txtPower.Text = model.Power.ToString();
                this.txtBrowseCount.Text = model.BrowseCount.ToString();
                this.txtClickCount.Text = model.ClickCount.ToString();
                this.dpStart.Text = Convert.ToDateTime(model.OverdueTime).ToShortDateString();
                this.chxExamine.Checked = model.Examine == 1 ? true : false;
                this.chxClickCount.Checked = model.StatClick == 1 ? true : false;
                this.chxBorwsCount.Checked = model.StatBrowse == 1 ? true : false;
                if (model.Adtype == 0)
                {
                    this.pnlType1.Visible = true;
                    this.txtWidth1.Text = model.SizeBreadth;
                    this.txtHeight1.Text = model.Hight;
                    this.txtLinkAddress.Text = model.LinkAddress;
                    this.txtHint1.Text = model.Hint;
                    this.rdolstTarget1.SelectedValue = model.BackgorTarget.ToString();
                    this.txtContent1.Text = model.Advertisecont;
                    this.txtUpspread1.Text = model.UpspreadAdd;
                    ViewState["adtype2"] = model.Adtype.ToString();
                    ViewState["picAddress"] = model.UpspreadAdd;
                }
                else if (model.Adtype == 1)
                {
                    this.pnlType1.Visible = false;
                    this.pnlType2.Visible = true;
                    this.txtWidth2.Text = model.SizeBreadth;
                    this.txtHeight2.Text = model.Hight;
                    this.rlistTarget2.SelectedValue = model.BackgorTarget.ToString();
                    this.chxClickCount.Enabled = false;
                    this.txtClickCount.Enabled = false;
                    ViewState["adtype2"] = model.Adtype.ToString();
                    ViewState["picAddress"] = model.UpspreadAdd;

                }
                else if (model.Adtype == 2)
                {
                    this.pnlType1.Visible = false;
                    this.pnlType2.Visible = false;
                    this.pnlType3.Visible = true;
                    this.txtContent3.Text = model.Advertisecont;
                    this.chxClickCount.Enabled = false;
                    this.txtClickCount.Enabled = false;
                    ViewState["adtype2"] = model.Adtype.ToString();

                }
                else if (model.Adtype == 3)
                {
                    this.pnlType4.Visible = true;
                    this.pnlType1.Visible = false;
                    this.pnlType2.Visible = false;
                    this.pnlType3.Visible = false;
                    this.txtWidth4.Text = model.SizeBreadth;
                    this.txtHeight4.Text = model.Hight;
                    this.txtLinkAddress4.Text = model.LinkAddress;
                    this.txtHint4.Text = model.Hint;
                    this.rlistTarget4.SelectedValue = model.BackgorTarget.ToString();
                    this.txtContent4.Text = model.Advertisecont;
                    this.txtUpspread4.Text = model.UpspreadAdd;
                    ViewState["adtype2"] = model.Adtype.ToString();
                    ViewState["picAddress"] = model.UpspreadAdd;
                }
            }
            #endregion

            #region 添加数据
            else
            {
                this.dpStart.Text = DateTime.Now.ToShortDateString();
                this.txtClickCount.Text = "0";
                this.txtBrowseCount.Text = "0";
            }
            #endregion
        }