Exemplo n.º 1
0
        private void BindRepeater()
        {
            int      recordCount;
            DateTime startDate;

            if (!DateTime.TryParse(txtStartDate.Text, out startDate)) //如果没有填时间,就当前时间减一个星期
            {
                startDate = DateTime.Now.AddDays(-7);
            }

            DateTime endDate;

            if (!DateTime.TryParse(txtEndDate.Text, out endDate))
            {
                endDate = DateTime.Now.AddDays(7);
            }
            List <WeekPlanEntity> list =
                new App.WeekPlanApplication().GetList(int.Parse(ddlUsers.SelectedValue), startDate, endDate, UserInfo.Role, aspNetPager1.CurrentPageIndex, aspNetPager1.PageSize, out recordCount);

            if (recordCount == 0)
            {
                lblNoResult.Visible   = true;
                lblNoResult.InnerHtml = "<span style='color: Red;'>&nbsp; No records</span>";
                rptList.DataSource    = null;
                rptList.DataBind();
            }
            else
            {
                lblNoResult.Visible = false;
                rptList.DataSource  = list;
                rptList.DataBind();
            }
            aspNetPager1.RecordCount = recordCount;
        }
Exemplo n.º 2
0
        private void BindRepeater(string date)
        {
            int      recordCount;
            DateTime startDate;
            DateTime endDate;

            if (!DateTime.TryParse(date, out startDate))
            {
                int weekOfDay = (int)DateProvider.DayOfWeek;
                weekOfDay = weekOfDay == 0 ? 7 : weekOfDay;
                startDate = DateProvider.AddDays(1 - weekOfDay);
            }
            else
            {
                int weekOfDay = (int)startDate.DayOfWeek;
                weekOfDay = weekOfDay == 0 ? 7 : weekOfDay;
                startDate = startDate.AddDays(1 - weekOfDay);
            }
            endDate           = startDate.AddDays(6);
            lblStartDate.Text = startDate.ToString("MM/dd/yyyy");
            lblEndDate.Text   = endDate.ToString("MM/dd/yyyy");

            List <WeekPlanEntity> list =
                new App.WeekPlanApplication().GetList(QS("user", 0), startDate, endDate, UserInfo.Role, CurrentPageIndex, int.MaxValue, out recordCount);


            DateTime.Parse(DateProvider.ToShortDateString());
            if (DateTime.Parse(DateProvider.ToShortDateString()) >= DateTime.Parse(startDate.ToShortDateString()) &&
                DateTime.Parse(DateProvider.ToShortDateString()) <= DateTime.Parse(endDate.ToShortDateString()))
            {
                weekDay = (int)DateProvider.DayOfWeek;
            }
            StringBuilder headHtml = new StringBuilder();

            headHtml.AppendFormat("<td >&nbsp;</td>");
            headHtml.AppendFormat("<td width='10%'><strong>Total Remaining &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hour</strong></td>");
            headHtml.AppendFormat("<td width='13%' class='{1}'><strong>Monday</strong> {0}</td>", startDate.ToString("MM/dd"), weekDay == 1 ? "wpitemtoday" : "");
            headHtml.AppendFormat("<td width='13%' class='{1}'><strong>Tuesday</strong> {0}</td>", startDate.AddDays(1).ToString("MM/dd"), weekDay == 2 ? "wpitemtoday" : "");
            headHtml.AppendFormat("<td width='13%' class='{1}'><strong>Wednesday</strong> {0}</td>", startDate.AddDays(2).ToString("MM/dd"), weekDay == 3 ? "wpitemtoday" : "");
            headHtml.AppendFormat("<td width='13%' class='{1}'><strong>Thursday</strong> {0}</td>", startDate.AddDays(3).ToString("MM/dd"), weekDay == 4 ? "wpitemtoday" : "");
            headHtml.AppendFormat("<td width='13%' class='{1}'><strong>Friday</strong> {0}</td>", startDate.AddDays(4).ToString("MM/dd"), weekDay == 5 ? "wpitemtoday" : "");
            headHtml.AppendFormat("<td width='13%' class='{1}'><strong>Saturday</strong> {0}</td>", startDate.AddDays(5).ToString("MM/dd"), weekDay == 6 ? "wpitemtoday" : "");
            headHtml.AppendFormat("<td width='13%' class='{1}'><strong>Sunday</strong> {0}</td>", startDate.AddDays(6).ToString("MM/dd"), weekDay == 0 ? "wpitemtoday" : "");
            dvHead.InnerHtml = headHtml.ToString();
            if (recordCount == 0)
            {
                trNoRecords.Visible = true;
                rptList.DataSource  = null;
                rptList.DataBind();
            }
            else
            {
                trNoRecords.Visible = false;
                rptList.DataSource  = list.OrderBy(e => e.FirstName);
                rptList.DataBind();
            }
        }