Esempio n. 1
0
 //更新
 public static void Update(ResidentMission mission)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         try
         {
             entity.ResidentMissions.Remove(Get(mission.ResidentMissionId));
             entity.ResidentMissions.Add(mission);
             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}");
         }
     }
 }
Esempio n. 2
0
        private void dgvMissionList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            ResidentMission mission     = MissionBindingSource.Current as ResidentMission;
            MissionList     missionList = new MissionList(mission);

            missionList.ShowDialog();
        }
Esempio n. 3
0
        // Worker & Administrator
        private void btnRefuse_Click(object sender, EventArgs e)
        {
            ResidentMission mission = MissionBindingSource.Current as ResidentMission;

            if (mission == null)
            {
                MessageBox.Show("请选择一个需求进行拒绝");
                return;
            }
            mission.State = MissionStatus.拒绝;
            QueryAll(CurrentUser);
        }
Esempio n. 4
0
        // Worker
        private void btnFinish_Click(object sender, EventArgs e)
        {
            ResidentMission mission = MissionBindingSource.Current as ResidentMission;

            if (mission == null)
            {
                MessageBox.Show("请选择一个需求");
                return;
            }
            mission.State        = MissionStatus.已完成;
            mission.FinishedTime = DateTime.Now;
            QueryAll(CurrentUser);
        }
Esempio n. 5
0
        // Residents
        private void btnCancel_Click(object sender, EventArgs e)
        {
            ResidentMission mission = MissionBindingSource.Current as ResidentMission;

            if (mission == null)
            {
                MessageBox.Show("请选择一个需求进行取消");
                return;
            }
            if (mission.State == MissionStatus.已接受)
            {
                MessageBox.Show("订单已接受,无法取消!如有特殊情况请联系管理员。");
                return;
            }
            ResidentMissionService.Remove(mission.ResidentMissionId);
            QueryAll(CurrentUser);
        }
Esempio n. 6
0
        // Administrator
        private void btnAllocate_Click(object sender, EventArgs e)
        {
            ResidentMission mission = MissionBindingSource.Current as ResidentMission;

            if (mission == null)
            {
                MessageBox.Show("请选择一个需求进行分配");
                return;
            }
            mission = ResidentMissionService.Get(mission.ResidentMissionId);
            MissionAllocate allocate = new MissionAllocate(mission);

            if (allocate.ShowDialog() == DialogResult.OK)
            {
                allocate.Mission.State = MissionStatus.已接受;
                ResidentMissionService.Update(allocate.Mission);
                QueryAll(CurrentUser);
            }
        }
Esempio n. 7
0
        // Residents
        private void btnEdit_Click(object sender, EventArgs e)
        {
            ResidentMission mission = MissionBindingSource.Current as ResidentMission;

            if (mission == null)
            {
                MessageBox.Show("请选择一个需求进行修改");
                return;
            }
            if (mission.State == MissionStatus.已接受)
            {
                MessageBox.Show("订单已接受,无法修改!如有特殊情况请联系管理员。");
                return;
            }
            mission = ResidentMissionService.Get(mission.ResidentMissionId);
            MissionAddResident addResident = new MissionAddResident(mission);

            if (addResident.ShowDialog() == DialogResult.OK)
            {
                ResidentMissionService.Update(addResident.Mission);
                QueryAll(CurrentUser);
            }
        }
Esempio n. 8
0
 public MissionList(ResidentMission mission) : this()
 {
     this.mission = mission;
     this.MissionBindingSource.DataSource = mission;
 }
Esempio n. 9
0
 public MissionAllocate(ResidentMission mission) : this()
 {
     this.Mission = mission;
     this.MissionBindingSource.DataSource = mission;
 }