using System;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Crm.Sdk.Messages; /// <summary>
/// 销售订单
/// </summary>
public class SoleOrderHelper
{
public static readonly string entityName = "salesorder";
public Guid soleorderId = Guid.Empty;
public IOrganizationService service; /// <summary>
/// 创建销售订单
/// </summary>
public void Create(Guid accountId)
{
Entity en = new Entity() { LogicalName = entityName, Id = accountId };
en["name"] = "销售订单测试";
en["accountid"] = new EntityReference() { LogicalName = "account", Id = accountId };
soleorderId = service.Create(en);
} /// <summary>
/// 将销售订单分派给其他用户或团队
/// </summary>
/// <param name="assignee">用户或团队引用</param>
public void Assign(EntityReference assignee)
{
AssignRequest request = new AssignRequest();
request.Target = new EntityReference() { LogicalName = entityName, Id = soleorderId };
request.Assignee = assignee;
AssignResponse response = (AssignResponse)service.Execute(request);
} /// <summary>
/// 取消销售订单
/// </summary>
/// <param name="status">取消的状态</param>
public void CancelSalesOrder(int status)
{
CancelSalesOrderRequest request = new CancelSalesOrderRequest();
request.OrderClose = new Entity() { LogicalName = entityName, Id = soleorderId };
request.Status = new OptionSetValue(status);
CancelSalesOrderResponse response = (CancelSalesOrderResponse)service.Execute(request);
} /// <summary>
/// 将销售订单转换为发票
/// </summary>
public void ConvertSalesOrderToInvoice()
{
ConvertSalesOrderToInvoiceRequest request = new ConvertSalesOrderToInvoiceRequest();
request.SalesOrderId = soleorderId;
request.ColumnSet = new ColumnSet("name", "accountid");
ConvertSalesOrderToInvoiceResponse response = (ConvertSalesOrderToInvoiceResponse)service.Execute(request);
Entity invoiceEn = response.Entity;
} /// <summary>
/// 完成销售订单
/// </summary>
/// <param name="status">完成的状态</param>
public void FulfillSalesOrder(int status)
{
FulfillSalesOrderRequest request = new FulfillSalesOrderRequest();
request.OrderClose = new Entity() { LogicalName = entityName, Id = soleorderId };
request.Status = new OptionSetValue(status);
FulfillSalesOrderResponse response = (FulfillSalesOrderResponse)service.Execute(request);
} /// <summary>
/// 从指定商机中检索销售订单的产品组
/// </summary>
/// <param name="opportunityId">商机id</param>
public void GetSalesOrderProductsFromOpportunity(Guid opportunityId)
{
GetSalesOrderProductsFromOpportunityRequest request = new GetSalesOrderProductsFromOpportunityRequest();
request.OpportunityId = opportunityId;
request.SalesOrderId = soleorderId;
GetSalesOrderProductsFromOpportunityResponse response =
(GetSalesOrderProductsFromOpportunityResponse)service.Execute(request);
} /// <summary>
/// 锁定销售订单定价
/// </summary>
public void LockSalesOrderPricing()
{
LockSalesOrderPricingRequest request = new LockSalesOrderPricingRequest();
request.SalesOrderId = soleorderId;
LockSalesOrderPricingResponse response = (LockSalesOrderPricingResponse)service.Execute(request);
} /// <summary>
/// 解锁指定的销售订单(订单)中产品的单价
/// </summary>
public void UnlockSalesOrderPricing()
{
UnlockSalesOrderPricingRequest request = new UnlockSalesOrderPricingRequest();
request.SalesOrderId = soleorderId;
UnlockSalesOrderPricingResponse response = (UnlockSalesOrderPricingResponse)service.Execute(request);
} /// <summary>
/// 取消指定安全主体(用户或团队)对销售订单的所有访问权限
/// </summary>
/// <param name="revokee">用户或团队引用</param>
public void RevokeAccess(EntityReference revokee)
{
RevokeAccessRequest request = new RevokeAccessRequest();
request.Target = new EntityReference() { LogicalName = entityName, Id = soleorderId };
request.Revokee = revokee;
RevokeAccessResponse response = (RevokeAccessResponse)service.Execute(request);
} /// <summary> ///
/// 删除销售订单 ///
/// </summary>
public void Delete() { service.Delete(entityName, soleorderId); }
}

