CB2-20200827ONU\Administrator
2021-10-08 7992fcc44d231e823736fd36483bf990a28b0536
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
195
196
197
198
199
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL.EC;
using CY.Infrastructure.Common;
using CY.Model;
using CY.BLL;
using CY.Model.Inquiry;
using CY.BLL.Sys;
using CY.Infrastructure.Query;
 
namespace CY.WebForm.Pages.business
{
    public partial class xiaoshouyejiReportPrint : BasePage
    {
        EC_OrderBLL bll_EC_OrderBLL = new EC_OrderBLL();
 
        string txtDeliveryTime = "";
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                switch (Request["Target"])
                {
                    case "GetCommunication":
                        break;
                    case "print":
                        break;
                    default:
                        Page_Load_Default();
                        return;
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                Response.Clear();
                Response.Write("-1");
            }
            Response.End();
        }
 
 
        /// <summary>
        /// 默认加载事件方法
        /// </summary>
        private void Page_Load_Default()
        {
            
            if (string.IsNullOrEmpty(Request["txtDeliveryTime"]))
            {
                JavaScript.MessageBox("必须填写查询时间", this);
                return;
            }
 
            LoadOrderInfo();
        }
 
        /// <summary>
        /// 加载订单信息
        /// </summary>
        private bool LoadOrderInfo()
        {
 
 
 
            txtDeliveryTime = Request["txtDeliveryTime"] == null ? "" : Request["txtDeliveryTime"];
 
 
 
            string selBusinessManagerId = Request["selBusinessManagerId"] == null ? "" : Request["selBusinessManagerId"];
 
 
            string chaxuntimestart = "";
            string chaxuntimeend = "";
 
            if (this.txtDeliveryTime == "本周业绩")
            {
                DateTime nowTime = DateTime.Now;
                #region 获取本周第一天
                //星期一为第一天  
                int weeknow = Convert.ToInt32(nowTime.DayOfWeek);
 
                //因为是以星期一为第一天,所以要判断weeknow等于0时,要向前推6天。  
                weeknow = (weeknow == 0 ? (7 - 1) : (weeknow - 1));
                int daydiff = (-1) * weeknow;
 
                //本周第一天  
                DateTime FirstDay = nowTime.AddDays(daydiff);
                #endregion
 
                #region 获取本周最后一天
                //星期天为最后一天  
                int lastWeekDay = Convert.ToInt32(nowTime.DayOfWeek);
                lastWeekDay = lastWeekDay == 0 ? (7 - lastWeekDay) : lastWeekDay;
                int lastWeekDiff = (7 - lastWeekDay);
 
                //本周最后一天  
                DateTime LastDay = nowTime.AddDays(lastWeekDiff);
 
                #endregion
                chaxuntimestart = FirstDay.ToString("yyyy-MM-dd");
                chaxuntimeend = LastDay.ToString("yyyy-MM-dd");
 
            }
            else if (this.txtDeliveryTime == "上周业绩")
            {
                DateTime nowTime = DateTime.Now.AddDays(-7);
                #region 获取本周第一天
                //星期一为第一天  
                int weeknow = Convert.ToInt32(nowTime.DayOfWeek);
 
                //因为是以星期一为第一天,所以要判断weeknow等于0时,要向前推6天。  
                weeknow = (weeknow == 0 ? (7 - 1) : (weeknow - 1));
                int daydiff = (-1) * weeknow;
 
                //本周第一天  
                DateTime FirstDay = nowTime.AddDays(daydiff);
                #endregion
 
                #region 获取本周最后一天
                //星期天为最后一天  
                int lastWeekDay = Convert.ToInt32(nowTime.DayOfWeek);
                lastWeekDay = lastWeekDay == 0 ? (7 - lastWeekDay) : lastWeekDay;
                int lastWeekDiff = (7 - lastWeekDay);
 
                //本周最后一天  
                DateTime LastDay = nowTime.AddDays(lastWeekDiff);
 
                #endregion
                chaxuntimestart = FirstDay.ToString("yyyy-MM-dd");
                chaxuntimeend = LastDay.ToString("yyyy-MM-dd");
            }
            else if (this.txtDeliveryTime == "本月业绩")
            {
                chaxuntimestart = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.ToString("yyyy-MM-dd");
 
                chaxuntimeend = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
 
            }
            else if (this.txtDeliveryTime == "上月业绩")
            {
                chaxuntimestart = DateTime.Now.AddMonths(-1).AddDays(1 - DateTime.Now.Day).Date.ToString("yyyy-MM-dd");
 
                chaxuntimeend = DateTime.Now.AddMonths(-1).AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
            }
            else if (this.txtDeliveryTime == "本年业绩")
            {
                DateTime dt = DateTime.Now;
                //本年第一天  
                chaxuntimestart = new DateTime(dt.Year, 1, 1).ToString("yyyy-MM-dd");
                chaxuntimeend = new DateTime(dt.Year, 12, 31).ToString("yyyy-MM-dd");
            }
            else if (this.txtDeliveryTime == "上年业绩")
            {
                DateTime dt = DateTime.Now.AddYears(-1);
                //本年第一天  
                chaxuntimestart = new DateTime(dt.Year, 1, 1).ToString("yyyy-MM-dd");
                chaxuntimeend = new DateTime(dt.Year, 12, 31).ToString("yyyy-MM-dd");
            }
 
 
 
 
 
            Infrastructure.Query.Pagination pagination = new Infrastructure.Query.Pagination()
            {
                PageSize = 1000,
                PageIndex = 1
            };
 
 
 
            this.rptOrder.DataSource = bll_EC_OrderBLL.GetyewurenportList(pagination,
               CurrentUser.MemberId,
 
               selBusinessManagerId,
               chaxuntimestart,
               chaxuntimeend
              );
            this.rptOrder.DataBind();
 
 
 
 
 
 
            return true;
        }
    }
}