Esempio n. 1
0
        /// <summary>
        /// 实现鼠标悬停在ListView上显示相关信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listView1_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e)
        {
            ToolTip toolTip = new ToolTip();

            string itemInfor =
                "课程名称:" + e.Item.Text + "\n" +
                "上课教室:" + e.Item.SubItems[1].Text + "\n" +
                "任课老师:" + e.Item.SubItems[2].Text + "\n" +
                "其他安排:" + "\n";

            List <EventDetails> eventDetails = db.GetEventDetails(e.Item.Text);

            eventDetails = eventDetails.OrderBy(ed => Calculated.Calculate(ed.createTime.Year, ed.createTime.Month, ed.createTime.Day)).ToList();
            foreach (var a in eventDetails)
            {
                string   rstStr = "距离:";
                DateTime dt     = a.createTime;
                int      year   = dt.Year;
                int      month  = dt.Month;
                int      day    = dt.Day;
                int      count  = Calculated.Calculate(year, month, day);
                rstStr += a.eventName;
                if (count >= 0)
                {
                    rstStr += "还有" + Convert.ToString(count) + "天\n";
                }
                else
                {
                    rstStr = a.eventName + "时间已过\n";
                }
                itemInfor += rstStr;
            }
            toolTip.SetToolTip((e.Item).ListView, itemInfor);
        }
Esempio n. 2
0
        /// <summary>
        /// 对ListView3进行SET
        /// </summary>
        /// <param name="eventDetails"></param>
        public void SetListView3(List <EventDetails> eventDetails)
        {
            this.listView3.BeginUpdate();
            eventDetails = eventDetails.OrderBy(ed => Calculated.Calculate(ed.createTime.Year, ed.createTime.Month, ed.createTime.Day)).ToList();
            for (int i = 0; i < eventDetails.Count; i++)
            {
                int      count = 0;
                DateTime dt    = eventDetails[i].createTime;
                int      year  = dt.Year;
                int      month = dt.Month;
                int      day   = dt.Day;
                count = Calculated.Calculate(year, month, day);
                ListViewItem lvi = new ListViewItem();
                lvi.Text = "距离" + eventDetails[i].courseName + eventDetails[i].eventName;

                if (count > 0)
                {
                    lvi.SubItems.Add("还有" + Convert.ToString(count) + "天");
                }
                else if (count == 0)
                {
                    lvi.SubItems.Add("今日任务");
                }
                else
                {
                    lvi.SubItems.Add("已过期");
                }
                lvi.SubItems.Add(Convert.ToString(eventDetails[i].eventId));
                this.listView3.Items.Add(lvi);
            }
            this.listView3.EndUpdate();
        }
Esempio n. 3
0
 private void submitButton_Click(object sender, EventArgs e)
 {
     if (listNumber == 1)
     {
         string       detail       = detailTextBox.Text;
         DateTime     date         = DateTime.Parse(dateTime.Text);
         EventDb      db           = new EventDb();
         EventDetails eventDetails = new EventDetails();
         eventDetails.eventName  = detail;
         eventDetails.createTime = date;
         eventDetails.courseName = className;
         db.AddEvent(eventDetails);
         mainFrm.eventDetails = mainFrm.db.GetEventDetails();
         mainFrm.listView3.Items.Clear();
         mainFrm.SetListView3(mainFrm.eventDetails);
         this.Dispose();
     }
     else if (listNumber == 3)
     {
         if (detailTextBox.Text == "")
         {
             MessageBox.Show("请设置事件!");
             return;
         }
         else
         {
             DateTime dt    = DateTime.Parse(this.dateTime.Text);
             int      year  = dt.Year;
             int      month = dt.Month;
             int      day   = dt.Day;
             int      count = Calculated.Calculate(year, month, day);
             if (count < 0)
             {
                 MessageBox.Show("抱歉,日期选择出错!");
             }
             else
             {
                 EventDetails ev = new EventDetails();
                 ev.eventName  = detailTextBox.Text;
                 ev.createTime = dt;
                 ev.courseName = "";
                 mainFrm.db.AddEvent(ev);
                 mainFrm.eventDetails = mainFrm.db.GetEventDetails();
                 mainFrm.listView3.Items.Clear();
                 mainFrm.SetListView3(mainFrm.eventDetails);
                 this.Dispose();
                 return;
             }
         }
     }
 }
Esempio n. 4
0
        private void updataButton_Click(object sender, EventArgs e)
        {
            eventDetails = db.GetEventDetails();
            var query = eventDetails.Where(ed => Calculated.Calculate(ed.createTime.Year, ed.createTime.Month, ed.createTime.Day) <= 0);
            List <EventDetails> unEventDetails = query.ToList();

            for (int i = 0; i < unEventDetails.Count; i++)
            {
                db.deleteEvent(unEventDetails[i]);
                eventDetails.Remove(unEventDetails[i]);
            }
            listView3.Items.Clear();
            SetListView3(eventDetails);
            return;
        }
Esempio n. 5
0
        private void submitEditButton_Click(object sender, EventArgs e)
        {
            DateTime dt    = DateTime.Parse(dateTime.Text);
            int      year  = dt.Year;
            int      month = dt.Month;
            int      day   = dt.Day;
            int      count = Calculated.Calculate(year, month, day);

            if (count <= 0)
            {
                MessageBox.Show("抱歉,日期选择出错!");
            }
            else
            {
                ed.eventName  = detailTextBox.Text;
                ed.createTime = dt;
                mainFrm.db.edit(ed);
                MessageBox.Show("修改成功!");
                mainFrm.eventDetails = mainFrm.db.GetEventDetails();
                mainFrm.listView3.Items.Clear();
                mainFrm.SetListView3(mainFrm.eventDetails);
            }
            this.Close();
        }