using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CY.BLL; using CY.Model; using CY.Infrastructure.Query; using CY.Infrastructure.Common; using CY.BLL.Sys; using CY.BLL.OA; using CY.BLL.EC; using System.Drawing; namespace CY.WebForm.Pages.business { public partial class xiaoshouyejiReportList : BasePage { EC_OrderBLL bll_EC_OrderBLL = null; OA_StaffBLL bll_OA_StaffBLL = null; //初始化 public xiaoshouyejiReportList() { bll_EC_OrderBLL = new EC_OrderBLL(); bll_OA_StaffBLL = new OA_StaffBLL(); } protected void Page_Load(object sender, EventArgs e) { UCPager1.AspNetPager.PageChanged += AspNetPager1_PageChanged; if (!IsPostBack) { InitialSelectData(); BindList(); } } //加载查询条件 protected void InitialSelectData() { if (this.txtDeliveryTime.Value == "") { this.txtDeliveryTime.Value = "本周业绩"; } //业务经理 this.selBusinessManagerId.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, true, false); this.selBusinessManagerId.DataTextField = "Name"; this.selBusinessManagerId.DataValueField = "Keyid"; this.selBusinessManagerId.DataBind(); this.selBusinessManagerId.Items.Insert(0, new ListItem("全部", "")); } //绑定列表 private void BindList() { if (this.txtDeliveryTime.Value == "") { this.txtDeliveryTime.Value = this.Button0.Text; } if (this.txtDeliveryTime.Value == this.Button0.Text) { this.Button0.BorderColor = Color.Black; this.Button1.BorderColor = Color.LightBlue; this.Button2.BorderColor = Color.LightBlue; this.Button3.BorderColor = Color.LightBlue; this.Button4.BorderColor = Color.LightBlue; this.Button5.BorderColor = Color.LightBlue; } else if (this.txtDeliveryTime.Value == this.Button1.Text) { this.Button1.BorderColor = Color.Black; this.Button2.BorderColor = Color.LightBlue; this.Button3.BorderColor = Color.LightBlue; this.Button4.BorderColor = Color.LightBlue; this.Button5.BorderColor = Color.LightBlue; this.Button0.BorderColor = Color.LightBlue; } else if (this.txtDeliveryTime.Value == this.Button2.Text) { this.Button2.BorderColor = Color.Black; this.Button3.BorderColor = Color.LightBlue; this.Button4.BorderColor = Color.LightBlue; this.Button5.BorderColor = Color.LightBlue; this.Button0.BorderColor = Color.LightBlue; this.Button1.BorderColor = Color.LightBlue; } else if (this.txtDeliveryTime.Value == this.Button3.Text) { this.Button3.BorderColor = Color.Black; this.Button4.BorderColor = Color.LightBlue; this.Button5.BorderColor = Color.LightBlue; this.Button0.BorderColor = Color.LightBlue; this.Button1.BorderColor = Color.LightBlue; this.Button2.BorderColor = Color.LightBlue; } else if (this.txtDeliveryTime.Value == this.Button4.Text) { this.Button4.BorderColor = Color.Black; this.Button5.BorderColor = Color.LightBlue; this.Button0.BorderColor = Color.LightBlue; this.Button1.BorderColor = Color.LightBlue; this.Button2.BorderColor = Color.LightBlue; this.Button3.BorderColor = Color.LightBlue; } else if (this.txtDeliveryTime.Value == this.Button5.Text) { this.Button5.BorderColor = Color.Black; this.Button0.BorderColor = Color.LightBlue; this.Button1.BorderColor = Color.LightBlue; this.Button2.BorderColor = Color.LightBlue; this.Button3.BorderColor = Color.LightBlue; this.Button4.BorderColor = Color.LightBlue; } string chaxuntimestart = ""; string chaxuntimeend = ""; if (this.txtDeliveryTime.Value== "本周业绩") { 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.Value == "上周业绩") { 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.Value == "本月业绩") { 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.Value == "上月业绩") { 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.Value == "本年业绩") { 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.Value == "上年业绩") { 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"); } Pagination pa = new Pagination(); pa.PageSize = UCPager1.AspNetPager.PageSize; pa.PageIndex = UCPager1.AspNetPager.CurrentPageIndex; this.RepClientList.DataSource = bll_EC_OrderBLL.GetyewurenportList(pa, CurrentUser.MemberId, this.selBusinessManagerId.Value, chaxuntimestart, chaxuntimeend ); this.RepClientList.DataBind(); UCPager1.AspNetPager.RecordCount = pa.RecordCount; } //分页事件 protected void AspNetPager1_PageChanged(object src, EventArgs e) { BindList(); } //查询事件 protected void btn_Search_Click(object sender, EventArgs e) { BindList(); } protected void btn_Search_Click0(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button0.Text; BindList(); } protected void btn_Search_Click1(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button1.Text; BindList(); } protected void btn_Search_Click2(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button2.Text; BindList(); } protected void btn_Search_Click3(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button3.Text; BindList(); } protected void btn_Search_Click4(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button4.Text; BindList(); } protected void btn_Search_Click5(object sender, EventArgs e) { this.txtDeliveryTime.Value = this.Button5.Text; BindList(); } } }