Example #1
0
        public void AddEvent()
        {
            //数据验证过程
            if (!new DepartmentVaildater(_ItsView).Vaildate())
            {
                return;
            }
            //数据收集过程
            _ANewObject = new Department(0, "");
            new DepartmentDataCollector(_ItsView).CompleteTheObject(_ANewObject);
            try
            {
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    _DepartmentBll.CreateDept(Convert.ToInt32(_ItsView.ParentID), _ANewObject, _LoginUser);
                    if (CompanyConfig.HasHrmisSystem)
                    {
                        IDepartmentHistoryFacade hrmisDepartmentHistoryFacade =
                            new DepartmentHistoryFacade();
                        hrmisDepartmentHistoryFacade.AddDepartmentHistory(_LoginUser);
                    }
                    ts.Complete();
                }

                _ItsView.ActionSuccess = true;
            }
            catch (ApplicationException ae)
            {
                _ItsView.Message = ae.Message;
            }
            catch (Exception e)
            {
                _ItsView.Message = e.Message;
            }
        }
Example #2
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;
            }
        }
Example #3
0
 private void DeleteEvent()
 {
     try
     {
         if (CompanyConfig.HasHrmisSystem && new CompanyInvolveFacade().GetEmployeeBasicInfoByCompanyID(Convert.ToInt32(_ItsView.DepartmentID)).Count > 0)
         {
             throw new ApplicationException("该公司下存在员工,禁止删除!");
         }
         using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
         {
             _DepartmentBll.DeleteDept(Convert.ToInt32(_ItsView.DepartmentID), _LoginUser);
             IDepartmentHistoryFacade hrmisDepartmentHistoryFacade = new DepartmentHistoryFacade();
             hrmisDepartmentHistoryFacade.AddDepartmentHistory(_LoginUser);
             ts.Complete();
         }
         _ItsView.ActionSuccess = true;
     }
     catch (ApplicationException ae)
     {
         _ItsView.Message = ae.Message;
     }
 }