/// <summary> /// 激活停用服务 /// </summary> public bool ActiveService(long serviceId, bool isActive, long userId, ref string faileReason) { var isDal = new ivt_service_dal(); var thisSer = isDal.FindNoDeleteById(serviceId); if (thisSer == null) { faileReason = "未查询到该服务信息"; return(false); } if (thisSer.is_active == (sbyte)(isActive ? 1 : 0)) { faileReason = $"该服务已经是{(isActive?"激活":"停用")}状态!"; return(false); } thisSer.is_active = (sbyte)(isActive ? 1 : 0); thisSer.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); thisSer.update_user_id = userId; var oldSer = isDal.FindNoDeleteById(serviceId); isDal.Update(thisSer); OperLogBLL.OperLogUpdate <ivt_service>(thisSer, oldSer, thisSer.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE, "编辑服务"); return(true); }
/// <summary> /// 删除服务相关,不能删除时,返回所有不能删除相关对象数量 /// </summary> public bool DeleteService(long serviceId, long userId, ref string faileReason) { try { var isbDal = new ivt_service_dal(); var thisSer = isbDal.FindNoDeleteById(serviceId); if (thisSer == null) { return(true); } var conSerList = new ctt_contract_service_dal().getContractByServiceId(thisSer.id); if (conSerList != null && conSerList.Count > 0) { faileReason += $"{conSerList.Count} 合同\n"; } var quoteItemList = new crm_quote_item_dal().GetItemByObjId(thisSer.id); if (quoteItemList != null && quoteItemList.Count > 0) { faileReason += $"{quoteItemList.Count} 报价项\n"; } var labourList = new sdk_work_entry_dal().GetListByService(thisSer.id); if (labourList != null && labourList.Count > 0) { faileReason += $"{labourList.Count} 工时\n"; } var insProList = new crm_installed_product_dal().GetInsListBySerId(thisSer.id); if (insProList != null && insProList.Count > 0) { faileReason += $"{insProList.Count} 配置项\n"; } if (!string.IsNullOrEmpty(faileReason)) { return(false); } else { isbDal.SoftDelete(thisSer, userId); OperLogBLL.OperLogDelete <ivt_service>(thisSer, thisSer.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE, "删除服务"); } } catch (Exception) { return(false); } return(true); }