zoukankan      html  css  js  c++  java
  • crm操作货币实体

        using System;
        using Microsoft.Xrm.Sdk;
        using Microsoft.Crm.Sdk.Messages;

        /// <summary>
        /// 货币
        /// </summary>
        public class TransactionCurrencyHelper
        {
            public static readonly string entityName = "transactioncurrency";
            public Guid transactionCurrencyId = Guid.Empty;

            /// <summary>
            /// 创建货币
            /// </summary>
            /// <param name="service">服务</param>
            public void Create(IOrganizationService service)
            {
                Entity en = new Entity() { LogicalName = entityName };
                //货币代码
                en["isocurrencycode"] = "CNY";
                //货币名称
                en["currencyname"] = "人命币";
                //货币精度
                en["currencyprecision"] = 2;
                //货币符合
                en["currencysymbol"] = "¥";
                //换算比率
                en["exchangerate"] = 1.0;

                transactionCurrencyId = service.Create(en);
            }

            /// <summary>
            /// 改动货币
            /// </summary>
            /// <param name="service">服务</param>
            public void Update(IOrganizationService service)
            {
                Entity en = new Entity() { LogicalName = entityName,Id = transactionCurrencyId };
                //货币名称
                en["currencyname"] = "人命币-2000";

                service.Update(en);
            }

            /// <summary>
            /// 检索汇率
            /// </summary>
            /// <param name="service">服务</param>
            public decimal SearchRateById(IOrganizationService service)
            {
                decimal value = 0;
                RetrieveExchangeRateRequest request = new RetrieveExchangeRateRequest();
                request.TransactionCurrencyId = transactionCurrencyId;
                RetrieveExchangeRateResponse response = (RetrieveExchangeRateResponse)service.Execute(request);
                value = response.ExchangeRate;
                return value; 
            }

            /// <summary>
            /// 停用和启用货币
            /// </summary>
            public void UpdateTransactionCurrencyState(IOrganizationService service)
            {
                //停用货币
                UpdateState(entityName, transactionCurrencyId, 1, 2, service);
                //启用货币
                UpdateState(entityName, transactionCurrencyId, 0, 1, service);
            }

            private void UpdateState(string enName, Guid id, int state, int status, IOrganizationService service)
            {
                SetStateRequest setState = new SetStateRequest()
                {
                    EntityMoniker = new EntityReference()
                    {
                        Id = id,
                        LogicalName = enName
                    },
                    State = new OptionSetValue(state),
                    Status = new OptionSetValue(status)
                };
                service.Execute(setState);
            }

            /// <summary>
            /// 删除货币
            /// </summary>
            /// <param name="service">服务</param>
            public void Delete(IOrganizationService service)
            {
                service.Delete(entityName, transactionCurrencyId);
            }
        }

  • 相关阅读:
    ABAP POH和POV事件中 获得屏幕字段的值
    SAP 发送邮件 面向对象
    SAP文件的上传下载 SMW0,二进制文件
    SAP smartform 实现打印条形码
    SAP GB01替代 程序:RGUGBR00
    SAP问题【转载】
    物料库存确定组
    SAP ECC EHP7 RFC 发布成WebService
    NUMBER_GET_NEXT 获取编号 遇到关于按年度编号的问题
    SAP 参照sto订单创建外向交货BAPI
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/5361155.html
Copyright © 2011-2022 走看看