Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Load event of the Form control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="eventArgs">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void Form_Load(object sender, EventArgs eventArgs)
        {
            var availableTypes = DataAccess.Instance.TaskTypes.GetAll().ToDictionary(availableType => availableType.Id, availableType => availableType.Name);
            this.Form.TaskTypeComboBox.DataSource = new BindingSource(availableTypes, null);
            this.Form.TaskTypeComboBox.DisplayMember = "Value";
            this.Form.TaskTypeComboBox.ValueMember = "Key";

            if (this.IsEditForm)
            {
                this.task = DataAccess.Instance.Tasks.Single(x => x.Id == this.ItemToEditID);

                this.Form.NameTextBox.Text = this.task.Name;
                this.Form.DescriptionTextBox.Text = this.task.Description;
                var startDate = this.task.StartDate;
                if (startDate != null)
                {
                    this.Form.StartDateTimePicker.Value = (DateTime)startDate;
                }

                var endDate = this.task.EndDate;
                if (endDate != null)
                {
                    this.Form.StartDateTimePicker.Value = (DateTime)endDate;
                }

                this.Form.IsDoneCheckBox.Checked = this.task.IsDone;
                this.Form.TaskTypeComboBox.Text = availableTypes.Where(x => x.Key == this.task.TypeId).Select(x => x.Value).FirstOrDefault();

                this.Form.Text = "Edycja zadania";
            }
            else
            {
                this.Form.Text = "Nowe zadanie";
            }
        }
Ejemplo n.º 2
0
 private void btnAddTask_Click(object sender, EventArgs e)
 {
     Domain.Task _task = null;
     if ( txtTaskName.Text.Trim().Length <= 10 || txtTaskDesc.Text.Trim().Length <= 10 )
     {
         MessageBox.Show("Your inputs need to be more descriptive.");
         return;
     }
     _task = new Domain.Task()
     {
         TaskName = txtTaskName.Text.Trim(),
         TaskDesc = txtTaskDesc.Text.Trim(),
         TaskDueHour = (int)cbHours.SelectedItem,
         TaskDueMinutes = (int)cbMinutes.SelectedItem,
         TaskDueDate = dtOneTimeDate.Value,
         RecurrenceBusinessDayStep = calculateIndex(labelsWeek, cbBusinessDay.SelectedIndex),
         RecurrencePattern = lbPattern.SelectedItem.ToString()
     };
     if ( rdReccurring.Checked )
         _task.TaskDueDate = null;
     var taskId = TaskManager.AddTask(_task);
     // add emails to alerter list
     foreach (var email in lbEmailList.Items)
     {
         using(var db = new SqlConnection(ConnectionString))
         {
             db.Open();
             var q = @"INSERT INTO [Collect2000].[ERCTasks].[TasksAlerterEmail] (TaskId, Email) VALUES (@taskId, @Email)";
             db.Query(q, new { taskId = taskId, Email = email });
         }
     }
     MessageBox.Show("Task successfully added");
     this.Close();
 }
Ejemplo n.º 3
0
 public TaskModel(Task task)
 {
     Id = task.Id;
     Name = task.Name;
     Complited = task.Complited;
     Progress = task.Progress;
     Color = task.Color.Name;
 }
Ejemplo n.º 4
0
        public int AddTask(Task _obj)
        {
            try
            {
               return  TaskManager.AddTask(_obj);

            }
            catch (Exception ex) { return 0; }
        }
Ejemplo n.º 5
0
 public bool EditTask(Task _obj)
 {
     try
     {
         TaskManager.EditTask(_obj);
         return true;
     }
     catch (Exception ex) { return false; }
 }
