Friday 14 March 2014

Simple Tick Tock Program in C#.net , Displaying Thread Synchronization

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 thread
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        object objlock = new object();

        public void tick()
        {
           
            for (int i = 0; i < 10; i++)
            {
                lock (objlock)
                {
                    textBox1.Text += "Tick"+Environment.NewLine;

                    Monitor.Pulse(objlock);
                    Monitor.Wait(objlock);
                }
            }
        }
        public void tock()
        {
           
            for (int i = 0; i < 10; i++)
            {
                lock (objlock)
                {
                    textBox1.Text += "Tock";

                    Monitor.Pulse(objlock);
                    Monitor.Wait(objlock);
                }
            }
        }
       // public void toe()
       // {
//
        //    for (int i = 0; i < 10; i++)
         //   {
          //      lock (objlock)
           //     {
            //        textBox1.Text += "Toe";
//
              //      Monitor.Pulse(objlock);
               //     Monitor.Wait(objlock);
               // }
           // }
     //   }

        private void Form2_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Thread th = new Thread(tick);
            Thread th1 = new Thread(tock);
            //Thread th2 = new Thread(toe);

            th.Start();
            th1.Start();
           // th2.Start();

        }

    }
}

Saturday 8 March 2014

Progress Bar Race Using Thread C#.NET

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 thread
{
    public partial class Form1 : Form
    {
     
        public Form1()
        {
            InitializeComponent();
        }
       

        bool flag=true;
       
        public void prog1()
        {
            //Change Property of progress bar
            //min=1
            //max=50000
            //size=127, 23

            for (int i = 1; i <= 50000; i++)
            {
                if (flag)
                {
                    progressBar1.Value = i;
                    textBox1.Text = i.ToString();
                    //Uncomment below code for simple progress bar

                    //if (progressBar1.Value == 100)
                    //{
                    //  MessageBox.Show("Progress Bar1 done");
                    //break;

                    //Uncomment above code for simple progress bar
                }
                else
                {
                 
                    break;
                }
            }
            flag=false;
         
        }
        public void prog2()
        {
            //Change Property of progress bar
            //min=1
            //max=50000
            //size=127, 23

            for (int i = 1; i <= 50000; i++)
            {
                if (flag)
                {
                    progressBar2.Value = i;
                    textBox2.Text = i.ToString();
                    //Uncomment below code for simple progress bar

                    //if (progressBar2.Value == 100)
                    //{
                    //    MessageBox.Show("Progress Bar2 done");
                    //    break;

                    //Uncomment above code for simple progress bar
                }
                else
                {
                   
                    break;
                }
               
            }
            flag=false;
        }
           

        private void Form1_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Thread th1 = new Thread(prog1);
            Thread th2 = new Thread(prog2);

         
            th1.Start();
            th2.Start();
           
        }
    }
}

Wednesday 5 March 2014

Horizontal Menus With Vertical SubMenus Using Css : Very Basic

<html>
<head>
<style>

body ul ul
{
display:none;
text-shadow:10px 5px 5px red;


}

body ul li
{
list-style:none;
padding:10;
float:left; /*Remove this comment to make it horizontal*/
}

body ul li:hover > ul
{
display:block;
position:absolute;
margin-top:10px;
top:20px;
width:30px;
left:80px;

}







</style>





</head>
<body>
<div>
<div>
<ul>
<li>Home</li>
<li>Gallery
<ul>
<li>Img1</li>
<li>img2</li>
</ul>



</li>
<li>ContactUs</li>
</ul>
</div>
</div>

</body>
</html>

Vertical Menu With Horizontal SubMenus USING CSS : VERY BASIC

<html>
<head>
<style>

body ul ul
{
display:none;
background-color:green;
}

body ul li
{
list-style:none;
padding:10;


}

body ul li:hover >   ul
{


display:inline;
}
body ul li:hover > ul li
{
height:500px;
display:inline;

}






</style>





</head>
<body>
<div>
<div>
<ul>
<li>Home</li>
<li>Gallery

<ul>
<li>Img1</li>
<li>Img2</li>



</ul>



</li>
<li>ContactUs</li>
</ul>
</div>
</div>

</body>
</html>



Friday 21 February 2014

TIC TAC TOE

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;

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

        int count = 1;


        private void btnall(object sender, EventArgs e)
        {
            Button b = (Button)sender;
           
           b.Text= (count % 2 == 0) ? "O" : "X";
         
           // if (count % 2 == 0)
           //{
           //    //b.BackColor = Color.Red;
           //    b.ForeColor = Color.Red;
             
           //}
           //else
           //{
           //    b.BackColor = Color.Blue;
           //}
           b.Enabled = false;
           count++;
            check();
        }


        void check()
        {
            if (button1.Text == button2.Text && button2.Text == button3.Text && button1.Text != "")
            {
                result(button1.Text);
            }
             if (button1.Text == button4.Text && button4.Text == button7.Text && button1.Text != "")
            {
                result(button1.Text);
            }
             if (button4.Text == button5.Text && button5.Text == button6.Text && button4.Text != "")
            {
                result(button4.Text);
            }
             if (button7.Text == button8.Text && button8.Text == button9.Text && button7.Text != "")
            {
                result(button7.Text);
            }
             if (button2.Text == button5.Text && button5.Text == button8.Text && button2.Text != "")
            {
                result(button2.Text);
            }
             if (button3.Text == button6.Text && button6.Text == button9.Text && button3.Text != "")
            {
                result(button3.Text);
            }
             if (button1.Text == button5.Text && button5.Text == button9.Text && button1.Text != "")
            {
                result(button1.Text);
            }
             if (button3.Text == button5.Text && button5.Text == button7.Text && button3.Text != "")
            {
                result(button3.Text);
            }

        }
        void result( string txt)
        {
            if (txt=="O")
            {
                MessageBox.Show("Second Player Win");
            }
            else
            {
                MessageBox.Show("First Player Win");
            }
           
        }

        private void button10_Click(object sender, EventArgs e)
        {
             reset();
        }
     
        void reset()
        {
            foreach (Button b in this.Controls)
            {
                b.Text = "";
                b.Enabled = true;
                b.BackColor = Control.DefaultBackColor;
                button10.Text = "Reset";
                button11.Text = "Play Again";

            }
            count = 1;
        }

        private void button11_Click(object sender, EventArgs e)
        {
           
            if (MessageBox.Show("Are You Want To Play Again!"," "  , MessageBoxButtons.YesNo) == DialogResult.Yes)

           
            {

                reset();
            }
            else
            {
                Form1 frm = new Form1();
                frm.Focus();

            }
        }



        }
   
}


