1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
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;
            }
        }
    }
}