Esempio n. 1
0
        public override void Delete()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                // If the leave record is accepted we should update the leave summary when we want remove the leave record.
                // This case only happened in Unit Test as delete method is not allowed to invoke in real business logic.
                if (this.Status == LeaveStatus.Accepted)
                {
                    int    year;
                    double usedHours = GetDurationHours(timeDurationList, out year);

                    if (usedHours != 0 && year != 0)
                    {
                        List <SearchCondition> conditions = new List <SearchCondition>();
                        conditions.Add(SearchCondition.CreateSearchCondition(GlobalParams.FKEmployeeID, FKSubmitEmployeeID.ToString(), SearchComparator.Equal, SearchType.SearchString));
                        conditions.Add(SearchCondition.CreateSearchCondition(GlobalParams.FKLeaveTypeID, FKLeaveTypeID.ToString(), SearchComparator.Equal, SearchType.SearchString));
                        conditions.Add(SearchCondition.CreateSearchCondition(GlobalParams.Year, year.ToString(), SearchComparator.Equal, SearchType.SearchNotString));
                        EmployeeLeaveSummary leaveSummary = CommonDAL <EmployeeLeaveSummary> .GetSingleObject(conditions);

                        leaveSummary.UsedHours -= usedHours;
                        leaveSummary.Save();
                    }
                }

                foreach (TimeDurationInfo item in timeDurationList)
                {
                    item.Delete();
                }

                CommonDAL <LeaveInfo> .Delete(this);

                ts.Complete();
            }
        }
Esempio n. 2
0
        public bool Delete(TEntity entity)
        {
            try
            {
                dal.Delete(entity);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw (ex);
            }
        }
Esempio n. 3
0
        public override void Delete()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                foreach (EmployeeRoleRL item in employeeRoleList)
                {
                    item.Delete();
                }

                CommonDAL <Employee> .Delete(this);

                ts.Complete();
            }
        }
Esempio n. 4
0
        public static bool RecallLeave(string leaveID)
        {
            bool result = false;

            LeaveInfo leave = null;

            try
            {
                if (!string.IsNullOrEmpty(leaveID))
                {
                    List <SearchCondition> conditions = new List <SearchCondition>();
                    conditions.Add(SearchCondition.CreateSearchCondition(GlobalParams.PKLeaveInfoID, leaveID, SearchComparator.Equal, SearchType.SearchString));
                    leave = CommonDAL <LeaveInfo> .GetSingleObject(conditions);
                }

                if (leave == null)
                {
                    throw new DataException("Record not found in DB");
                }
                else if (leave.Status != LeaveStatus.Applying)
                {
                    throw new DataException(string.Format("Record has been locked since it's {0} already.", leave.Status.ToString()));
                }

                // delete FK time duration first
                List <SearchCondition> conditionsTimeDuration = new List <SearchCondition>();
                conditionsTimeDuration.Add(SearchCondition.CreateSearchCondition(GlobalParams.FKLeaveInfoID, leaveID, SearchComparator.Equal, SearchType.SearchString));

                List <TimeDurationInfo> timeDurations = CommonDAL <TimeDurationInfo> .GetObjects(conditionsTimeDuration);

                for (int i = timeDurations.Count - 1; i >= 0; i--)
                {
                    CommonDAL <TimeDurationInfo> .Delete(timeDurations[i]);
                }

                // delete leave info
                CommonDAL <LeaveInfo> .Delete(leave);

                result = true;
            }
            catch (Exception ex)
            {
                result = false;
                throw new Exception(ex.Message);
            }

            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// 删除记录
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public static bool Delete(string tableName, string where)
        {
            int obj = CommonDAL.Delete(tableName, where);

            return(obj > 0);
        }
Esempio n. 6
0
 public override void Delete()
 {
     CommonDAL <TimeDurationInfo> .Delete(this);
 }
Esempio n. 7
0
 public override void Delete()
 {
     CommonDAL <ReportPeriod> .Delete(this);
 }
Esempio n. 8
0
 public static void DeleteEmployee(Employee employee)
 {
     CommonDAL <Employee> .Delete(employee);
 }
Esempio n. 9
0
 public override void Delete()
 {
     CommonDAL <EmployeeLeaveSummary> .Delete(this);
 }
Esempio n. 10
0
 public override void Delete()
 {
     CommonDAL <Role> .Delete(this);
 }
Esempio n. 11
0
 public override void Delete()
 {
     CommonDAL <EmployeeRoleRL> .Delete(this);
 }
Esempio n. 12
0
 public override void Delete()
 {
     CommonDAL <LeaveType> .Delete(this);
 }