Vehicle insurance project in c#.net


vehicle insurance project is a mini college project .you can download this project:

Download:  http://www.4shared.com/file/Z4HxQ7Z0/vcl_insurence_prj.html

The product entitled “automation” aim at automation of many processes of Vehicle Insurance. Current manual system that is employed is extremely. Laborious and quite in adequate it only maker the process more difficult and hard. Main purpose of this software is to reduce to manpower, paperwork and provide the security from unauthorized access. It helps in producing difficult kinds of report required in showroom for different managerial aspects.

Store image in SQL Database using vb.net


Store image in SQL data base it is not a new thing in SQL and VB.net which I going to explain
To store the image in database we convert the image in bytes in vb.net and then it send to database to store.it will very simple step to store it.

Download :: http://www.4shared.com/file/VScQwina/image_in_sql_vbnet_2005_.html

1).  Create a table called ImagesStore.

CREATE TABLE ImagesStore (ImageId int IDENTITY (1, 1) NOT NULL ,OriginalPath varchar (200)  NOT NULL ,ImageData image NOT NULL)

2). Then the main code is written in vb.net . Bellow code is use to convert the image into byte and the send it to the database to store.

Convert the image and send it to database:


Dim str As String
        Dim fstream As FileStream
        Dim imgdata As Byte()
        Dim data As Byte()
        Dim finfo As FileInfo
        finfo = New FileInfo(TextBox3.Text)
        Dim numbyte As Long
        Dim br As BinaryReader
        numbyte = finfo.Length
        fstream = New FileStream(TextBox3.Text, FileMode.Open, FileAccess.Read)
        br = New BinaryReader(fstream)
        data = br.ReadBytes(numbyte)
        imgdata = data
        con = New SqlConnection(TextBox1.Text)
        con.Open()
        str = "insert into ImagesStore (OriginalPath,ImageData) values(@op, @i)"
        cmd = New SqlCommand(str, con)
        cmd.Parameters.Add(New SqlParameter("op", SqlDbType.Char, 200))
        cmd.Parameters("op").Value = TextBox1.Text
        cmd.Parameters.Add(New SqlParameter("i", SqlDbType.Image))
        cmd.Parameters("i").Value = imgdata
        cmd.ExecuteNonQuery()
        MsgBox("Image Inserted In DataBase..", MsgBoxStyle.Information)
        Me.Close()
End Sub

 3). to retrieve the image from the database and display in the Picture Box .below code is responsible for display the picture in picture box. The main function of code is to retrieve the data in bytes and convert it to a normal image and display it.


Dim imagedata As Byte()
        Try
            PictureBox1.Location = New Point(3, 3)
            Timer1.Enabled = False
            imagedata = (DataGridView1.Rows(e.RowIndex).Cells("ImageData").Value)
            Dim ms As MemoryStream
            ms = New MemoryStream(imagedata, 0, imagedata.Length)
            ms.Write(imagedata, 0, imagedata.Length)
            Dim im As Image
            im = Image.FromStream(ms, True)
            PictureBox1.Image = im
        Catch ex As Exception
            Timer1.Enabled = True
        End Try

Database connection with C#


To connect the database with c#(vs 2010) is very easy I connect my database to c# using the query method and add the data grid vied in project to display the table content.
To connect the c# apps to SQL data base use the following steps:

1)      Write this code in using part  “using System.Data.SqlClient;”

2)      Declare one variable connection string type.

3)      Declare SQLconnection():it make connection between database and c# Apps

4)      Declare SQL command(): for execute the command.

5)      Declare SqldataAdapter() for binding the connection with database

6)      Declare dataset.

Download you can download this Example from: http://www.4shared.com/file/TnR6qUzE/data.html

Code for display the data in data grid view:

        if(dataGridView1.DataSource != null)
               ((DataView)dataGridView1.DataSource).Table.Clear();
con = new SqlConnection(connection);
qry = "select * from customer";
if (con.State == ConnectionState.Open)
    con.Close();
 else
     con.Open();
sda = new SqlDataAdapter(qry, con);
sda.Fill(ds, "customer");
this.dataGridView1.DataSource = ds.Tables["customer"].DefaultView;
dataGridView1.Columns[1].ReadOnly = true;

this Code will check the data grid view is null or not if it is not null then it’s clear the data:

