示例#1
0
        /// <summary>
        /// 根据员工id删除员工的方法
        /// </summary>
        /// <returns></returns>
        public ActionResult DelEmByID()
        {
            int  id                = Convert.ToInt32(Request["delid"]);
            bool isDelemp          = dal.DelEmployeerByID(id); //删除该员工
            bool isDelsalary       = false;                    //删除该员工的薪资
            bool isDelsalaryRecord = false;                    //删除该员工的薪资记录
            bool isDelCalendar     = false;                    //删除该员工的日程

            if (isDelemp)
            {
                //查询该员工有无薪资有则删除该员工的薪资
                Payroll emerpay = dal.SelEmployeerSalaryByID(id);
                if (emerpay != null)
                {
                    isDelsalary = dal.DelEmployeerSalaryByID(emerpay);
                    //查询该员工有无薪资记录有则删除该员工的薪资记录
                    PayrollDal          pdal   = new PayrollDal();
                    List <SalaryRecord> srlist = pdal.GetByID(id);
                    if (srlist.Count > 0 && isDelsalary == true)
                    {
                        isDelsalaryRecord = pdal.DelByID(srlist);
                    }
                    //查询该员工有无日程有则删除该员工的日程
                    CalendarsDal    cdal = new CalendarsDal();
                    List <Calendar> cal  = cdal.GetCalendarByID(id);
                    if (cal.Count > 0)
                    {
                        isDelCalendar = cdal.DelCalendarByID(cal);
                    }
                    if (isDelsalary && isDelsalaryRecord && isDelCalendar)
                    {
                        return(RedirectToAction("EmployeerList"));
                    }
                }
                else
                {
                    //查询该员工有无日程有则删除该员工的日程
                    CalendarsDal    cdal = new CalendarsDal();
                    List <Calendar> cal  = cdal.GetCalendarByID(id);
                    if (cal.Count > 0)
                    {
                        isDelCalendar = cdal.DelCalendarByID(cal);
                    }
                    if (isDelCalendar)
                    {
                        return(RedirectToAction("EmployeerList"));
                    }
                }
            }
            return(RedirectToAction("EmployeerList"));
        }
示例#2
0
        /// <summary>
        /// 删除多个员工根据员工id
        /// </summary>
        /// <returns></returns>
        public ActionResult ExeDelByIDs()
        {
            //接收员工IDS
            string ids = Request["ids"];

            if (ids != null)
            {
                List <string> list              = ids.Split(',').ToList();
                bool          isDelemper        = false;
                bool          isDelSalary       = false;
                bool          isDelSalaryRecord = false;
                bool          isDelCalendar     = false;
                for (int i = 0; i < list.Count() - 1; i++)
                {
                    isDelemper = dal.DelEmployeerByID(Convert.ToInt32(list[i]));//删除多个员工
                    //查询该员工有无薪资有则删除该员工的薪资
                    Payroll emerpay = dal.SelEmployeerSalaryByID(Convert.ToInt32(list[i]));
                    if (emerpay != null)
                    {
                        isDelSalary = dal.DelEmployeerSalaryByID(emerpay);
                        //查询该员工有无薪资记录有则删除该员工的薪资记录
                        PayrollDal          pdal   = new PayrollDal();
                        List <SalaryRecord> srlist = pdal.GetByID(Convert.ToInt32(list[i]));
                        if (srlist.Count > 0 && isDelSalary == true)
                        {
                            isDelSalaryRecord = pdal.DelByID(srlist);
                        }
                        //查询该员工有无日程有则删除该员工的日程
                        CalendarsDal    cdal = new CalendarsDal();
                        List <Calendar> cal  = cdal.GetCalendarByID(Convert.ToInt32(list[i]));
                        if (cal.Count > 0)
                        {
                            isDelCalendar = cdal.DelCalendarByID(cal);
                        }
                    }
                    else
                    {
                        //查询该员工有无日程有则删除该员工的日程
                        CalendarsDal    cdal = new CalendarsDal();
                        List <Calendar> cal  = cdal.GetCalendarByID(Convert.ToInt32(list[i]));
                        if (cal.Count > 0)
                        {
                            isDelCalendar = cdal.DelCalendarByID(cal);
                        }
                    }
                }
                return(RedirectToAction("EmployeerList"));
            }
            return(RedirectToAction("EmployeerList"));
        }