Here is a gift to .Net Application Programmers: A huge collection of useful .Net functions which you will find useful and interesting in your daily .Net programming. The project is written in C#.Net, and still being updated. Let me know if you have any question or suggestions, I would be glad to help you.
Here are the usage guide-lines for some important classes and functions of the library:
1. DataMethods Class
DataMethods class provides all core functionality for SQL database.
Only once, you just need to provide the database connection string at the start up of your application.
Or if you are using configuration file (App.config or Web.config):
Some of the important functions form this class:
- ExecuteQuery: Execute non-query types like Insert, Update or Delete.
- SearchEntireDatabase: Search for a string in all tables of the database
You can also use SQL transaction very easily with this class: Just call your all queries after calling BeginTrans: Use RollBackTrans to cancel (undo) the transaction and use CommitTrans at last on success.
DataMethods class is used for all database related operations by other classes of the library too- like DataExporter class.
2. StringMethods Class
All methods related to string which you are missing in C#.Net.
- IsNumeric: Check if the provided text is a numeric value or not
- IsStringEmpty: Check if the string is null or empty with trimming spaces
- ToSentenceCase: Convert the text to proper sentence case
- NumberToWords: Convert a numeric value into word format.
3. FileHandling Class
Offers functions related to writing in files and getting file information. Important functions:
- GetFileName: Get a file name from the full path
- GetDirectoryPath: Get directory path of the file
- IsDirectory: Check if the given path is a directory or a file
- CopyFiles: Copy or move files from given sources to the destination
4. MediaPlayer Class
Easily play background sound using methods of this class. Offers Play, Pause, Stop and functions to control volume, treble and bass.
bool Loop = true;
5. Calculator Class
Provide any simple or complex input formula and this class will evaluate it and give you the result. The function automatically handles parenthesis.
6. DataExporter Class
Export data from your data table or from SQL Select query to a file in formats like plain text, HTML and CSV (Excel).
objExporter.DataTable = dt1;
objExporter.TableTitle = “Daily Report”;
7. DateDifference Class
Easily find difference between two dates in year, month and days.
string difference = objDateDiff.ToString();
8. DateTimeMethods Class
Functions related to date-time like convert a string to usable date, get month number from month name or month short-name, convert a date into word format.
- ConvertToSystemDate (“09/28/1982”, “M/d/yyyy”)
- GetMonthNumberFromMonthName (“JAN”)
9. HTMLUtil Class
Easily generate HTML formatted text and save to a file. You can provide a DataTable and automatically convert it into HTML format.
objHTML.FilePath = Application.StartupPath + “\\” + “Contacts.html”;
objHTML.AddText(“Contacts”, “bold”, null, “underline”, null, null, null, HTMLUtil.Align.Center);
objHTML.AddTable(dtContacts, “Name|Phone1|Phone2”, “Name|Phone 1|Phone 2”, “200px|100px|100px”);
10. Networking Class
Useful networking related methods like check if a website is running or down, check if internet connection is available or not.
- CheckInternetConnection (“http://techforworld.com”)