예제 #1
0
 /// <summary>
 /// 删除服务包相关,不能删除时,返回所有不能删除相关对象数量
 /// </summary>
 public bool DeleteServiceBundle(long serviceId, long userId, ref string faileReason)
 {
     try
     {
         var isbDal        = new ivt_service_bundle_dal();
         var thisSerBundle = isbDal.FindNoDeleteById(serviceId);
         if (thisSerBundle == null)
         {
             return(true);
         }
         var conSerList = new ctt_contract_service_dal().getContractByServiceId(thisSerBundle.id);
         if (conSerList != null && conSerList.Count > 0)
         {
             faileReason += $"{conSerList.Count} 合同\n";
         }
         var quoteItemList = new crm_quote_item_dal().GetItemByObjId(thisSerBundle.id);
         if (quoteItemList != null && quoteItemList.Count > 0)
         {
             faileReason += $"{quoteItemList.Count} 报价项\n";
         }
         var labourList = new sdk_work_entry_dal().GetListByService(thisSerBundle.id);
         if (labourList != null && labourList.Count > 0)
         {
             faileReason += $"{labourList.Count} 工时\n";
         }
         var insProList = new crm_installed_product_dal().GetInsListBySerBunId(thisSerBundle.id);
         if (insProList != null && insProList.Count > 0)
         {
             faileReason += $"{insProList.Count} 配置项\n";
         }
         if (!string.IsNullOrEmpty(faileReason))
         {
             return(false);
         }
         else
         {
             var isbsDal = new ivt_service_bundle_service_dal();
             var serList = GetServiceListByServiceBundleId(thisSerBundle.id);
             if (serList != null && serList.Count > 0)
             {
                 serList.ForEach(_ => {
                     isbsDal.Delete(_);
                 });
             }
             isbDal.SoftDelete(thisSerBundle, userId);
             OperLogBLL.OperLogDelete <ivt_service_bundle>(thisSerBundle, thisSerBundle.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE_BUNDLE, "删除服务包");
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
예제 #2
0
        /// <summary>
        /// 激活停用服务包
        /// </summary>
        public bool ActiveServiceBundle(long serviceId, bool isActive, long userId, ref string faileReason)
        {
            var isbDal  = new ivt_service_bundle_dal();
            var thisSer = isbDal.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 = isbDal.FindNoDeleteById(serviceId);

            isbDal.Update(thisSer);
            OperLogBLL.OperLogUpdate <ivt_service_bundle>(thisSer, oldSer, thisSer.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE_BUNDLE, "编辑服务包");
            return(true);
        }
예제 #3
0
 /// <summary>
 /// 编辑服务包
 /// </summary>
 public bool EditServiceBundle(ivt_service_bundle SerBun, long userId, string serIds)
 {
     try
     {
         var isbDal    = new ivt_service_bundle_dal();
         var oldSerBun = isbDal.FindNoDeleteById(SerBun.id);
         if (oldSerBun == null)
         {
             return(false);
         }
         var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
         SerBun.update_time    = timeNow;
         SerBun.update_user_id = userId;
         isbDal.Update(SerBun);
         OperLogBLL.OperLogUpdate <ivt_service_bundle>(SerBun, oldSerBun, SerBun.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE_BUNDLE, "编辑服务包");
         ServiceBundleManage(SerBun.id, serIds, userId);
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }