示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (PlansAdd plansAddFrm = new PlansAdd())
            {
                if (plansAddFrm.ShowDialog() == DialogResult.OK)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = plansAddFrm.detailsText;
                    lvi.SubItems.Add(plansAddFrm.locationText);
                    listView1.Items.Add(lvi);

                    DatePlans addItem = new DatePlans();

                    addItem.date     = monthCalendar1.SelectionStart;
                    addItem.details  = lvi.Text;
                    addItem.location = lvi.SubItems[1].Text;
                    datePlans.Add(addItem);
                    if (!boldDates.Contains(monthCalendar1.SelectionStart))
                    {
                        boldDates.Add(monthCalendar1.SelectionStart);
                    }
                    monthCalendar1.BoldedDates = boldDates.ToArray();
                    AppendDates(addItem);
                }
            }
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                using (PlansAdd plansAddFrm = new PlansAdd())
                {
                    ListViewItem curItem      = listView1.SelectedItems[0];
                    DatePlans    curDatePlans = new DatePlans();
                    curDatePlans.date     = monthCalendar1.SelectionStart;
                    curDatePlans.details  = curItem.Text;
                    curDatePlans.location = curItem.SubItems[1].Text;

                    plansAddFrm.detailsText  = curItem.Text;
                    plansAddFrm.locationText = curItem.SubItems[1].Text;

                    if (plansAddFrm.ShowDialog() == DialogResult.OK)
                    {
                        curItem.Text             = plansAddFrm.detailsText;
                        curItem.SubItems[1].Text = plansAddFrm.locationText;

                        DatePlans replace = new DatePlans();
                        replace.date     = curDatePlans.date;
                        replace.details  = curItem.Text;
                        replace.location = curItem.SubItems[1].Text;

                        datePlans.Remove(curDatePlans);
                        datePlans.Add(replace);
                        StoreAllDates();
                    }
                }
            }
            else
            {
                MessageBox.Show("Please select an activity to edit", "Error");
            }
        }