Ejemplo n.º 6
0
        public void Replace(Domain.Task _task)
        {
            var index = tasks.FindIndex(task => task.ID.Equals(_task.ID));

            if (index != -1)
            {
                tasks[index] = _task;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a new <see cref="Task"/> with the given information.
        /// </summary>
        /// <param name="model"></param>
        public void CreateNewTask(TaskInputModel model)
        {
            if (model == null) return;

            var task = new Task
            {
                Description = model.Description,
                Name = model.Name,
                Created = DateTime.Now
            };

            TaskRepository.Add(task);
        }
Ejemplo n.º 8
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var task = new Domain.Task {
                    Id          = request.Id,
                    TaskToDo    = request.TaskToDo,
                    ProjectId   = request.ProjectId,
                    StatusId    = request.StatusId,
                    AssigneeId  = request.AssigneeId,
                    StartDate   = request.StartDate,
                    EndDate     = request.EndDate,
                    Description = request.Description,
                    Comment     = request.Comment
                };

                _context.tasks.Add(task);
                var succes = await _context.SaveChangesAsync() > 0;

                if (succes)
                {
                    return(Unit.Value);
                }
                throw new Exception("Problem saving changes");
            }
Ejemplo n.º 9
0
        private void btnAddTask_Click(object sender, EventArgs e)
        {
            Domain.Task _task = null;
            if (txtTaskName.Text.Trim().Length <= 10 || txtTaskDesc.Text.Trim().Length <= 10)
            {
                MessageBox.Show("Your inputs need to be more descriptive.");
                return;
            }
            _task = new Domain.Task()
            {
                TaskName                  = txtTaskName.Text.Trim(),
                TaskDesc                  = txtTaskDesc.Text.Trim(),
                TaskDueHour               = (int)cbHours.SelectedItem,
                TaskDueMinutes            = (int)cbMinutes.SelectedItem,
                TaskDueDate               = dtOneTimeDate.Value,
                RecurrenceBusinessDayStep = calculateIndex(labelsWeek, cbBusinessDay.SelectedIndex),
                RecurrencePattern         = lbPattern.SelectedItem.ToString()
            };
            if (rdReccurring.Checked)
            {
                _task.TaskDueDate = null;
            }
            var taskId = TaskManager.AddTask(_task);

            // add emails to alerter list
            foreach (var email in lbEmailList.Items)
            {
                using (var db = new SqlConnection(ConnectionString))
                {
                    db.Open();
                    var q = @"INSERT INTO [Collect2000].[ERCTasks].[TasksAlerterEmail] (TaskId, Email) VALUES (@taskId, @Email)";
                    db.Query(q, new { taskId = taskId, Email = email });
                }
            }
            MessageBox.Show("Task successfully added");
            this.Close();
        }
Ejemplo n.º 10
0
        public bool insertTask(Domain.Task task)
        {
            using (SqlConnection conn = new SqlConnection(Utility.CONNECTION_STRING))
                using (SqlCommand cmd = new SqlCommand(Utility.SP_INSERT_TASK, conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("name", SqlDbType.VarChar).Value        = task.Name;
                    cmd.Parameters.Add("activity", SqlDbType.VarChar).Value    = task.Activity;
                    cmd.Parameters.Add("description", SqlDbType.VarChar).Value = task.Description;

                    conn.Open();

                    if (cmd.ExecuteNonQuery() > 0)
                    {
                        conn.Close();
                        return(true);
                    }
                    else
                    {
                        conn.Close();
                        return(false);
                    }
                }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Create a new Task object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="employeeId">Initial value of the EmployeeId property.</param>
 /// <param name="isDone">Initial value of the IsDone property.</param>
 /// <param name="typeId">Initial value of the TypeId property.</param>
 public static Task CreateTask(global::System.Int32 id, global::System.Int32 employeeId, global::System.Boolean isDone, global::System.Int32 typeId)
 {
     Task task = new Task();
     task.Id = id;
     task.EmployeeId = employeeId;
     task.IsDone = isDone;
     task.TypeId = typeId;
     return task;
 }
Ejemplo n.º 12
0
 public Domain.Task Upsert(Domain.Task source)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 13
0
 public void DeleteTask(Domain.Task source)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Handles the Click event of the OkButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void OkButton_Click(object sender, EventArgs e)
        {
            string taskName = this.Form.NameTextBox.Text;
            string taskDescription = this.Form.DescriptionTextBox.Text;
            DateTime startDate = this.Form.StartDateTimePicker.Value;
            DateTime endDate = this.Form.EndDateTimePicker.Value.AddSeconds(1.0);
            bool isDone = this.Form.IsDoneCheckBox.Checked;
            int taskTypeId = 0;
            int.TryParse(this.Form.TaskTypeComboBox.SelectedValue.ToString(), out taskTypeId);

            if (string.IsNullOrEmpty(taskName) || startDate >= endDate)
            {
                MessageBox.Show(
                    "Podane wartości nie są prawidłowe lub pozostawiono niewypełnione pola.",
                    "Błąd",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button1);

                return;
            }

            if (this.IsEditForm)
            {
                this.task.Name = taskName;
                this.task.Description = taskDescription;
                this.task.IsDone = isDone;
                this.task.StartDate = startDate;
                this.task.EndDate = endDate;
                this.task.TypeId = taskTypeId;
            }
            else
            {
                this.task = new Task
                {
                    Name = taskName,
                    Description = taskDescription,
                    IsDone = isDone,
                    TypeId = taskTypeId,
                    StartDate = startDate,
                    EndDate = endDate,
                    EmployeeId = this.SecondaryId
                };

                DataAccess.Instance.Tasks.Add(this.task);
            }

            DataAccess.Instance.UnitOfWork.Commit();

            this.Form.Dispose();
        }
Ejemplo n.º 15
0
 public void Unshift(Domain.Task _task) => tasks.Insert(0, _task);
Ejemplo n.º 16
0
 public Domain.Task Replace(Status _status, Domain.Task _task) => new Domain.Task(_task.ID, _task.Title, _task.Explain, _status);
Ejemplo n.º 17
0
 public Domain.Task Replace(Explain _explain, Domain.Task _task) => new Domain.Task(_task.ID, _task.Title, _explain, _task.Status);
Ejemplo n.º 18
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Tasks EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTasks(Task task)
 {
     base.AddObject("Tasks", task);
 }
Ejemplo n.º 19
0
 public bool insertTask(Domain.Task task)
 {
     return(taskData.insertTask(task));
 }
Ejemplo n.º 20
0
 public Domain.Task Replace(Title _title, Domain.Task _task) => new Domain.Task(_task.ID, _title, _task.Explain, _task.Status);