Esempio n. 1
0
        public void UpdateEvent()
        {
            //数据验证过程
            if (!new DepartmentVaildater(_ItsView).Vaildate())
            {
                return;
            }
            //数据收集过程
            Department theObject = new Department(Convert.ToInt32(_ItsView.DepartmentID), _ItsView.DepartmentName);

            new DepartmentDataCollector(_ItsView).CompleteTheObject(theObject);
            //执行事务过程
            try
            {
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    Department theOldObject =
                        _DepartmentBll.GetDepartmentById(Convert.ToInt32(_ItsView.DepartmentID), null);
                    _DepartmentBll.UpdateDept(theObject, _LoginUser);
                    if (CompanyConfig.HasHrmisSystem)
                    {
                        if (theOldObject.Name != theObject.Name ||
                            theOldObject.Leader.Id != theObject.Leader.Id || theOldObject.Address != theObject.Address || theOldObject.Phone != theObject.Phone || theOldObject.Fax != theObject.Fax || theOldObject.FoundationTime != theObject.FoundationTime || theOldObject.Others != theObject.Others || theOldObject.Description != theObject.Description
                            )
                        {
                            IDepartmentHistoryFacade hrmisDepartmentHistoryFacade =
                                new DepartmentHistoryFacade();
                            hrmisDepartmentHistoryFacade.AddDepartmentHistory(_LoginUser);
                        }
                        if (theOldObject.Name != theObject.Name || theOldObject.Address != theObject.Address || theOldObject.Phone != theObject.Phone || theOldObject.Fax != theObject.Fax || theOldObject.FoundationTime != theObject.FoundationTime || theOldObject.Others != theObject.Others)
                        {
                            IEmployeeHistoryFacade hrmisEmployeeHistoryFacade =
                                new EmployeeHistoryFacade();
                            hrmisEmployeeHistoryFacade.AddEmployeeHistoryByDepartment(theObject, _LoginUser);
                        }
                    }
                    ts.Complete();
                }
                _ItsView.ActionSuccess = true;
            }
            catch (ApplicationException ae)
            {
                _ItsView.Message = ae.Message;
            }
        }