public void Delete(EmployeeWorkingDay data)
 {
     EmployeeWorkingDayDAO.Delete(data);
 }
 public void Update(EmployeeWorkingDay data)
 {
     EmployeeWorkingDayDAO.Update(data);
 }
 public EmployeeWorkingDay Add(EmployeeWorkingDay data)
 {
     EmployeeWorkingDayDAO.Add(data);
     return data;
 }
Exemplo n.º 4
0
 private bool UpdateEndTimeInList(EmployeeWorkingDaysCollection collection, EmployeeWorkingDay day)
 {
     foreach (EmployeeWorkingDay workingDay in collection)
     {
         if(workingDay.EmployeeWorkingDayPK.EmployeeId.Equals(day.EmployeeWorkingDayPK.EmployeeId)
             && workingDay.Department.DepartmentId == day.Department.DepartmentId
             && workingDay.EmployeeWorkingDayPK.WorkingDay.CompareTo(day.EmployeeWorkingDayPK.WorkingDay) == 0
             )
         {
             workingDay.EndTime = day.EndTime;
             return true;
         }
     }
     return false;
 }
        void employeeWorkingView_SaveEmployeeWorkingDay(object sender, EmployeeWorkingsLogicEventArg e)
        {
            string barCode = e.EmployeeId;
            ObjectCriteria criteria = new ObjectCriteria();
            criteria.AddEqCriteria("Barcode", barCode);
            IList list = EmployeeInfoLogic.FindAll(criteria);
            if (list != null && list.Count == 1)
            {
                EmployeeInfo info = (EmployeeInfo)list[0];
                EmployeeWorkingDay workingDay = e.EmployeeWorkingDay;
                if (workingDay == null)
                {
                    workingDay = new EmployeeWorkingDay();
                    workingDay.CreateDate = DateTime.Now;
                    workingDay.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                    workingDay.UpdateDate = DateTime.Now;
                    workingDay.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    //workingDay.StartTime = DateTime.Now;

                    workingDay.EndTime = DateTime.MinValue;
                    workingDay.EmployeeWorkingDayPK = new EmployeeWorkingDayPK
                                                          {
                                                              //DepartmentId = CurrentDepartment.Get().DepartmentId,
                                                              EmployeeId = info.EmployeePK.EmployeeId,
                                                              WorkingDay = DateTime.Now
                                                          };

                    workingDay.Employee = info.Employee;
                    workingDay.Department = CurrentDepartment.Get();
                    workingDay.DelFlg = 0;
                    workingDay.ExclusiveKey = 1;
                }

                ObjectCriteria wDayCrit = new ObjectCriteria();
                wDayCrit.AddEqCriteria("Department.DepartmentId", workingDay.Department.DepartmentId);
                wDayCrit.AddEqCriteria("EmployeeWorkingDayPK.EmployeeId", workingDay.EmployeeWorkingDayPK.EmployeeId);
                wDayCrit.AddBetweenCriteria("EmployeeWorkingDayPK.WorkingDay", DateUtility.ZeroTime(DateTime.Now),
                                            DateUtility.MaxTime(DateTime.Now));

                IList wDayResult = EmployeeWorkingDayLogic.FindAll(wDayCrit);
                if (wDayResult == null || wDayResult.Count == 0)
                {
                    workingDay.StartTime = DateTime.Now;
                    EmployeeWorkingDayLogic.Add(workingDay);

                }
                else
                {
                    EmployeeWorkingDay currWDay = (EmployeeWorkingDay) wDayResult[0];
                    currWDay.EndTime = DateTime.Now;
                    workingDay.EndTime = currWDay.EndTime;
                    EmployeeWorkingDayLogic.Update(currWDay);

                }

                e.EmployeeWorkingDay = workingDay;

                e.HasErrors = false;
            }
            else
            {
                e.HasErrors = true;
                throw new BusinessException("Mã vạch của nhân viên không đúng");
            }
        }
 /// <summary>
 /// Delete EmployeeWorkingDay from database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Delete(EmployeeWorkingDay data)
 {
     HibernateTemplate.Delete(data);
 }
 /// <summary>
 /// Add EmployeeWorkingDay to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public EmployeeWorkingDay Add(EmployeeWorkingDay data)
 {
     HibernateTemplate.Save(data);
     return data;
 }
 /// <summary>
 /// Update EmployeeWorkingDay to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Update(EmployeeWorkingDay data)
 {
     HibernateTemplate.Update(data);
 }