コード例 #1
0
 //修改外来人员到访记录
 public static void UpdateRecord(VisitorAccessManagement rec)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         try
         {
             entity.VisitorAccessManagements.Remove(Get(rec.VisitorAccessManagementId));
             entity.VisitorAccessManagements.Add(rec);
             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}");
         }
     }
 }
コード例 #2
0
        private void btnLeave_Click(object sender, EventArgs e)
        {
            VisitorAccessManagement visitorAccessManagement = VisitorAccessManagementBindingSource.Current as VisitorAccessManagement;

            if (visitorAccessManagement == null)
            {
                MessageBox.Show("请选择一位访客");
                return;
            }
            else
            {
                visitorAccessManagement.LeaveTime = DateTime.Now;
                VisitorsAccessManagementService.UpdateRecord(visitorAccessManagement);
                VisitorQueryALL();
            }
        }
コード例 #3
0
 public AccessManagementAddOut(VisitorAccessManagement visitorAccessManagement) : this()
 {
     VisitorAccessManagement = visitorAccessManagement;
     VisitorAccessBindingSource.DataSource = visitorAccessManagement;
 }