Subscribe For Free Updates!

We'll not spam mate! We promise.

Showing posts with label windows applications. Show all posts
Showing posts with label windows applications. Show all posts

Apr 30, 2012

Send and Receive SMS Through AT commands

Views:

Send Sms Through AT commands
AT commands is use to communicate with GSM  Madame and Mobile Phone.There are a lot of libraries which has been made using AT commands and These libraries are not Free it charge money for Using it But Today You learn how to Send and receive sms through AT commands .

Using AT commands you're not restricted to a specific phone model, as long as the phone supports the commands you are using.

This program uses the text mode for sending the message, which is good for starting, but it may not be supported by every phone. If you want to use the PDU mode instead of the text mode - which is supported by all mobiles but is more complicated - see the PDU encoding sample for creating the required data.
Sample source code is available for VB6.
Details about the VB6 sample:
  • Shows how to use the MSComm ActiveX control
  • Shows how to use the SMS AT commands
  • Includes a trace output to see what's going on
  • Includes error handling for common errors
  • Is not optimized for performance

Download
VB6 projectVB6: SendSMS_AT_VB6_20041025.zip

Encoding SMS messages for PDU mode

This demonstrates how to create an SMS-SUBMIT PDU for a simple text message.
Download
VB6 projectVB6: EncodePDU_VB6_20040419.zip
C# projectC#: EncodePDU_CS_20040418.zip
Requires .NET Framework 1.1
Note: This program does only the coding, it does not actually send the message. For testing you can use a terminal program like HyperTerminal (included in Windows) to transfer the encoded message, as given in the following sample:

AT+CMGF=0<CR>
AT+CMGS=<actual PDU length><CR>
<encoded message><EOF>
<CR> = ASCII 13 = ENTER
<EOF> = ASCII 26 = CTRL+Z

Using AT commands to read SMS messages

Using AT commands you're not restricted to a specific phone model, as long as the phone supports the commands you are using.
This program uses the text mode for reading the messages, which is good for learning how it works, but it may not be supported by every phone. You may have to change character sets depending on the characters used in the messages to get the original text back.
Download
C# projectC#: ReadSMS_AT_CS20_20060718.zip
Requires .NET Framework 2.0

Basically there are two ways to send SMS.

  1. Connect a mobile phone or GSM/GPRS modem to a computer / PC. Then use the computer / PC and AT commands to instruct the mobile phone or GSM/GPRS modem to send SMS messages.
  2. Connect the computer / PC to the SMS center (SMSC) or SMS gateway of a wireless carrier or SMS service provider. Then send SMS messages using a protocol / interface supported by the SMSC or SMS gateway.
 In this tutorial we'll use first method. We can send SmS through AT commands, AT commands are instructions to Send/Receive SMS. (for more detail about AT Commands wait for my Next Post about AT commands).

Lets Start..
Step-1
Open Visual Studio, Create a New Project with the Name SMS. (In this tutorial I'm not going to show you how to create a new project, I'm skipping the detail about it.)

Step-2
In the solution Explorer, Right Click on the Project and Click on Add -> Add New Item and Add New Class with the name SmsClass.cs copy the following code in the class.

SmsClass.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.IO.Ports;
using System.Windows.Forms;
namespace SMS
{
    class SmsClass
    {
        SerialPort serialPort;
        public SmsClass(string comPort)
        {
            this.serialPort = new SerialPort();
            this.serialPort.PortName = comPort;
            this.serialPort.BaudRate = 9600;
            this.serialPort.Parity = Parity.None;
            this.serialPort.DataBits = 8;
            this.serialPort.StopBits = StopBits.One;
            this.serialPort.Handshake = Handshake.RequestToSend;
            this.serialPort.DtrEnable = true;
            this.serialPort.RtsEnable = true;
            this.serialPort.NewLine = System.Environment.NewLine;
        }
        public bool sendSms(string cellNo, string sms)
        {
            string messages = null;
            messages = sms;
            if (this.serialPort.IsOpen == true)
            {
                try
                {
                    this.serialPort.WriteLine("AT" + (char)(13));
                    Thread.Sleep(4);
                    this.serialPort.WriteLine("AT+CMGF=1" + (char)(13));
                    Thread.Sleep(5);
                    this.serialPort.WriteLine("AT+CMGS=\"" + cellNo + "\"");
                    Thread.Sleep(10);
                    this.serialPort.WriteLine(">" + messages + (char)(26));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Source);
                }
                return true;
            }
            else
                return false;
        }

