Friday, 28 December 2012

Displaying Indian Currency Symbol in C#

The new Indian Currency Symbol () can be shown in a C# application by using the Unicode escape sequence (\u). The Unicode character value assigned to the new Indian currency symbol is 8377. It is equivalent to 20B9 in hexadecimal (base 16) notation.
 
So, we can display the new currency symbol in a C# application in the following manner:

label1.Text =  "\u20B9";

Please see the screenshot below that shows a Windows Forms C# application displaying the new currency symbol.


The labels in the above screenshot have been assigned text using the following commands:

label1.Text = "\u20B9 - " + label1.Font.Name;
label2.Text = "\u20B9 - " + label2.Font.Name;
label3.Text = "\u20B9 - " + label3.Font.Name; 


To display the currency symbol, the font used must support Unicode Standard 6.0 or later.  If your OS is Windows 7 or Vista and you are using a Microsoft font and it is not displaying the currency symbol, you may like to install the update that Microsoft released in early 2011 to update its fonts. To know more about this update, please visit this link.

Happy coding! 

Android Application Source Code

Around two years back I wrote an application in the process of learning Android application development. The application created was named 'Schedule View' as it would let a user view the complete schedule of the ICC Cricket World Cup held in the Indian subcontinent in 2011. The application was posted online and made available for free, and it had a fair number of downloads. You can still download the application from here & here.

Well, I am now making available the source code of this application in the hope that it could be of help to somebody who is learning the ropes of Android application development. The source code is available as an Eclipse project, and can be downloaded from here.

Thank you. :-)

Thursday, 27 December 2012

Number To Words in C# - Source Code

In my previous post Number To Words in Java, I presented the code to convert a number to words in the Indian Numbering System (INS). Now I translated that code to C# so that it could be used in a .NET application. The translation was fairly easy as C# and Java's syntax resemble quit a lot.

The class in the translated code retains the same name which is NumberToWords. A typical usage of the class would be like this:

decimal number = 1084.92M;
string numberInWords =  (line break given for clarity)
NumberToWords.ConvertNumberToWords(number);

The class produces the same output as its corresponding Java class.

Class download link 
 

Number To Words In Java - Source Code

The invoices now-a-days carry not only the invoice amount but the amount in words also (Though it is not a requirement, and I personally don't see any usefulness of showing the amount in words).

While converting a number to words, we have to find a solution that is unique to the Indian Numbering System (INS).

The INS is different from the Western Numbering System (WNS) in the sense that after the first grouping that is done on thousand, the rest of the groupings are done on hundred. So, for a amount like 374892, the conversion in INS would read as "Three Lakh (or Lac) Seventy Four Thousand Eight Hundred & Ninety Two"; While this same number would be converted to WNS as "Three Hundred Seventy Four Thousand Eight Hundred & Ninety Two". The words Million, Billion, Trillion, Zillion and so forth are alien to INS, whereas WNS is ignorant of the words Lakh (or Lac), Crore, Paisa.

In one of my applications, I had to write code to convert amount to words, and the result of which is the class "NumberToWords". The typical usage of this class is as under:

String numberInWords = NumberToWords.convertNumberToWords(numberVariable);

Here, numberVariable is of type java.math.BigDecimal and can be declared and initialised like this:

BigDecimal numberVariable =  new BigDecimal("1094.75");

To download the code, please visit this link.


Below is a table that shows numbers on the left and their corresponding conversion to words on the right done by the aforesaid class.


Amount Conversion To Words
1084.72 One Thousand Eighty Four & Seventy Two Paise
0.96 Ninety Six Paise
558972691 Fifty Five Crore Eighty Nine Lakh Seventy Two Thousand Six Hundred Ninety One
10932756847 One Thousand Ninety Three Crore Twenty Seven Lakh Fifty Six Thousand Eight Hundred Forty Seven
0.00 Zero
7 Seven
11.15 Eleven & Fifteen Paise
109 One Hundred Nine
-111.11 Minus One Hundred Eleven & Eleven Paise

Trust this is of use to somebody. And thank you for your time for reading this post. :-))

