Thursday, March 17, 2011

بہائم کی اور اُن کی حالت ہے یکساں

بہائم کی اور اُن کی حالت ہے یکساں
کہ جس حال میں ہیں، اسی میں ہیں شاداں
نہ ذلت سے نفرت نہ عزت کا ارماں
نہ دوزخ کے ترساں نہ جنت کے خواہاں
لیا عقل و دیں سے نہ کچھ کام انہوں نے
کیا دین بر حق کو بدنام انہوں نے

Tuesday, March 08, 2011

New .NET Ribbon Control

f you like this post, please visit our sponsors above. Thanks!

Recently I have been exploring the use of Ribbon Control. Yesterday, I posted a tutorial on its use with Windows Workflow Foundation. However, I am far more comfortable developing applications with Windows Forms . So, I searched for Ribbon Control for Windows Forms. Although I found an open source version here, there was no associated tutorial. So I decided to write one. In this tutorial I will explain how to create a simple windows forms application with a Ribbon Control and how to add buttons.

1. Download the Ribbon Control binaries here.

2. Create a Windows Forms Visual Studio Project.

3. Add reference to the downloaded System.Windows.Forms.Ribbon.dll

4. Chose Items and Browes the Ribbon dll and Add then you can see Ribbon controls on you
Item list.
5. Dreag and drop the Ribbon Penal and Ribbon Tab on your frm.

Your Windows Form Should look like this;



















From this point onward, adding controls to the ribbon should be easy.

5. To add a tab to your ribbon control, click ‘Add Tab’. I have added three tabs; Home, Data Manipulation and Visualization. As with any control, you can change the properties of the tabs using the properties grid.

6. Once the panels have been created, click a panel. The property grid shows options for the panel. Besides ‘Add Button’, these options include ‘Add Button List’, ‘Add Item Group’, ‘Add Separator’ etc. Click the ‘Add Button’ command. A button is created. You can use the property grid to set the text, tool tip and image for the button.

7. Ribbon Button click Event.

Private Sub RibbonButton7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RibbonButton1.Click
MsgBox("test")
End Sub
MsgBox("test")
End Sub



Congratulations! you have successfully added a ribbon control to your Windows Forms Application. You are good to go!

Thursday, March 03, 2011

بدلتا ہے رنگ آسماں کیسے کیسے

زندگی میں ہمارے ساتھ چلنے والا ہر شخص اس لیے نہیں ہوتا کہ ہم ٹھوکر کھا کر گریں اور وہ ہمیں سنبھال لے ہاتھ تھام کر، گرنے سے پہلے یا بازو کھینچ کر گرنے کے بعد۔ بعض لوگ زندگی کے اس سفر میں ہمارے ساتھ صرف یہ دیکھنے کے لیے ہوتے ہیں کہ ہم کب کہاں اور کیسے گرتے ہیں۔ لگنے والی ٹھوکر ہمارے گھٹنوں کو زخمی کرتی ہے یا ہاتھوں کو، خاک ہمارے چہرے کو گند ا کرتی ہے یا کپڑوں کو۔
بدلتا ہے رنگ آسماں کیسے کیسے

وہ لوگ بہت خوش قسمت تھے

وہ لوگ بہت خوش قسمت تھے
جو عشق کو کام سمجھتے تھے
یا کام سے عاشقی کرتے تھے
ہم جیتے جی مصروف رہے
کچھ عشق کیا کچھ کام کیا
کام عشق کے آڑے آتا رہا
اور عشق سے کام اُلجھتا رہا
پھر آخر تنگ آ کر ہم نے
دونوں کو ادھورا چھوڑ دیا

فیض احمد فیض

Monday, February 28, 2011

Create Data Table and Data Row.

Table name "WorkAddress"
Table Columns name , type


Public Function MyDataTable() As DataTable

Dim dt As DataTable

dt = New DataTable()
dt.TableName = "WorkAddress"

dt.Columns.Add("name")
dt.Columns.Add("type")

Dim r As DataRow

r = dt.NewRow()
r(0) = "id"
r(1) = "uniqueidentifier"
dt.Rows.Add(r)

r = dt.NewRow()
r(0) = "street"
r(1) = "smallint"
dt.Rows.Add(r)

r = dt.NewRow()
r(0) = "address"
r(1) = "varchar"
dt.Rows.Add(r)

r = dt.NewRow()
r(0) = "city"
r(1) = "varchar"
dt.Rows.Add(r)

r = dt.NewRow()
r(0) = "state"
r(1) = "varchar"
dt.Rows.Add(r)

Return dt

End Function



Sunday, October 24, 2010

SQL number with .00 decimal 2 disgits

SQL number with .00 decimal 2 disgits

