Currency Helper
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的更多相关文章
- [C#] 简单的 Helper 封装 -- RegularExpressionHelper
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- handlebars自定义helper的写法
handlebars相对来讲算一个轻量级.高性能的模板引擎,因其简单.直观.不污染HTML的特性,我个人特别喜欢.另一方面,handlebars作为一个logicless的模板,不支持特别复杂的表达式 ...
- 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": { " ...
- 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 ...
- JavaScript模板引擎artTemplate.js——template.helper()方法
上一篇文章我们已经讲到了helper()方法,但是上面的例子只是一个参数的写法,如果是多个参数,写法就另有区别了. <div id="user_info"></d ...
- POJ1860 Currency Exchange(bellman-ford)
链接:http://poj.org/problem?id=1860 Currency Exchange Description Several currency exchange points are ...
- [ASP.NET MVC 小牛之路]13 - Helper Method
我们平时编程写一些辅助类的时候习惯用“XxxHelper”来命名.同样,在 MVC 中用于生成 Html 元素的辅助类是 System.Web.Mvc 命名空间下的 HtmlHelper,习惯上我们把 ...
- asp.net MVC helper 和自定义函数@functions小结
asp.net Razor 视图具有.cshtml后缀,可以轻松的实现c#代码和html标签的切换,大大提升了我们的开发效率.但是Razor语法还是有一些棉花糖值得我们了解一下,可以更加强劲的提升我们 ...
- C# random helper class
项目中经常需要模拟些假数据,来做测试.这个随机生成数据的helper类就应用而生: using System; using System.Text; using System.Windows.Me ...
随机推荐
- ubuntu下root不能复制 abc用户下的软连接文件
使用root用户去复制,提示权限不足: 那么这个软连接是个什么东西??
- tcp.cc
ns2-tcp-tcp.cc /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ /* * Copyri ...
- 一段SQL代码
begin transaction set quoted_identifier on set arithabort on set numeric_roundabort off set concat_n ...
- C#常用排序和查找算法
1.C#堆排序代码 private static void Adjust (int[] list, int i, int m) { int Temp = list[i]; int j = i * 2 ...
- Java不带.classpath的svn项目下载,转成到eclipse中
.classpath是Eclipse的工程文件,别人没有将工程的信息传到SVN库中,就检查不出.classpath文件,识别不了项目结构. 这种做法也是比较提倡的方法.SVN上只要有项目的源码信息就可 ...
- 【Leetcode】【Medium】Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes ...
- 抓取windows系统进程
最近在开发辅流分享界面,然后之前的windows编程的代码都忘记了,翻到了一个博客,具体的还是去msdn去查函数,这个是入门的链接如下: http://blog.csdn.net/zdragon200 ...
- mongodb 副本集+分片集群搭建
数据分片节点#192.168.114.26mongod --shardsvr --replSet rsguo --port 2011 --dbpath=/data/mongodb/guo --logp ...
- hdu5194 DZY Loves Balls 【概率论 or 搜索】
//yy:那天考完概率论,上网无聊搜个期望可加性就搜到这题,看到以后特别有亲和感,挺有意思的. hdu5194 DZY Loves Balls [概率论 or 搜索] 题意: 一个盒子里有n个黑球和m ...
- 3.为JDeveloper添加不能的workspace
1.点击选中JDeveloper,在属性中,选中快捷方式, 可以看到目标中的值为C:\Oracle\Middleware\jdeveloper\jdeveloper.exe, 只需要在修改为C:\Or ...