using System;using Microsoft.Xrm.Sdk;using Microsoft.Xrm.Sdk.Query;using Microsoft.Crm.Sdk.Messages;
/// <summary>/// 销售订单/// </summary>public class SoleOrderHelper{    public static readonly string entityName = "salesorder";    public Guid soleorderId = Guid.Empty;    public IOrganizationService service;
    /// <summary>    /// 创建销售订单    /// </summary>    public void Create(Guid accountId)    {        Entity en = new Entity() { LogicalName = entityName, Id = accountId };        en["name"] = "销售订单测试";        en["accountid"] = new EntityReference() { LogicalName = "account", Id = accountId };        soleorderId = service.Create(en);    }
    /// <summary>    /// 将销售订单分派给其他用户或团队    /// </summary>    /// <param name="assignee">用户或团队引用</param>    public void Assign(EntityReference assignee)    {        AssignRequest request = new AssignRequest();        request.Target = new EntityReference() { LogicalName = entityName, Id = soleorderId };        request.Assignee = assignee;        AssignResponse response = (AssignResponse)service.Execute(request);    }
    /// <summary>    /// 取消销售订单    /// </summary>    /// <param name="status">取消的状态</param>    public void CancelSalesOrder(int status)    {        CancelSalesOrderRequest request = new CancelSalesOrderRequest();        request.OrderClose = new Entity() { LogicalName = entityName, Id = soleorderId };        request.Status = new OptionSetValue(status);        CancelSalesOrderResponse response = (CancelSalesOrderResponse)service.Execute(request);    }
    /// <summary>    /// 将销售订单转换为发票    /// </summary>    public void ConvertSalesOrderToInvoice()    {        ConvertSalesOrderToInvoiceRequest request = new ConvertSalesOrderToInvoiceRequest();        request.SalesOrderId = soleorderId;        request.ColumnSet = new ColumnSet("name", "accountid");        ConvertSalesOrderToInvoiceResponse response = (ConvertSalesOrderToInvoiceResponse)service.Execute(request);        Entity invoiceEn = response.Entity;    }
    /// <summary>    /// 完成销售订单    /// </summary>    /// <param name="status">完成的状态</param>    public void FulfillSalesOrder(int status)    {        FulfillSalesOrderRequest request = new FulfillSalesOrderRequest();        request.OrderClose = new Entity() { LogicalName = entityName, Id = soleorderId };        request.Status = new OptionSetValue(status);        FulfillSalesOrderResponse response = (FulfillSalesOrderResponse)service.Execute(request);    }
    /// <summary>    /// 从指定商机中检索销售订单的产品组    /// </summary>    /// <param name="opportunityId">商机id</param>    public void GetSalesOrderProductsFromOpportunity(Guid opportunityId)    {        GetSalesOrderProductsFromOpportunityRequest request = new GetSalesOrderProductsFromOpportunityRequest();        request.OpportunityId = opportunityId;        request.SalesOrderId = soleorderId;        GetSalesOrderProductsFromOpportunityResponse response =            (GetSalesOrderProductsFromOpportunityResponse)service.Execute(request);    }
    /// <summary>    /// 锁定销售订单定价    /// </summary>    public void LockSalesOrderPricing()    {        LockSalesOrderPricingRequest request = new LockSalesOrderPricingRequest();        request.SalesOrderId = soleorderId;        LockSalesOrderPricingResponse response = (LockSalesOrderPricingResponse)service.Execute(request);    }
    /// <summary>    /// 解锁指定的销售订单(订单)中产品的单价    /// </summary>    public void UnlockSalesOrderPricing()    {        UnlockSalesOrderPricingRequest request = new UnlockSalesOrderPricingRequest();        request.SalesOrderId = soleorderId;        UnlockSalesOrderPricingResponse response = (UnlockSalesOrderPricingResponse)service.Execute(request);    }
    /// <summary>    /// 取消指定安全主体(用户或团队)对销售订单的所有访问权限    /// </summary>    /// <param name="revokee">用户或团队引用</param>    public void RevokeAccess(EntityReference revokee)    {        RevokeAccessRequest request = new RevokeAccessRequest();        request.Target = new EntityReference() { LogicalName = entityName, Id = soleorderId };        request.Revokee = revokee;        RevokeAccessResponse response = (RevokeAccessResponse)service.Execute(request);    }
    /// <summary>         ///     /// 删除销售订单         ///     /// </summary>             public void Delete() { service.Delete(entityName, soleorderId); }}

