1. using System;
  2. using Microsoft.Xrm.Sdk;
  3. using Microsoft.Xrm.Sdk.Query;
  4. using Microsoft.Crm.Sdk.Messages;
  5.  
  6. /// <summary>
  7. /// 发票
  8. /// </summary>
  9. public class InvoiceHelper
  10. {
  11. public static readonly string entityName = "invoice";
  12. public Guid invoiceId = Guid.Empty;
  13. public IOrganizationService service;
  14.  
  15. /// <summary>
  16. /// 创建发票
  17. /// </summary>
  18. public void Create(Guid accountId)
  19. {
  20. Entity en = new Entity() { LogicalName = entityName, Id = accountId };
  21. en["name"] = "发票测试";
  22. en["accountid"] = new EntityReference() { LogicalName = "account", Id = accountId };
  23. invoiceId = service.Create(en);
  24. }
  25.  
  26. /// <summary>
  27. /// 将发票分派给其他用户或团队
  28. /// </summary>
  29. /// <param name="assignee">用户或团队引用</param>
  30. public void Assign(EntityReference assignee)
  31. {
  32. AssignRequest request = new AssignRequest();
  33. request.Target = new EntityReference() { LogicalName = entityName, Id = invoiceId };
  34. request.Assignee = assignee;
  35. AssignResponse response = (AssignResponse)service.Execute(request);
  36. }
  37.  
  38. /// <summary>
  39. /// 锁定指定发票中产品的单价
  40. /// </summary>
  41. public void LockInvoicePricing()
  42. {
  43. LockInvoicePricingRequest request = new LockInvoicePricingRequest();
  44. request.InvoiceId = invoiceId;
  45. LockInvoicePricingResponse response = (LockInvoicePricingResponse)service.Execute(request);
  46. }
  47.  
  48. /// <summary>
  49. /// 解锁指定发票中产品的单价
  50. /// </summary>
  51. public void UnlockInvoicePricing()
  52. {
  53. UnlockInvoicePricingRequest request = new UnlockInvoicePricingRequest();
  54. request.InvoiceId = invoiceId;
  55. UnlockInvoicePricingResponse response = (UnlockInvoicePricingResponse)service.Execute(request);
  56. }
  57.  
  58. /// <summary>
  59. /// 取消指定安全主体(用户或团队)对发票的所有访问权限
  60. /// </summary>
  61. /// <param name="revokee">用户或团队引用</param>
  62. public void RevokeAccess(EntityReference revokee)
  63. {
  64. RevokeAccessRequest request = new RevokeAccessRequest();
  65. request.Target = new EntityReference() { LogicalName = entityName, Id = invoiceId };
  66. request.Revokee = revokee;
  67. RevokeAccessResponse response = (RevokeAccessResponse)service.Execute(request);
  68. }
  69.  
  70. /// <summary> ///
  71. /// 删除发票 ///
  72. /// </summary>
  73. public void Delete() { service.Delete(entityName, invoiceId); }
  74. }

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. Oracle中用户和方案的区别

    从定义中我们可以看出方案(Schema)为数据库对象的集合,为了区分各个集合,我们需要给这个集合起个名字,这些名字就是我们在企业管理器的方案下看到的许多类似用户名的节点,这些类似用户名的节点其实就是一 ...

  2. java面试题之----jdbc中使用的设计模式(桥接模式)

    1.JDBC(JavaDatabase Connectivity) JDBC是以统一方式访问数据库的API. 它提供了独立于平台的数据库访问,也就是说,有了JDBC API,我们就不必为访问Oracl ...

  3. mongodb 3.4复制搭建

    mongodb数据库主从复制的原理:在主从结构中,主节点的操作记录称为oplog(operation log).oplog存储在一个系统数据库local的集合oplog.$main中,这个集合的每个文 ...

  4. Oracle修改表名的几种方式

    因为原来所在表不想被删除,但又需要新建立一个相同表名的表,故先把原来的表的表名更改为另一个临时表名. 查看当前用户下所有的表  select tname from tab where tabtype= ...

  5. 永中Office的ibus输入法问题

    我在永中Office下无法调用ibus输入法,但是在其他窗口中都没有问题,如:gVIM,LeafPad,OpenOffice等等.我按照网上的方法在.bashrc文件中也添加了以下内容,可是还是不行. ...

  6. (转)C++ 自由存储区是否等价于堆?

      “free store” VS “heap” 当我问你C++的内存布局时,你大概会回答: “在C++中,内存区分为5个区,分别是堆.栈.自由存储区.全局/静态存储区.常量存储区”. 如果我接着问你 ...

  7. CodeForces 91A Newspaper Headline

    题目链接:CodeForces - 91A  Newspaper Headline 官方题解: In this problem letters from s1 should be taken gree ...

  8. newcoder NOIP提高组模拟赛C题——保护

    我是发了疯才来写这道题的 我如果用写这道题的时间去写dp,我估计我能写上三四道 可怕的数据结构题 题目 这道题的鬼畜之处在于实在是不太好写 我们看到要求离树根尽量的近,所以我们很容易就能想到树上倍增, ...

  9. WMIC常用

    显示详细的进程信息 查找进程的具体路径 通过比较严查可疑文件 显示本机安装的软件

  10. PAT——1009. 说反话

    给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出. 输入格式:测试输入包含一个测试用例,在一行内给出总长度不超过80的字符串.字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区 ...