Exemplo n.º 1
0
        //如果存在员工排班,则不可删除
        public ActionResult Delete(int id, FormCollection collection)
        {
            ResultMessage msg = new ResultMessage();

            try
            {
                IShiftScheduleService shfSi = new ShiftSheduleService(Settings.Default.db);
                ShiftSchedule         shf   = shfSi.FindShiftScheduleByShiftId(id);

                if (null != shf && shf.id > 0)
                {
                    msg.Success = false;
                    msg.Content = "班次信息正在使用,不能删除!";

                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    IShiftService cs        = new ShiftService(Settings.Default.db);
                    bool          isSucceed = cs.DeleteById(id);

                    msg.Success = isSucceed;
                    msg.Content = isSucceed ? "" : "删除失败";

                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new ResultMessage()
                {
                    Success = false, Content = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }