CRM operation currency entity

Source: Internet
Author: User

Using system;
Using Microsoft. xrm. SDK;
Using Microsoft. CRM. SDK. messages;

/// <Summary>
/// Currency
/// </Summary>
Public class transactioncurrencyhelper
{
Public static readonly string entityname = "transactioncurrency ";
Public guid transactioncurrencyid = guid. empty;

/// <Summary>
/// Create a currency
/// </Summary>
/// <Param name = "service"> service </param>
Public void create (iorganizationservice Service)
{
Entity en = new entity () {logicalname = entityname };
// Currency code
En ["isocurrencycode"] = "CNY ";
// Currency name
En ["currencyname"] = "coins for life ";
// Currency precision
En ["currencyprecision"] = 2;
// Currency conformity
En ["currencysymbol"] = "¥ ";
// Conversion Rate
En [& quot; exchangerate & quot;] = 1.0;

Transactioncurrencyid = service. Create (en );
}

/// <Summary>
/// Modify the currency
/// </Summary>
/// <Param name = "service"> service </param>
Public void Update (iorganizationservice Service)
{
Entity en = new entity () {logicalname = entityname, id = transactioncurrencyid };
// Currency name
En ["currencyname"] = "aliyun.com-2000 ";

Service. Update (en );
}

/// <Summary>
/// Retrieve the Exchange Rate
/// </Summary>
/// <Param name = "service"> 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>
/// Disable and enable currency
/// </Summary>
Public void updatetransactioncurrencystate (iorganizationservice Service)
{
// Deprecated currency
Updatestate (entityname, transactioncurrencyid, 1, 2, Service );
// Enable currency
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>
/// Delete currency
/// </Summary>
/// <Param name = "service"> service </param>
Public void Delete (iorganizationservice Service)
{
Service. Delete (entityname, transactioncurrencyid );
}
}

CRM operation currency entity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.