private void btnAdd_Click(object sender, EventArgs e) { string date = null; string time = null; string subject = null; string content = null; Schedule schedule = null; AddScheduleForm addScheduleDialog = new AddScheduleForm(); if (addScheduleDialog.ShowDialog(this) == DialogResult.OK) { date = addScheduleDialog.monthCalendar.SelectionStart.ToString("yyyy-MM-dd"); time = addScheduleDialog.comboBox_hour.Text + ":" + addScheduleDialog.comboBox_minute.Text; subject = addScheduleDialog.subject.Text; content = addScheduleDialog.content.Text; schedule = new Schedule(date, time, subject, content); this.schedules.Add(schedule.ToString(), schedule); updateListView(date,time); } else { } addScheduleDialog.Dispose(); }
public static Hashtable getSchedulesFromXML() { Hashtable schedules = new Hashtable(); XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.Load(FileName); XmlNodeList xschedules = xmlDoc.SelectSingleNode("schedules").ChildNodes; if (xschedules != null) { foreach (XmlNode xschedule in xschedules) { string date = xschedule.SelectSingleNode("date").InnerText; string time = xschedule.SelectSingleNode("time").InnerText; string subject = xschedule.SelectSingleNode("subject").InnerText; string content = xschedule.SelectSingleNode("content").InnerText; Schedule s = new Schedule(date, time, subject, content); try { schedules.Add(s.ToString(), s); } catch (ArgumentException) { } } } } catch (FileNotFoundException) { //MessageBox.Show("Cannot open file\n" + e.Message); } return schedules; }
private void btnAlter_Click(object sender, EventArgs e) { string date = null; string time = null; string subject = null; string content = null; Schedule schedule = null; ModifyScheduleForm dia = new ModifyScheduleForm(); if (listViewAgendaTable.SelectedItems.Count == 0) { MessageBox.Show("请在列表框中选择日程然后修改。"); } foreach (ListViewItem item in listViewAgendaTable.SelectedItems) { date = item.Text; time = item.SubItems[1].Text; subject = item.SubItems[2].Text; schedule = new Schedule(date, time, subject, ""); schedule = (Schedule)schedules[schedule.ToString()]; dia.monthCalendar.SelectionStart = DateTime.ParseExact(schedule.getYear()+schedule.getMonth()+schedule.getDay(),"yyyyMMdd",null); dia.comboBox_hour.Text = schedule.getHour(); dia.comboBox_minute.Text = schedule.getMinute(); ; dia.subject.Text = schedule.subject; dia.content.Text = schedule.content; if (dia.ShowDialog(this) == DialogResult.OK) { schedules.Remove(schedule.ToString()); date = dia.monthCalendar.SelectionStart.ToString("yyyy-MM-dd"); time = dia.comboBox_hour.Text + ":" + dia.comboBox_minute.Text; subject = dia.subject.Text; content = dia.content.Text; schedule = new Schedule(date, time, subject, content); this.schedules.Add(schedule.ToString(), schedule); updateListView(date,time); this.richTBAgenda.Text = content; } else { } dia.Dispose(); } }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { string date = null; string time = null; string subject = null; Schedule schedule; richTBAgenda.Text = ""; foreach (ListViewItem item in listViewAgendaTable.SelectedItems) { date = item.Text; time = item.SubItems[1].Text; subject = item.SubItems[2].Text; } if (date!=null && time!=null && subject!=null) { schedule = new Schedule(date, time, subject, ""); schedule = (Schedule)schedules[schedule.ToString()]; if (schedule != null) { richTBAgenda.Text = schedule.content; } } }
private void btnDelete_Click(object sender, EventArgs e) { string date = null; string time = null; string subject = null; Schedule schedule = null; foreach (ListViewItem item in listViewAgendaTable.SelectedItems) { date = item.Text; time = item.SubItems[1].Text; subject = item.SubItems[2].Text; schedule = new Schedule(date, time, subject, ""); schedule = (Schedule)schedules[schedule.ToString()]; schedules.Remove(schedule.ToString()); updateListView(date,time); this.richTBAgenda.Text = ""; } }