Sunday, 23 December 2012

A Free C# Billing Application with Source Code (.NET)

Biller - The Free Billing Application

I am glad to present Biller - a free billing application. This application has been developed keeping small Indian businesses in mind. In India, most of the goods are sold without paying any taxes i.e. tax evasion is done on most of the sales, and hence no tax is added in the invoice. The invoices issued to the customers in general are not the ones that are shown to the Sales Tax officials. This application therefore in keeping in mind its target users don't support the concept of tax. 

Application Screenshots

16 screenshots of the application are available. To view these, please click this link.
Application Screenshots link

Application Download

The application can be downloaded for free. The application download size is less than a MB. 
Application Download link

Application Pre-requisites (Important)

Though the application code itself is quite small, the framework and tools used by it are bulky. To install and run the application, you need to have the following software installed on your computer:

1) .NET Framework 4.0
Full version of .Net Framework 4.0 needs to be installed on your computer. The compact version of .NET Framework better known as the Client Profile version won't suffice for running this application as it uses Crystal Reports.
.NET Framework Download link


If you are using Windows 8, then you are not required to download the .NET Framework as Windows 8 comes bundled with .NET Framework 4.5.

2) Crystal Reports Runtime Engine for .NET Framework 4.0
Though I hated to use it in my application due to its bulkiness, I had no other option but to use it as it is the only professional quality reporting tool available for .NET world for free. Microsoft's ReportViewer infrastructure that comes bundled with Visual Studio is not adequate for professional reporting requirements.
Download link for Crystal Reports Runtime Engine for .NET Framework 4.0


Application Source Code

Full souce code of the application is available for download. The application has been written in C# using Visual Studio 2010. The database used is SQL Server Compact Edition (CE) version 4.0.  

Application Source Code Download link
 

Few people may wonder why I am making available the complete source code of the application available for free. Well, to tell you the truth it was a tough decision and at the same time easy decision for me to take. It was tough because for a developer the source code is a very valued and dear capital. Its value can only be appreciated by those people who have devoted their significant time and energy to acquire the knowledge to write it. And it was a easy decision for me to take because I really wanted to give something back to the world. It is my way of expressing my gratitude and acknowledge indebtedness to the Internet community for their magnanimity and helpfulness. If it were not for the help available to me through numerous articles, tips and tricks, free e-books, code samples & Videos posted on Internet, and also help offered by kind souls available in various forums, I would not even think about writing software.

Feedback Solicited

I would love to receive your feedback about the application - good or bad. You can provide the feedback through the comment section to this blog post. You can also email me on the email address provided in the 'About...' option under the Help menu in the application.

Thank you :-))

 

Sunday, 16 December 2012

Disabling Parameter Prompt Dialog Box in Crystal Reports For Visual Studio

While working with Crystal Reports for Visual Studio 2010, I came across a strange problem. The problem was that the report was prompting me through a dialog box to input values for the parameters defined in the report when I was showing the report in my application. It was indeed a strange behavior as I had assigned the values to all the parameters in the report before showing the ReportViewer control.

I then started searching the internet for the solution to this problem, and came to know that users are experiencing this problem from as early as 2005!!! This made me wonder why this problem has not been resolved yet as I am using the very latest version (CR for VS 2010 Update 4) downloaded few days before from the SAP website. I came across many solutions that had been suggested to get rid of the dialog box.  I tried most of them but unsuccessfully as the obdurate dialog box refused to let go, and this made me really frustrated.

After spending many hours trying to find a fix to this issue, I finally got the solution posted in this blog post. The solution is to follow the steps provided below when showing a report:
  1. Assign a data source to the report like repotDocumentObject.SetDataSource(aDataSourceObject)
  2. Assign the report to the CrystalReportViewer control like reportViewer.ReportSource = reportDocumentObject.
  3. Set parameter values like reportDocumentObject.SetParameterValue(0, invoiceDate).
That's it. That is all required to get rid of the annoying Parameter Prompt  Dialog box in Crystal Reports for Visual Studio.