Exemplo n.º 1
0
 //删除
 public static void Remove(string task_id)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         try
         {
             AdministratorTask task = Get(task_id);
             entity.AdministratorTasks.Remove(task);
             entity.SaveChanges();
         }
         catch (Exception ex)
         {
             string errorInfo = ex.Message;
             if (ex is DbEntityValidationException)
             {
                 foreach (var validationResult in ((DbEntityValidationException)ex).EntityValidationErrors)
                 {
                     foreach (var error in validationResult.ValidationErrors)
                     {
                         errorInfo = $"{errorInfo}" + "\n" + $"{error.ErrorMessage}";
                     }
                 }
             }
             throw new ApplicationException("删除时出错!\n" + $"{errorInfo}");
         }
     }
 }
Exemplo n.º 2
0
        //新增
        public static void Add(AdministratorTask task)
        {
            using (var entity = new CommunityEpidemicManagementSystemContext())
            {
                if (Get(task.AdministratorTaskId) != null)
                {
                    throw new ApplicationException("已经存在!");
                }

                try
                {
                    entity.AdministratorTasks.Add(task);
                    entity.SaveChanges();
                }
                catch (Exception ex)
                {
                    string errorInfo = ex.Message;
                    if (ex is DbEntityValidationException)
                    {
                        foreach (var validationResult in ((DbEntityValidationException)ex).EntityValidationErrors)
                        {
                            foreach (var error in validationResult.ValidationErrors)
                            {
                                errorInfo = $"{errorInfo}" + "\n" + $"{error.ErrorMessage}";
                            }
                        }
                    }
                    throw new ApplicationException("添加时出错!\n" + $"{errorInfo}");
                }
            }
        }
Exemplo n.º 3
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            AdministratorTask administratorTask = AdministratorTaskBindingSource.Current as AdministratorTask;

            if (administratorTask == null)
            {
                MessageBox.Show("请选择要删除的任务");
                return;
            }
            else
            {
                AdministratorTaskService.Remove(administratorTask.AdministratorTaskId);
                QueryAll();
            }
        }
Exemplo n.º 4
0
        private void btnComplete_Click(object sender, EventArgs e)
        {
            AdministratorTask administratorTask = WorkerTaskBindingSource.Current as AdministratorTask;

            if (administratorTask == null)
            {
                MessageBox.Show("请选择要完成的任务");
                return;
            }
            else
            {
                administratorTask.State = TaskStatus.Finished;

                QueryUnFinished(CurrentWorker);
            }
        }
Exemplo n.º 5
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            AdministratorTask administratorTask = AdministratorTaskBindingSource.Current as AdministratorTask;

            if (administratorTask == null)
            {
                MessageBox.Show("请选择一项任务进行修改");
                return;
            }
            else
            {
                AdministratorTaskAdd addAdministratorTask = new AdministratorTaskAdd(administratorTask);
                if (addAdministratorTask.ShowDialog() == DialogResult.OK)
                {
                    AdministratorTaskService.Update(addAdministratorTask.AdministratorTask);
                    QueryAll();
                }
            }
        }
Exemplo n.º 6
0
 public AdministratorTaskAdd(AdministratorTask administratorTask) : this()
 {
     AdministratorTask = administratorTask;
     AdministratorTaskBindingSource.DataSource = administratorTask;
 }