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. Pycharm使用中背景颜色和更改项目的Python版本

    一.背景颜色 颜色是每一个人都会去更改的,而且可以保护眼睛! 第二步: 选择图中画框的位置,便可以更改背景颜色! 二.项目版本的更改: python2 和 python3 有很大的不同,使用pytho ...

  2. MYSQL连接相关参数和状态值详解

    针对mysql的连接参数和状态值,本文做些介绍和对比 一.MYSQL连接参数变量 1.常用连接数限制参数 show variables like '%connect%'; | max_connect_ ...

  3. FQDN说明

    以下摘自百度百科: FQDN:(Fully Qualified Domain Name)完全合格域名/全称域名,是指主机名加上全路径,全路径中列出了序列中所有域成员.全域名可以从逻辑上准确地表示出主机 ...

  4. 图解:TCP协议中的三次握手和四次挥手

    建立TCP需要三次握手才能建立,而断开连接则需要四次握手.整个过程如下图所示: 先来看看如何建立连接的. 首先Client端发送连接请求报文,Server段接受连接后回复ACK报文,并为这次连接分配资 ...

  5. Linux命令 标签: linux 2016-08-01 10:26 508人阅读 评论(0) 收藏

    Linux常用命令 文件.目录的基本操作 ls - 查看文件 cp - 拷贝文件 mv - 移动或重命名文件 rm - 删除文件 touch - 创建空文件或更新文件时间 cd - 改变当前路径 pw ...

  6. 美国加拿大著名公共知识分子简·雅各布斯 (Jane Jacobs)的5本书

    作者是美国.加拿大著名公共知识分子.最近看了她的三本书<城市经济><城市与国家财富><经济的本质>.出版社把这三本书归入“城市-经济”三部曲,三本书英文原版的出版日 ...

  7. 浅谈jquery之on()绑定事件和off()解除绑定事件

    off()函数用于移除元素上绑定的一个或多个事件的事件处理函数. off()函数主要用于解除由on()函数绑定的事件处理函数. 该函数属于jQuery对象(实例). 语法 jQuery 1.7 新增该 ...

  8. hdu 6169 gems gems gems【DP】

    题目链接:hdu 6169 gems gems gems Now there are n gems, each of which has its own value. Alice and Bob pl ...

  9. POJ-2992 Divisors---组合数求因子数目

    题目链接: https://cn.vjudge.net/problem/POJ-2992 题目大意: 给出组合数Cnk,求出其因子个数,其中n,k不大于431,组合数的值在long long范围内 解 ...

  10. Excel 移动列操作