コード例 #1
0
        protected override void ExcuteSelf()
        {
            List <Department> departmentList = _IDepartmentBll.GetAllDepartment();

            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
            {
                List <DepartmentHistory> departmentHistoryList = new List <DepartmentHistory>();
                foreach (Department department in departmentList)
                {
                    DepartmentHistory departmentHistory = new DepartmentHistory();
                    departmentHistory.Department = _IDepartmentBll.GetDepartmentById(department.Id, null);
                    departmentHistory.Department.ParentDepartment = _IDepartmentBll.GetParentDept(department.Id, null);
                    if (departmentHistory.Department.ParentDepartment == null)
                    {
                        departmentHistory.Department.ParentDepartment =
                            new Department(0, new Account(0, "", ""), "", null);
                    }
                    departmentHistory.OperationTime = _DtNow;
                    departmentHistory.Operator      = _OperatorAccount;
                    departmentHistoryList.Add(departmentHistory);
                }
                _DalDepartmentHistory.InsertDepartmentHistory(departmentHistoryList);
                ts.Complete();
            }
        }
コード例 #2
0
        public void ChangeDepartmentOrShift(Department department, [Optionally] Shift shift)
        {
            CurrentAssignment().EndDate = DateTime.Now;
            var newAssignment = Container.NewTransientInstance <EmployeeDepartmentHistory>();

            newAssignment.Department = department;
            newAssignment.Shift      = shift;
            newAssignment.Employee   = this;
            newAssignment.StartDate  = DateTime.Now;
            Container.Persist(ref newAssignment);
            DepartmentHistory.Add(newAssignment);
        }
コード例 #3
0
        /// <summary>
        /// 获得dt时间点部门的信息
        /// </summary>
        /// <param name="departmentID"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public DepartmentHistory GetDepartmentByDepartmentIDAndDateTime(int departmentID, DateTime dt)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.Add(_DepartmentID, SqlDbType.Int).Value       = departmentID;
            cmd.Parameters.Add(_OperationTime, SqlDbType.DateTime).Value = dt;
            using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetDepartmentByDepartmentIDAndDateTime", cmd))
            {
                while (sdr.Read())
                {
                    DepartmentHistory departmentHistory = new DepartmentHistory();
                    string            departmentName    = sdr[_DbDepartmentName].ToString();
                    Department        parentDepartment  = new Department(Convert.ToInt32(sdr[_DbParentID]), "");
                    Department        depatment         =
                        new Department(departmentID,
                                       new Account(Convert.ToInt32(sdr[_DbLeaderID]), "", sdr[_DbLeaderName].ToString()),
                                       departmentName, parentDepartment);
                    if (sdr[_DbAddress] != DBNull.Value)
                    {
                        depatment.Address = sdr[_DbAddress].ToString();
                    }
                    if (sdr[_DbPhone] != DBNull.Value)
                    {
                        depatment.Phone = sdr[_DbPhone].ToString();
                    }
                    if (sdr[_DbFax] != DBNull.Value)
                    {
                        depatment.Fax = sdr[_DbFax].ToString();
                    }
                    if (sdr[_DbOthers] != DBNull.Value)
                    {
                        depatment.Others = sdr[_DbOthers].ToString();
                    }
                    if (sdr[_DbDescription] != DBNull.Value)
                    {
                        depatment.Description = sdr[_DbDescription].ToString();
                    }
                    if (sdr[_DbFoundationTime] != DBNull.Value)
                    {
                        depatment.FoundationTime = Convert.ToDateTime(sdr[_DbFoundationTime]);
                    }
                    departmentHistory.Department            = depatment;
                    departmentHistory.DepartmentHistoryPKID = Convert.ToInt32(sdr[_DbDepartmentHistoryID].ToString());
                    departmentHistory.OperationTime         = Convert.ToDateTime(sdr[_DbOperationTime].ToString());
                    departmentHistory.Operator = new Account(0, "", sdr[_DbOperatorName].ToString());
                    return(departmentHistory);
                }
            }
            return(null);
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("PersonelId,FirstName,LastName,Salary,JobId,DeparmentId")] Employees employees)
        {
            if (id != employees.PersonelId)
            {
                return(NotFound());
            }

            var deptId = _context.Employees
                         .Where(x => x.PersonelId == id)
                         .Select(x => x.DeparmentId)
                         .FirstOrDefault();



            if (employees.DeparmentId != deptId)
            {
                DepartmentHistory deptHist = new DepartmentHistory();
                deptHist.DepartmentName = deptId + "";
                _context.DepartmentHistory.Add(deptHist);
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employees);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeesExists(employees.PersonelId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DeparmentId"] = new SelectList(_context.Departments, "DepartmentId", "DepartmentId", employees.DeparmentId);
            ViewData["JobId"]       = new SelectList(_context.Jobs, "JobId", "JobId", employees.JobId);
            return(View(employees));
        }
コード例 #5
0
        private EmployeeDepartmentHistory CurrentAssignment()
        {
            EmployeeDepartmentHistory current = DepartmentHistory.Where(n => n.EndDate == null).FirstOrDefault();

            return(current);
        }
コード例 #6
0
 public IList <DepartmentHistoryData> GetAllHistory(string id)
 {
     return(DepartmentHistory.ToJavaScriptDepartmentHistory(_eventStoreRepository.All(id)));
 }