Пример #1
0
        private void btnAddLogItem_Click(object sender, EventArgs e)
        {
            if(lvActivities.SelectedItems.Count == 1)
            {
                var selected = lvActivities.SelectedItems[0];
                foreach (var item in flowPanel.Controls)
                {
                    if (((ActivityTime)item).Name == selected.Text)
                    {
                        return;
                    }
                }

                //flow panel doesn't contain such activity now
                //can add
                var logTime = new LogTimeItem();
                logTime.ActivityID = selected.Text;
                logTime.DayOfLogging = dateTimePicker.Value.Date;

                LogItemsService.AddLogItem(logTime);

                var control = new ActivityTime(logTime);
                control.RemoveButtonClicked += control_RemoveButtonClicked;
                control.AddButtonClicked += control_AddButtonClicked;
                flowPanel.Controls.Add(control);

                FormChanged();
            }
        }
Пример #2
0
 public void LoadLogTimeItems(DateTime date)
 {
     var items = LogItemsService.GetItemsByDate(date);
     flowPanel.Controls.Clear();
     foreach (var item in items)
     {
         var control = new ActivityTime(item);
         control.RemoveButtonClicked += control_RemoveButtonClicked;
         control.AddButtonClicked += control_AddButtonClicked;
         flowPanel.Controls.Add(control);
     }
 }