示例#1
0
        /// <summary>
        /// 服务新增
        /// </summary>
        /// <param name="ser"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool AddService(ivt_service ser, long userId)
        {
            ivt_service     service = new ivt_service();
            ivt_service_dal dal     = new ivt_service_dal();

            service.id                  = dal.GetNextIdCom();
            service.create_time         = Tools.Date.DateHelper.ToUniversalTimeStamp();
            service.update_time         = service.create_time;
            service.create_user_id      = userId;
            service.update_user_id      = userId;
            service.name                = ser.name;
            service.description         = ser.description;
            service.invoice_description = ser.invoice_description;
            service.sla_id              = ser.sla_id;
            service.vendor_account_id   = ser.vendor_account_id;
            service.period_type_id      = ser.period_type_id;
            service.unit_cost           = ser.unit_cost;
            service.unit_price          = ser.unit_price;
            service.cost_code_id        = ser.cost_code_id;
            service.is_active           = ser.is_active;

            dal.Insert(service);
            OperLogBLL.OperLogAdd <ivt_service>(service, service.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE, "新增服务");
            return(true);
        }
示例#2
0
        /// <summary>
        /// 服务编辑
        /// </summary>
        /// <param name="ser"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool EditService(ivt_service ser, long userId)
        {
            ivt_service_dal dal     = new ivt_service_dal();
            ivt_service     service = dal.FindById(ser.id);
            ivt_service     serOld  = dal.FindById(ser.id);

            service.update_time         = Tools.Date.DateHelper.ToUniversalTimeStamp();
            service.update_user_id      = userId;
            service.name                = ser.name;
            service.description         = ser.description;
            service.invoice_description = ser.invoice_description;
            service.sla_id              = ser.sla_id;
            service.vendor_account_id   = ser.vendor_account_id;
            service.period_type_id      = ser.period_type_id;
            service.unit_cost           = ser.unit_cost;
            service.unit_price          = ser.unit_price;
            service.cost_code_id        = ser.cost_code_id;
            service.is_active           = ser.is_active;

            var desc = OperLogBLL.CompareValue <ivt_service>(serOld, service);

            if (!string.IsNullOrEmpty(desc))
            {
                dal.Update(service);
                OperLogBLL.OperLogUpdate(desc, service.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE, "编辑服务");
            }
            return(true);
        }
示例#3
0
        /// <summary>
        /// 返回服务集信息
        /// </summary>
        /// <param name="context"></param>
        /// <param name="service_bundle_id"></param>
        public void GetServiceBundle(HttpContext context, long service_bundle_id)
        {
            var service_bundle = new ivt_service_dal().FindSignleBySql <ivt_service>($"select * from ivt_service_bundle where id= {service_bundle_id} ");

            if (service_bundle != null)
            {
                context.Response.Write(new EMT.Tools.Serialize().SerializeJson(service_bundle));
            }
        }
示例#4
0
        /// <summary>
        /// 根据ID 集合获取相应的服务信息
        /// </summary>
        public void GetServicesByIds(HttpContext context)
        {
            var serviceIds = context.Request.QueryString["ids"];

            if (!string.IsNullOrEmpty(serviceIds))
            {
                var serList = new ivt_service_dal().GetServiceList($" and id in({serviceIds})");
                if (serList != null && serList.Count > 0)
                {
                    List <ServiceDto> serDtoList = new List <ServiceDto>();
                    var accBll = new CompanyBLL();
                    var dDal   = new d_general_dal();
                    var dccDal = new d_cost_code_dal();
                    serList.ForEach(_ => {
                        var thisDto = new ServiceDto()
                        {
                            id             = _.id,
                            name           = _.name,
                            description    = _.description,
                            unit_cost      = (_.unit_cost ?? 0),
                            unit_price     = (_.unit_price ?? 0),
                            cost_code_id   = _.cost_code_id,
                            period_type_id = _.period_type_id,
                            vendor_id      = _.vendor_account_id,
                        };
                        if (_.vendor_account_id != null)
                        {
                            var thisVendor = accBll.GetCompany((long)_.vendor_account_id);
                            if (thisVendor != null)
                            {
                                thisDto.vendor_name = thisVendor.name;
                            }
                        }
                        if (_.period_type_id != null)
                        {
                            var thisType = dDal.FindNoDeleteById((long)_.period_type_id);
                            if (thisType != null)
                            {
                                thisDto.period_type_name = thisType.name;
                            }
                        }
                        var thisCode = dccDal.FindNoDeleteById(_.cost_code_id);
                        if (thisCode != null)
                        {
                            thisDto.cost_code_name = thisCode.name;
                        }
                        serDtoList.Add(thisDto);
                    });

                    context.Response.Write(new EMT.Tools.Serialize().SerializeJson(serDtoList));
                }
            }
        }
示例#5
0
 /// <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);
 }
示例#6
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("");
        }
示例#7
0
        /// <summary>
        /// 根据ID 集合获取相应的服务 每月价格
        /// </summary>
        public void GetServicePriceByIds(HttpContext context)
        {
            decimal unit_price = 0;
            var     serviceIds = context.Request.QueryString["ids"];

            if (!string.IsNullOrEmpty(serviceIds))
            {
                var serList = new ivt_service_dal().GetServiceList($" and id in({serviceIds})");
                if (serList != null && serList.Count > 0)
                {
                    serList.ForEach(_ => {
                        switch (_.period_type_id)
                        {
                        case (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.ONE_TIME:
                        case (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.MONTH:
                            unit_price += (_.unit_price ?? 0);
                            break;

                        case (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.QUARTER:
                            unit_price += ((_.unit_price ?? 0) / 3);
                            break;

                        case (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.HALFYEAR:
                            unit_price += ((_.unit_price ?? 0) / 6);
                            break;

                        case (int)DTO.DicEnum.QUOTE_ITEM_PERIOD_TYPE.YEAR:
                            unit_price += ((_.unit_price ?? 0) / 12);
                            break;

                        default:
                            break;
                        }
                    });
                }
            }
            context.Response.Write(unit_price.ToString("#0.0000"));
        }
示例#8
0
        /// <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);
        }
示例#9
0
        /// <summary>
        /// 新增合同时添加服务
        /// </summary>
        /// <param name="context"></param>
        /// <param name="id"></param>
        public void AddService(HttpContext context, long id)
        {
            var     service         = new ivt_service_dal().FindById(id);
            string  txt             = "";
            decimal pricePerPeriod  = 0;
            int     monthsPerPeriod = 1;

            if (service != null)
            {
                // 获取供应商名称
                string vendorName = "";
                if (service.vendor_account_id != null)
                {
                    var vendorDal  = new ivt_product_vendor_dal();
                    var accountDal = new crm_account_dal();
                    var vendor     = vendorDal.FindById((long)service.vendor_account_id);
                    if (vendor.vendor_account_id != null)
                    {
                        vendorName = accountDal.FindById((long)vendor.vendor_account_id).name;
                    }
                }

                // 周期
                string period = "";
                if (service.period_type_id != null)
                {
                    period = new GeneralBLL().GetGeneralName((int)service.period_type_id);
                    if (service.unit_price == null)
                    {
                        pricePerPeriod = 0;
                    }
                    else
                    {
                        pricePerPeriod = (decimal)service.unit_price;
                    }

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

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

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

            List <object> result = new List <object>();

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

            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
示例#10
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);
        }