Query
SELECT CONVERT(VARCHAR,CONVERT(VARCHAR,786),0) as Currency_COL

Result
------------------
Currency_COL
------------------
780.00
------------------


Saturday, October 16, 2010

DateTime.ToString() Patterns

DateTime.ToString() Patterns

All the patterns:

0 MM/dd/yyyy 08/22/2006
1 dddd, dd MMMM yyyy Tuesday, 22 August 2006
2 dddd, dd MMMM yyyy HH:mm Tuesday, 22 August 2006 06:30
3 dddd, dd MMMM yyyy hh:mm tt Tuesday, 22 August 2006 06:30 AM
4 dddd, dd MMMM yyyy H:mm Tuesday, 22 August 2006 6:30
5 dddd, dd MMMM yyyy h:mm tt Tuesday, 22 August 2006 6:30 AM
6 dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
7 MM/dd/yyyy HH:mm 08/22/2006 06:30
8 MM/dd/yyyy hh:mm tt 08/22/2006 06:30 AM
9 MM/dd/yyyy H:mm 08/22/2006 6:30
10 MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM
10 MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM
10 MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM
11 MM/dd/yyyy HH:mm:ss 08/22/2006 06:30:07
12 MMMM dd August 22
13 MMMM dd August 22
14 yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK 2006-08-22T06:30:07.7199222-04:00
15 yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK 2006-08-22T06:30:07.7199222-04:00
16 ddd, dd MMM yyyy HH':'mm':'ss 'GMT' Tue, 22 Aug 2006 06:30:07 GMT
17 ddd, dd MMM yyyy HH':'mm':'ss 'GMT' Tue, 22 Aug 2006 06:30:07 GMT
18 yyyy'-'MM'-'dd'T'HH':'mm':'ss 2006-08-22T06:30:07
19 HH:mm 06:30
20 hh:mm tt 06:30 AM
21 H:mm 6:30
22 h:mm tt 6:30 AM
23 HH:mm:ss 06:30:07
24 yyyy'-'MM'-'dd HH':'mm':'ss'Z' 2006-08-22 06:30:07Z
25 dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
26 yyyy MMMM 2006 August
27 yyyy MMMM 2006 August

The patterns for DateTime.ToString ( 'd' ) :

0 MM/dd/yyyy 08/22/2006

The patterns for DateTime.ToString ( 'D' ) :

0 dddd, dd MMMM yyyy Tuesday, 22 August 2006

The patterns for DateTime.ToString ( 'f' ) :

0 dddd, dd MMMM yyyy HH:mm Tuesday, 22 August 2006 06:30
1 dddd, dd MMMM yyyy hh:mm tt Tuesday, 22 August 2006 06:30 AM
2 dddd, dd MMMM yyyy H:mm Tuesday, 22 August 2006 6:30
3 dddd, dd MMMM yyyy h:mm tt Tuesday, 22 August 2006 6:30 AM

The patterns for DateTime.ToString ( 'F' ) :

0 dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07

The patterns for DateTime.ToString ( 'g' ) :

0 MM/dd/yyyy HH:mm 08/22/2006 06:30
1 MM/dd/yyyy hh:mm tt 08/22/2006 06:30 AM
2 MM/dd/yyyy H:mm 08/22/2006 6:30
3 MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM

The patterns for DateTime.ToString ( 'G' ) :

0 MM/dd/yyyy HH:mm:ss 08/22/2006 06:30:07

The patterns for DateTime.ToString ( 'm' ) :

0 MMMM dd August 22

The patterns for DateTime.ToString ( 'r' ) :

0 ddd, dd MMM yyyy HH':'mm':'ss 'GMT' Tue, 22 Aug 2006 06:30:07 GMT

The patterns for DateTime.ToString ( 's' ) :

0 yyyy'-'MM'-'dd'T'HH':'mm':'ss 2006-08-22T06:30:07

The patterns for DateTime.ToString ( 'u' ) :

0 yyyy'-'MM'-'dd HH':'mm':'ss'Z' 2006-08-22 06:30:07Z

The patterns for DateTime.ToString ( 'U' ) :

0 dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07

The patterns for DateTime.ToString ( 'y' ) :

0 yyyy MMMM 2006 August

Building a custom DateTime.ToString Patterns

