Beispiel #1
0
        public Item(GroupPlanItem group, PlanItem item, DateTime today)
        {
            InitializeComponent();
            this.group         = group;
            this.item          = item;
            this.title.Text    = item.title;
            this.location.Text = item.location;
            if (today.Day == item.startTime.Day && today.Month == item.startTime.Month && today.Year == item.startTime.Year)
            {
                this.startTime.Text = item.startTime.Hour.ToString("00.##") + ":" + item.startTime.Minute.ToString("00.##");
            }
            else
            {
                this.startTime.Text = "00:00";
            }

            if (today.Day == item.endTime.Day && today.Month == item.endTime.Month && today.Year == item.endTime.Year)
            {
                this.endTime.Text = item.endTime.Hour.ToString("00.##") + ":" + item.endTime.Minute.ToString("00.##");
            }
            else
            {
                this.endTime.Text = "23:59";
            }
        }
Beispiel #2
0
        public EditEvent(PlanData planData, GroupPlanItem group, PlanItem item)
            :
            base(planData)
        {
            InitializeComponent();

            this.group         = group;
            this.item          = item;
            this.title.Text    = item.title;
            this.location.Text = item.location;
            this.notes.Text    = item.note;

            this.Day_Start.Text    = item.startTime.Day.ToString();
            this.Month_Start.Text  = item.startTime.Month.ToString();
            this.Year_Start.Text   = item.startTime.Year.ToString();
            this.Hour_Start.Text   = item.startTime.Hour.ToString();
            this.Minute_Start.Text = item.startTime.Minute.ToString();

            this.Day_End.Text    = item.endTime.Day.ToString();
            this.Month_End.Text  = item.endTime.Month.ToString();
            this.Year_End.Text   = item.endTime.Year.ToString();
            this.Hour_End.Text   = item.endTime.Hour.ToString();
            this.Minute_End.Text = item.endTime.Minute.ToString();

            this.Repeat.SelectedIndex = group.repeatKind;
            if (group.repeatKind == 5)
            {
                repeatValue.Text = group.repeatValue.ToString();
            }

            this.Day_RepeatEnd.Text   = group.repeatEnd.Day.ToString();
            this.Month_RepeatEnd.Text = group.repeatEnd.Month.ToString();
            this.Year_RepeatEnd.Text  = group.repeatEnd.Year.ToString();

            this.priority.SelectedIndex = (int)item.priority;

            TimeSpan ts = item.startTime - item.alert;

            if (ts.Hours == 1)
            {
                this.alert.SelectedIndex = 0;
            }
            else if (ts.Minutes == 30)
            {
                this.alert.SelectedIndex = 1;
            }
            else if (ts.Minutes == 15)
            {
                this.alert.SelectedIndex = 2;
            }
            else
            {
                this.alert.SelectedIndex = 3;
            }
        }
Beispiel #3
0
 public void Delete(GroupPlanItem item)
 {
     group.Remove(item);
 }