</pre>
if(dataGridView1.DataSource != null)
((DataView)dataGridView1.DataSource).Table.Clear();

Code for insert the record in table:

qry = "insert into customer values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";
con = new SqlConnection(connection);
cmd = new SqlCommand(qry, con);
if (con.State == ConnectionState.Open)
con.Close();
else
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Recored is inserted");

Code for update the record:


qry = "update customer set id='" + textBox1.Text + "',name='" + textBox2.Text + "',number='" + textBox3.Text + "',email='" + textBox4.Text + "'where id='" + textBox1.Text + "'";

con = new SqlConnection(connection);cmd = new SqlCommand(qry, con);

if (con.State == ConnectionState.Open)
con.Close();

else

con.Open();

if( cmd.ExecuteNonQuery()==1)

MessageBox.Show("Recored is update");

else

MessageBox.Show("unable to update or Id not found.");

con.Close();

Code for delete the record:


qry = "delete from customer where id='" + textBox1.Text + "'";

con = new SqlConnection(connection);

cmd = new SqlCommand(qry, con);

if (con.State == ConnectionState.Open)

con.Close();

else

con.Open();

if (cmd.ExecuteNonQuery() == 1)

MessageBox.Show("Recored is deleted");

else

MessageBox.Show("unable to delete record or Id not found.");

con.Close();

when we check the sql connection is open or not if it is open the close the connection

            if (con.State == ConnectionState.Open)
                con.Close();

qry = “delete from customer where id='” + textBox1.Text + “‘”;

con = new SqlConnection(connection);

cmd = new SqlCommand(qry, con);

if (con.State == ConnectionState.Open)

con.Close();

else

con.Open();

if (cmd.ExecuteNonQuery() == 1)

MessageBox.Show(“Recored is deleted”);

else

MessageBox.Show(“unable to delete record or Id not found.”);

con.Close();

FTP using c#.net 2010


Shipper (file transfer) project is developed in c#.net (vs 2010).it use the file transfer protocol to send the file from one computer to another computer.as a small project it is able to send only limited size of file.
it is combination of two project one is shipper sever and other one is Shipper client. First discus the Shipper server part.

Download:

You can download this project from: http://www.4shared.com/file/4ha5NFj0/networking_project.html

Shipper Server

In shipper sever has two mode one is send file and second is receive file.

Send file mode: in this mode server will read to send the file to client.

And

In Receive mode: Server is ready to receive the file from client.

But the question is how?

Ans is when server is set to send mode first select the file which is send to client and give client IP address and port number.

To send the files then start the server.

Same steps will be follow when we receive the file from client but u select the path where the file will store.

Screen Shot:

Welcome screen:

Server screen


Codding:

For sending the file: we declare these namespace at the top of the project file

<br />
using System.Net;<br />
using System.Net.Sockets;<br />
using System.IO;<br />
try<br />
{<br />
IPEndPoint ipEnd;<br />
Socket sock;<br />
ipEnd = new IPEndPoint(IPAddress.Any, Convert.ToInt32( txt_port.Text));<br />
sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);<br />
sock.Bind(ipEnd);<br />
msgsender = &quot;Starting...&quot;;<br />
sock.Listen(100);<br />
msgsender = &quot;Running and waiting to Send  The file.&quot;;<br />
clientSock = sock.Accept();<br />
string fileName = Path.GetFileName(dlg_open.FileName);<br />
string filePath = Path.GetDirectoryName(dlg_open.FileName);<br />
byte[] fileNameByte = Encoding.ASCII.GetBytes(fileName);<br />
if (fileNameByte.Length &gt; 850 * 1024)<br />
{<br />
lst_sserver.Items.Add(&quot;File size is more than 850kb, please try with small file.&quot;);<br />
return;<br />
}<br />
byte[] fileData = File.ReadAllBytes(filePath + &quot;\\&quot; + fileName);<br />
byte[] clientData = new byte[4 + fileNameByte.Length + fileData.Length];<br />
byte[] fileNameLen = BitConverter.GetBytes(fileNameByte.Length);<br />
msgsender = &quot;Sending data...&quot;;<br />
fileNameLen.CopyTo(clientData, 0);<br />
fileNameByte.CopyTo(clientData, 4);<br />
fileData.CopyTo(clientData, 4 + fileNameByte.Length);<br />
clientSock.Send(clientData);<br />
clientSock.Close();<br />
msgsender = &quot;File send.&quot;;<br />
msgsender = &quot;Connection close.&quot;;<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(&quot;Unable to send the file.&quot; + ex.Message);<br />
}<br />

