Example #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);
 }
Example #2
0
        /// <summary>
        /// 获取到引用此合同的定期服务合同数量
        /// </summary>
        public void GetServiceContractCount(HttpContext context)
        {
            var count     = 0;
            var serviceId = context.Request.QueryString["serivce_id"];

            if (!string.IsNullOrEmpty(serviceId))
            {
                var objCount = new ivt_service_bundle_dal().GetServiceContractCount(long.Parse(serviceId));
                if (objCount != null && !string.IsNullOrEmpty(objCount.ToString()))
                {
                    count = int.Parse(objCount.ToString());
                }
            }
            context.Response.Write(count);
        }
Example #3
0
        public string isServiceOrBag(long object_id)
        {
            // GetSinService
            var service = new ivt_service_dal().GetSinService(object_id);

            if (service != null)
            {
                return(service.name);
            }

            var serviceBundle = new ivt_service_bundle_dal().GetSinSerBun(object_id);

            if (serviceBundle != null)
            {
                return(serviceBundle.name);
            }
            return("");
        }
Example #4
0
 /// <summary>
 /// 新增服务包相关
 /// </summary>
 public bool AddServiceBundle(ivt_service_bundle SerBun, long userId, string serIds)
 {
     try
     {
         var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
         var isbDal  = new ivt_service_bundle_dal();
         SerBun.id             = isbDal.GetNextIdCom();
         SerBun.create_time    = timeNow;
         SerBun.update_time    = timeNow;
         SerBun.create_user_id = userId;
         SerBun.update_user_id = userId;
         isbDal.Insert(SerBun);
         OperLogBLL.OperLogAdd <ivt_service_bundle>(SerBun, SerBun.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE_BUNDLE, "新增服务包");
         ServiceBundleManage(SerBun.id, serIds, userId);
     }
     catch (Exception msg)
     {
         return(false);
     }
     return(true);
 }
Example #5
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);
 }
Example #6
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);
        }
