Пример #1
0
        /// <summary>
        /// Dodawanie nowego zadania
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void taskSave_Click(object sender, EventArgs e)
        {
            Model.Task taskToSave = this.task;
            if (taskToSave == null)
            {
                taskToSave = new Model.Task();
            }

            MessageBox.Show(taskToSave.name);

            if (this.taskName.TextLength < 10 || this.taskDescription.TextLength < 10)
            {
                if (this.taskName.TextLength <= 10)
                {
                    MessageBox.Show("Prosze uzupełnij poprawnie 'Zadanie' minimalna długość to 10 znaków! ");
                }
                else if (this.taskDescription.TextLength <= 4)
                {
                    MessageBox.Show("Prosze uzupełnij poprawnie 'Opis zadania' minimalna długość to 10 znaków! ");
                }
                return;
            }

            EmployeeSelectItem selectedEmployee = this.taskEmployeeSelect.SelectedItem as EmployeeSelectItem;

            taskToSave.name        = this.taskName.Text;
            taskToSave.description = this.taskDescription.Text;
            taskToSave.startDate   = this.taskDateTimePickerStart.Value;
            taskToSave.endDate     = this.taskDataTimePickerEnd.Value;
            taskToSave.finished    = this.taskFinished.Checked;

            if (selectedEmployee != null)
            {
                taskToSave.employeeId = selectedEmployee.id;
            }


            if (this.task != null && this.task.id != 0)
            {
                Repo.TaskRepository.update(this.task.id, taskToSave);
            }
            else
            {
                Repo.TaskRepository.add(taskToSave);
            }

            this.formParent.renderTasksTab();
            this.Close();
        }
Пример #2
0
        /// <summary>
        /// Wypełnienia selecta danymi
        /// </summary>
        private void fillSelect()
        {
            List <Employee> employees = EmployeeRepository.getAll();

            this.taskEmployeeSelect.Items.Clear();
            employees.ForEach(e =>
            {
                EmployeeSelectItem item = new EmployeeSelectItem(e.id, e.firstName + " " + e.lastName);
                this.taskEmployeeSelect.Items.Add(item);
                if (this.task != null && e.id == this.task.employeeId)
                {
                    this.taskEmployeeSelect.SelectedItem = item;
                }
            });
        }