Difference between pages "Convert Money to Text in C Sharp" and "SMS Notify! Obsolete Version"

From CDYNE Wiki
(Difference between pages)
Jump to navigation Jump to search
imported>ChristopherC
 
imported>Ddrake
(New page: Send SMS Text Messages to your mobile telephone devices without the use developing your own software! Send custom alert messages to your valued customers without paying a dime on expensive...)
 
Line 1: Line 1:
This C# code allows you to convert currency numbers into words.
+
Send SMS Text Messages to your mobile telephone devices without the use developing your own software! Send custom alert messages to your valued customers without paying a dime on expensive hardware, and software.  
  
Example:
 
$152.17 into One Hundred Fifty Two Dollars and Seventeen Cents.
 
  
<code type=c#>
+
== General Information ==
 +
[http://www.cdyne.com/products/default.aspx SMS Notify!] - Coming Soon!
  
public static string ConvertMoneyToText(string value)
+
== Sign up for a license Key ==  
{
 
value = value.Replace(",", "").Replace("$", "");
 
int decimalCount = 0;
 
int Val = value.Length - 1;
 
for (int x = 0; x <= Val; x++)
 
{
 
char Val2 = value[x];
 
if (Val2.ToString() == ".")
 
{
 
decimalCount++;
 
if (decimalCount > 1)
 
{
 
throw new ArgumentException("Only monetary values are accepted");
 
}
 
}
 
Val2 = value[x];
 
char Valtemp = value[x];
 
if (!(char.IsDigit(value[x]) | (Val2.ToString() == ".")) & !((x == 0) & (Valtemp.ToString() == "-")))
 
{
 
throw new ArgumentException("Only monetary values are accepted");
 
}
 
}
 
string returnValue = "";
 
string[] parts;
 
if (value.Contains("."))
 
parts = value.Split(new char[] { '.' });
 
else
 
parts = (value + ".00").Split(new char[] { '.' });
 
  
 +
=== All Volume Customers ===
 +
[https://secure.cdyne.com/support/register.aspx?qs=34 Register Here!] - Create an account and click add next to  '''SMS Notify!'''. Use this license key  in your development projects. Inquire for volume discounts.
  
parts[1] = new string((parts[1] + "00").Substring(0, 2).ToCharArray());
+
==== Pricing ====
bool IsNegative = parts[0].Contains("-");
+
[https://secure.cdyne.com/products/pricing.aspx?PGID=37ba219f-979e-426f-8515-dd65cebe184b SMS Notify! Pricing]  
if (parts[0].Replace("-", "").Length > 0x12)
 
{
 
throw new ArgumentException("Maximum value is $999,999,999,999,999,999.99");
 
}
 
if (IsNegative)
 
{
 
parts[0] = parts[0].Replace("-", "");
 
returnValue = returnValue + "Minus ";
 
}
 
if (parts[0].Length > 15)
 
{
 
returnValue = ((((returnValue + HundredsText(parts[0].PadLeft(0x12, '0').Substring(0, 3)) + "Quadrillion ")
 
+ HundredsText(parts[0].PadLeft(0x12, '0').Substring(3, 3)) + "Trillion ") +
 
HundredsText(parts[0].PadLeft(0x12, '0').Substring(6, 3)) + "Billion ") +
 
HundredsText(parts[0].PadLeft(0x12, '0').Substring(9, 3)) + "Million ") +
 
HundredsText(parts[0].PadLeft(0x12, '0').Substring(12, 3)) + "Thousand ";
 
}
 
else if (parts[0].Length > 12)
 
{
 
returnValue = (((returnValue + HundredsText(parts[0].PadLeft(15, '0').Substring(0, 3)) +
 
"Trillion ") + HundredsText(parts[0].PadLeft(15, '0').Substring(3, 3)) + "Billion ") +
 
HundredsText(parts[0].PadLeft(15, '0').Substring(6, 3)) + "Million ") +
 
HundredsText(parts[0].PadLeft(15, '0').Substring(9, 3)) + "Thousand ";
 
}
 
else if (parts[0].Length > 9)
 
{
 
returnValue = ((returnValue + HundredsText(parts[0].PadLeft(12, '0').Substring(0, 3)) +
 
"Billion ") + HundredsText(parts[0].PadLeft(12, '0').Substring(3, 3)) + "Million ") +
 
HundredsText(parts[0].PadLeft(12, '0').Substring(6, 3)) + "Thousand ";
 
}
 
else if (parts[0].Length > 6)
 
{
 
returnValue = (returnValue + HundredsText(parts[0].PadLeft(9, '0').Substring(0, 3)) +
 
"Million ") + HundredsText(parts[0].PadLeft(9, '0').Substring(3, 3)) + "Thousand ";
 
}
 
else if (parts[0].Length > 3)
 
{
 
returnValue = returnValue + HundredsText(parts[0].PadLeft(6, '0').Substring(0, 3)) +
 
"Thousand ";
 
}
 
string hundreds = parts[0].PadLeft(3, '0');
 
int tempInt = 0;
 
hundreds = hundreds.Substring(hundreds.Length - 3, 3);
 
if (int.TryParse(hundreds, out tempInt) == true)
 
{
 
if (int.Parse(hundreds) < 100)
 
{
 
//returnValue = returnValue + "and ";
 
}
 
returnValue = returnValue + HundredsText(hundreds) + "Dollar";
 
if (int.Parse(hundreds) != 1)
 
{
 
returnValue = returnValue + "s";
 
}
 
if (int.Parse(parts[1]) != 0)
 
{
 
returnValue = returnValue + " and ";
 
}
 
}
 
if ((parts.Length == 2) && (int.Parse(parts[1]) != 0))
 
{
 
returnValue = returnValue + HundredsText(parts[1].PadLeft(3, '0')) + "Cent";
 
if (int.Parse(parts[1]) != 1)
 
{
 
returnValue = returnValue + "s";
 
}
 
}
 
return returnValue;
 
}
 
  
 +
== Developer/Tester Information ==
 +
* [http://ws.cdyne.com/SmsWS/SMS.asmx?wsdl WSDL]
 +
* [http://ws.cdyne.com/SmsWS/SMS.asmx Testing URL]
 +
*
  
static string[] Tens = new string[] {
 
"Ten",
 
"Twenty",
 
"Thirty",
 
"Forty",
 
"Fifty",
 
"Sixty",
 
"Seventy",
 
"Eighty",
 
"Ninety" };
 
static string[] Ones = new string[] {
 
"One",
 
"Two",
 
"Three",
 
"Four",
 
"Five",
 
"Six",
 
"Seven",
 
"Eight",
 
"Nine",
 
"Ten",
 
"Eleven",
 
"Twelve",
 
"Thirteen",
 
"Fourteen",
 
"Fifteen",
 
"Sixteen",
 
"Seventeen",
 
"Eighteen",
 
"Nineteen" };
 
  
  
  
private static string HundredsText(string value)
 
{
 
char Val_1;
 
char Val_2;
 
  
string returnValue = "";
 
bool IsSingleDigit = true;
 
char Val = value[0];
 
if (int.Parse(Val.ToString()) != 0)
 
{
 
Val_1 = value[0];
 
returnValue = returnValue + Ones[int.Parse(Val_1.ToString()) - 1] + " Hundred ";
 
IsSingleDigit = false;
 
}
 
Val_1 = value[1];
 
if (int.Parse(Val_1.ToString()) > 1)
 
{
 
Val = value[1];
 
returnValue = returnValue + Tens[int.Parse(Val.ToString()) - 1] + " ";
 
Val_1 = value[2];
 
if (int.Parse(Val_1.ToString()) != 0)
 
{
 
Val = value[2];
 
returnValue = returnValue + Ones[int.Parse(Val.ToString()) - 1] + " ";
 
}
 
return returnValue;
 
}
 
Val_1 = value[1];
 
if (int.Parse(Val_1.ToString()) == 1)
 
{
 
Val = value[1];
 
Val_2 = value[2];
 
return (returnValue + Ones[int.Parse(Val.ToString() + Val_2.ToString()) - 1] + " ");
 
}
 
Val_2 = value[2];
 
if (int.Parse(Val_2.ToString()) == 0)
 
{
 
return returnValue;
 
}
 
if (!IsSingleDigit)
 
{
 
returnValue = returnValue + "and ";
 
}
 
Val_2 = value[2];
 
return (returnValue + Ones[int.Parse(Val_2.ToString()) - 1] + " ");
 
}
 
  
</code>
+
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
https://secure.cdyne.com/products/pricing.aspx?PGID=37ba219f-979e-426f-8515-dd65cebe184b

Revision as of 14:48, 23 January 2008

Send SMS Text Messages to your mobile telephone devices without the use developing your own software! Send custom alert messages to your valued customers without paying a dime on expensive hardware, and software.


General Information

SMS Notify! - Coming Soon!

Sign up for a license Key

All Volume Customers

Register Here! - Create an account and click add next to SMS Notify!. Use this license key in your development projects. Inquire for volume discounts.

Pricing

SMS Notify! Pricing

Developer/Tester Information













https://secure.cdyne.com/products/pricing.aspx?PGID=37ba219f-979e-426f-8515-dd65cebe184b