コード例 #1
0
        private void btn_SaveChange_Click(object sender, EventArgs e)
        {
            Task task = new Task
            {
                ID          = Convert.ToInt32(tbx_ID.Text),
                Name        = tbx_Name.Text,
                Description = tbx_Description.Text,
                StartDate   = dtp_Start.Value,
                EndDate     = dtp_End.Value,
                Status      = cbb_Status.Text == "Chưa hoàn thành" ? 0 : 1,
                IDProject   = (cbb_ChooseProject.SelectedItem as Project).ID,
            };

            foreach (Employee employee in lbx_ListEmployee.Items)
            {
                task.Employees.Add(employee);
            }

            if (btn_SaveChange.Tag.ToString() == "Add")
            {
                AddTask(task);
                Reset();
            }
            else if (btn_SaveChange.Tag.ToString() == "Update")
            {
                UpdateTask(task);
                Reset();
            }

            pn_TaskDetail.Enabled = false;
        }
        public static bool AddTask(Task task)
        {
            try
            {
                using (var _context = new DBILABEntities())
                {
                    foreach (var employee in task.Employees)
                    {
                        var employeedb = (from e in _context.Employees
                                          where e.ID == employee.ID
                                          select e).Single();
                        employeedb.Tasks.Add(task);
                    }
                    task.Employees.Clear();

                    _context.Tasks.AddOrUpdate(task);
                    _context.SaveChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
        private void Mtl_Click(object sender, EventArgs e)
        {
            MetroLink link = sender as MetroLink;
            Task      task = TaskController.GetTasktByID((int)link.Tag);

            try
            { Process.Start(task.LinkDocuments); }
            catch
            { }
        }
コード例 #4
0
 void UpdateTask(Task task)
 {
     if (TaskController.UpdateTask(task))
     {
         MessageBox.Show("Chỉnh sửa công việc thành công", "Thông báo", MessageBoxButtons.OK);
     }
     else
     {
         MessageBox.Show("Chỉnh sửa công việc không thành công", "Lỗi", MessageBoxButtons.OK);
     }
 }
コード例 #5
0
 void AddTask(Task task)
 {
     if (TaskController.AddTask(task))
     {
         MessageBox.Show("Thêm công việc thành công", "Thông báo", MessageBoxButtons.OK);
     }
     else
     {
         MessageBox.Show("Thêm công việc không thành công", "Lỗi", MessageBoxButtons.OK);
     }
 }
コード例 #6
0
        private void dtgv_ListTask_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            int id = (int)dtgv_ListTask.Rows[e.RowIndex].Cells[0].Value;

            Task task = TaskController.GetTasktByID(id);

            FillTaskDetail(task);
        }
 public static bool UpdateTask(Task task)
 {
     try
     {
         DeleteTask(task.ID);
         AddTask(task);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #8
0
        private void FillTaskDetail(Task task)
        {
            tbx_ID.Text          = task.ID.ToString();
            tbx_Name.Text        = task.Name;
            tbx_Description.Text = task.Description;
            dtp_Start.Value      = task.StartDate.Value;
            dtp_End.Value        = task.EndDate.Value;
            cbb_Status.Text      = (task.Status == 1 ? "Hoàn thành" : "Chưa hoàn thành");
            tbx_Link.Text        = task.LinkDocuments;

            lbx_ListEmployee.Items.Clear();
            foreach (Employee e in task.Employees)
            {
                lbx_ListEmployee.Items.Add(e);
            }
            lbx_ListEmployee.DisplayMember = "Name";
        }
        private void Btn_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            if (btn.Text == "")
            {
                return;
            }

            if (btn.Tag is Project)
            {
                f_Project f = new f_Project();
                f.ShowDialog();
            }
            else if (btn.Tag is Task)
            {
                Task       t = btn.Tag as Task;
                f_TaskEdit f = new f_TaskEdit(Convert.ToInt32(t.IDProject.ToString()));
                f.ShowDialog();
            }
        }