This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Thursday, 9 May 2013

CREATE DIGITAL CLOCK IN C#



HI FRIENDS !!

In my last post  we are learn about  analog clock but now we are going to creating digital clock.
We are using visual studio and take label from tools and one timer also for match the system date and time.

Like this picture:






 Now we are going to coding path we are using C# language which is .net supported language .


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

namespace d_clock
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {
          
        }


// here we are using timer_tick event for match are time with system date  //or time

        private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Text = System.DateTime.Now.ToString();
        }

// here we are using form load event for starting our timer when form   //load

        private void Form1_Load(object sender, EventArgs e)
        {
            timer1.Start();
        }
    }
}


  Then the output is like this picture:


THANK YOU !


Monday, 6 May 2013

HOW TO STOP COPY PASTING

HI GUYS !

Welcome Back !!!!

Now we are creating a very simple but very use full application through ADO.NET. As we see our heading is "how to stop copy pasting" .For this application we are using c# language which is .net saturated language.
very simply i am using  a form from visual studio and take text box.

like this image :

Now, we are using a event like mouse-down and key-down event.

c# code :


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

namespace WindowsApplication4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_MouseDown(object sender, MouseEventArgs e)
        {
            textBox1.SelectionLength = 0;
        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            textBox1.SelectionLength = 0;
        }
    }
}


and the ouput come like this image :




Any word we are write here but nothing will be copy past from here!!!
Thank you friends..... 

HOW TO CREATE ANALOG CLOCK IN JAVA



Hello guys!
Today we are creating a clock with using java program. We are using some packages like SimpleDateFormat. And also we are using the variables for coordinate x and y to declare center coordinate of a clock, second, minute and hour.


import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class ClockEx extends JPanel implements Runnable
{
Thread thread = null;
SimpleDateFormat formatter = new SimpleDateFormat("s", Locale.getDefault());
Date currentDate;
//declareing the variables for coordinates and x_sec,x_min,x_hw,y_sec,y_min, and y_hw  defining the //end coordinate of the minutes and hours.
int x = 175, y = 175, x_sec = 0, y_sec = 0, x_min = 0, y_min = 0, x_hw = 0,y_hw= 0;

private void drawStructure(Graphics gr)
{
gr.setFont(new Font("TimesRoman", Font.BOLD, 20));
gr.setColor(Color.yellow);
gr.fillOval(x - 150, y - 150, 300, 300);
gr.setColor(Color.gray);
gr.drawString("JAYANT" ,130, 60);
gr.setColor(Color.blue);
gr.drawString("9", x - 145, y +0); // difining the
gr.drawString("3", x + 135, y + 0);

gr.drawString("12", x - 10, y - 130);

gr.drawString("6", x - 10, y + 145);

}
public void paint(Graphics gr1) {
int xhour, yhour, xminute, yminute, xsecond, ysecond, second, minute, hour;drawStructure
(gr1);
currentDate = new Date();
formatter.applyPattern("s");
second = Integer.parseInt(formatter.format(currentDate));
formatter.applyPattern("m");
minute = Integer.parseInt(formatter.format(currentDate));
formatter.applyPattern("h");
hour = Integer.parseInt(formatter.format(currentDate));
xsecond = (int) (Math.cos(second * 3.14f / 30 - 3.14f / 2) * 120 + x);
ysecond = (int) (Math.sin(second * 3.14f / 30 - 3.14f / 2) * 120 + y);
xminute = (int) (Math.cos(minute * 3.14f / 30 - 3.14f / 2) * 100 + x);
yminute = (int) (Math.sin(minute * 3.14f / 30 - 3.14f / 2) * 100 + y);
xhour = (int) (Math.cos((hour * 30 + minute / 2) * 3.14f / 180 - 3.14f / 2) * 80 + x);
yhour = (int) (Math.sin((hour * 30 + minute / 2) * 3.14f / 180 - 3.14f / 2) * 80 + y);
// Erase if necessary, and redraw
gr1.setColor(Color.pink);
if (xsecond != x_sec || ysecond != y_sec)
{
gr1.drawLine(x, y,x_sec, y_sec);
}
if (xminute != x_min || yminute != y_min)
{
gr1.drawLine(x , y  - 1, x_min, y_min);

gr1.drawLine(x  - 1, y , x_min, y_min);
}
if (xhour != x_hw || yhour != y_hw)
{
gr1.drawLine(x , y  - 1, x_hw, y_hw);
gr1.drawLine(x  - 1, y , x_hw, y_hw);
}
gr1.setColor(Color.pink);
gr1.drawLine(x , y , xsecond, ysecond);
gr1.setColor(Color.red);
gr1.drawLine(x , y  - 1, xminute, yminute);
gr1.drawLine(x  - 1, y , xminute, yminute);
gr1.setColor(Color.green);
gr1.drawLine(x , y  - 1, xhour, yhour);
gr1.drawLine(x  - 1, y , xhour, yhour);
 x_sec = xsecond;
y_sec = ysecond;
x_min = xminute;
y_min = yminute;
x_hw = xhour;
 y_hw = yhour;
}
  public void start() {
    if (thread == null) {
      thread = new Thread(this);
      thread.start();
    }
  }
  public void stop()
{
thread = null;
}
  public void run() {
     while (thread != null) {
      try {
        Thread.sleep(100);
      } catch (InterruptedException e) {
      }
      repaint();
    }
    thread = null;
  }
  public void update(Graphics g) {
    paint(g);
  }
  public static void main(String args[]) {
     JFrame window = new JFrame();
      Color c=new Color(118,73,190);
      window.setBackground(c);
      window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      window.setBounds(0, 0, 400, 400);
      ClockEx clock = new ClockEx();
      window.getContentPane().add(clock);
      window.setVisible(true);
      clock.start();
   }
}

