本文整理汇总了C#中System.Decimal.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Decimal.ToString方法的具体用法?C# Decimal.ToString怎么用?C# Decimal.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Decimal
的用法示例。
在下文中一共展示了Decimal.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CurrencyName
public string CurrencyName(string Code,
string DecPrecise
)
{
string Name = "";
if (Code != "")
{
//不需要加入小數位判斷(DecPrecise) 因為SLP已有屬性控制
Decimal d = new Decimal();
if (Decimal.TryParse(Code, out d))
{
string tempStr = "";
string[] d2 = d.ToString().Split('.');
string _NT = "NT$";
for (int i = 0; i < d2.Length; i++)
{
switch (i)
{
case 0:
_NT += d.ToString("n").Split('.')[0];
break;
case 1:
_NT += d.ToString("#." + tempStr.PadRight(int.Parse(DecPrecise), '0')).Split('.')[1];
break;
default:
break;
}
Name = _NT;
}
}
}
return Name;
}
示例2: AddTransaction
public ActionResult AddTransaction(string CardCode, Decimal bp)
{
RKCRM.Transaction model = new RKCRM.Transaction();
model.transaction = new RKCRM.Transaction.TransactionInfo();
model.transaction.External_ID = "159357";
model.transaction.External_Index = "951357";
model.transaction.Amount = bp.ToString();
model.transaction.Transaction_Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " +10:00";
model.transaction.External_Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
model.transaction.Card_Code = CardCode;
model.transaction.Account_Type_ID = "16";
if (bp >= 0)
{
model.transaction.Remarks = "Ручное начисление средств через Вегу пользователем " + User.Identity.Name.ToString();
}
else
{
model.transaction.Remarks = "Ручное списание средств через Вегу пользователем " + User.Identity.Name.ToString();
}
if (model.AddTransaction())
{
if (bp >= 0)
ViewBag.ErrorMessage += "Начислено " + bp.ToString() + " б.";
else
ViewBag.ErrorMessage += "Списано " + bp.ToString() + " б.";
}
else
ViewBag.ErrorMessage += model.LastResult;
return View("Notification/DefaultNotification");
}
示例3: ActualizarFechaPeriodo
public String ActualizarFechaPeriodo(Decimal ID_EMPRESA, String PERIODOSPROCESO, DateTime FECHA)
{
Conexion conexion = new Conexion(Empresa);
conexion.IniciarTransaccion();
Boolean ejecutar = true;
String sql = null;
String informacion = null;
String actualizado = "N";
tools fecha = new tools();
sql = "usp_actualizar_fecha_memorando ";
#region validaciones
if (ID_EMPRESA > 0)
{
sql += ID_EMPRESA.ToString() + ", ";
informacion += "ID_EMPRESA= '" + ID_EMPRESA.ToString() + ", ";
}
else
{
MensajeError = "El campo ID_EMPRESA es requerido para la consulta.";
ejecutar = false;
}
sql += "'" + PERIODOSPROCESO.ToString() + "', ";
informacion += "PERIODOSPROCESO = '" + PERIODOSPROCESO.ToString() + "', ";
sql += "'" + fecha.obtenerStringConFormatoFechaSQLServer(FECHA) + "', ";
informacion += "FECHA = '" + FECHA.ToString() + "', ";
sql += "'" + Usuario.ToString() + "'";
informacion += "USU_MOD = '" + Usuario.ToString() + "'";
#endregion
if (ejecutar)
{
try
{
conexion.ExecuteNonQuery(sql);
actualizado = "S";
#region auditoria
auditoria _auditoria = new auditoria(Empresa);
_auditoria.Adicionar(Usuario, tabla.NOM_PERIODO, tabla.ACCION_LIQUIDAR, sql, informacion, conexion);
#endregion auditoria
conexion.AceptarTransaccion();
}
catch (Exception e)
{
MensajeError = e.Message;
conexion.DeshacerTransaccion();
}
finally
{
conexion.Desconectar();
}
}
return actualizado;
}
示例4: Adicionar
public Decimal Adicionar(Decimal ID_EMPRESA, String DESCRIPCION_RIESGO, Conexion conexion)
{
String sql = null;
String idRecuperado = null;
String informacion = null;
Boolean ejecutar = true;
sql = "usp_ven_empresas_riesgos_adicionar ";
if (ID_EMPRESA != 0)
{
sql += ID_EMPRESA.ToString() + ", ";
informacion += "ID_EMPRESA = '" + ID_EMPRESA.ToString() + "', ";
}
else
{
MensajeError += "El campo ID_EMPRESA no puede ser nulo\n";
ejecutar = false;
}
if (!(String.IsNullOrEmpty(DESCRIPCION_RIESGO)))
{
sql += "'" + DESCRIPCION_RIESGO + "', ";
informacion += "DESCRIPCION_RIESGO = '" + DESCRIPCION_RIESGO + "', ";
}
else
{
MensajeError += "El campo DESCRIPCION_RIESGO no puede ser nulo\n";
ejecutar = false;
}
sql += "'" + Usuario + "' ";
informacion += "USU_CRE = '" + Usuario + "'";
if (ejecutar)
{
try
{
idRecuperado = conexion.ExecuteScalar(sql);
#region auditoria
auditoria _auditoria = new auditoria(Empresa);
_auditoria.Adicionar(Usuario, tabla.VEN_EMPRESAS_RIESGOS, tabla.ACCION_ADICIONAR, sql, informacion, conexion);
#endregion auditoria
}
catch (Exception e)
{
MensajeError = e.Message;
}
}
if (!(String.IsNullOrEmpty(idRecuperado))) return Convert.ToDecimal(idRecuperado);
else return 0;
}
示例5: ConvertDecimalToString
public static String ConvertDecimalToString(Decimal value)
{
CultureInfo cultureInfo = CultureInfo.GetCultureInfo("vi-VN"); // try with "en-US"
if (value.ToString().Equals(null) || value.ToString().Equals(String.Empty) || value.Equals(Decimal.Zero))
{
return AppConstraints.ZERO + AppConstraints.VND;
}
return (Decimal.Parse(value.ToString()).ToString("#,###.##", cultureInfo.NumberFormat)) + AppConstraints.VND;
}
示例6: PosTest2
public bool PosTest2()
{
bool retVal = true;
const string c_TEST_DESC = "PosTest2:Verify the param is UInt64.MinValue(0) ";
const string c_TEST_ID = "P002";
UInt64 dValue = UInt64.MinValue;
Decimal resValue = 0m;
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
try
{
Decimal decimalValue = new Decimal(dValue);
if (decimalValue != resValue)
{
string errorDesc = "Value is not " + resValue.ToString() + " as expected: param is " + decimalValue.ToString();
TestLibrary.TestFramework.LogError("003" + " TestId-" + c_TEST_ID, errorDesc);
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("004" + " TestId-" + c_TEST_ID + " TestId-" + c_TEST_ID, "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例7: ToDecimalTestCase1
public void ToDecimalTestCase1()
{
var expected = new Decimal( 100.12 );
var value = expected.ToString( CultureInfo.InvariantCulture );
var actual = ObjectEx.ToDecimal( value, CultureInfo.InvariantCulture );
Assert.AreEqual( expected, actual );
}
示例8: MainForm
public MainForm(Decimal versionNumber)
{
InitializeComponent();
Text = String.Format("Plutus (v{0})", versionNumber.ToString());
_dam = new DataAccessManager(); //also loads all data from .XML files
}
示例9: LeviedDetailForList
public LeviedDetailForList(string levydesc, Decimal rate, Decimal basis, Decimal levied)
{
this.basis = basis.ToString();
this.rate = rate.ToString("#.000000");
this.levyDescription = levydesc;
this.levied = levied.ToString("C");
}
示例10: PosTest1
public bool PosTest1()
{
bool retVal = true;
const string c_TEST_DESC = "PosTest1:Verify the param is a random UInt64 ";
const string c_TEST_ID = "P001";
System.UInt64 uint64Value = Convert.ToUInt64(TestLibrary.Generator.GetInt64(-55));
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
try
{
Decimal decimalValue = new Decimal(uint64Value);
if (decimalValue != Convert.ToDecimal(uint64Value))
{
string errorDesc = "Value is not " + Convert.ToDecimal(uint64Value).ToString() + " as expected: param is " + decimalValue.ToString();
TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID + " TestId-" + c_TEST_ID, "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例11: Buy
public Uri Buy(string customerId, string prodId, Decimal paymentAmount)
{
string paymentAmountStr = paymentAmount.ToString("F", NumberFormatInfo.InvariantInfo);
string returnUrl = Settings.Default.PayPalApiReturn;
string cancelUrl = Settings.Default.PayPalApiCancel;
var paymentAction = PaymentActionCodeType.Sale;
var currencyCode = CurrencyCodeType.USD;
var ppResponse = this.ECSetExpressCheckoutCode(paymentAmountStr, returnUrl, cancelUrl, paymentAction, currencyCode);
if (ppResponse.Ack == AckCodeType.Success)
{
// save and redirect
SavePayPalTransactionBegin(customerId, prodId, ppResponse);
string payPalServer = Settings.Default.PayPalApiServer;
string payPalCheckoutCmd = "/webscr?cmd=_express-checkout&token=" + ppResponse.Token;
return new Uri(payPalServer + payPalCheckoutCmd);
}
else
{
// save and show error
SavePayPalTransactionBeginError(customerId, prodId, ppResponse);
throw new ApplicationException("PayPal returned error: " + ppResponse.Errors[0].LongMessage);
}
}
示例12: PosTest1
public bool PosTest1()
{
bool retVal = true;
const string c_TEST_DESC = "PosTest1:Verify the param is a random float ";
const string c_TEST_ID = "P001";
float dValue = TestLibrary.Generator.GetSingle(-55);
while (dValue > Convert.ToSingle(Decimal.MaxValue) || dValue < Convert.ToSingle(Decimal.MinValue))
{
dValue = TestLibrary.Generator.GetSingle(-55);
}
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
try
{
Decimal decimalValue = new Decimal(dValue);
if (decimalValue != Convert.ToDecimal(dValue))
{
string errorDesc = "Value is not " + decimalValue.ToString() + " as expected: param is " + dValue.ToString();
TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID + " TestId-" + c_TEST_ID, "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例13: ObtenerInformacionParaSemaforoPrincipal
public DataTable ObtenerInformacionParaSemaforoPrincipal(Decimal ID_EMPRESA)
{
Conexion conexion = new Conexion(Empresa);
DataSet _dataSet = new DataSet();
DataView _dataView = new DataView();
DataTable _dataTable = new DataTable();
String sql = null;
Boolean ejecutar = true;
sql = "usp_nom_empleados_obtenerSemaforoPrincipalGestionHumana ";
sql += ID_EMPRESA.ToString();
if (ejecutar)
{
try
{
_dataSet = conexion.ExecuteReader(sql);
_dataView = _dataSet.Tables[0].DefaultView;
_dataTable = _dataView.Table;
}
catch (Exception e)
{
MensajeError = e.Message;
}
finally
{
conexion.Desconectar();
}
}
return _dataTable;
}
示例14: ObtenerNominasHojaTrabajo
public DataTable ObtenerNominasHojaTrabajo(Decimal ID_EMPRESA, String ID_EMPRESAS, String ANALISTA)
{
Conexion conexion = new Conexion(Empresa);
DataSet _dataSet = new DataSet();
DataView _dataView = new DataView();
DataTable _dataTable = new DataTable();
String sql = null;
Boolean ejecutar = true;
sql = "usp_obtener_nomina_proceso_hoja_trabajo ";
#region validaciones
if (ID_EMPRESA > 0)
{
sql += ID_EMPRESA.ToString() + " ";
}
else
{
sql += "0" + " ";
}
if (!(String.IsNullOrEmpty(ID_EMPRESAS)))
{
sql += ", '" + ID_EMPRESAS.ToString() + "'";
}
else
{
sql += ",''";
}
if (!(String.IsNullOrEmpty(ANALISTA)))
{
sql += ", '" + ANALISTA.ToString() + "'";
}
else
{
sql += ",''";
}
#endregion
if (ejecutar == true)
{
try
{
_dataSet = conexion.ExecuteReader(sql);
_dataView = _dataSet.Tables[0].DefaultView;
_dataTable = _dataView.Table;
}
catch (Exception e)
{
MensajeError = e.Message;
}
finally
{
conexion.Desconectar();
}
}
return _dataTable;
}
示例15: SaveToDecimalTestCase4
public void SaveToDecimalTestCase4()
{
var expected = new Decimal( RandomValueEx.GetRandomInt32() + 0.123 );
var actual = expected.ToString( CultureInfo.InvariantCulture )
.SaveToDecimal( Decimal.MaxValue );
Assert.AreEqual( expected, actual );
}