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

        }

    }

最新文章

  1. MediaCodec Name &amp; Type
  2. 我总结的js性能优化的小知识
  3. LeetCode 263 Ugly Number
  4. android学习笔记54——ContentProvider
  5. 理解与模拟一个简单servlet容器
  6. ABAP程序中退出操作(CHECK, EXIT, RETURN, LEAVE PROGRAM)
  7. 改变placeholder颜色
  8. list.clear()和list=null的区别
  9. Iso language code table之(软件国际化)
  10. hdu 1839 Delay Constrained Maximum Capacity Path
  11. mysql trouble shooting---- 从库停止同步lock_wait_timeout_exceeded_try_restarting_transaction
  12. Javascript中变量作用域(2)
  13. C语言函函数嵌套
  14. 开发技巧(3-1)Eclipse查找关键字
  15. Canvas绘制五角星
  16. Python的logging日志
  17. Anatomy of a Database System学习笔记 - 公共模块、结语
  18. [转]Database Transactions in Laravel
  19. nginx.conf配置文件详解
  20. iptables filter表 案例、iptables nat表的路由功能 、端口映射

热门文章

  1. Session、Cookie总结
  2. Most common words
  3. ListView的setOnItemClickListener回调不能执行的解决
  4. Webfont 的兼容性问题[持续更新]
  5. TabLayout中Indicator的样式修改
  6. .net 操作INI文件
  7. 维生素C主要生理功能
  8. LocalDateTime与mysql日期类型的交互(基于mybatis)
  9. 洛谷 P3467 [POI2008]PLA-Postering
  10. 四 过滤模式 map Only - 作业完成 bloomFilter、top10、去重