The following details the meaning of each pattern character. Note the Kz character. and
d Represents the day of the month as a number from 1 through 31. A single-digit day is formatted without a leading zero
dd Represents the day of the month as a number from 01 through 31. A single-digit day is formatted with a leading zero
ddd Represents the abbreviated name of the day of the week (Mon, Tues, Wed etc)
dddd Represents the full name of the day of the week (Monday, Tuesday etc)
h 12-hour clock hour (e.g. 7)
hh 12-hour clock, with a leading 0 (e.g. 07)
H 24-hour clock hour (e.g. 19)
HH 24-hour clock hour, with a leading 0 (e.g. 19)
m Minutes
mm Minutes with a leading zero
M Month number
MM Month number with leading zero
MMM Abbreviated Month Name (e.g. Dec)
MMMM Full month name (e.g. December)
s Seconds
ss Seconds with leading zero
t Abbreviated AM / PM (e.g. A or P)
tt AM / PM (e.g. AM or PM
y Year, no leading zero (e.g. 2001 would be 1)
yy Year, leadin zero (e.g. 2001 would be 01)
yyy Year, (e.g. 2001 would be 2001)
yyyy Year, (e.g. 2001 would be 2001)
K Represents the time zone information of a date and time value (e.g. +05:00)
z With DateTime values, represents the signed offset of the local operating system's time zone from Coordinated Universal Time (UTC), measured in hours. (e.g. +6)
zz As z but with leadin zero (e.g. +06)
zzz With DateTime values, represents the signed offset of the local operating system's time zone from UTC, measured in hours and minutes. (e.g. +06:00)
f Represents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value.
ff Represents the two most significant digits of the seconds fraction; that is, it represents the hundredths of a second in a date and time value.
fff Represents the three most significant digits of the seconds fraction; that is, it represents the milliseconds in a date and time value.
ffff Represents the four most significant digits of the seconds fraction; that is, it represents the ten thousandths of a second in a date and time value. While it is possible to display the ten thousandths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.
fffff Represents the five most significant digits of the seconds fraction; that is, it represents the hundred thousandths of a second in a date and time value. While it is possible to display the hundred thousandths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.
ffffff Represents the six most significant digits of the seconds fraction; that is, it represents the millionths of a second in a date and time value. While it is possible to display the millionths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.
fffffff Represents the seven most significant digits of the seconds fraction; that is, it represents the ten millionths of a second in a date and time value. While it is possible to display the ten millionths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.
F Represents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value. Nothing is displayed if the digit is zero.
: Represents the time separator defined in the current DateTimeFormatInfo..::.TimeSeparator property. This separator is used to differentiate hours, minutes, and seconds.
/ Represents the date separator defined in the current DateTimeFormatInfo..::.DateSeparator property. This separator is used to differentiate years, months, and days.
" Represents a quoted string (quotation mark). Displays the literal value of any string between two quotation marks ("). Your application should precede each quotation mark with an escape character (\).
' Represents a quoted string (apostrophe). Displays the literal value of any string between two apostrophe (') characters.
%c Represents the result associated with a c custom format specifier, when the custom date and time format string consists solely of that custom format specifier. That is, to use the d, f, F, h, m, s, t, y, z, H, or M custom format specifier by itself, the application should specify %d, %f, %F, %h, %m, %s, %t, %y, %z, %H, or %M. For more information about using a single format specifier, see Using Single Custom Format Specifiers.


 Easy Convert String to DateTime Formatting with ASP.NET C#


DateTime dtnow = new DateTime();     // data type dataTime declare
dtnow = System.DateTime.Now;          // assign current date
string strdtnow = dtnow.ToString("dd/MM/yyyy").ToString();   // Convert String to DateTime with date Formatting

Sunday, October 10, 2010

Get MAC address of your system with c#.Net

This sample code shows how to retrieve the MAC address of your computer using C#.
Can convert this code to VB.NET easily.


public string GetMACAddress()
{
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
string MACAddress = String.Empty;
foreach (ManagementObject mo in moc)
{
if (MACAddress == String.Empty) // only return MAC Address from first card
{
if ((bool)mo["IPEnabled"] == true) MACAddress = mo["MacAddress"].ToString();
}
mo.Dispose();
}

MACAddress = MACAddress.Replace(":", "");
return MACAddress;
}

Wednesday, October 06, 2010

How to use CASE function to form conditional expressions?

Introduction
Here I will describe the function in the SQL with conditional expressions or CASE   function in your SQL Query
Execute the following Microsoft SQL Server T-SQL database scripts in Management Studio Query Editor to demonstrate the use of the CASE function to build complex conditional expressions.
-- SQL CASE function in WHERE clause - QUICK SYNTAX
DECLARE @ProductID INT = NULL -- input parameter
SELECT * FROM AdventureWorks2008.Production.Product
WHERE ProductID = CASE
WHEN @ProductID is not null THEN @ProductID
ELSE ProductID END
GO
-- (504 row(s) affected)
DECLARE @ProductID INT = 800 -- input parameter
SELECT * FROM AdventureWorks2008.Production.Product
WHERE ProductID = CASE
WHEN @ProductID is not null THEN @ProductID
ELSE ProductID END
-- (1 row(s) affected)