        public void Opens()
        {
            if (this.serialPort.IsOpen == false)
            {
                this.serialPort.Open();
            }
        }
        public void Closes()
        {
            if (this.serialPort.IsOpen == true)
            {
                this.serialPort.Close();
            }
        }
    }
}
Step-3
Now on the Form1, we'll use
  1. combo Box (cboPorts) which will show the available ports on the computer.
  2. Two TextBoxes One for Receivers Cell No. (txtphone) and other for Message body (txtMessage) with Multiline property set to True.
  3. Send Button (btnSend) to Send SMS.
 Step-4
Copy and Paste the following code in the Form1 Code.
Form1
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;
namespace SMS
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            loadPorts();
        }
        private void loadPorts()
        {
            string[] ports = SerialPort.GetPortNames();
            foreach (string port in ports)
            {
                cboPorts.Items.Add(port);
            }
        }
        private void btnSend_Click(object sender, EventArgs e)
        {
            SmsClass sm = new SmsClass(cboPorts.Text);
            sm.Opens();
            sm.sendSms(txtPhone.Text, txtMessage.Text);
            sm.Closes();
            MessageBox.Show("Message Sent!");
        }

      
    }
}
Now , You Just need to connect your GSM modem/mobile to your PC through USB or Serial cable.
and Run the Project. From the main Window Select COM Port  on which your Modem/Phone is Connected to.

Note: This application is Tested using Nokia N82 By Me...

Download Source Code:
http://www.multiupload.com/1E2JGHS1ZF


Sep 29, 2011

Delete a seleted row from a DataGrid using c# windows application

Views:

Place a DataGrid on the form and populate it, now double click the dataGrid and use the below code.



private void DataGridvie_selected(Object sender, EventArgs e)

    {

        DataSet da = new DataSet();

        //when you select a row that index will storing in i variable

        int j = datagrid1.selectedIndex;



        int empidval = ds.Tables["emp"].Rows[j][0].ToString();

        //above what you had selected that row value exa:empid has 101 is stored in empidval vairable



        //write the delete query



        SqlConnection conn = new Sqlconnection("conn string");

        conn.Open();

        SqlCommand cmd = new SqlCommand("delect emp where empid=" + empid + "", conn);

        cmd.ExecuteNonQuery();

        MessageBox.Show("Row Deleted");

    }


How to get the Values of Selected Cell Row DataGridview(Windows Appliction) using C# ?

Views:

Open Windows Form.Add on DataGridview and the three Textboxes on the Windows Form.
In the above example I am creating it on emp table and my 3 columns are
id number,empname(varchar (20),salary number(20).
In form load Retrive the data a emp Table and fill in the Datagridview.


When you click or Select a Row on DataGridview the particular selected row values
will display in Textboxes when we use the following code.
int i;
i = dataGridView1.SelectedCells[0].RowIndex;
textBox1.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
textBox2.Text = dataGridView1.Rows[i].Cells[1].Value.ToString();
textBox3.Text = dataGridView1.Rows[i].Cells[2].Value.ToString();

before using this code you have to double click your DataGridview and write the 
code in
between the 

Private void dataGridView1_CellContentClick_(objectsender,DataGridViewCellEventArgs e)
{  //write above code here...

}

when you selecte a row in datagrid ,the selected row Values will display in text boxes. Below is the output image:

below is the complete code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        SqlDataAdapter da;
        DataSet ds;
        int i;
        SqlConnection conn;
        private void Form1_Load(object sender, EventArgs e)
        {           
            conn = new SqlConnection("connetion tring");
            conn.Open();
            da= new SqlDataAdapter("select * from emp", conn);
            SqlCommandBuilder builder = new SqlCommandBuilder(da);
            ds = new DataSet();
            da.Fill(ds, "emp");
            dataGridView1.DataSource = ds.Tables["emp"];
        }

Private void dataGridView1_CellContentClick_1
(objectsender,DataGridViewCellEventArgs e)
    {
i = dataGridView1.SelectedCells[0].RowIndex;
textBox1.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
textBox2.Text = dataGridView1.Rows[i].Cells[1].Value.ToString();
textBox3.Text = dataGridView1.Rows[i].Cells[2].Value.ToString();
  }
}

