• 按周查询报表


       
     按周查询报表,获取开始和截止时间


    aspx页面

       &nbsp;&nbsp;按周查询:&nbsp;<asp:DropDownList ID="drpYear2" runat="server" AutoPostBack="True" OnSelectedIndexChanged="drpYear2_SelectedIndexChanged"></asp:DropDownList> <asp:DropDownList ID="drpWeek" runat="server"></asp:DropDownList>                                 
                                <asp:Button ID="btnAdvancedSearchConfirm2" runat="server" OnClick="btnAdvancedSearchConfirm2_Click"
                                    Text="【查询】"  CssClass="submit"/>

     //获取开始和截止时间
     DateTime beginTime ;
            DateTime endTime ;
            string[] arr = StringHelper.SplitString(drpWeek.SelectedValue, "#");
            beginTime = DataConverter.StrToDateTime(arr[0], DateTime.Now);
            endTime = DataConverter.StrToDateTime(arr[1], DateTime.Now);


        private void drpYear_DataBind()
        {
            for (int min = DateTime.Now.Year - 10; min <= DateTime.Now.Year; min++)
            {
                ListItem item = new ListItem(min.ToString());
                drpYear.Items.Add(item);
                drpYear2.Items.Add(item);
            }
            drpYear.SelectedValue = DateTime.Now.Year.ToString();
            drpYear2.SelectedValue = DateTime.Now.Year.ToString();
        }

        private void drpWeek_DataBind()
        {
            drpWeek.Items.Clear();
            DateTime beginTime = DataConverter.StrToDateTime(string.Format("{0}-1-1", drpYear2.SelectedValue), DateTime.Now.Date);
            DateTime endTime = beginTime.AddYears(1).AddSeconds(-1).Date;
            int dayOfWeek = (int) beginTime.DayOfWeek;
            if(dayOfWeek == 0)
                dayOfWeek = 7;
            beginTime = beginTime.AddDays((8 - dayOfWeek) % 7);

            dayOfWeek = (int)endTime.DayOfWeek;
            if (dayOfWeek == 0)
                dayOfWeek = 7;
            endTime = endTime.AddDays(7 - dayOfWeek);

            for (DateTime i = beginTime; i <= endTime;)
            {
                DateTime endOfWeek = i.Date.AddDays(6);
                ListItem item = new ListItem(string.Format("{0}至{1}", i.Date.ToString("MM-dd"), endOfWeek.Date.ToString("MM-dd")), string.Format("{0}#{1}", i.Date.ToString("yyyy-MM-dd"), endOfWeek.Date.ToString("yyyy-MM-dd")));
                drpWeek.Items.Add(item);
                i = endOfWeek.Date.AddDays(1);
            }
        }

        protected void drpYear2_SelectedIndexChanged(object sender, EventArgs e)
        {
            drpWeek_DataBind();
        }
     

  • 相关阅读:
    为什么包含多句代码的宏要用do while包括起来?
    Android之JUnit深入浅出
    android unit test
    dlopen,dlsym的问题,实在搞不明白了。
    pthread多线程学习笔记五条件变量2使用
    posix多线程程序使用条件变量的一个常见bug
    Android Bitmap和Canvas学习笔记
    c++filt
    pthread_cond_signal只能唤醒已经处于pthread_cond_wait的线程
    百度知道推广技巧大全
  • 原文地址:https://www.cnblogs.com/059212315/p/1679726.html
Copyright © 2020-2023  润新知