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. python三次输入错误验证登录

    # login.py# 提示用户输入用户名和密码# 验证用户名和密码# 如果v错误,则输出用户名或密码错误# 如果成功,则输出欢迎,xxxnum = 0while True: name = input ...

  2. How to prepare system design questions in a tech interview?

    http://blog.baozitraining.org/2014/09/how-to-prepare-system-design-questions.html 如何准备面试中的系统设计问题一直都是 ...

  3. Python学习---重点模块之json

    注意:JSON不能转换类,不能转换函数 重点方法示例 json.dumps():实现文件写入,字符串转换[写入文件当然是JSON字符串楼] 实际上,json.dumps()只是帮我们做了一个字符串的转 ...

  4. CDN缓存策略

    以下内容就是FAQ,自己也学习一下... 1.CDN加速原理通过动态域名解析,网友的请求被分配到离自己最快的服务器.CDN服务器直接返回缓存文件或通过专线代理原站的内容.网络加速+内容缓存,有效提供访 ...

  5. WSGI、flup、fastcgi、web.py、uwsgi

    ==================        网上别人的理解 =================== http://www.douban.com/note/13508388/ 1.Apache/ ...

  6. SOJ1029 Humble Numbers (枚举)

    A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, ...

  7. UVa 12169 - Disgruntled Judge(拓展欧几里德)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  8. mongodb、parse-server、parse-dashboard 的启动命令

    1.mongodb启动: 1$ C:\MongoDB\Server\bin>mongod --logpath d:\mongodb\logs\log.log $ C:\MongoDB\Serve ...

  9. zabbix安装(网络)

    https://www.zabbix.com/documentation/3.4/zh/manual/quickstart/login   zabbix安装官网 https://www.zabbix. ...

  10. MVC 实现下拉框

    MVC动态实现下拉框的方式有很多种,但是方便快捷的却是很少,现在记录一种常用的下拉框实现方式: 1.先看看视图代码是怎么写的 <div class="form-group col-xs ...