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. 

Friday 16 November 2012

Windows Forms DataGridView FAQ PDF Download


Link to the FAQ file

A developer who has worked with Windows Forms will appreciate the importantance  of the control DataGridView to the application development. It is an all-in-one control that enables one to display, add, edit and delete data in a grid. It exposes numerous properties, methods & events to fully customize its behavior. It is therefore not uncommon that one will look for some help (apart from the documentation) when working with it.

When one goes to the Windows Forms Data Controls and Databinding forum hosted by Microsoft to seek help, he/she is asked to refer to the DataGridView FAQ before posting any query in the forum as the FAQ contains the answers to the most common questions related to the control. The link presented therein is : http://www.windowsclient.net/Samples/Go%20To%20Market/DataGridView/DataGridView%20FAQ.doc

However, the above-mentioned link doesn't work as it takes one to the MSDN Code Repository, where the FAQ in question can't be found. I also faced the same problem, but on a further Google search, I was able to find the FAQ .doc file hosted on a third-party file sharing site. I then converted it to a PDF file since I find it more convenient to read, and then hosted it on my SkyDrive account so that others can access it. The link to the file is provided at the very beginning of this post.

Thank you for reading this post. :-) 

Friday 10 August 2012

MLM Admin - Source code for JavaFX application

Hello and welcome to my blog :-).  In this blog post, I am sharing a JavaFX application that I have written. The application has been written using Java 7 Update 5 and JavaFX version 2.1.

Background for this post:

Actually, I never intended to write this blog, and made this application available public. But, it so happened that the client who had contracted me to write this application was offering peanuts to me as a fee for writing this app. His behavior was not unusual as software piracy is very rampant in Katni, Madhya Pradesh, India where I live, and people are just not inclined to shell out money for the software. They in general don't value any thing that can't be touched e.g writing (sorry for sounding accusative). So frustrated at on not getting the reasonable fee for this app, I decided to make it available to the public in large.

This application is a result of my first serious attempt at writing a JavaFX application. Prior to that I have written few Swing applications, but was not satisfied with the sedate looks they offered. So when I heard about the graphically rich behavior of the JavaFX framework, I was naturally excited.

So enough of background  info for the app and this blog post :-), now let me turn my attention to the app itself. Before I could start writing about the app, you may want to know how it looks. Well, few screenshots of the application are available here. The application (sans source code) can be downloaded by clicking here.

Objective of the application:

The objective is to the manage the membership details of a multi-level marketing firm. The client's primary demand was that the application should notify the user about the commissions due (if any) to the existing members when a new member joins the business. The application supports so-called Matrix plans, where formed a matrix of 3, 4 or etc. which continues to every level. If you choose a matrix of 3 then every member has to join three members under him/her.


The app works according to the principle that the the joining fee of a member becomes due to him/her on completing level 1. The commission due to a member on completing level 2 or more can be specified in the Business rules dialog box as a percentage of the total amount received as joining fee from the members of the completed level. See the image below:



As expected, the application allows to view the member tree, and let you find out the number of members that have joined (directly or indirectly) under a particular member. See the screenshot below:




FXML & Scene Builder:

When I started writing the application, I had heard about the JavaFX FXML language, but I didn't use it initially as I was not inclined to learn a new XML derivative just for writing the user interfaces (UIs). So, I wrote the user interfaces for the first two windows (a.k.a. Stages in JavaFX parlance) in Java code. But, I soon realized that it is not going to work out as writing code for designing UIs is very cumbersome. So, reluctantly I turned my attention to FXML, and fortunately I stumbled upon JavaFX Scene Builder tool. This tool is really good as it makes designing user faces just a matter of drag and drop (you of course need to know various layout panes available in JavaFX to effectively use the tool).

Relative newness of the JavaFX platform:

As the JavaFX platform is relatively new, it doesn't yet have all the necessary armory to design the modern day apps. They have started few separate projects to fill this void, and one such project is JFXtras2. It features, among other controls, a useful Calendar control that is missing from the standard control library of JavaFX. I though have not used it in this app as I found it midway through the development of this project.

The biggest plus point for JavaFX is its rich multimedia support and the support to design attractive user interfaces by just using the standard Cascading Style Sheets (CSS).  How I wish I had more knowledge of the CSS so that I could design better user interfaces for my apps.

Source Code:

You can download the complete source code for the application as a Netbeans 7.2 project from this link.

The applications uses few external libraries, and you will need to include those libraries in your Netbeans project to compile the application. The external libraries are: Joda Time, Jasper Reports, and Apache Derby.

Disclaimer:

I don't hold the license for the icons used in the application. I have used them for illustrative purposes only. Use the icons at your responsibility only.


Feedback:

I would be glad to hear your feedback regarding the application and this blog post. If you have any question related to the app, please feel free to ask, and time permitting, I shall try my best to answer them.

Thank you for reading the post. :-)