Description:

“IPEndPoint” Represents a network endpoint as an IP address and a port number. It’s come under the System.Net. And “Socket” initializes a new instance of the Socket class using the specified value.

Sock.bind(ipend) is use to bind the connection. After the binding the connection set the listing state of socket which is 100. After that select the file and file file path get the file size in bytes and check if it is more than 850 kb then display the error message if it not then send the file to client data. Server socket and client socket number will be same when the server is sending the file or receiving the file from client it’s the short description of the server part code.

Shipper Client

In shipper client it has two parts one is download and other one is uploading. When client is uploading the file it selects the file and give server IP address and port number then click the upload button.when it want to download a file it select the path where the file will be store.

Screen shot

Client screen

Codding

Download part:

</p>
<p>try</p>
<p>{</p>
<p>lst_client.Items.Add(&quot;Buffering ...&quot;);</p>
<p>IPAddress[] ipAddress = Dns.GetHostAddresses(txt_ipaddress.Text);</p>
<p>IPEndPoint ipEnd = new IPEndPoint(ipAddress[0], Convert.ToInt32(txt_port.Text));</p>
<p>Socket clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);</p>
<p>lst_client.Items.Add( &quot;Connection to server ...&quot;);</p>
<p>clientSock.Connect(ipEnd);</p>
<p>byte[] clientData = new byte[1024 * 5000];</p>
<p>string receivedPath = dlg_folderbrowser.SelectedPath;</p>
<p>int receivedBytesLen = clientSock.Receive(clientData);</p>
<p>int fileNameLen = BitConverter.ToInt32(clientData, 0);</p>
<p>string fileName = Encoding.ASCII.GetString(clientData, 4, fileNameLen);</p>
<p>lst_client.Items.Add(&quot;File Reciving...&quot;);</p>
<p>BinaryWriter bWrite = new BinaryWriter(File.Open(receivedPath + &quot;\\&quot; + fileName, FileMode.Append));</p>
<p>bWrite.Write(clientData, 4 + fileNameLen, receivedBytesLen - 4 - fileNameLen);</p>
<p>bWrite.Close();</p>
<p>lst_client.Items.Add(&quot;Disconnecting....&quot;);</p>
<p>clientSock.Close();</p>
<p>lst_client.Items.Add(&quot;File Recived. from:&quot; + txt_ipaddress.Text + &quot;.&quot;);</p>
<p>}</p>
<p>catch (Exception ex)</p>
<p>{</p>
<p>MessageBox.Show(&quot;Unable to recive the file.&quot; + ex.Message, &quot;Shipper Client&quot;, MessageBoxButtons.OK, MessageBoxIcon.Error);</p>
<p>}</p>
<p>

Upload part:

