Tuesday, 15 April 2014

Getting LogicalDrive Info

 private void button3_Click(object sender, EventArgs e)
        {
            String[] obj = System.Environment.GetLogicalDrives();
            //obj.show
            comboBox1.Items.AddRange(obj);
           
            listBox1.Items.AddRange(obj);


        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.BackColor = System.Drawing.Color.DarkGreen;
            System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
            for (int i = 0; i <= drives.Length - 1; i++)
            {
                comboBox1.Items.Add(drives[i].Name);
            }
            comboBox1.SelectedIndex = -1;
         
        }

BACK GROUND AND FORE GROUND COLOR for all windows forms controls

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.IO;


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

        private void button1_Click(object sender, EventArgs e)
        {
       
            ColorDialog OBJ2 = new ColorDialog();
            OBJ2.ShowDialog();
            textBox1.ForeColor = OBJ2.Color;
         
         
        }

        private void button2_Click(object sender, EventArgs e)
        {
             {
       
            ColorDialog OBJ3 = new ColorDialog();
            OBJ3.ShowDialog();
       
            textBox1.BackColor= OBJ3.Color;
         
        }
        }

        private void button3_Click(object sender, EventArgs e)
        {
         

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.BackColor = System.Drawing.Color.DarkGreen;
         
        }
    }
}

database

db is 2 types
1.file management system
2.db management system

FILE MANAGEMENT SYSTEM
 private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog obj1 = new OpenFileDialog();
            obj1.ShowDialog();
           
           txtopenfile.Text = obj1.FileName;
            private void write_btn_Click(object sender, EventArgs e)
        {
            FileStream fs = new FileStream(txtopenfile.Text,FileMode.Open,FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs);
            sw.WriteLine(txtwrit.Text);
            sw.Close();
            fs.Close();
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            FileStream fs = new FileStream(txtopenfile.Text,FileMode.Open,FileAccess.Read);
            StreamReader sr = new StreamReader(fs);
            textBox1.Text = sr.ReadToEnd();
            sr.Close();
            fs.Close();

        }
    }
}

Friday, 11 April 2014

disconnection oriented programming







              SqlConnection con = new SqlConnection("Data Source=RKMS-PC\\SQLEXPRESS;Initial Catalog=master;Integrated Security=True");
            SqlCommand cmd= new SqlCommand();
            SqlDataAdapter da = new SqlDataAdapter("select * FROM EMPDETAILS", con);
            DataSet ds = new DataSet();
            da.Fill(ds,"emp");
            dispGridView1.DataSource = ds.Tables[0];
           

Wednesday, 2 April 2014

code for calculator



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

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void bntadd_Click(object sender, EventArgs e)
        {
            int a = Convert.ToInt32(txtfname.Text.ToString());
            int b = Convert.ToInt32(txtsname.Text.ToString());
            int c = a + b;
            txtdisp.Text = c.ToString();


        }

        private void btnsub_Click(object sender, EventArgs e)
        {
            int a = Convert.ToInt32(txtfname.Text.ToString());
            int b = Convert.ToInt32(txtsname.Text.ToString());
            int c = a - b;
            txtdisp.Text = c.ToString();

        }

        private void btnmul_Click(object sender, EventArgs e)
        {
            int a = Convert.ToInt32(txtfname.Text.ToString());
            int b = Convert.ToInt32(txtsname.Text.ToString());
            int c = a * b;
            txtdisp.Text = c.ToString();

        }

        private void btndiv_Click(object sender, EventArgs e)
        {
          float a = Convert.ToInt32(txtfname.Text.ToString());
          float b = Convert.ToInt32(txtsname.Text.ToString());
          float c = a / b;
            txtdisp.Text = c.ToString();

        }
    }
}