コード例 #1
0
        /// <summary>
        /// Obsluguje klikniecie danego zadania na liscie
        /// Otwiera formularz z wybranym zadaniem
        /// </summary>
        /// <param name="sender">Obiekt wywołujący zdarzenie</param>
        /// <param name="e">Akrumenty eventu</param>
        private void taskListView_Click(object sender, EventArgs e)
        {
            var selected = taskListView.SelectedItems[0].SubItems[0];
            int id       = int.Parse(selected.Text);

            Model.Task task = TaskRepository.getById(id);

            TaskForm taskForm = new TaskForm(this, task);

            taskForm.Show(this);
        }
コード例 #2
0
 /// <summary>
 /// Konstruktor TaskForm
 /// </summary>
 /// <param name="form"></param>
 /// <param name="task"></param>
 public TaskForm(MainForm form, Model.Task task = null) : this(form)
 {
     if (task != null)
     {
         initTask(task);
     }
     else
     {
         this.task = new Model.Task();
     }
     fillSelect();
 }
コード例 #3
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();
        }
コード例 #4
0
        /// <summary>
        /// Inicjlalizacja wszystkich zadań
        /// </summary>
        /// <param name="task"></param>
        private void initTask(Model.Task task)
        {
            this.task = task;
            this.Text = task.id + " " + task.startDate + " " + task.startDate;

            this.taskName.Text        = task.name;
            this.taskDescription.Text = task.description;

            this.taskDateTimePickerStart.Format       = DateTimePickerFormat.Custom;
            this.taskDateTimePickerStart.CustomFormat = "dd-mm-yyyy HH:mm";
            if (task.startDate != null)
            {
                this.taskDateTimePickerStart.Value = (DateTime)task.startDate;
            }

            this.taskDataTimePickerEnd.Format       = DateTimePickerFormat.Custom;
            this.taskDataTimePickerEnd.CustomFormat = "dd-mm-yyyy HH:mm";
            if (task.endDate != null)
            {
                this.taskDataTimePickerEnd.Value = (DateTime)task.endDate;
            }

            this.taskFinished.Checked = task.isFinished();
        }