OUTPUT :

    

Saturday, 4 May 2013

How to auto generate id in ado.net



Hi friends,
I am back with a new concept for ADO.NET. Here we are create an application for generate a unique ID for every student. It is very small example for all my viewers through this concept we can use and make same more application.
In this application we are using some textboxes, labels, datetimepicker, and form and button also. In this apps user can enter the name, address and phone number with date, then “ID” will be generated automatically.
For all this phenomena we must make database for store the IDs, names, addresses, contacts number and dates. We are using the sql2008 for create data base.

Now let’s create database using SQL2008 :


CREATE DATABASE RAHUL
CREATE TABLE UNIQU
(
STUDENT_ID CHAR(15),
NAME VARCHAR(50),
ADDRESS VARCHAR(100),
CONTACT BIGINT,
DATE_OF_JOIN DATETIME,
DATE_OF_BIRTH DATETIME
)
INSERT INTO RAHUL VALUES (“0”,”0”,”0”,””,””)
Now execute the query.

This is the image after the query was executed successfully:





Now come for the design the windows form with using Visual Studio 2010 and we can also choose another version of visual studio (but V.S._2010 always supports SQL 2008).

I give a snapshot of visual studio design path:





Now we can go to the coding path of “form1” and write the code.

I am using c# language for this framework but you can also us the another .NET


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 WindowsApplication4
{
publicpartialclassForm1 : Form
    {
public Form1()
        {
            InitializeComponent();
        }
static int j; //global variable 
int c;
SqlConnection con = newSqlConnection("Data Source=.;Initial Catalog=rahul;Integrated Security=True");
//code for conection with sql
privatevoid button1_Click(object sender, EventArgs e)
        {
//Data Source=.;Integrated Security=True
            errorProvider1.Clear();
bool flag = true;
            c = 0;
if (textBox2.Text.Length == 0)
            {
                errorProvider1.SetError(textBox2, "fill");
                flag = false;
                c = 1;
            }
if (textBox3.Text.Length == 0)
            {
                errorProvider1.SetError(textBox3, "fill");
                flag = false;
                c = 1;
            }
if (textBox4.Text.Length == 0)
            {
                errorProvider1.SetError(textBox4, "fill");
                flag = false;
                c = 1;
            }
if (dateTimePicker2.Text.Length==0)
            {
                errorProvider1.SetError(dateTimePicker2, "update");
                flag=false;
                c = 1;
            }
if (c == 0)
            {
if (textBox4.Text.Length != 10)
                {
MessageBox.Show("must be 10 digit");
                    flag = false;
                }
            }

if (flag)
            {


//try
//{
                con.Open();
SqlCommand cmd = newSqlCommand("insert into uniqu values('" + j + "','" + textBox2.Text + "','" + textBox3.Text + "','" + dateTimePicker1.Value + "','" + dateTimePicker2.Value + "','" + textBox4.Text + "')", con);
int i = cmd.ExecuteNonQuery();
if (i > 0)
                {
MessageBox.Show("saved");
                    textBox2.Text = null;
                    textBox3.Text = null;
                    textBox4.Text = null;
                    j = j + 1;
                    textBox1.Text = "S1200" + j.ToString();


                }

else
                {
MessageBox.Show("sorry");
                }

//catch (Exception ex)
//{
//    MessageBox.Show("" + ex);
//}
                con.Close();
            }
/* else
            {
                MessageBox.Show("correct error!");
            }*/


    }

privatevoid dateTimePicker2_ValueChanged(object sender, EventArgs e)
        {

        }

privatevoid Form1_Load(object sender, EventArgs e)
        {
           con.Open();
SqlCommand comm=newSqlCommand("select  max(s_id) from ID ",con);
SqlDataReader dr = comm.ExecuteReader();
while (dr.Read())
            {
                 j = (int)dr[0] + 1;
               textBox1.Text= "S1200" + j.ToString();

            }
            con.Close();
            dr.Close();

        }

privatevoid textBox4_TextChanged(object sender, EventArgs e)
        {


        }
    }
}