Example #7
0
        /// <summary>
        /// 新增合同时添加服务包
        /// </summary>
        /// <param name="context"></param>
        /// <param name="id"></param>
        public void AddServiceBundle(HttpContext context, long id)
        {
            var           serBun          = new ivt_service_bundle_dal().FindById(id);
            string        txt             = "";
            decimal       pricePerPeriod  = 0;
            int           monthsPerPeriod = 1;
            List <object> result          = new List <object>();

            if (serBun == null)
            {
                result.Add(txt);
                result.Add(pricePerPeriod);

                context.Response.Write(new Tools.Serialize().SerializeJson(result));
                return;
            }

            // 获取供应商名称
            string vendorName = "";

            if (serBun.vendor_account_id != null)
            {
                var vendorDal  = new ivt_product_vendor_dal();
                var accountDal = new crm_account_dal();
                var vendor     = vendorDal.FindById((long)serBun.vendor_account_id);
                if (vendor.vendor_account_id != null)
                {
                    vendorName = accountDal.FindById((long)vendor.vendor_account_id).name;
                }
            }

            // 周期
            string period = "";

            if (serBun.period_type_id != null)
            {
                period = new GeneralBLL().GetGeneralName((int)serBun.period_type_id);
                if (serBun.unit_price == null)
                {
                    pricePerPeriod = 0;
                }
                else
                {
                    pricePerPeriod = (decimal)serBun.unit_price;
                }

                if (serBun.period_type_id == (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.QUARTER)
                {
                    monthsPerPeriod = 3;
                }
                if (serBun.period_type_id == (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.HALFYEAR)
                {
                    monthsPerPeriod = 6;
                }
                if (serBun.period_type_id == (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.YEAR)
                {
                    monthsPerPeriod = 12;
                }
            }

            string unitCost = "";

            if (serBun.unit_cost != null)
            {
                unitCost = "¥" + serBun.unit_cost.ToString();
            }

            txt += $"<tr id='service{serBun.id}'>";
            txt += $"<td style='white - space:nowrap; '><img src = '../Images/delete.png' onclick='RemoveServiceBundle({serBun.id})' alt = '' /></ td > ";
            txt += $"<td><span>{serBun.name}</span></td>";
            txt += $"<td nowrap>{vendorName}</td>";
            txt += $"<td nowrap><span>{period}</span><input type='hidden' id='period{serBun.id}' value='{monthsPerPeriod}' ></td>";
            txt += $"<td nowrap align='right'><span>{unitCost}</span></td>";
            txt += $"<td nowrap align='right'>" + $"<input type='text' onblur='CalcService()' id='price{serBun.id}' name='price{serBun.id}' value = '{pricePerPeriod}' >" + "</ td > ";
            txt += $"<td nowrap align='right'>" + $"<input type='text' onblur='CalcService()' id='num{serBun.id}' name='num{serBun.id}' value = '1' >" + "</ td > ";
            txt += $"<td nowrap align='right'>¥" + $"<input type='text' id='pricenum{serBun.id}' value = '{pricePerPeriod}' disabled >" + "</ td > ";
            txt += "</tr>";

            result.Add(txt);
            result.Add(pricePerPeriod);
            result.Add(serBun.id);
            result.Add(monthsPerPeriod);

            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
Example #8
0
        private crm_quote_item GetParam(out Dictionary <long, int> wareDic)
        {
            var quote_item = AssembleModel <crm_quote_item>();

            quote_item.optional       = Convert.ToUInt64(_optional.Checked ? 1 : 0);
            quote_item.period_type_id = quote_item.period_type_id == 0 ? null : quote_item.period_type_id;
            if (isAdd)
            {
                quote_item.type_id  = int.Parse(Request.Form["ItemTypeId"]);
                quote_item.quote_id = int.Parse(Request.QueryString["quote_id"]);
            }
            else
            {
                quote_item.type_id        = this.quote_item.type_id;
                quote_item.create_time    = this.quote_item.create_time;
                quote_item.create_user_id = this.quote_item.create_user_id;
                quote_item.update_time    = this.quote_item.update_time;
                quote_item.update_user_id = this.quote_item.update_user_id;
                quote_item.id             = this.quote_item.id;
                quote_item.quote_id       = this.quote_item.quote_id;
                quote_item.oid            = this.quote_item.oid;
            }
            wareDic = new Dictionary <long, int>();
            switch (quote_item.type_id)
            {
            case (int)QUOTE_ITEM_TYPE.WORKING_HOURS:

                break;

            case (int)QUOTE_ITEM_TYPE.COST:

                break;

            case (int)QUOTE_ITEM_TYPE.DEGRESSION:

                break;

            case (int)QUOTE_ITEM_TYPE.DISCOUNT:
                break;

            case (int)QUOTE_ITEM_TYPE.PRODUCT:
                var wareIds = Request.Form["wareIds"];
                if (!string.IsNullOrEmpty(wareIds))
                {
                    var wareIdArr = wareIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var wareId in wareIdArr)
                    {
                        var thisAvailable = Request.Form[wareId + "_available"];
                        var hand          = Request.Form[wareId + "_hand"];
                        var use           = Request.Form[wareId + "_use"];
                        if (!string.IsNullOrEmpty(thisAvailable))
                        {
                            wareDic.Add(long.Parse(wareId), int.Parse(thisAvailable));
                        }
                    }
                }
                break;

            case (int)QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES:

                break;

            case (int)QUOTE_ITEM_TYPE.SERVICE:
                var opBLL = new OpportunityBLL();
                if (quote_item.object_id != null)
                {
                    if (opBLL.isServiceOrBag((long)quote_item.object_id) == 1)
                    {
                        var service = new ivt_service_dal().GetSinService((long)quote_item.object_id);
                        if (service != null)
                        {
                            quote_item.period_type_id = service.period_type_id;
                        }
                    }
                    else if (opBLL.isServiceOrBag((long)quote_item.object_id) == 2)
                    {
                        var serviceBundle = new ivt_service_bundle_dal().GetSinSerBun((long)quote_item.object_id);
                        if (serviceBundle != null)
                        {
                            quote_item.period_type_id = serviceBundle.period_type_id;
                        }
                    }
                }
                break;

            case (int)QUOTE_ITEM_TYPE.START_COST:
                quote_item.period_type_id = (int)QUOTE_ITEM_PERIOD_TYPE.ONE_TIME;
                break;

            default:
                break;
            }

            return(quote_item);
        }