Example #1
0
 //更新
 public static void Update(Emergency emergency)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         try
         {
             entity.Emergencies.Remove(Get(emergency.EmergencyId));
             entity.Emergencies.Add(emergency);
             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}");
         }
     }
 }
Example #2
0
        private void btnFinish_Click(object sender, EventArgs e)
        {
            Emergency emergency = EmergencyBindingSource.Current as Emergency;

            if (emergency == null)
            {
                MessageBox.Show("请选择一个事件");
                return;
            }
            emergency.EmergState = EmergencyStatus.已完成;
            QueryAll(CurrentUser);
        }
Example #3
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            Emergency emergency = EmergencyBindingSource.Current as Emergency;

            if (emergency == null)
            {
                MessageBox.Show("请选择一个事件");
                return;
            }
            emergency.WorkerId   = WorkerService.QueryByUser(CurrentUser.UserId)[0].WorkerId;
            emergency.EmergState = EmergencyStatus.处理中;
            QueryAll(CurrentUser);
        }
Example #4
0
        private void btnAllocate_Click(object sender, EventArgs e)
        {
            Emergency emergency = EmergencyBindingSource.Current as Emergency;

            if (emergency == null)
            {
                MessageBox.Show("请选择一个需求进行分配");
                return;
            }
            emergency = EmergencyService.Get(emergency.EmergencyId);
            EmergencyAllocate allocate = new EmergencyAllocate(emergency);

            if (allocate.ShowDialog() == DialogResult.OK)
            {
                EmergencyService.Update(allocate.emergency);
                QueryAll(CurrentUser);
            }
        }
Example #5
0
 public EmergencyAllocate(Emergency emergency) : this()
 {
 }
Example #6
0
 public EmergencyAddResident(Emergency emergency) : this()
 {
     this.emergency = emergency;
     this.EmergencyBindingSource.DataSource = emergency;
 }