</p>
<p>try</p>
<p>{</p>
<p>if(x==0)</p>
<p>{</p>
<p>try</p>
<p>{</p>
<p>IPAddress[] ipAddress = Dns.GetHostAddresses(txt_ipaddress.Text);</p>
<p>IPEndPoint ipEnd = new IPEndPoint(ipAddress[0], Convert.ToInt32(txt_port.Text));</p>
<p>Socket clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);</p>
<p>string fileName = dlg_open.FileName;</p>
<p>string filePath = &quot;&quot;;</p>
<p>fileName = fileName.Replace(&quot;\\&quot;, &quot;/&quot;);</p>
<p>while (fileName.IndexOf(&quot;/&quot;) &gt; -1)</p>
<p>{</p>
<p>filePath += fileName.Substring(0, fileName.IndexOf(&quot;/&quot;) + 1);</p>
<p>fileName = fileName.Substring(fileName.IndexOf(&quot;/&quot;) + 1);</p>
<p>}</p>
<p>byte[] fileNameByte = Encoding.ASCII.GetBytes(fileName);</p>
<p>if (fileNameByte.Length &gt; 850 * 1024)</p>
<p>{</p>
<p>lst_client.Items.Add(&quot;File size is more than 850kb, please try with small file.&quot;);</p>
<p>return;</p>
<p>}</p>
<p>lst_client.Items.Add(&quot;Buffering ...&quot;);</p>
<p>byte[] fileData = File.ReadAllBytes(filePath + fileName);</p>
<p>byte[] clientData = new byte[4 + fileNameByte.Length + fileData.Length];</p>
<p>byte[] fileNameLen = BitConverter.GetBytes(fileNameByte.Length);</p>
<p>fileNameLen.CopyTo(clientData, 0);</p>
<p>fileNameByte.CopyTo(clientData, 4);</p>
<p>fileData.CopyTo(clientData, 4 + fileNameByte.Length);</p>
<p>lst_client.Items.Add(&quot;Connection to server ...&quot;);</p>
<p>clientSock.Connect(ipEnd);</p>
<p>lst_client.Items.Add(&quot;File sending...&quot;);</p>
<p>clientSock.Send(clientData);</p>
<p>lst_client.Items.Add(&quot;Disconnecting...&quot;);</p>
<p>clientSock.Close();</p>
<p>lst_client.Items.Add(&quot;File transferred.&quot;);</p>
<p>}</p>
<p>catch (Exception ex)</p>
<p>{</p>
<p>MessageBox.Show(&quot;File Sending fail.&quot; + ex.Message,&quot;Shipper Client&quot;,MessageBoxButtons.OK,MessageBoxIcon.Error);</p>
<p>}</p>
<p>

Description: when we download some file from server it connects the server by giving the server IP address and its port number. “BinaryWriter” is responsible for receiving the file from server first it bind the connections using the IP address and port number. And receive the file from server byte by byte.
When we upload the file it will be done in three steps. First file length will be send to server, second file name will copy to server, it will create the file on server then the data will upload to the server using the “fileData.CopyTo()”.

Shutdown Computer Using C#.net(Cessation)


Cessation
Cessation is the project which is able to shut down your computer or reboot and perform many tasks like logoff, switch user, sleep, hibernate just one click but don’t forget to set the time for task. I use this project when I want to shut down my computer when some downloading finished. I this project is developed in c#.net 2010.
Download
You can get this project by open this link http://www.4shared.com/file/XqTzCYuH/cessation.html
Description
When developing this project I use Radio button, panels, timer, button, tools tip, notification, Doman up down components.Radio button: radio button is use to select the task it may be shut down etc…Timer is use to track the time and trigger the code of your selected task.One reset button is use to reset the application fields and abort the task.Tool tip is use to show the tip on particular components.Notification in use to send my APPs to notification area.Domain up down component is to select the hour minutes and seconds and AM/PM.

Note: Don’t forget to include user32.dll file, write this code after the class.

<br />
[DllImport(&quot;user32.dll&quot;)]<br />
 public static extern void LockWorkStation();<br />
 [DllImport(&quot;user32.dll&quot;)]<br />
 public static extern int ExitWindowsEx(int uFlags, int dwReason);<br />

Screen shot

Main form

Popup window

About Me

here the following code for shutdown,reboot, log-off,lock,switch user,hibernate,sleep

<br />
//Code for shutdown:<br />
System.Diagnostics.Process.Start(&quot;shutdown&quot;, &quot;/s /f /t 0&quot;);<br />
//Code for reboot<br />
System.Diagnostics.Process.Start(&quot;shutdown&quot;, &quot;/r /f /t 0&quot;);<br />
//Code for sleep:<br />
Application.SetSuspendState(PowerState.Suspend, true, true);<br />
//Code for logoff:<br />
ExitWindowsEx(0, 0);<br />
//Code for lock the computer:<br />
LockWorkStation();<br />
//Code for hibernate<br />
Application.SetSuspendState(PowerState.Hibernate, true, true);<br />

Display Current System Time

For displaying the current system time the following code is responsible,Timer1 code is trigger every one second

<br />
private void timer1_Tick(object sender, EventArgs e)<br />
 {<br />
 lbl_time.Text = Convert.ToString(DateTime.Now.ToLongTimeString());<br />
 }<br />

Displaying the message:

This code is responsible for display the default message on the status area.

<br />
private void tm_msg_Tick(object sender, EventArgs e)<br />
 {<br />
 lbl_msg.ForeColor = Color.Black;<br />
 lbl_msg.Text = &quot;Set Time and opration for performe the Task.&quot;;<br />
 tm_msg.Enabled = false;<br />
 }<br />

Check all the input is properly given or not

For checking all the input is proper given or not . Time and task is set or not if it is set then display the message like “your computer will be shut down at 12:00:00 pm” and display the popup window, and show notify tool tip.Trace the time and complete the peration This code is trace the time if the given time and system time is match then it execute the given task code.

<br />
private void tm_setgo_Tick(object sender, EventArgs e)<br />
{<br />
string tm = (ud_hh.Text + &quot;:&quot; + ud_mm.Text + &quot;:&quot; + ud_ss.Text + &quot; &quot; + ud_pa.Text);<br />
if (flag == true &amp;amp;&amp;amp; flag2 == true &amp;amp;&amp;amp; tm == Convert.ToString(DateTime.Now.ToLongTimeString()))<br />
{<br />
tm_setgo.Enabled = false;<br />
if (rd_hiber.Checked == true)<br />
{<br />
frm_cess.Show();<br />
Application.SetSuspendState(PowerState.Hibernate, true, true);<br />
msg = &quot;Hibernate&quot;;<br />
}<br />
if (rd_lock.Checked == true)<br />
{<br />
cessation_task fm_cess=new cessation_task();<br />
fm_cess.Show();<br />
LockWorkStation();<br />
msg = &quot;Lock&quot;;<br />
}<br />
if (rd_logoff.Checked == true)<br />
{<br />
cessation_task fm_cess = new cessation_task();<br />
fm_cess.Show();<br />
ExitWindowsEx(0, 0);<br />
msg = &quot;Logoff&quot;;<br />
}<br />
if (rd_res.Checked == true)<br />
{<br />
cessation_task fm_cess = new cessation_task();<br />
frm_cess.Show();<br />
System.Diagnostics.Process.Start(&quot;shutdown&quot;, &quot;/r /f /t 0&quot;);<br />
msg = &quot;Reboot&quot;;<br />
}<br />
if (rd_sleep.Checked == true)<br />
{<br />
cessation_task fm_cess = new cessation_task();<br />
fm_cess.Show();<br />
Application.SetSuspendState(PowerState.Suspend, true, true);<br />
msg = &quot;Sleep&quot;;<br />
}<br />
if (rd_sh.Checked == true)<br />
{<br />
cessation_task fm_cess = new cessation_task();<br />
fm_cess.Show();<br />
System.Diagnostics.Process.Start(&quot;shutdown&quot;, &quot;/s /f /t 0&quot;);<br />
msg = &quot;Shutdown&quot;;<br />
}<br />
}<br />
}<br />

Send for to notify area and display the pop up window

To hide the form and display the notification and popup window the following code is responsible

For tracing the window state define one function definition in form1.designer.cs File inside the private void InitializeComponent() Function.

<br />
private void mn_cessation_Resize(object sender, EventArgs e)<br />
{<br />
if (this.WindowState == FormWindowState.Minimized)<br />
{<br />
this.Hide();<br />
if(msg!=&quot;&quot;)<br />
frm_cess.Show();<br />
}<br />
}<br />

Main form(form1.cs ) source code

<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.Runtime.InteropServices;<br />
using System.Management;<br />
namespace cessation<br />
{<br />
 public partial class mn_cessation : Form<br />
{<br />
 // Importing Windows API library<br />
 [DllImport(&quot;user32.dll&quot;)]<br />
 public static extern void LockWorkStation();<br />
 [DllImport(&quot;user32.dll&quot;)]<br />
 public static extern int ExitWindowsEx(int uFlags, int dwReason);<br />
 bool flag=false;<br />
 bool flag2=false;<br />
 string msg;<br />
 int flg=0;<br />
 cessation_task frm_cess = new cessation_task();<br />
 public mn_cessation()<br />
 {<br />
 InitializeComponent();<br />
 }<br />
 private void mn_cessation_Load(object sender, EventArgs e)<br />
 {<br />
 msg = &quot;&quot;;<br />
 tm_time.Enabled = true;<br />
 }<br />
private void mn_cessation_Resize(object sender, EventArgs e)<br />
{<br />
 if (this.WindowState == FormWindowState.Minimized)<br />
 {<br />
 this.Hide();<br />
 if(msg!=&quot;&quot;)<br />
 frm_cess.Show();<br />
 }<br />
 }<br />
 private void timer1_Tick(object sender, EventArgs e)<br />
 {<br />
 lbl_time.Text = Convert.ToString(DateTime.Now.ToLongTimeString());<br />
 }<br />
 private void btn_rst_Click(object sender, EventArgs e)<br />
 {<br />
 btn_rst.Size = new Size(30, 27);&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;<br />
 reset();<br />
 btn_rst.Size = new Size(29, 26);<br />
 }<br />
 private void btn_rst_MouseLeave(object sender, EventArgs e)<br />
 {<br />
 btn_rst.Size = new Size(29, 26);<br />
 }<br />
 private void btn_rst_MouseHover(object sender, EventArgs e)<br />
 {<br />
 btn_rst.Size = new Size(30, 27);<br />
 }<br />
 public void reset()<br />
 {<br />
 msg = &quot;&quot;;<br />
 ud_hh.Text = &quot;&quot;;<br />
 ud_mm.Text = &quot;&quot;;<br />
 ud_ss.Text = &quot;&quot;;<br />
 ud_pa.Text = &quot;&quot;;<br />
 rd_hiber.Checked = false;<br />
 rd_lock.Checked = false;<br />
 rd_logoff.Checked = false;<br />
 rd_res.Checked = false;<br />
 rd_sh.Checked = false;<br />
 rd_sleep.Checked = false;<br />
 tm_msg.Enabled = true;<br />
 lbl_msg.ForeColor = Color.Blue;<br />
 lbl_msg.Text = &quot;Time and Operation will reset and task will be cancelled.&quot;;<br />
 flag2 = false;<br />
 flag = false;<br />
 }<br />
 private void rd_sh_CheckedChanged(object sender, EventArgs e)<br />
 {<br />
 if (rd_sh.Checked == true)<br />
 {<br />
 pic_oper.Visible = false;<br />
 pic_opr.Visible = true;<br />
 flag2 = true;<br />
 tm_setgo.Enabled = true;<br />
 msg = &quot;Shutdown&quot;;<br />
 }<br />
 if (rd_sh.Checked == false)<br />
 {<br />
 pic_oper.Visible = true;<br />
 pic_opr.Visible = false;<br />
 }<br />
 }<br />
 private void tm_msg_Tick(object sender, EventArgs e)<br />
 {<br />
 lbl_msg.ForeColor = Color.Black;<br />
 lbl_msg.Text = &quot;Set Time and opration for performe the Task.&quot;;<br />
 tm_msg.Enabled = false;<br />
 }<br />
 private void tm_check_Tick(object sender, EventArgs e)<br />
 {<br />
 if (ud_hh.Text == &quot;&quot; &amp;amp;&amp;amp; ud_mm.Text == &quot;&quot; &amp;amp;&amp;amp; ud_ss.Text == &quot;&quot; &amp;amp;&amp;amp; ud_pa.Text == &quot;&quot;)<br />
 {<br />
 pic_tmr.Visible = false;<br />
 pic_tmer.Visible = true;<br />
 flag = false;<br />
 }<br />
 if (ud_hh.Text != &quot;&quot; &amp;amp;&amp;amp; ud_mm.Text != &quot;&quot; &amp;amp;&amp;amp; ud_ss.Text != &quot;&quot; &amp;amp;&amp;amp; ud_pa.Text != &quot;&quot;)<br />
 {<br />
 DateTime d = DateTime.Now;<br />
 pic_tmr.Visible = true;<br />
 pic_tmer.Visible = false;<br />
 flag = true;<br />
 if (msg != &quot;&quot;)<br />
 {<br />
 int hh, mm, ss;<br />
 string tm;<br />
 tm = (ud_hh.Text + &quot;:&quot; + ud_mm.Text + &quot;:&quot; + ud_ss.Text + &quot; &quot; + ud_pa.Text);<br />
 lbl_msg.Text = &quot;Your computer will &quot; + msg + &quot; at &quot; + tm;<br />
 nty_cess.Text = &quot;Your computer will &quot; + msg + &quot; at &quot; + tm;<br />
 frm_cess.msg(lbl_msg.Text);<br />
 if (flg == 0)<br />
 {<br />
 nty_cess.ShowBalloonTip(1000, &quot;cessation&quot;, &quot;Your computer will &quot; + msg + &quot; at &quot; + tm , ToolTipIcon.Info);<br />
 flg++;<br />
 }<br />
 }<br />
 }<br />
 tm_check.Enabled = true;<br />
 }<br />
private void rd_hiber_CheckedChanged(object sender, EventArgs e)<br />
 {<br />
 if (rd_hiber.Checked == true)<br />
 {<br />
 pic_oper.Visible = false;<br />
 pic_opr.Visible = true;<br />
 flag2 = true;<br />
 msg = &quot;Hibernate&quot;;<br />
 tm_setgo.Enabled = true;<br />
 }<br />
 if (rd_hiber.Checked == false)<br />
 {<br />
 pic_oper.Visible = true;<br />
 pic_opr.Visible = false;<br />
 }<br />
 }<br />
 private void rd_lock_CheckedChanged(object sender, EventArgs e)<br />
 {<br />
 if (rd_lock.Checked == true)<br />
 {<br />
 pic_oper.Visible = false;<br />
 pic_opr.Visible = true;<br />
 flag2 = true;<br />
 msg = &quot;Lock&quot;;<br />
 tm_setgo.Enabled = true;<br />
 }<br />
 if (rd_lock.Checked == false)<br />
 {<br />
 pic_oper.Visible = true;<br />
 pic_opr.Visible = false;<br />
 }<br />
 }<br />
 private void rd_logoff_CheckedChanged(object sender, EventArgs e)<br />
 {<br />
 if (rd_logoff.Checked == true)<br />
 {<br />
 pic_oper.Visible = false;<br />
 pic_opr.Visible = true;<br />
 flag2 = true;<br />
 msg = &quot;Logoff&quot;;<br />
 tm_setgo.Enabled = true;<br />
 }<br />
 if (rd_logoff.Checked == false)<br />
 {<br />
 pic_oper.Visible = true;<br />
 pic_opr.Visible = false;<br />
 }<br />
 }<br />
 private void rd_res_CheckedChanged(object sender, EventArgs e)<br />
 {<br />
 if (rd_res.Checked == true)<br />
 {<br />
 pic_oper.Visible = false;<br />
 pic_opr.Visible = true;<br />
 flag2 = true;<br />
 msg = &quot;Reboot&quot;;<br />
 tm_setgo.Enabled = true;<br />
 }<br />
 if (rd_res.Checked == false)<br />
 {<br />
 pic_oper.Visible = true;<br />
 pic_opr.Visible = false;<br />
 }<br />
 }<br />
 private void rd_sleep_CheckedChanged(object sender, EventArgs e)<br />
 {<br />
 if (rd_sleep.Checked == true)<br />
 {<br />
 pic_oper.Visible = false;<br />
 pic_opr.Visible = true;<br />
 flag2 = true;<br />
 msg = &quot;Sleep&quot;;<br />
 tm_setgo.Enabled = true;<br />
 }<br />
 if (rd_sleep.Checked == false)<br />
 {<br />
 pic_oper.Visible = true;<br />
 pic_opr.Visible = false;<br />
 }<br />
 }<br />
 private void tm_setgo_Tick(object sender, EventArgs e)<br />
 {<br />
 string tm = (ud_hh.Text + &quot;:&quot; + ud_mm.Text + &quot;:&quot; + ud_ss.Text + &quot; &quot; + ud_pa.Text);<br />
 if (flag == true &amp;amp;&amp;amp; flag2 == true &amp;amp;&amp;amp; tm == Convert.ToString(DateTime.Now.ToLongTimeString()))<br />
 {<br />
 tm_setgo.Enabled = false;<br />
 if (rd_hiber.Checked == true)<br />
 {<br />
 frm_cess.Show();<br />
 Application.SetSuspendState(PowerState.Hibernate, true, true);<br />
 msg = &quot;Hibernate&quot;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;<br />
 }<br />
 if (rd_lock.Checked == true)<br />
 {<br />
 cessation_task fm_cess=new cessation_task();<br />
 fm_cess.Show();<br />
 LockWorkStation();<br />
 msg = &quot;Lock&quot;;<br />
 }<br />
 if (rd_logoff.Checked == true)<br />
 {<br />
 cessation_task fm_cess = new cessation_task();<br />
 fm_cess.Show();<br />
 ExitWindowsEx(0, 0);<br />
 msg = &quot;Logoff&quot;;<br />
 }<br />
 if (rd_res.Checked == true)<br />
 {<br />
 cessation_task fm_cess = new cessation_task();<br />
 fm_cess.Show();<br />
 System.Diagnostics.Process.Start(&quot;shutdown&quot;, &quot;/r /f /t 0&quot;);<br />
 msg = &quot;Reboot&quot;;<br />
 }<br />
 if (rd_sleep.Checked == true)<br />
 {<br />
 cessation_task fm_cess = new cessation_task();<br />
 fm_cess.Show();<br />
 Application.SetSuspendState(PowerState.Suspend, true, true);<br />
 msg = &quot;Sleep&quot;;<br />
 }<br />
 if (rd_sh.Checked == true)<br />
 {<br />
 cessation_task fm_cess = new cessation_task();<br />
 fm_cess.Show();<br />
 System.Diagnostics.Process.Start(&quot;shutdown&quot;, &quot;/s /f /t 0&quot;);<br />
 msg = &quot;Shutdown&quot;;<br />
 }<br />
 }<br />
 }<br />
 private void nty_cess_MouseDoubleClick(object sender, MouseEventArgs e)<br />
 {<br />
 this.Show();<br />
 this.WindowState = FormWindowState.Normal;<br />
}<br />
 private void toolStripMenuItem1_Click(object sender, EventArgs e)<br />
 {<br />
 this.Hide();<br />
 }<br />
 private void toolStripMenuItem2_Click(object sender, EventArgs e)<br />
 {<br />
 this.Show();<br />
 this.WindowState = FormWindowState.Normal;<br />
 }<br />
 private void toolStripMenuItem3_Click(object sender, EventArgs e)<br />
 {<br />
 Application.Exit();<br />
 }<br />
 private void label6_Click(object sender, EventArgs e)<br />
 {<br />
 aboutme abm = new aboutme();<br />
abm.Show();<br />
 }<br />
private void pictureBox2_Click(object sender, EventArgs e)<br />
 {<br />
 aboutme abm = new aboutme();<br />
 abm.Show();<br />
 }<br />
 }<br />
}<br />

cessation_task.cs code

<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
namespace cessation<br />
{<br />
 public partial class cessation_task : Form<br />
 {<br />
 public cessation_task()<br />
 {<br />
 InitializeComponent();<br />
 }<br />
 private void cessation_task_Load(object sender, EventArgs e)<br />
 {<br />
 this.Opacity = 0.1;<br />
 Screen screen = Screen.PrimaryScreen;<br />
 int S_width = screen.Bounds.Width;<br />
 int S_height = screen.Bounds.Height;<br />
 this.Location = new Point((S_width - 240), (S_height-150));<br />
 timer1.Enabled = true;<br />
 timer1.Interval = 100;<br />
 }<br />
 public void msg(string msgg)<br />
 {<br />
 lbl_msg.Text = msgg;<br />
 }<br />
 private void timer1_Tick(object sender, EventArgs e)<br />
 {<br />
 if (this.Opacity &amp;lt; 1)<br />
 {<br />
 this.Opacity = this.Opacity + 0.1;<br />
 timer1.Enabled = true;<br />
 }<br />
 else<br />
 {<br />
 timer1.Enabled = false;<br />
 timer2.Enabled = true;<br />
 timer2.Interval = 3000;<br />
 }<br />
 }<br />
 private void button1_Click(object sender, EventArgs e)<br />
 {<br />
 this.Hide();<br />
 }<br />
 private void timer2_Tick(object sender, EventArgs e)<br />
 {<br />
 if (timer2.Interval == 3000)<br />
 timer3.Enabled = true;<br />
 }<br />
private void timer3_Tick(object sender, EventArgs e)<br />
 {<br />
 if (this.Opacity &gt; .1)<br />
 {<br />
 this.Opacity -= .1;<br />
 timer3.Enabled = true;<br />
 }<br />
 else<br />
 {<br />
 timer3.Enabled = false;<br />
 this.Close();<br />
 }<br />
 }<br />
 }<br />
}<br />

aboutme.cs code

<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
namespace cessation<br />
{<br />
 public partial class aboutme : Form<br />
 {<br />
 public aboutme()<br />
 {<br />
 InitializeComponent();<br />
 }<br />
 private void button1_Click(object sender, EventArgs e)<br />
 {<br />
 this.Close();<br />
 }<br />
 }<br />
}<br />