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 Guid invoiceId = 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 };
invoiceId = 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 = invoiceId };
request.Assignee = assignee;
AssignResponse response = (AssignResponse)service.Execute(request);
} /// <summary>
/// 锁定指定发票中产品的单价
/// </summary>
public void LockInvoicePricing()
{
LockInvoicePricingRequest request = new LockInvoicePricingRequest();
request.InvoiceId = invoiceId;
LockInvoicePricingResponse response = (LockInvoicePricingResponse)service.Execute(request);
} /// <summary>
/// 解锁指定发票中产品的单价
/// </summary>
public void UnlockInvoicePricing()
{
UnlockInvoicePricingRequest request = new UnlockInvoicePricingRequest();
request.InvoiceId = invoiceId;
UnlockInvoicePricingResponse response = (UnlockInvoicePricingResponse)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 = invoiceId };
request.Revokee = revokee;
RevokeAccessResponse response = (RevokeAccessResponse)service.Execute(request);
} /// <summary> ///
/// 删除发票 ///
/// </summary>
public void Delete() { service.Delete(entityName, invoiceId); }
}

Invoice Helper的更多相关文章

  1. [C#] 简单的 Helper 封装 -- RegularExpressionHelper

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  2. handlebars自定义helper的写法

    handlebars相对来讲算一个轻量级.高性能的模板引擎,因其简单.直观.不污染HTML的特性,我个人特别喜欢.另一方面,handlebars作为一个logicless的模板,不支持特别复杂的表达式 ...

  3. Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with value '"*, Microsoft.AspNet.Mvc.TagHelpers"'

    project.json 配置: { "version": "1.0.0-*", "compilationOptions": { " ...

  4. VS2015突然报错————Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with value 'Microsoft.AspNet.Mvc.Razor.TagHelpers.UrlResolutionTagHelper

    Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with ...

  5. JavaScript模板引擎artTemplate.js——template.helper()方法

    上一篇文章我们已经讲到了helper()方法,但是上面的例子只是一个参数的写法,如果是多个参数,写法就另有区别了. <div id="user_info"></d ...

  6. [ASP.NET MVC 小牛之路]13 - Helper Method

    我们平时编程写一些辅助类的时候习惯用“XxxHelper”来命名.同样,在 MVC 中用于生成 Html 元素的辅助类是 System.Web.Mvc 命名空间下的 HtmlHelper,习惯上我们把 ...

  7. asp.net MVC helper 和自定义函数@functions小结

    asp.net Razor 视图具有.cshtml后缀,可以轻松的实现c#代码和html标签的切换,大大提升了我们的开发效率.但是Razor语法还是有一些棉花糖值得我们了解一下,可以更加强劲的提升我们 ...

  8. C# random helper class

      项目中经常需要模拟些假数据,来做测试.这个随机生成数据的helper类就应用而生: using System; using System.Text; using System.Windows.Me ...

  9. @helper函数使用方法

    这个函数方法,我也是通过别人博客看到的,感觉不错和大家一起学习分享一下. 1.自定义函数方法,只在同一个view视图文件里调用 Controller public ActionResult Index ...

随机推荐

  1. Linq批量建表

    public JsonResult CreateTable() { db = new RZBDbContext(); var query = (from c in db.Clients select ...

  2. 查看源代码HTML

    HTML 提示 - 如何查看源代码 如果您想找到其中的奥秘,只需要单击右键,然后选择“查看源文件”(IE)或“查看页面源代码”(Firefox),其他浏览器的做法也是类似的.这么做会打开一个包含页面 ...

  3. sqlserver数据库使用空间监控

    数据库使用空间监控,并且每周发邮件预警,下面是操作步骤: 1:建立一张表 ), database_name ), file_group ), logical_name ), physical_name ...

  4. c#编程指南(六) 类索引器(Class Indexer)

    类索引器,可以使得你使用数组一样的方式来访问类的数据. 这种访问多见于数组,列表,词典,哈希表的快捷访问. 实际上写法很简单,写成:public T1 this[T2 i] 代码如下: using S ...

  5. July 08th 2017 Week 27th Saturday

    You are never wrong to do the right thing. 坚持做对的事情,永远都不会错. I think the translation may be not precis ...

  6. C#配置IIS搭建网站的工具类

    public class IISWorker { public static string HostName = "localhost"; /// <summary> ...

  7. SSH2整合需要jar包解释

    hibernate3.jar, Hibernate的库,必须使用的jar包 antlr-2.7.6.jar, 语法分析生成器 语言转换工具,hibernate利用它实现HQL到SQL的转换 cglib ...

  8. 解析纯真IP地址库

    一周以来,一直在做 IP地址库的解析.从调研到编码到优化,大概花了有七八天的时间.感觉很好玩.总结一下整个做的过程. 1.关于IP 地址库的解析方式 目前主要的解析方式有两种:通过API,或通过IP数 ...

  9. C 语言实现多态的原理:函数指针

    C语言实现多态的原理:函数指针 何为函数指针?答案:C Programming Language. 能够查阅下,从原理上来讲,就是一个内存地址.跳过去运行相应的代码段. 既然如此,在运行时决定跳到哪个 ...

  10. php函数:call_user_func

    前段时间浏览文档发现一个有意思的PHP函数:call_user_func [文档地址] 函数作用:该函数主要用于通过函数名去调用该函数 例如: function test(){ echo " ...