zoukankan      html  css  js  c++  java
  • Invoice Helper

    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); }
    }
  • 相关阅读:
    MVC传递数据的方式
    c#面向对象的多态
    使用扩展方法创建 HTML Helper
    了解视图、视图数据和 HTML Helper
    十种技能方法提高IT人薪酬
    ASP.net 2.0:系统优化
    第一个简单的MVC页面
    用户体验时代到来,功能不再重要
    关于SQL递归优化
    web(2)
  • 原文地址:https://www.cnblogs.com/bennylam/p/9920870.html
Copyright © 2011-2022 走看看