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"] = ;
//货币符合
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 = ;
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, , , service);
//启用货币
UpdateState(entityName, transactionCurrencyId, , , 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); }
}

Currency 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. POJ1860 Currency Exchange(bellman-ford)

    链接:http://poj.org/problem?id=1860 Currency Exchange Description Several currency exchange points are ...

  7. [ASP.NET MVC 小牛之路]13 - Helper Method

    我们平时编程写一些辅助类的时候习惯用“XxxHelper”来命名.同样,在 MVC 中用于生成 Html 元素的辅助类是 System.Web.Mvc 命名空间下的 HtmlHelper,习惯上我们把 ...

  8. asp.net MVC helper 和自定义函数@functions小结

    asp.net Razor 视图具有.cshtml后缀,可以轻松的实现c#代码和html标签的切换,大大提升了我们的开发效率.但是Razor语法还是有一些棉花糖值得我们了解一下,可以更加强劲的提升我们 ...

  9. C# random helper class

      项目中经常需要模拟些假数据,来做测试.这个随机生成数据的helper类就应用而生: using System; using System.Text; using System.Windows.Me ...

随机推荐

  1. 面试题Spring Boot

    Spring Boot 是微服务中最好的 Java 框架. 我们建议你能够成为一名 Spring Boot 的专家. 问题一 Spring Boot.Spring MVC 和 Spring 有什么区别 ...

  2. JS 获取指定日期的前几天,后几天

    function getNextDate(date,day) { var dd = new Date(date); dd.setDate(dd.getDate() + day); var y = dd ...

  3. 面向对象编程——parent—this

    PHP5 中使用 parent::来引用父类的方法. parent:: 可用于调用父类中定义的成员方法. parent::的追溯不仅于直接父类. PHP5 中为解决变量的命名冲突和不确定性问题,引入关 ...

  4. Linux下SVN安装配置及应用

    一.安装篇 centos下yum安装 yum install subversion 查看安装是否成功: svnserve --version 二.配置篇 创建svn版本库目录 mkdir /home/ ...

  5. antd Grid

    import { Row, Col } from 'antd'; <Row type="flex" //内容布局(左靠齐,右靠齐,居中) justify="star ...

  6. Graph 133. Clone Graph in three ways(bfs, dfs, bfs(recursive))

    Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's ...

  7. Steeltoe

    谈谈Circuit Breaker在.NET Core中的简单应用 http://www.cnblogs.com/catcher1994/p/8975192.html 前言 由于微服务的盛行,不少公司 ...

  8. C#图解教程读书笔记(第8章 表达式和运算符)

    表达式 字面量 整数字面量 字符字面量 字符串字面量 求值顺序 优先级 结合性 与C和C++不同,在C#中的数字不具有布尔意义. 各种运算符的作用(过) 用户定义类型转换 class XiXiInt ...

  9. HDU 6206 Apple (高精确度+JAVA BigDecimal)

    Problem Description Apple is Taotao's favourite fruit. In his backyard, there are three apple trees ...

  10. sysctl.conf学习和调优

    转载于简书:sysctl.conf学习和调优 ,如有版本问题,请联系我 前言 记得第一次接触/etc/security/limits.conf和/etc/sysctl.conf时是因为部署Oracle ...