Thursday, July 23, 2009

How to send Sms?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using MailtoSMS;

namespace MailtoSMS
{
class sendSMS
{
String PORT;
public sendSMS()
{
try
{
char[] ch = new char[10];
string reply;
string[] s = System.IO.Ports.SerialPort.GetPortNames();
for (int i = 0; i < s.Length; i++)
{
SerialPort sp1 = new SerialPort(s[i].ToString());
sp1.Open();
sp1.Write("at\r\n");
System.Threading.Thread.Sleep(3500);
reply = sp1.ReadExisting();
if (reply.Contains("OK"))
{
PORT = s[i].ToString();
sp1.Close();
break;
}
}
SerialPort sp = new SerialPort(PORT);
sp.Open();
sp.Write("at\r\n");
System.Threading.Thread.Sleep(3500);
reply = sp.ReadExisting();
if (reply.Contains("OK"))
{
try
{
int i = 26;
char ctrlz = (char)i;
//textBox1.Text = textBox1.Text + s.ToString() + "\r\n";
sp.Write("at+cmgf=1\r\n");
System.Threading.Thread.Sleep(3500);
reply = sp.ReadExisting();
sp.Write("at+cmgs=\"" + Form1.MobNo + "\"\r\n");
System.Threading.Thread.Sleep(3500);
sp.Write(Form1.message + ctrlz);
reply = sp.ReadExisting();
sp.Close();
sp.Dispose();
}
catch (ObjectDisposedException ex)
{
Console.WriteLine(ex.Message);
}
}

//for(int i=0; i
//textBox1.Text = textBox1.Text + s.ToString() + "\r\n";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}

Monday, July 20, 2009

How to print document?


protected void btnPrint_Click(object sender, EventArgs e)
{
btnPrint.Visible = false;
btnEdit.Visible = false;
Response.Write("");
}

Thursday, July 2, 2009

Menu Control:

.aspx

Menu ID="Menu1"
runat="server"
orientation="Horizontal"/"Vertical"
StaticEnableDefaultPopOutImage="false"



.aspx.cs

Single Menu


MenuItem fixmenu =new MenuItem();
fixmenu.Text = "Home";
fixmenu.NavigateUrl = "~/Sample1.aspx";
Menu1.Items.Add(fixmenu);


Parent and there child :

//PARENT1
MenuItem parentMenu = new MenuItem();
parentMenu.Text = "Parent";
parentMenu.NavigateUrl = "~/Sample.aspx";
//CHILD1
MenuItem childMenu = new MenuItem();
childMenu.Text = "Child1";
childMenu.NavigateUrl = "~/ChildMenu.aspx";
parentMenu.ChildItems.Add(childMenu);
//CHILD2
MenuItem childMenu2 = new MenuItem();
childMenu2.Text = "Child2";
childMenu2.NavigateUrl = "~/ChildMenu.aspx";
parentMenu.ChildItems.Add(childMenu2);

Menu1.Items.Add(parentMenu);

In SQL Server 2005 How to Find Tables With Primary Key Constraint in Database?

USE database
GO
SELECT i.name AS IndexName,
OBJECT_NAME(ic.OBJECT_ID) AS TableName,
COL_NAME(ic.OBJECT_ID,ic.column_id) AS ColumnName
FROM sys.indexes AS i
INNER JOIN sys.index_columns AS ic
ON i.OBJECT_ID = ic.OBJECT_ID
AND i.index_id = ic.index_id
WHERE i.is_primary_key = 1

In SQL Server 2005 How to Find Tables With Foreign Key Constraint in Database?

USE database
GO
SELECT f.name AS ForeignKey,
OBJECT_NAME(f.parent_object_id) AS TableName,
COL_NAME(fc.parent_object_id,
fc.parent_column_id) AS ColumnName,
OBJECT_NAME (f.referenced_object_id) AS ReferenceTableName,
COL_NAME(fc.referenced_object_id,
fc.referenced_column_id) AS ReferenceColumnName
FROM sys.foreign_keys AS f
INNER JOIN sys.foreign_key_columns AS fc
ON f.OBJECT_ID = fc.constraint_object_id

Wednesday, July 1, 2009

Short-cuts In VS 2008?

There are 450 keyboard shortcuts in key VS 2005.
If you want to see all these then use following macro.
To Run Macro
1.Tools->Macro->Macro IDE OR ALT+F11
2.Expan MyMacro->Open Module1
3.Copy the following code
4.Run Macro (F5)

Check file c:\\Shortcuts.html

'Start Macro
Public Module Module1

Public Sub ListShortcutsInHTML()

'Declare a StreamWriter
Dim sw As System.IO.StreamWriter
sw = New IO.StreamWriter("c:\\Shortcuts.html")

'Write the beginning HTML
WriteHTMLStart(sw)

' Add a row for each keyboard shortcut
For Each c As Command In DTE.Commands
If c.Name <> "" Then
Dim bindings As System.Array
bindings = CType(c.Bindings, System.Array)
For i As Integer = 0 To bindings.Length - 1
sw.WriteLine("")
sw.WriteLine("" + c.Name + "")
sw.WriteLine("" + bindings(i) + "")
sw.WriteLine("")
Next

End If
Next

'Write the end HTML
WriteHTMLEnd(sw)

'Flush and close the stream
sw.Flush()
sw.Close()
End Sub
Public Sub WriteHTMLStart(ByVal sw As System.IO.StreamWriter)
sw.WriteLine("")
sw.WriteLine("")
sw.WriteLine("")</span><br /><br /><span style="color: rgb(51, 102, 255);"> sw.WriteLine("Visual Studio Keyboard Shortcuts")</span><br /><span style="color: rgb(51, 102, 255);"> sw.WriteLine("")
sw.WriteLine("")

sw.WriteLine("")
sw.WriteLine("

Visual Studio 2005 Keyboard Shortcuts

")

sw.WriteLine("")
sw.WriteLine("")
sw.WriteLine("")


End Sub

Public Sub WriteHTMLEnd(ByVal sw As System.IO.StreamWriter)
sw.WriteLine("
CommandShortcut
")

sw.WriteLine("")

sw.WriteLine("")
sw.WriteLine("")
End Sub

End Module