Tuesday 11 February 2014

Example Of Array With Sturctue

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 Microsoft.VisualBasic;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public int index;
        public int ch,temp=0;
       
        public Form1()
        {
            InitializeComponent();
        }
       public struct Student
        {
            public int sno;
            public string fname;
            public string lname;
            public DateTime dob;
        }
         Student [] arr=new Student[1];

        private void btnSave_Click(object sender, EventArgs e)
        {
             //Student[] arr = new Student[1];  
            arr[index].sno = Convert.ToInt32(textBox1.Text);
            arr[index].fname = textBox2.Text;
            arr[index].lname = textBox3.Text;
            arr[index].dob = Convert.ToDateTime(textBox4.Text);
            index++;
            Array.Resize(ref arr,index+1);
            textclear();

        }

        private void textclear()
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";


        }

       

        private void btnLast_Click(object sender, EventArgs e)
        {
           // Student[] arr = new Student[1];
            textBox1.Text = arr[index-1].sno.ToString();
            textBox2.Text = arr[index-1].fname;
            textBox3.Text = arr[index-1].lname;
            textBox4.Text = arr[index-1].dob.ToShortDateString();
            temp = index;
        }

        private void btnFirst_Click(object sender, EventArgs e)
        {
            //Student[] arr = new Student[1];
            textBox1.Text = arr[0].sno.ToString();
            textBox2.Text = arr[0].fname;
            textBox3.Text = arr[0].lname;
            textBox4.Text = arr[0].dob.ToShortDateString();
            temp = 0;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            textclear();

        }

        private void btnCLose_Click(object sender, EventArgs e)
        {
            Form.ActiveForm.Close();

        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            int i;

           
            //For this right click on project add refrence click on .net and select microsoft visual basic
           int sear= Convert.ToInt32(Microsoft.VisualBasic.Interaction.InputBox("Enter The Sno.To Be Searched"));
       
                for(i=0;i<=arr.Length-1;i++)
                {
                    if(arr[i].sno==sear)
                    {
                        //break;
                        textBox1.Text = arr[i].sno.ToString();
                        textBox2.Text = arr[i].fname;
                        textBox3.Text = arr[i].lname;
                        textBox4.Text = arr[i].dob.ToShortDateString();
                        ch = i;
                        return;

                    }
                   
                }
                MessageBox.Show ("Id Not Found");



           


        }

     

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
           


            arr[ch].sno = Convert.ToInt32(textBox1.Text);
             arr[ch].fname=textBox2.Text ;
             arr[ch].lname=textBox3.Text ;
             arr[ch].dob = Convert.ToDateTime(textBox4.Text);

        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            int i;
           

            //For this right click on project add refrence click on .net and select microsoft visual basic
            int sear = Convert.ToInt32(Microsoft.VisualBasic.Interaction.InputBox("Enter The Sno.To Be Deleted"));

            for (i = 0; i < index; i++)
            {
                if (arr[i].sno == sear)
                {
                    for (int j = i; j <index; j++)
                    {
                        arr[j] = arr[j+1];
                        index--;
                        Array.Resize(ref arr, index + 1);


                       
                    }
                }
            }
           
         




        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            if (temp < index-1)
            {
                temp++;
                textBox1.Text = arr[temp].sno.ToString();
                textBox2.Text = arr[temp].fname;
                textBox3.Text = arr[temp].lname;
                textBox4.Text=arr[temp].dob.ToShortDateString();
            }
        }

        private void btnPre_Click(object sender, EventArgs e)
        {
            if (temp > 0)
            {
                temp--;
                textBox1.Text = arr[temp].sno.ToString();
                textBox2.Text = arr[temp].fname;
                textBox3.Text = arr[temp].lname;
                textBox4.Text = arr[temp].dob.ToShortDateString();
            }

        }

       


       

       
    }
 
   


}

Friday 7 February 2014

PHP: "How To Show Images From Database using GET in PHP Without PHP"

<!-- HTML CODE BEIGNS -->

<html>
<head>
<title> Image Showing </title>
</head>
<body>
<a href="ShowImage.php?id=1">IMG1</a>
<a href="ShowImage.php?id=2">IMG2</a>
<a href="ShowImage.php?id=3">IMG3</a>
</body>
</html>

<!-- HTML CODE ENDS -->
------------------------------------------------------------------------------------------------------------
<!-- PHP CODE BEGINS -->

<?php
$id=$_GET[id];
$con=mysqli_connect("localhost","root","","images");
if(mysqli_connect_errno())
{
echo "Failed To Connect"." ".mysqli_connect_errno();
}
$sql="SELECT * FROM Table1 WHERE Id=".$id; // in single qoutes(' ')  string types  values only 
$rs=mysqli_query($con,$sql);
while($row=mysqli_fetch_array($rs))
{
$check=$row[img_name];
}
 
echo "<img src='$check'>";

?>

<!-- PHP CODE ENDS -->