how to add CheckBox inside DataGridView in windows application

Views:

This article will explain you how to insert Checkbox inside DataGridView in windows application. This article is for beginners.

First create a windows application from Visual Studio Menu File->Project-> Then select C#->Windows Form Application.



Then add DataGridView from toolbox of Visual Studio. And also add One Button to test the CheckBox Value inside DatGridView.

Now from the property window of DataGridView Select the Columns Property.
You will see this screen:


Click on the (Collection) button from the above shown window.
You will see the below screen:


From this window click on "Add" button.
You will see below window:


From the above window select "Type" as "GridViewCheckboxColumn" Column as shown in above window
Then press Add Button from above Window.
Now you have added the checkbox DataGridView in windows application. Now it's time to add some code in your .cs file .

Now create one function, which will return a DataTable with sample data containing in it. This Data Table  will bind to DataGridView.
  /// <summary>
        /// Create DataTable to add to DataGridView
        /// </summary>
        /// <returns>DataTabe</returns>
        private DataTable SampleDataTable()
        {
            DataTable dt = new DataTable("MyDataTable");
            //Create columns and add to DataTable;
            DataColumn dcID = new DataColumn("ID");
            dt.Columns.Add(dcID); //ID column created and add to DataTable
            DataColumn dcSomeText = new DataColumn("SomeText");
            dt.Columns.Add(dcSomeText); //LastName column created and add to DataTable
            //Now Add some data to the DataTable
            DataRow dr;
            for (int count = 0; count <= 9; count++)
            {
                dr = dt.NewRow();
                dr["ID"] = count;
                dr["SomeText"] = "Some Text " + count;
                dt.Rows.Add(dr);
            }
            return dt;
        }

On the FormLoad_Event add this line of code to bind SampleDataTable() as a datasource of of windows application like this
private void Form1_Load(object sender, EventArgs e)
{
      myDataGridView.DataSource = SampleDataTable();
}

Now on Button click Event add this line of code to check what all rows user has selected from DataGridView.
private void btnSubmit_Click(object sender, EventArgs e)
{
     foreach (DataGridViewRow dr in myDataGridView.Rows)
     {
         if(dr.Cells[0].Value != null) //Cells[0] Because in cell 0th cell we have added checkbox
          {
                    MessageBox.Show("Rows " +dr.Index + " selected");
          }
      }
}
Now, its time to run the application,once you run your application you will see the output window like this:


Now, select the check box and press the Get Selected Rows Button. You will see this window:

Happy Coding!!!

Jun 1, 2011

PLDC Assingment (Part 2 of 2) Mobile Applications with JAVA,C# and PHP

Views:



Video about Mobile Application be care full and Watch it sincerely OK

Apr 1, 2011

SQL Server Tutorials

Views:

Video Sub Category

NOTE:-  To view a video, click on the title. To update time watched, please login. (The Microsoft videos are totally free, but they  do require that you register with them to view the videos and you also have to use Internet Explorer browser, instead of Firefox, Safari, etc.)




SeriesTitleDatePresenterMin
SQL Server 2005 ExpressWhat is a Database?3/29/2006Bob Taylor28
SQL Server 2005 ExpressUnderstanding Database Tables and Records3/29/2006Bob Taylor 25
SQL Server 2005 ExpressMore about Column Data Types and Other Properties2/22/2006Bob Taylor 22
SQL Server 2005 ExpressDesigning Relational Database Tables3/29/2006Bob Taylor34
SQL Server 2005 ExpressManipulating Database Data3/29/2006Bob  Taylor40
SQL Server 2005 ExpressMore Structured Query Language3/29/2006Bob Taylor23
SQL Server 2005 ExpressUnderstanding Security and Network Connectivity3/29/2006Bob  Taylor41
SQL Server 2005 ExpressConnecting your Web Application to SQL Server 2005 Express Edition3/26/2006Bob Taylor66
SQL Server 2005 ExpressUsing SQL Server Management Studio10/23/2006Bob Taylor40
SQL Server 2005 ExpressGetting Started with Reporting Services10/21/2006Bob Taylor33
SQL Server 2005 ExpressBuilding and Customizing Reports in Business Intelligence Development Studio10/22/2006Bob Taylor45
SQL Server 2005 ExpressCreating and Using Stored Procedures11/14/2006Bob Taylor43
SQL Server 2005 ExpressEnabling Full-Text Search in your Text Data11/14/2006Bob Taylor38
Total478




