Exemplo n.º 1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (lvwTimes.SelectedItems.Count == 1)
            {
                ListViewItem item = lvwTimes.SelectedItems[0];
                frmTimeInput ti   = new frmTimeInput("Edit Time");

                ti.StartTime = (DateTime)item.SubItems[0].Tag;
                ti.StopTime  = (DateTime)item.SubItems[1].Tag;
                ti.Comment   = item.SubItems[2].Text;

                if (ti.ShowDialog() == DialogResult.OK)
                {
                    int i = lvwTimes.SelectedIndices[0];
                    if (ScheduleConflictsWith(ti.StartTime, ti.StopTime, i))
                    {
                        ShowScheduleConflictError();
                    }
                    else
                    {
                        lvwTimes.Items[i] = CreateLVI(ti.StartTime, ti.StopTime, ti.Comment);
                        SelectItem(ti.StartTime);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmTimeInput ti = new frmTimeInput("Add Time");

            ti.StartTime = DateTime.Now.AddSeconds(10.0);
            ti.StopTime  = DateTime.Now.AddSeconds(20.0);

            if (ti.ShowDialog() == DialogResult.OK)
            {
                if (ScheduleConflictsWith(ti.StartTime, ti.StopTime))
                {
                    ShowScheduleConflictError();
                }
                else
                {
                    lvwTimes.Items.Add(CreateLVI(ti.StartTime, ti.StopTime, ti.Comment));
                    SelectItem(ti.StartTime);
                }
            }
        }