Esempio n. 1
0
        /// <summary>
        /// 对ListView1进行set操作
        /// </summary>
        /// <param name="week"></param>
        /// <param name="dayOfWeek"></param>
        public void SetListView1(int week, int dayOfWeek)
        {
            ClassTool     classTool = new ClassTool();
            List <Course> courses0  = classTool.GetOrderedCourses(courses[dayOfWeek]);
            List <Course> courses1  = new List <Course>();

            foreach (Course a in courses0)
            {
                if (classTool.IfHaveClass(a, week))
                {
                    courses1.Add(a);
                }
            }

            this.listView1.BeginUpdate();
            for (int i = 0; i < courses1.Count; i++)
            {
                ListViewItem lvi = new ListViewItem();
                lvi.Text = Convert.ToString(courses1[i].name);
                lvi.SubItems.Add(classTool.GetClassroom(courses1[i]));
                lvi.SubItems.Add(courses1[i].teacher);
                lvi.SubItems.Add(classTool.GetClassTime(courses1[i]));
                this.listView1.Items.Add(lvi);
            }
            this.listView1.EndUpdate();
        }
Esempio n. 2
0
        private void SetDateLabel()
        {
            ClassTool classTool = new ClassTool();

            if (dayComboBox.SelectedIndex == 0)
            {
                dateLabel.Text = classTool.startDay.AddDays((weekComboBox.SelectedIndex) * 7 + 6).ToString("yyyy/MM/dd");
            }
            else
            {
                dateLabel.Text = classTool.startDay.AddDays((weekComboBox.SelectedIndex) * 7 + (dayComboBox.SelectedIndex - 1)).ToString("yyyy/MM/dd");
            }
        }
Esempio n. 3
0
        public MainFrm()
        {
            InitializeComponent();
            ClassTool classTool = new ClassTool();
            int       thisWeek  = classTool.GetThisWeek();
            int       dayOfWeek = classTool.GetDayOfWeek();

            courses = GetCourses();
            weekComboBox.SelectedIndexChanged -= new EventHandler(weekComboBox_SelectedIndexChanged);
            dayComboBox.SelectedIndexChanged  -= new EventHandler(dayComboBox_SelectedIndexChanged);
            weekComboBox.SelectedIndex         = thisWeek - 1;
            dayComboBox.SelectedIndex          = dayOfWeek;
            weekComboBox.SelectedIndexChanged += new EventHandler(weekComboBox_SelectedIndexChanged);
            dayComboBox.SelectedIndexChanged  += new EventHandler(dayComboBox_SelectedIndexChanged);
            SetListView1(thisWeek, dayOfWeek);
            SetDateLabel();

            //载入所有事件到sheduleService
            foreach (string dt in evtDb.getAllDate())
            {
                Schedule schedule = new Schedule(dt);
                foreach (Event evt in evtDb.GetEvents(dt))
                {
                    if (evtDb.GetEvents(dt).Count > 0)
                    {
                        schedule.AddEvents(evt);
                    }
                }
                s.AddSchedule(schedule);
            }
            //载入当天事件显示在listview上
            date = DateTime.Now;
            Schedule sch;

            if (s.GetByDate(date.ToShortDateString()) != null)
            {
                sch = s.GetByDate(date.ToShortDateString());
            }
            else
            {
                sch = new Schedule(date.ToShortDateString());
                s.AddSchedule(sch);
            }
            SetListView2(sch.Events);

            eventDetails = db.GetEventDetails();
            SetListView3(eventDetails);
        }