Beispiel #4
0
        public virtual void SaveButton_Click(object sender, EventArgs e)
        {
            TimeSpan alertTimeSpane = new TimeSpan();

            if (alert.SelectedIndex == 0)
            {
                alertTimeSpane = new TimeSpan(1, 0, 0);
            }
            else if (alert.SelectedIndex == 1)
            {
                alertTimeSpane = new TimeSpan(0, 30, 0);
            }
            else if (alert.SelectedIndex == 2)
            {
                alertTimeSpane = new TimeSpan(0, 15, 0);
            }
            else if (alert.SelectedIndex == 3)
            {
                alertTimeSpane = new TimeSpan(0, 0, 0);
            }

            GroupPlanItem newGroup = new GroupPlanItem();

            int tDay_Start, tMonth_Start, tYear_Start, tHour_Start, tMinute_Start;

            Int32.TryParse(Day_Start.Text, out tDay_Start);
            Int32.TryParse(Month_Start.Text, out tMonth_Start);
            Int32.TryParse(Year_Start.Text, out tYear_Start);
            Int32.TryParse(Hour_Start.Text, out tHour_Start);
            Int32.TryParse(Minute_Start.Text, out tMinute_Start);
            if (CheckLegitDate(tYear_Start, tMonth_Start, tDay_Start) == false)
            {
                MessageBox.Show("Invalid Start Date");
                return;
            }
            DateTime start = new DateTime(tYear_Start, tMonth_Start, tDay_Start, tHour_Start, tMinute_Start, 0);

            int tDay_End, tMonth_End, tYear_End, tHour_End, tMinute_End;

            Int32.TryParse(Day_End.Text, out tDay_End);
            Int32.TryParse(Month_End.Text, out tMonth_End);
            Int32.TryParse(Year_End.Text, out tYear_End);
            Int32.TryParse(Hour_End.Text, out tHour_End);
            Int32.TryParse(Minute_End.Text, out tMinute_End);
            if (CheckLegitDate(tYear_End, tMonth_End, tDay_End) == false)
            {
                MessageBox.Show("Invalid End Date");
                return;
            }
            DateTime end = new DateTime(tYear_End, tMonth_End, tDay_End, tHour_End, tMinute_End, 0);

            if (end <= start)
            {
                MessageBox.Show("End Day must after Start Day");
                return;
            }

            ////////////////////////////////////////////////////////////////
            ///
            // FOR NONE //
            if (Repeat.Text.ToString() == "None")
            {
                newGroup.repeatKind = 0;
                newGroup.Insert(new PlanItem(title.Text, notes.Text, start, end, priority.SelectedIndex, start - alertTimeSpane, location.Text));
                thisPlan.Insert(newGroup);
                this.Close();
                return;
            }

            int tDay_RepeatEnd, tMonth_RepeatEnd, tYear_RepeatEnd;

            Int32.TryParse(Day_RepeatEnd.Text, out tDay_RepeatEnd);
            Int32.TryParse(Month_RepeatEnd.Text, out tMonth_RepeatEnd);
            Int32.TryParse(Year_RepeatEnd.Text, out tYear_RepeatEnd);
            if (CheckLegitDate(tYear_RepeatEnd, tMonth_RepeatEnd, tDay_RepeatEnd) == false)
            {
                MessageBox.Show("Invalid RepeatEnd Date");
                return;
            }
            DateTime repeatEnd = new DateTime(tYear_RepeatEnd, tMonth_RepeatEnd, tDay_RepeatEnd, 23, 59, 59);

            if (repeatEnd < end)
            {
                MessageBox.Show("The end for Repeat end must after the end of event");
                return;
            }

            newGroup.repeatEnd = repeatEnd;

            if (Repeat.Text.ToString() == "Daily")
            {
                newGroup.repeatKind = 1;
                while (true)
                {
                    newGroup.Insert(new PlanItem(title.Text, notes.Text, start, end, priority.SelectedIndex, start - alertTimeSpane, location.Text));

                    start = start.AddDays(1);
                    end   = end.AddDays(1);

                    if (start > repeatEnd)
                    {
                        thisPlan.Insert(newGroup);
                        this.Close();
                        return;
                    }
                }
            }
            else if (Repeat.Text.ToString() == "A Week")
            {
                newGroup.repeatKind = 2;
                while (true)
                {
                    newGroup.Insert(new PlanItem(title.Text, notes.Text, start, end, priority.SelectedIndex, start - alertTimeSpane, location.Text));

                    start = start.AddDays(7);
                    end   = end.AddDays(7);

                    if (start > repeatEnd)
                    {
                        thisPlan.Insert(newGroup);
                        this.Close();
                        return;
                    }
                }
            }
            else if (Repeat.Text.ToString() == "A Month")
            {
                newGroup.repeatKind = 3;

                TimeSpan timeSpan = end - start;
                while (true)
                {
                    newGroup.Insert(new PlanItem(title.Text, notes.Text, start, start + timeSpan, priority.SelectedIndex, start - alertTimeSpane, location.Text));

                    do
                    {
                        Date.AddMonth(tYear_Start, tMonth_Start, out tYear_Start, out tMonth_Start, 1);
                    }while (tDay_Start > Year.GetMaxDaysOfMonth(tYear_Start, tMonth_Start));

                    start = new DateTime(tYear_Start, tMonth_Start, tDay_Start, tHour_Start, tMinute_Start, 0);
                    if (start > repeatEnd)
                    {
                        thisPlan.Insert(newGroup);
                        this.Close();
                        return;
                    }
                }
            }
            else if (Repeat.Text.ToString() == "A Year")
            {
                newGroup.repeatKind = 4;

                TimeSpan timeSpan = end - start;
                while (true)
                {
                    newGroup.Insert(new PlanItem(title.Text, notes.Text, start, start + timeSpan, priority.SelectedIndex, start - alertTimeSpane, location.Text));

                    do
                    {
                        Date.AddMonth(tYear_Start, tMonth_Start, out tYear_Start, out tMonth_Start, 12);
                    }while (tDay_Start > Year.GetMaxDaysOfMonth(tYear_Start, tMonth_Start));

                    start = new DateTime(tYear_Start, tMonth_Start, tDay_Start, tHour_Start, tMinute_Start, 0);
                    if (start > repeatEnd)
                    {
                        thisPlan.Insert(newGroup);
                        this.Close();
                        return;
                    }
                }
            }
            else
            {
                newGroup.repeatKind  = 5;
                newGroup.repeatValue = Convert.ToInt32(repeatValue.Text);

                while (true)
                {
                    newGroup.Insert(new PlanItem(title.Text, notes.Text, start, end, priority.SelectedIndex, start - alertTimeSpane, location.Text));

                    start = start.AddDays(Convert.ToInt32(repeatValue.Text));
                    end   = end.AddDays(Convert.ToInt32(repeatValue.Text));

                    if (start > repeatEnd)
                    {
                        thisPlan.Insert(newGroup);
                        this.Close();
                        return;
                    }
                }
            }
        }
Beispiel #5
0
 public void Insert(GroupPlanItem item)
 {
     group.Add(item);
 }