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

}

}

时间: 2024-10-26 21:12:11

crm操作产品实体的相关文章

crm操作报价单实体

using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk.Query; /// <summary> /// 报价单 /// </summary> public class QuoteHelper { public static readonly string entityName = "quote"; public Guid q

crm操作商机实体

using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; public class OpportunityHelper { public static readonly string entityName = "opportunity"; public Guid opportunityId = Guid.Empty; /// <summary> /// 创建商机 /// </sum

crm操作发票实体

using System; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; using Microsoft.Crm.Sdk.Messages; /// <summary> /// 发票 /// </summary> public class InvoiceHelper { public static readonly string entityName = "invoice"; public Gui

crm操作约会实体

using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk.Query; /// <summary> /// 约会 /// </summary> public class AppointmentHelper { public static readonly string entityName = "appointment"; pu

crm操作案例实体

using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk.Query; /// <summary> /// 案例 /// </summary> public class IncidentHelper { public static readonly string entityName = "incident"; public G

crm操作销售合同实体

using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk.Query; /// <summary> /// 销售合同 /// </summary> public class ContractHelper { public static readonly string entityName = "contract"; public

crm操作货币实体

using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; /// <summary> /// 货币 /// </summary> public class TransactionCurrencyHelper { public static readonly string entityName = "transactioncurrency"; public Guid trans

crm操作传真实体

using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk.Query; /// <summary> /// 传真 /// </summary> public class FaxHelper { public static readonly string entityName = "fax"; public Guid faxId

crm操作权限

using System; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; using System.Collections.Generic; using Microsoft.Crm.Sdk.Messages; /// <summary> /// 权限 /// </summary> public class PrivilegeHelper { public static readonly string entityNa