Output come like this image:





If we click on the save button then error generated  like this image




And if we fulfill all the text then student ID will be auto generated like this image:




Thank you!


If any problems have you face then kindly, Ask question through comments I can try to help you. 





Friday, 3 May 2013

How to move an image in ADO.NET

                        
Hi friends this is my first blogging site, dedicated to all my friends who interested in programming.
At first we can use  the visual studio then select the windows application. We can drag the picture box from tool menu and choose the image from local resources.
Like this picture:
Now choose one more picture box from tool menu and choose another image from local resources for moving around the picturebox1 and we can drag one timer from tool.

Like this picture:



Now come for coding path we use the c# language for this application.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace movingimage
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            pictureBox2.SetBounds(438, 104, 100, 61);
            Thread.Sleep(100);

            pictureBox2.SetBounds(303, 79, 100, 61);
            Thread.Sleep(100);

            pictureBox2.SetBounds(162, 105, 100, 61);
            Thread.Sleep(100);

            pictureBox2.SetBounds(132, 194, 100, 61);
            Thread.Sleep(100);

            pictureBox2.SetBounds(155, 284, 100, 61);
            Thread.Sleep(100);

            pictureBox2.SetBounds(294, 320, 100, 61);
            Thread.Sleep(100);

            pictureBox2.SetBounds(426, 291, 100, 61);
            Thread.Sleep(100);

            pictureBox2.SetBounds(457, 200, 100, 61);
            Thread.Sleep(100);


        }

        private void Form1_Load(object sender, EventArgs e)
        {
            pictureBox1.SetBounds(225, 140, 237, 174);
            timer1.Start();
        }

        private void Form1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            timer1.Stop();
        }
    }
}

//the output comes like football move around the earth. 

//I hope both of  you understood.
//Thank you !









I'M a new Blogger

Hello !!