using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CY.Model; using CY.BLL; using CY.Infrastructure.Common; using System.Data; using CY.BLL.Sys; using System.Text; namespace CY.WebForm.Pages.front { //吴辉 //添加/修改广告 public partial class HelpCentersAdDestine : FrontBasePage { Info_AdBLL bll_Info_AdBLL = null; Info_AdLoctionBLL bll_Info_AdLoctionBLL = null; Sys_DictionaryBLL bll_Sys_DictionaryBLL = null; EC_MemberBasicBLL bll_EC_MemberBasicBLL = null; public int? Keyid = 0; //初始化 public HelpCentersAdDestine() { bll_Info_AdBLL = new Info_AdBLL(); bll_Info_AdLoctionBLL = new Info_AdLoctionBLL(); bll_Sys_DictionaryBLL = new Sys_DictionaryBLL(); bll_EC_MemberBasicBLL = new EC_MemberBasicBLL(); } //页面加载 protected void Page_Load(object sender, EventArgs e) { if (ViewState["Keyid"] == null) { ViewState["Keyid"] = Request["Keyid"].ToInt32(); } Keyid = ViewState["Keyid"].ToInt32(); if (CurrentUser != null) { InitData(); } else JavaScript.MessageBox("请先登录", this); } //页面加载 public void InitData() { Info_AdLoction m_Info_AdLoction = bll_Info_AdLoctionBLL.SelectModelByKeyId(Keyid); if (m_Info_AdLoction != null) { this.spanNumber.InnerText = m_Info_AdLoction.Keyid.Value.ToString("0000"); this.spanRemark.InnerText = m_Info_AdLoction.RemarkName; this.spanAdLocation.InnerText = m_Info_AdLoction.AP_Title + " [宽:" + m_Info_AdLoction.AP_WidePixels + ",高:" + m_Info_AdLoction.AP_HighPixels + "]"; } } //提交事件 protected void btn_Submit_form(object sender, EventArgs e) { try { Info_AdLoction m_Info_AdLoction = bll_Info_AdLoctionBLL.SelectModelByKeyId(Keyid); int nowTime = this.selTimeChange.SelectedValue.ToInt32() ?? 0; string ARemarks = ""; switch (nowTime) { case 1: ARemarks = "一个月:"+m_Info_AdLoction.Price_Month.Value.ToString("0")+"元"; break; case 3: ARemarks = "一季度:"+m_Info_AdLoction.Price_Season.Value.ToString("0")+"元"; break; case 6: ARemarks = "半年:"+m_Info_AdLoction.Price_Half.Value.ToString("0")+"元"; break; case 12: ARemarks = "一年:"+m_Info_AdLoction.Price_Year.Value.ToString("0")+"元"; break; default: nowTime = 0; ARemarks = ""; break; } if (nowTime == 0) { JavaScript.MessageBox("预定失败", this); } else { DateTime? StardTime = DateTime.Now; DateTime? EndTime = DateTime.Now; Info_Ad m_Info_AdLast = bll_Info_AdBLL.SelectListByAdLocationId(Keyid); if (m_Info_AdLast != null && m_Info_AdLast.A_EndTime != null) StardTime = m_Info_AdLast.A_EndTime; EndTime = StardTime.Value.AddMonths(nowTime); Info_Ad m_Info_Ad = new Info_Ad(); m_Info_Ad.A_Title = this.txtAP_Title.Value.ToString2(); m_Info_Ad.A_Pic = "xx"; m_Info_Ad.A_Url = this.txtA_Url.Value.ToString2(); m_Info_Ad.AdLocationId = Keyid; m_Info_Ad.A_IsTarget = true; m_Info_Ad.A_StartTime = StardTime; m_Info_Ad.A_EndTime = EndTime; m_Info_Ad.A_MemberId = CurrentUser.MemberId; m_Info_Ad.A_Remarks = ARemarks; m_Info_Ad.LastUpdateTime = DateTime.Now; m_Info_Ad.Operator = CurrentUser.ShortName; m_Info_Ad.Remark = m_Info_AdLoction.AP_Title + " [宽:" + m_Info_AdLoction.AP_WidePixels + ",高:" + m_Info_AdLoction.AP_HighPixels + "]"; if (bll_Info_AdBLL.InsertModel(m_Info_Ad)) JavaScript.MessageBox("预定成功", this); else JavaScript.MessageBox("预定失败", this); } } catch (Exception ex) { PAGEHandleException(ex); JavaScript.MessageBox("预定失败", this); } } //切换位置获取开始时间和结束时间 protected void changeLoctionGetTimeAndMoney(object sender, EventArgs e) { DateTime? LastedTime = DateTime.Now; Info_Ad m_Info_Ad = bll_Info_AdBLL.SelectListByAdLocationId(Keyid); if (m_Info_Ad != null && m_Info_Ad.A_EndTime != null) { LastedTime = m_Info_Ad.A_EndTime; } string startTimeString = LastedTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); string endTimeString = LastedTime.Value.AddMonths(1).ToString("yyyy-MM-dd HH:mm:ss"); this.spanStartTime.InnerText = startTimeString; this.spanEndTime.InnerText = endTimeString; this.selTimeChange.Items.Clear(); this.selTimeChange.Items.Add(new ListItem("一个月", "1")); this.selTimeChange.Items.Add(new ListItem("一季度", "3")); this.selTimeChange.Items.Add(new ListItem("半年", "6")); this.selTimeChange.Items.Add(new ListItem("一年", "12")); } //切换时长更新 protected void changeTimeGetStartAndEnd(object sender, EventArgs e) { DateTime? LastedTime = DateTime.Now; Info_Ad m_Info_Ad = bll_Info_AdBLL.SelectListByAdLocationId(Keyid); Info_AdLoction m_Info_AdLoction = bll_Info_AdLoctionBLL.SelectModelByKeyId(Keyid); if (m_Info_Ad != null && m_Info_Ad.A_EndTime != null) { LastedTime = m_Info_Ad.A_EndTime; } int nowTime = this.selTimeChange.SelectedValue.ToInt32() ?? 1; string startTimeString = LastedTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); string endTimeString = LastedTime.Value.AddMonths(nowTime).ToString("yyyy-MM-dd HH:mm:ss"); this.spanStartTime.InnerText = startTimeString; this.spanEndTime.InnerText = endTimeString; switch (nowTime) { case 1: this.spanPrice.InnerText = m_Info_AdLoction.Price_Month.Value.ToString("0").ToString2(); break; case 3: this.spanPrice.InnerText = m_Info_AdLoction.Price_Season.Value.ToString("0").ToString2(); break; case 6: this.spanPrice.InnerText = m_Info_AdLoction.Price_Half.Value.ToString("0").ToString2(); break; case 12: this.spanPrice.InnerText = m_Info_AdLoction.Price_Year.Value.ToString("0").ToString2(); break; default: this.spanPrice.InnerText = m_Info_AdLoction.Price_Month.Value.ToString("0").ToString2(); break; } } } }