VB Soup to Nuts

Views:

Video Sub Category

NOTE:-  To view a video, click on the title. To update time watched, please login. (The Microsoft videos are totally free, but they  do require that you register with them to view the videos and you also have to use Internet Explorer browser, instead of Firefox, Safari, etc.)




SeriesTitleDatePresenterMin
VB Soup to Nuts Introduction - video missing2/7/2007Ron Cundiff 60
VB Soup to NutsVisual Basic 2005 Express Edition- video missing2/13/2007Ron Cundiff 60
VB Soup to NutsClass Libraries -video missing2/19/2007Ron Cundiff 60
VB Soup to NutsVB.NET Program Structure - video missing2/20/2007Ron Cundiff 60
VB Soup to NutsLanguage Fundamentals3/5/2007Ron Cundiff 60
VB Soup to NutsClasses and Objects3/19/2007Ron Cundiff 60
VB Soup to NutsOperator Basics3/26/2007Ron Cundiff 60
VB Soup to NutsBranching and Looping - video missing4/2/2007Ron Cundiff 60
VB Soup to NutsBasic Debugging - video missing4/9/2007Ron Cundiff 60
VB Soup to NutsArrays and Collections4/16/2007Ron Cundiff 43
VB Soup to NutsException Handling4/23/2007Ron Cundiff 55
VB Soup to NutsDelegates and Events4/30/2007Ron Cundiff 32
VB Soup to NutsInheritance and Polymorphism - video missing5/7/2007Ron Cundiff 60
VB Soup to NutsVisual Basic and the Web5/14/2007Ron Cundiff 68
VB Soup to NutsCustom Web Controls5/21/2007Ron Cundiff 73
VB Soup to NutsVisual Basic and Windows Applications5/22/2007Ron Cundiff 68
VB Soup to Nuts Custom Windows Forms Controls5/29/2007Ron Cundiff 67
VB Soup to NutsCreating and Manipulating Strings6/4/2007Ron Cundiff 68
VB Soup to NutsVisual Basic and SQL Server 20056/6/2007Ron Cundiff 62
VB Soup to Nuts Visual Basic Application Deployment Options6/18/2007Ron Cundiff 53
VB Soup to Nuts Building a Multi-Tier Business Application6/25/2007Ron Cundiff 62
   Total 1251

Modern Software Visual Basic VB

Views:

Video Sub Category

NOTE:-  To view a video, click on the title. To update time watched, please login. (The Microsoft videos are totally free, but they  do require that you register with them to view the videos and you also have to use Internet Explorer browser, instead of Firefox, Safari, etc.)





SeriesTitleDatePresenterMin
Modern Software Dev in VBProgram Execution in the 21st Century2/3/2004Joe Hummel 124
Modern Software Dev in VBOOP and Class Design2/10/2004Joe Hummel 118
Modern Software Dev in VBWorking with Classes and Class Libraries2/17/2004Joe Hummel 113
Modern Software Dev in VBWinForms: What's New in GUI Development2/24/2004Joe Hummel 81
Modern Software Dev in VBDefensive Programming3/2/2004Joe Hummel 90
Modern Software Dev in VBDatabases I: Relational Database Design, SQL, and Stored Procedures3/16/2004Joe Hummel 90
Modern Software Dev in VBDatabases II: DB Programming with ADO.NET3/23/2004Joe Hummel 90
Modern Software Dev in VBInterfaces3/31/2004Joe Hummel 90
Modern Software Dev in VBInheritance4/6/2004Joe Hummel 90
Modern Software Dev in VBDatabases II - Data and Business Tier4/15/2004Joe Hummel 90
Modern Software Dev in VBComponent-Based Programming4/20/2004Joe Hummel 90
Modern Software Dev in VBApplication Design and Deployment4/28/2004Joe Hummel 90
Modern Software Dev in VBDistributed Programming: Remoting vs Web Services5/4/2004Joe Hummel 90
Modern Software Dev in VBConcurrent Programming: Delegates and Multi-threading5/11/2004Joe Hummel 90
Modern Software Dev in VBSoftware Practices Today: Best Practices and Patterns5/18/2004Joe Hummel 90
   Total 1426




