zoukankan      html  css  js  c++  java
  • Product Helper

    using System;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Crm.Sdk.Messages;
    
    /// <summary>
    /// 产品
    /// </summary>
    public class ProductHelper
    {
        public static readonly string entityName = "product";
        public Guid productId = Guid.Empty;
        public IOrganizationService service;
    
        /// <summary>
        /// 创建产品
        /// </summary>
        public void Create()
        {
            Entity en = new Entity() { LogicalName = entityName };
            en["name"] = "产品测试";
            productId = service.Create(en);
        }
    
        /// <summary>
        /// 向配套件中添加产品。配套件是包含一个或多个产品的产品目录项
        /// </summary>
        /// <param name="kitId">配套件id</param>
        public void AddProductToKit(Guid kitId)
        {
            AddProductToKitRequest request = new AddProductToKitRequest();
            request.KitId = kitId;
            request.ProductId = productId;
            AddProductToKitResponse response = (AddProductToKitResponse)service.Execute(request);
        }
    
        /// <summary>
        /// 将配套件转换为产品
        /// </summary>
        /// <param name="kitId">配套件id</param>
        public void ConvertKitToProduct(Guid kitId)
        {
            ConvertKitToProductRequest request = new ConvertKitToProductRequest();
            request.KitId = kitId;
            ConvertKitToProductResponse response = (ConvertKitToProductResponse)service.Execute(request);
        }
    
        /// <summary>
        /// 将产品转换为配套件
        /// </summary>
        public void ConvertProductToKit()
        {
            ConvertProductToKitRequest request = new ConvertProductToKitRequest();
            request.ProductId = productId;
            ConvertProductToKitResponse response = (ConvertProductToKitResponse)service.Execute(request);
        }
    
        /// <summary>
        /// 从配套件中删除产品
        /// </summary>
        /// <param name="kitId">配套件id</param>
        public void RemoveProductFromKit(Guid kitId)
        {
            RemoveProductFromKitRequest request = new RemoveProductFromKitRequest();
            request.KitId = kitId;
            request.ProductId = productId;
            RemoveProductFromKitResponse response = (RemoveProductFromKitResponse)service.Execute(request);
        }
    
        /// <summary>         /// 
        /// 删除产品         /// 
        /// </summary>         
        public void Delete() { service.Delete(entityName, productId); }
    }
  • 相关阅读:
    自动装配Bean
    django的models模型 关联关系和关系查询
    django的models模块查询方法
    django的models模型类的常用数据类型和选项
    linux下查看mysql日志文件的方法
    Error loading MySQLdb module: No module named 'MySQLdb'----------- django成功连接mysql数据库的方法
    Django admin 中抛出 'WSGIRequest' object has no attribute 'user'的错误
    linux搭建django项目基本步骤
    找出字符串的最长不重复字串
    判断一个字符串是不是一个合法的IP地址
  • 原文地址:https://www.cnblogs.com/bennylam/p/9920723.html
Copyright © 2011-2022 走看看