码迷,mamicode.com
首页 > 其他好文 > 详细

crm操作产品实体

时间:2014-07-22 14:30:49      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:crm创建产品   crm将配套件转换为产品   crm将产品转换为配套件   crm从配套件中删除产品   crm删除产品   

    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);
        }
    }

crm操作产品实体

标签:crm创建产品   crm将配套件转换为产品   crm将产品转换为配套件   crm从配套件中删除产品   crm删除产品   

原文地址:http://blog.csdn.net/y_f123/article/details/38034009

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!