Ejemplo n.º 1
0
        private void editButton_Click(object sender, EventArgs e)
        {
            if (dataListView.SelectedItems.Count == 0)
            {
                MessageBox.Show(@"No selected record", @"Editing record", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            if (dataListView.SelectedItems.Count > 1)
            {
                MessageBox.Show(@"Only one record must be selected", @"Editing record", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            var item = dataListView.SelectedItems[0];
            var date = dateTimePicker.Value;
            var startTime = item.SubItems[0].Text;
            var endTime = item.SubItems[1].Text;
            var category = item.SubItems[2].Text;

            var editRecordForm = new EditRecordForm(id, categoriesHours, startTime, endTime, date);
            var result = editRecordForm.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            RemoveRecord(date, startTime, endTime, category);

            startTime = editRecordForm.StartTime;
            endTime = editRecordForm.EndTime;
            category = editRecordForm.Category;

            AddRecord(date, startTime, endTime, category);
            init();
        }
Ejemplo n.º 2
0
        private void addEventButton_Click(object sender, EventArgs e)
        {
            var editRecordForm = new EditRecordForm(id, categoriesHours, dateTimePicker.Value);
            var result = editRecordForm.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            var startTime = editRecordForm.StartTime;
            var endTime = editRecordForm.EndTime;
            var category = editRecordForm.Category;
            var date = dateTimePicker.Value;
            
            AddRecord(date, startTime, endTime, category);
            init();
        }