Modern Software C-Sharp

Views:

Video Sub Category

NOTE:-  To view a video, click on the title. To update time watched, please login. (The Microsoft videos are totally free, but they  do require that you register with them to view the videos and you also have to use Internet Explorer browser, instead of Firefox, Safari, etc.)






SeriesTitleDatePresenterMin
Modern Software Development Using C#Program Execution in the 21st Century3/1/2005Joe Hummel 69
Modern Software Development Using C#Classes, Components and Namespaces3/15/2005Joe Hummel 92
Modern Software Development Using C#Rapid Application Development with Visual Studio .NET3/22/2005Joe Hummel 89
Modern Software Development Using C#Class Design for the .NET Framework3/29/2005Joe Hummel 99
Modern Software Development Using C#Defensive Programming4/12/2005Joe Hummel 99
Modern Software Development Using C#WinForms: GUI Programming in .NET4/19/2005Joe Hummel 115
Modern Software Development Using C#ADO.NET: Database Programming in .NET 4/26/2005Joe Hummel 103
Modern Software Development Using C#Multi-tier Application Design 5/10/2005Joe Hummel 108
Modern Software Development Using C#Interfaces and Design-by-Contract in .NET 5/17/2005Joe Hummel 107
Modern Software Development Using C#Inheritance: Design and Code Reuse5/24/2005Joe Hummel 115
Modern Software Development Using C#Component-Based Design and Programming5/31/2005Joe Hummel 106
Modern Software Development Using C#Distributed Multi-Tier Applications 6/7/2005Joe Hummel 112
Modern Software Development Using C#What’s New in Visual Studio .NET 2005 6/14/2005Joe Hummel 97
Modern Software Development Using C#What’s New in C# and .NET 2.06/21/2005Joe Hummel 95
Modern Software Development Using C#The Microsoft .NET Team System 6/28/2005Joe Hummel 89
   Total 1495

C-Sharp Soup to Nuts tutorials

Views:

Video Sub Category

NOTE:-  To view a video, click on the title. To update time watched, please login. (The Microsoft videos are totally free, but they  do require that you register with them to view the videos and you also have to use Internet Explorer browser, instead of Firefox, Safari, etc.)




SeriesTitleDatePresenterMin
CSharp Soup to NutsIntroduction to C#11/13/2006William Steele58
CSharp Soup to NutsVisual C# Express11/20/2006William Steele64
CSharp Soup to NutsClass Libraries11/27/2006William Steele68
CSharp Soup to NutsC# Program Structure12/4/2006William Steele72
CSharp Soup to NutsLanguage Fundamentals12/11/2006William Steele61
CSharp Soup to NutsBranching and Looping12/18/2006William Steele60
CSharp Soup to NutsClasses and Objects1/8/2007William Steele53
CSharp Soup to NutsOperator Basics1/15/2007William Steele57
CSharp Soup to NutsBasic Debugging1/22/2007William Steele53
CSharp Soup to NutsArrays and Collections1/29/2007William Steele53
CSharp Soup to NutsCreating and Manipulating Strings2/5/2007William Steele53
CSharp Soup to NutsException Handling2/12/2007William Steele53
CSharp Soup to NutsDelegates and Events2/19/2007William Steele53
CSharp Soup to NutsInheritance and Polymorphism2/26/2007William Steele53
CSharp Soup to NutsC# and the Web3/5/2007William Steele53
CSharp Soup to NutsCustom Web Controls3/12/2007William Steele53
CSharp Soup to NutsC# and Windows Applications3/19/2007William Steele53
CSharp Soup to NutsCustom Controls3/26/2007William Steele53
CSharp Soup to NutsC# and Windows Presentation Foundation4/9/2007William Steele53
CSharp Soup to NutsC# and SQL Server 2005 4/16/2007William Steele74
CSharp Soup to NutsC# and Game Development4/23/2007William Steele64
CSharp Soup to NutsC# Application Deployment Options4/30/2007William Steele62
Total1276

Become a Fan

visual studio learn