Order Helper的更多相关文章

  1. 对依赖倒置原则(DIP)及Ioc、DI、Ioc容器的一些理解

    1.概述 所谓依赖倒置原则(Dependence Inversion Principle)就是要依赖于抽象,不要依赖于具体.简单的说就是要求对抽象进行编程,不要对实现进行编程,这样就降低了客户与实现模 ...

  2. leetcode & lintcode for bug-free

    刷题备忘录,for bug-free leetcode 396. Rotate Function 题意: Given an array of integers A and let n to be it ...

  3. leetcode & lintcode 题解

    刷题备忘录,for bug-free 招行面试题--求无序数组最长连续序列的长度,这里连续指的是值连续--间隔为1,并不是数值的位置连续 问题: 给出一个未排序的整数数组,找出最长的连续元素序列的长度 ...

  4. LeetCode---二叉树3-总结例题

    二叉树-总结例题 1-从中序与后序遍历序列构造二叉树 给定二叉树的后序遍历和二叉树的中序遍历 想法: 先根据后序遍历的最后一个元素构造根节点 寻找根节点在中序遍历中的位置 递归构建根节点的左右子树 / ...

  5. [LeetCode] Binary Tree Zigzag Level Order Traversal 二叉树的之字形层序遍历

    Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to ...

  6. Print a Binary Tree in Vertical Order

    http://www.geeksforgeeks.org/print-binary-tree-vertical-order/ package algorithms; import java.util. ...

  7. magento app/design/adminhtml/default/default/template/sales/order/view/info.phtml XSS Vul

    catalogue . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 Relevant Link: http://www.freebuf. ...

  8. WebGrid Helper with Check All Checkboxes

    WebGrid Helper with Check All Checkboxes myEvernote Link Tuesday, September 13, 2011ASP.NET ASP.NET ...

  9. Binary Tree Vertical Order Traversal

    Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bott ...

随机推荐

  1. bitekind

    xrp这个人到SNT家坐在IOST的椅子上,喝着THETA. 武之巅峰,是孤独,是寂寞,是漫漫求索,是高处不胜寒    逆境中成长,绝地里求生,不屈不饶,才能堪破武之极道.    凌霄阁试炼弟子兼扫地 ...

  2. androidwebview网页显示事件

    @Overridepublic void onPageCommitVisible(WebView view, String url) { super.onPageCommitVisible(view, ...

  3. 如何有效防止API的重放攻击(转自阿里云)

    API重放攻击(Replay Attacks)又称重播攻击.回放攻击,这种攻击会不断恶意或欺诈性地重复一个有效的API请求.攻击者利用网络监听或者其他方式盗取API请求,进行一定的处理后,再把它重新发 ...

  4. SSIS ->> Environment Variables

    SQL Server Integration Services(SSIS) 在2012版本引入了Environment Variables这个新特性.它允许我们为一个环境创建出一套变量用于为项目内的包 ...

  5. Studying TCP's Throughput and Goodput using NS

    Studying TCP's Throughput and Goodput using NS What is Throughput Throughput is the amount of data r ...

  6. WPF DatePicker日期控件只显示年月

    1.需要引用2个类,第一个类DatePickerCalendar public class DatePickerCalendar { public static readonly Dependency ...

  7. January 25 2017 Week 4 Wednesday

    In every triumph, there's a lot of try. 每个胜利背后都有许多尝试. There's a lot of try behind every success, and ...

  8. SAP S/4HANA CDS View的访问控制实现:DCL介绍

    来自我的同事Xu Miles Authorization Objects are business concept, they are distinguished by business scenar ...

  9. 最详细的Vue Hello World应用开发步骤

    很多Vue的初学者想尝试这个框架时,都被webpack过于复杂的配置所吓倒,导致最后无法跑出一个期望的hello word效果.今天我就把我第一次使用webpack打包一个Vue Hello Worl ...

  10. Maven的一些基本命令

    mvn -v 查看maven版本 compile 编译 test 测试 package 打包 clean 删除target install 安装jar包到项目 使用 archetype 创建目录文件 ...