for (int i = 0; i < Schedule.AL_Schedule1.Count; i++) {
if (((Schedule1)Schedule.AL_Schedule1[i]).IntDay == day && ((Schedule1)Schedule.AL_Schedule1[i]).IntMonth == month && ((Schedule1)Schedule.AL_Schedule1[i]).IntYear == year) {
if (((Schedule1)Schedule.AL_Schedule1[i]).StrImportant == \非常重要\ && ((Schedule1)Schedule.AL_Schedule1[i]).StrRemind == \提醒\) {
lb_Everyimportant1.Items.Add(((Schedule1)Schedule.AL_Schedule1[i]).StrTitle);
lb_Everyimportant1.Items.Add(((Schedule1)Schedule.AL_Schedule1[i]).IntHour + \时\ + ((Schedule1)Schedule.AL_Schedule1[i]).IntMinute + \分\); }
if (((Schedule1)Schedule.AL_Schedule1[i]).StrImportant == \重要\ && ((Schedule1)Schedule.AL_Schedule1[i]).StrRemind == \提醒\) {
lb_Important1.Items.Add(((Schedule1)Schedule.AL_Schedule1[i]).StrTitle);
lb_Important1.Items.Add(((Schedule1)Schedule.AL_Schedule1[i]).IntHour + \时\ + ((Schedule1)Schedule.AL_Schedule1[i]).IntMinute + \分\); }
if (((Schedule1)Schedule.AL_Schedule1[i]).StrImportant == \不重要\ && ((Schedule1)Schedule.AL_Schedule1[i]).StrRemind == \提醒\) {
lb_Unimportant1.Items.Add(((Schedule1)Schedule.AL_Schedule1[i]).StrTitle);
lb_Unimportant1.Items.Add(((Schedule1)Schedule.AL_Schedule1[i]).IntHour + \时\ + ((Schedule1)Schedule.AL_Schedule1[i]).IntMinute + \分\); } }
if ((((Schedule1)Schedule.AL_Schedule1[i]).IntDay - day) == 1 && ((Schedule1)Schedule.AL_Schedule1[i]).IntMonth == month && ((Schedule1)Schedule.AL_Schedule1[i]).IntYear == year) {
if (((Schedule1)Schedule.AL_Schedule1[i]).StrImportant == \非常重要\ && ((Schedule1)Schedule.AL_Schedule1[i]).StrRemind == \提醒\) {
lb_everyImportant2.Items.Add(((Schedule1)Schedule.AL_Schedule1[i]).StrTitle);
lb_everyImportant2.Items.Add(((Schedule1)Schedule.AL_Schedule1[i]).IntHour + \时\ + ((Schedule1)Schedule.AL_Schedule1[i]).IntMinute + \分\); }
if (((Schedule1)Schedule.AL_Schedule1[i]).StrImportant == \重要\ && ((Schedule1)Schedule.AL_Schedule1[i]).StrRemind == \提醒\) {
11
lb_Important2.Items.Add(((Schedule1)Schedule.AL_Schedule1[i]).StrTitle);
lb_Important2.Items.Add(((Schedule1)Schedule.AL_Schedule1[i]).IntHour + \时\ + ((Schedule1)Schedule.AL_Schedule1[i]).IntMinute + \分\); }
if (((Schedule1)Schedule.AL_Schedule1[i]).StrImportant == \不重要\ && ((Schedule1)Schedule.AL_Schedule1[i]).StrRemind == \提醒\) {
lb_Unmportant2.Items.Add(((Schedule1)Schedule.AL_Schedule1[i]).StrTitle);
lb_Unmportant2.Items.Add(((Schedule1)Schedule.AL_Schedule1[i]).IntHour + \时\ + ((Schedule1)Schedule.AL_Schedule1[i]).IntMinute + \分\); } } }
}
private void btn_close_Click(object sender, EventArgs e) {
this.Close(); } } }
3.6 查询,删除,修改代码:
using System;
using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System.Windows.Forms; using System.Collections;
namespace smartSchedule {
public partial class Schedule : Form {
public Schedule() {
InitializeComponent();
cbox_Del_Important2.SelectedItem = cbox_Del_Important2.Items[0]; cbox_Important1.SelectedItem = cbox_Important1.Items[0]; cbox_Remind1.SelectedItem = cbox_Remind1.Items[0]; }
public static Huanying h;
public static ArrayList AL_Schedule1 = new ArrayList(); int day, year, month, s, j = 1;
private void Schedule_Load(object sender, EventArgs e)
12
{
day = int.Parse(dateTimePicker1.Value.Day.ToString()); year = int.Parse(dateTimePicker1.Value.Year.ToString()); month = int.Parse(dateTimePicker1.Value.Month.ToString()); gbox_Change.Visible = false; gbox_Del.Visible = false; gbox_Time.Visible = false;
gbox_Important.Visible = false; h.Hide();
dgv_schedule.ColumnCount = 9;
dgv_schedule.ColumnHeadersVisible = true; dgv_schedule.Columns[0].Name = \日程量\; dgv_schedule.Columns[1].Name = \标题\; dgv_schedule.Columns[2].Name = \日期\; dgv_schedule.Columns[3].Name = \时间\; dgv_schedule.Columns[4].Name = \地点\;
dgv_schedule.Columns[5].Name = \联系电话\; dgv_schedule.Columns[6].Name = \重要性\; dgv_schedule.Columns[7].Name = \提醒\; dgv_schedule.Columns[8].Name = \备注\; dgv_schedule.Columns[0].Width = 80; dgv_schedule.Columns[7].Width = 110; dgv_schedule.Columns[8].Width = 180; //读取数据
string[] A_longPhone =
System.IO.File.ReadAllLines(\);
string[] A_intHour = System.IO.File.ReadAllLines(\); string[] A_intMinute =
System.IO.File.ReadAllLines(\); string[] A_strPlace =
System.IO.File.ReadAllLines(\); string[] A_strTitle =
System.IO.File.ReadAllLines(\); string[] A_strRemind =
System.IO.File.ReadAllLines(\); string[]
A_strImportant=System.IO.File.ReadAllLines(\); string[] A_strRemark =
System.IO.File.ReadAllLines(\);
string[] A_intDay = System.IO.File.ReadAllLines(\); string[] A_intYear = System.IO.File.ReadAllLines(\); string[] A_intMonth =
System.IO.File.ReadAllLines(\);
for (int i = 0; i < A_strTitle.Length; i++) {
Schedule1 sch = new Schedule1(); sch.StrTitle = A_strTitle[i]; sch.StrPlace = A_strPlace[i];
sch.StrImportant = A_strImportant[i]; sch.StrRemind = A_strRemind[i]; sch.StrRemark = A_strRemark[i];
sch.LongPhone = long.Parse(A_longPhone[i]); sch.IntDay = int.Parse(A_intDay[i]);
13
sch.IntYear = int.Parse(A_intYear[i]); sch.IntMonth = int.Parse(A_intMonth[i]); sch.IntHour = int.Parse(A_intHour[i]);
sch.IntMinute = int.Parse(A_intMinute[i]); Schedule.AL_Schedule1.Add(sch); }
//日程提醒
Remind remind = new Remind(); remind.ShowDialog(); }
//树状图功能选择
private void tv_schedule_AfterSelect(object sender, TreeViewEventArgs e)
{
nudown_Day.Value = day; //日程添加
if (e.Node.Text.Trim() == \添加\) {
gbox_Change.Visible = false; gbox_Del.Visible = false; gbox_Time.Visible = false;
gbox_Important.Visible = false; dgv_schedule.Visible = true; Form add = new Add(); add.ShowDialog(); }
//退出系统
if (e.Node.Text.Trim() == \退出系统\) {
DialogResult dr = MessageBox.Show(\您是否要保存并退出系统? \, \提示\, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.Yes) {
//数据储存
string[] B_longPhone = new string[AL_Schedule1.Count]; string[] B_intHour = new string[AL_Schedule1.Count]; string[] B_intMinute = new string[AL_Schedule1.Count]; string[] B_intDay = new string[AL_Schedule1.Count]; string[] B_intYear = new string[AL_Schedule1.Count]; string[] B_intMonth = new string[AL_Schedule1.Count]; string[] B_strPlace = new string[AL_Schedule1.Count]; string[] B_strTitle = new string[AL_Schedule1.Count]; string[] B_strRemind = new string[AL_Schedule1.Count]; string[] B_strImportant = new string[AL_Schedule1.Count]; string[] B_strRemark = new string[AL_Schedule1.Count]; for (int i = 0; i < AL_Schedule1.Count; i++) {
B_longPhone[i] =
(((Schedule1)AL_Schedule1[i]).LongPhone).ToString(); B_intHour[i] =
(((Schedule1)AL_Schedule1[i]).IntHour).ToString();
14
B_intMinute[i] =
(((Schedule1)AL_Schedule1[i]).IntMinute).ToString(); B_intDay[i] =
(((Schedule1)AL_Schedule1[i]).IntDay).ToString(); B_intYear[i] =
(((Schedule1)AL_Schedule1[i]).IntYear).ToString(); B_intMonth[i] =
(((Schedule1)AL_Schedule1[i]).IntMonth).ToString(); B_strImportant[i] = ((Schedule1)AL_Schedule1[i]).StrImportant; B_strPlace[i] = ((Schedule1)AL_Schedule1[i]).StrPlace; B_strRemark[i] = ((Schedule1)AL_Schedule1[i]).StrRemark; B_strRemind[i] = ((Schedule1)AL_Schedule1[i]).StrRemind; B_strTitle[i] = ((Schedule1)AL_Schedule1[i]).StrTitle; }
System.IO.File.WriteAllLines(\, B_longPhone);
System.IO.File.WriteAllLines(\, B_intDay); System.IO.File.WriteAllLines(\, B_intYear); System.IO.File.WriteAllLines(\, B_intMonth);
System.IO.File.WriteAllLines(\, B_intHour); System.IO.File.WriteAllLines(\, B_intMinute);
System.IO.File.WriteAllLines(\, B_strPlace);
System.IO.File.WriteAllLines(\, B_strTitle);
System.IO.File.WriteAllLines(\, B_strRemind);
System.IO.File.WriteAllLines(\, B_strImportant);
System.IO.File.WriteAllLines(\, B_strRemark);
Application.Exit(); }
else if (dr == DialogResult.No) {
Application.Exit(); } else {
return; } }
//按日期查询
if (e.Node.Text.Trim() == \按日期查询\) {
15