• Order Helper


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

  • 相关阅读:
    如何禁用Xcode7下iOS9 App传输安全,并修复无法连接服务器错误
    iOS单例清除
    Git忽略规则及.gitignore规则不生效的解决办法
    javascript 在ie8中报“缺少标识符、字符串或数字“问题再现:
    树莓派 远程桌面 设置显示中文
    在IIS Express中调试时无法读取配置文件 错误
    Win7 下IIS(7.5)发布 ASP.NET MVC
    .Net中使用com组件后发生System.ArithmeticException异常的解决办法(Message=算术运算中发生溢出或下溢。)
    CodeSimth
    windows 开机启动 CassiniDev(IIS替代软件)
  • 原文地址:https://www.cnblogs.com/bennylam/p/9920697.html
Copyright © 2020-2023  润新知