Saturday, October 2, 2010

Guys today I will introduce some great and small piece of code which will make your life heaven in respect of developing winform data entry applications with .net Framework 4.0 Win Forms, have you ever thought of applying functions/classes in application that’s really make life easy and automate your data entry applications development, like what you think of when you come to develop winform application, no.1 how would data would be shown, no.2 how would I clear , enable and disable all controls, no.3 how would I apply validations no.4 how can I make auto insert, update and delete statements with PKFields no .5 how can I make user navigation eaiser , all these questions are answered below with my own developed Utilty Class……Please note here that I haven’t used any third party control like infragistics, teleric etc, I have tried to use only .net controls, but you can also automate your app with third party controls too by modifiying this class. So here we go…..

//Author : Imran Raza //UTILITY CLASS is for having common functions that will be used in all data entry forms. class Utility {

// Populate Controls of winform with the help of datarow of datatable public void PopulateControls(Form frm, DataRow dtr) { CheckBox chkbox;

foreach (DataColumn Col in dtr.Table.Columns) { foreach (Control c in frm.Controls) { //Condition for compareing control name (starting from 3rd character) //for e.g. if control name is "txtName" then it will compare //with db field name like this (Name==Name) if (c.Name.Substring(2,c.Name.Length) == Col.ColumnName) { if (c is TextBox) c.Text = dtr[Col].ToString(); else if (c is CheckBox) { chkbox = (CheckBox)c; chkbox.Checked = dtr[Col].ToString().Equals("1"); }

//Populating Navigation Grid with Stored Procedure and set Column Header with the help of Control //Tag Property public void PopulateGrid(DataGridView grdDetail, Control.ControlCollection Controls,string strStoredPocedureName) {

About Me

My name is Imran Raza Panjwani. I am freelance custom web/desktop application consultant with 9 Years of experience in the field of custom software development which includes different business verticals Currently working with Asp.net , WPF, BizTalk , Share point. I have very strong and sound skills in database designing, mining and ware housing. Also I am associated with PMI being a member of one of the most prestigious project management institute. Recently I have also completed my PMP Certification and now i am PMP Certified. The PMP® Certification offered by the Project Management Institute (PMI) is recognized as the most esteemed Project Management Certification available. In addition to confirming the proficiency of a professional in project management, PMP certification is a useful tool for companies to determine which project managers have the experience and knowledge to do the job right. PMP certification is gaining in popularity with over 200,000 PMPs practicing in over 120 countries. These figures will continue to increase in the coming days. More and more organizations are recognizing the PMP certification as the industry standard for excellence in project management.