Ejemplo n.º 1
0
        private void Update()
        {
            string       s;
            List <Error> errors = new List <Error>();

            Valide(errors);
            if (errors.Count <= 0)
            {
                //数据收集过程
                Department theObject =
                    new Department(Convert.ToInt32(Request.Params["DepartmentID"]), Request.Params["DepartmentName"]);
                CompleteTheObject(theObject);
                //执行事务过程
                try
                {
                    using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                    {
                        Department theOldObject =
                            _DepartmentBll.GetDepartmentById(Convert.ToInt32(Request.Params["DepartmentID"]), null);
                        _DepartmentBll.UpdateDept(theObject, _LoginUser);
                        if (CompanyConfig.HasHrmisSystem)
                        {
                            if (!theOldObject.IsEqual(theObject))
                            {
                                IDepartmentHistoryFacade hrmisDepartmentHistoryFacade =
                                    InstanceFactory.CreateDepartmentHistoryFacade();
                                hrmisDepartmentHistoryFacade.AddDepartmentHistory(_LoginUser);
                            }
                            if (theOldObject.Name != theObject.Name)
                            {
                                IEmployeeHistoryFacade hrmisEmployeeHistoryFacade =
                                    InstanceFactory.CreateEmployeeHistoryFacade();
                                hrmisEmployeeHistoryFacade.AddEmployeeHistoryByDepartment(theObject, _LoginUser);
                            }
                        }
                        ts.Complete();
                    }
                    s = "[]";
                }
                catch (Exception ae)
                {
                    errors.Add(new Error("lblMessage", ae.Message));
                    s = JsonConvert.SerializeObject(errors);
                }
            }
            else
            {
                s = JsonConvert.SerializeObject(errors);
            }
            Response.Write(s);
            Response.End();
        }
Ejemplo n.º 2
0
        private void Move()
        {
            string       s;
            List <Error> errors = new List <Error>();

            try
            {
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    int        parentDepid  = Convert.ToInt32(Request.Params["ParentDepartmentID"]);
                    Department theOldObject =
                        _DepartmentBll.GetDepartmentById(Convert.ToInt32(Request.Params["DepartmentID"]), null);
                    if (parentDepid != theOldObject.Id)
                    {
                        _DepartmentBll.UpdateDept(parentDepid, theOldObject, _LoginUser);
                        if (CompanyConfig.HasHrmisSystem)
                        {
                            IDepartmentHistoryFacade hrmisDepartmentHistoryFacade =
                                InstanceFactory.CreateDepartmentHistoryFacade();
                            hrmisDepartmentHistoryFacade.AddDepartmentHistory(_LoginUser);

                            IEmployeeHistoryFacade hrmisEmployeeHistoryFacade =
                                InstanceFactory.CreateEmployeeHistoryFacade();
                            hrmisEmployeeHistoryFacade.AddEmployeeHistoryByDepartment(theOldObject, _LoginUser);
                        }
                    }
                    ts.Complete();
                }
                s = "[]";
            }
            catch (Exception ae)
            {
                errors.Add(new Error("trMessage", ae.Message));
                s = JsonConvert.SerializeObject(errors);
            }

            Response.Write(s);
            Response.End();
        }