• 小组冲刺周以及后续完成内容总结


    1.课程表框架的构建:

               

    2.项目输入框架的构建:

             

    3.通过算法的构建判断当前是开学第几周

         1)代码:

            public static int Excute(DateTime dTime)
            {
                try
                {
                    //确定此时间在一年中的位置
                    var dayOfYear = dTime.DayOfYear;
                    //本学期第一天
                    var tempDate = new DateTime(dTime.Year, 1, 1);
                    //确定第一天
                    var tempDayOfWeek = (int)tempDate.DayOfWeek;
                    tempDayOfWeek = tempDayOfWeek == 0 ? 7 : tempDayOfWeek;
                    //确定星期几
                    var index = (int)dTime.DayOfWeek;
                    index = index == 0 ? 7 : index;
                    //当前周的范围
                    DateTime retStartDay = dTime.AddDays(-(index - 1));
                    DateTime retEndDay = dTime.AddDays(7 - index);
                    //确定当前是第几周
                    var weekIndex = (int)Math.Ceiling(((double)dayOfYear + tempDayOfWeek - 1) / 7);
                    if (retStartDay.Year < retEndDay.Year)
                    {
                        weekIndex = 1;
                    }
                    return weekIndex;
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        
    
    
            private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
            {
                dateTimePicker2.Visible = false;
                button2.Visible = false;
                label3.Visible = false;
               DateTime dt = DateTime.Parse(dateTimePicker2.Text);  //获取当前时间
                DateTime date = DateTime.Parse(dateTimePicker1.Text);
                string hours = date.Hour.ToString();
                string minute = date.Minute.ToString();
                string second = date.Second.ToString();
                int zhoushu = Excute(date);
                int zhoushu1 = Excute(dt);
                MessageBox.Show("本周是开学后第" + Convert.ToString(zhoushu - zhoushu1+1)+"");
                label2.Visible = true;
                label2.Text = "" + Convert.ToString(zhoushu - zhoushu1 + 1) + "";
            }

    2)运行结果截图:

           

          

         

  • 相关阅读:
    Hadoop-03 基于Hadoop的JavaEE数据可视化简易案例(升级使用HBase存储结果集)
    Hadoop-02 基于Hadoop的JavaEE数据可视化简易案例
    Python03 变量
    Python01 VSCode开发环境和入门程序
    MyBatis01 Idea中搭建MyBatis开发环境
    Idea01 Idea2018中集成Tomcat9导致OutPut乱码
    MySQL-08 MySQL8.0新特性
    C11 C语言文件的读写
    C10 C语言数据结构
    C09 指针
  • 原文地址:https://www.cnblogs.com/qiyuea/p/10040711.html
Copyright © 2020-2023  润新知