44
NET PROGRAMS.txt C#.NET PROGRAMS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ DATA ENTITY MODEL ----------------------------------------------- FORM1.CS:::: namespace ado.net_entity_data_model { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { bhagyaEntities obj = new bhagyaEntities(); dataGridView1.DataSource = obj.emp.ToList(); } private void Form1_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'bhagyaDataSet.emp' table. You can move, or remove it, as needed. this.empTableAdapter.Fill(this.bhagyaDataSet.emp); } } }******************************************************* COLOR DAILOGBOX ----------------------- FORM1.CS::: namespace color_dailog { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { colorDialog1.ShowDialog(); foreach (Control i in this.Controls) { if (i is TextBox) { i.BackColor = colorDialog1.Color; } } } } }*********************************************************** Page 1

Net Programs

Embed Size (px)

DESCRIPTION

net

Citation preview

Page 1: Net Programs

NET PROGRAMS.txt

C#.NET PROGRAMS@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@DATA ENTITY MODEL-----------------------------------------------FORM1.CS::::

namespace ado.net_entity_data_model{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { bhagyaEntities obj = new bhagyaEntities(); dataGridView1.DataSource = obj.emp.ToList(); }

private void Form1_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'bhagyaDataSet.emp' table. You can move, or remove it, as needed. this.empTableAdapter.Fill(this.bhagyaDataSet.emp);

} }}*******************************************************

COLOR DAILOGBOX-----------------------

FORM1.CS:::

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

private void button1_Click(object sender, EventArgs e) { colorDialog1.ShowDialog(); foreach (Control i in this.Controls) { if (i is TextBox) { i.BackColor = colorDialog1.Color; } } }

}}***********************************************************

Page 1

Page 2: Net Programs

NET PROGRAMS.txt

CONNECTION ORIENTED ARCHITECTURE-------------------------------------------

FORM1.CS:::

using System.Data.SqlClient;namespace coa{ public partial class Form1 : Form { SqlConnection cn=new SqlConnection(); public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { cn= new SqlConnection(@"initial catalog=bhagya;integrated security=true;server=ADMIN-PC"); cn.Open(); SqlCommand cmd = new SqlCommand("select*from users where uname='" + textBox1.Text + "' and password='" + textBox2.Text + "'", cn); SqlDataReader dr=cmd.ExecuteReader(); if(dr.HasRows) { home obj=new home(); obj.Show(); obj.Hide();

} else MessageBox.Show("login failed");

} }}

FORM2.CS:::

namespace coa{ public partial class home : Form { public home() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { Form1 obj = new Form1(); obj.Show(); this.Hide(); } }}***************************************************************************************

CONSOLE APP Page 2

Page 3: Net Programs

NET PROGRAMS.txtEXAMPLES::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@PROGRAM.CS::::

namespace ConsoleApplication3{ class adhi { static void Main( string[] arg) { Console.WriteLine("enter your name"); string s = Console.ReadLine(); Console.WriteLine("hello " + s); Console.ReadKey(); } }}********************************************************************************************PROGRAM.CS:::

namespace ConsoleApplication1{ class Program { static void Main(string[] args) { Console.WriteLine("enter youyr name:"); string s = Console.ReadLine(); Console.WriteLine("hello" +s); Console.ReadKey(); } }}*********************************************************************************PROGRAM.CS:::

namespace ConsoleApplication2{ class addition { static void Main(string[] args) { Console.WriteLine("Enter the a and b values"); int c=Console.ReadLine(

} }}**********************************************************************************PROGRAM.CS:::

namespace ConsoleApplication4{ class Program { static void Main(string[] args) { int a, b, c; Console.WriteLine("enter first value:"); a = int.Parse(Console.ReadLine()); Console.WriteLine("enter second value:");

Page 3

Page 4: Net Programs

NET PROGRAMS.txt b = int.Parse(Console.ReadLine()); c = a * b; Console.WriteLine("the sum is:" + c); Console.ReadKey(); } }}*************************************************************************************PROGRAM.CS:::

namespace ConsoleApplication6{ class Program { static void Main(string[] args) { int num1, num2, opt; float result; label: Console.WriteLine("****MENU****"); Console.WriteLine("press 1 for addition"); Console.WriteLine("press 2 for sub"); Console.WriteLine("press 3 for mul"); Console.WriteLine("press 4 for div" ); Console.WriteLine("enter first num"); num1 = int.Parse(Console.ReadLine()); Console.WriteLine("enter sec num"); num2 = int.Parse(Console.ReadLine()); Console.WriteLine("enter your option"); opt = int.Parse(Console.ReadLine()); if (opt == 1) { result = num1 + num2; Console.WriteLine("{0}+{1}={2}", num1, num2, result); } else if (opt == 4) { result = num1 / num2; Console.WriteLine("{0}/{1}={2}", num1, num2, result); } else { Console.WriteLine("\n invalid opt"); goto label; } Console.ReadLine();

} }}**************************************************************PROGRAM.CS:::

namespace ConsoleApplication7{ class Program { static void Main(string[] args) { int m1, m2, m3, total, avg;

Page 4

Page 5: Net Programs

NET PROGRAMS.txt string sname; Console.WriteLine("Student Details"); Console.WriteLine("Enter the m1,m2,m3"); m1 = int.Parse(Console.ReadLine()); m2 = int.Parse(Console.ReadLine()); m3 = int.Parse(Console.ReadLine()); Console.Write("Enter ur name"); sname = Console.ReadLine(); total = m1 + m2 + m3; avg = total / 3; Console.ReadKey(); } }}******************************************************************PROGRAM.CS:::

namespace ConsoleApplication9{ class sample { public static string name = "this is static varriable"; public static void sample() { Console.WriteLine("this is static method:"); } class program { static void main(string[] args); sample obj=new sample()

Console.writeLine("this is static method:"); } }}***********************************************************************PROGRAM.CS:::::

namespace ConsoleApplication10{ static class sample { public static void name() { Console.WriteLine("\n\nthis is static varriable:\n\n"); } public static void m1() { Console.WriteLine("\n\nthis is static method:"); } } class Program { static void Main(string[] args) { Console.WriteLine("welcome :\n\n"); Console.BackgroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Yellow;

Page 5

Page 6: Net Programs

NET PROGRAMS.txt sample.m1(); sample.name(); Console.ReadKey(); } }}********************************************************************CLASS1.CS:::

namespace ConsoleApplication11{ class Class1 { static class employee { void ~employee() {

}class1() { int eno,sal; string ename,job; Console.WriteLine("emp num is:"+eno); Console.WriteLine("emp num is:"+ename); Console.WriteLine("sal:"+sal); Console.WriteLine("job is:"+job); } class Class1 { partial class employee { void ~employee() {

}}

PROGRAM1.CS::::

namespace ConsoleApplication11{

class program { static void Main(string[] args) { employee obj = new employee(); obj.display(); Console.ReadKey(); } }}

RAJI.CS::::

namespace ConsoleApplication11{ partial class employee

Page 6

Page 7: Net Programs

NET PROGRAMS.txt { int eno, sal; string ename, job; public employee() { Console.WriteLine("enter emp deatails:"); Console.WriteLine("enter emp number:"); eno = int.Parse(Console.ReadLine()); Console.WriteLine("enter ename:"); ename = Console.ReadLine(); Console.WriteLine("enter sal"); sal = int.Parse(Console.ReadLine()); Console.WriteLine("enter job:"); job = Console.ReadLine(); } } }

*********************************************************************PROGRAM.CS:::::

namespace ConsoleApplication12{ public class employee { public int id { get; set; } public string ename { get; set; } public int salary { get; set; } public int experience { get; set; } public static void promoteemployee(List<employee> obj) { foreach (employee e in obj) { if (e.experience > 4) { Console.WriteLine(e.ename + " " + "promoted"); } } }

static void Main(string[] args) { employee obj = new employee() { id = 1001, ename = "uday", salary = 5000, experience = 4 }; employee obj2=new employee() { id=1002, } }}************************************************************************PROGRAM.CS:::

Page 7

Page 8: Net Programs

NET PROGRAMS.txtnamespace exceptionwitharray

{ class Program { static void Main(string[] args) { try { string[] cities={"hyd","pune","bang","ap"}; Console.WriteLine(cities[3]); } catch(Exception ex) { Console.WriteLine(ex.Message); } finally { Console.WriteLine("this is finally block"); } Console.ReadKey();

} }}**************************************************************************

WINDOWS APP EXAMPLE@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

CREATING RUNTIME CONTROL----------------------------------------

FORM1.CS:::::

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

private void button1_Click(object sender, EventArgs e) { TextBox t1 = new TextBox(); t1.Location = new Point(230, 120); t1.BackColor = Color.Red; this.Controls.Add(t1); } }}

*******************************************************************CREATING RUNTIME CONTROL EXAMPLES-----------------------------------------

FORM1.CS:::

namespace creating_runtimecontrolexPage 8

Page 9: Net Programs

NET PROGRAMS.txt{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { Button b1 = new Button(); b1.Location = new Point(230, 120); b1.BackColor = Color.Yellow; b1.Text = "submit"; b1.Click += new EventHandler(b1_click); this.Controls.Add(b1); } private void b1_click(object sender, EventArgs e) { MessageBox.Show("welcome");

} }}*************************************************************************EXTENDER CONTROL-------------------------

FORM1.CS:::

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

private void button1_Click(object sender, EventArgs e) { if (int.Parse(textBox1.Text) > 10) { errorProvider1.SetError(textBox1," "); } else { errorProvider1.SetError(textBox1,"value must be above 10"); }

} }}**************************************************************

FILE STRING CLASSES--------------------------------------------

PROGRAM.CS:::

namespace filestringclasses{ class Program

Page 9

Page 10: Net Programs

NET PROGRAMS.txt { static void Main(string[] args) { Console.WriteLine("enter your file name:"); string filepath = Console.ReadLine(); FileInfo obj = new FileInfo(); if (obj.exists) { Console.WriteLine("name:" + obj.name); Console.WriteLine("fullpath:" + obj.fullname); Console.WriteLine("extension:" + obj.extention); Console.WriteLine("directory:" + obj.directoryname); Console.WriteLine("length:" + obj.length + "bytes"); Console.WriteLine("created on:" + obj.creationtime); Console.WriteLine("lastaccessed on:" + obj.lastacesstime); Console.WriteLine("last modified on:" + obj.lastwritetime); } else { Console.WriteLine("file does not exist"); } Console.ReadKey(); } }}***********************************************************************FONT DAILOGBOX-------------------------------------

FORM1.CS:::

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

private void button1_Click(object sender, EventArgs e) { fontDialog1.ShowDialog(); foreach (Control i in this.Controls) { i.Font = fontDialog1.Font; } }

private void button2_Click(object sender, EventArgs e) { colorDialog1.ShowDialog(); foreach (Control i in this.Controls) { if (i is TextBox) {

i.BackColor = colorDialog1.Color; }

Page 10

Page 11: Net Programs

NET PROGRAMS.txt } }

*************************************************************************GENERIC CLASSES---------------------------------------

PROGRAM.CS:::

namespace genericclasses{ public class sample { public static void m1<T>(T a) { Console.WriteLine("the value of a is:" + a); } } class Program { static void Main(string[] args) { sample.m1<int>(100); sample.m1<string>("welcome"); sample.m1<double>(23.5555); Console.ReadKey();

} }}***************************************************************LAMBDA EXPRESIONS----------------------------------------------

PROGRAM.CS::::

namespace lambdaexpressions{ class Program { static void Main(string[] args) { List<int> numbers = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int i = numbers.Count(x); Console.WriteLine("count of greater than 4 is:"+i); Console.ReadKey(); }

public static Func<int, bool> x { get; set; } }}***************************************************************LINQ TO INSERT,DELETE,UPDATE---------------------------------------

FORM1.CS:::

namespace linqtoinsert_delete_update{ public partial class Form1 : Form { public Form1() {

Page 11

Page 12: Net Programs

NET PROGRAMS.txt InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { sample2DataContext obj = new sample2DataContext(); emp e1 = new emp(); e1.eno = textBox1.Text; e1.ename =textBox2.Text; e1.sal = textBox3.Text; obj.emps.InsertOnSubmit(e1); obj.SubmitChanges(); MessageBox.Show("record added"); }

private void button2_Click(object sender, EventArgs e) { sample2DataContext obj = new sample2DataContext(); var x = from n in obj.emps where n.eno = textBox1.Text select n; if(x.Count==0) { MessageBox.Show("no such record"); } else { foreach(var rec in x) { rec.ename=textBox2.Text; rec.sal=int.Parse(textBox3.Text); obj.SubmitChanges(); MessageBox.Show("record added"); } } }

private void button3_Click(object sender, EventArgs e) { sample2DataContext obj = new sample2DataContext(); var x = from n in obj.emps where n.eno = int.Parse(textBox1.Text) select n; if (x.Count == 0) { MessageBox.Show("no such record"); } else { foreach (var rec in x) { obj.emps.DeleteOnSubmit(rec); obj.SubmitChanges(); MessageBox.Show("record deleted"); } }

}

}

Page 12

Page 13: Net Programs

NET PROGRAMS.txt}*************************************************************************LISTBOX WITH OUT DUPLICATE VALUES-------------------------------------------

FORM1.CS:::

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

private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == " ") { MessageBox.Show("enter any item"); return; } for (int i = 0; i < listBox1.Items.count; i++) { if (textBox1.Text == listBox1.Items[i].ToString) { MessageBox.Show("duplicates are not allowed"); textBox1.Focus(); return; } } listBox1.Items.Add(textBox1.Text); textBox1.Clear(); textBox1.Focus(); }

}}******************************************************************************LOGIN FORM--------------------LOGIN.CS:::

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

private void button1_Click(object sender, EventArgs e) { logout obj = new logout(); obj.label1.Text = "welcome to" + textBox1.Text; obj.Show(); this.Hide(); } }}

Page 13

Page 14: Net Programs

NET PROGRAMS.txt

LOGOUT:::

namespace Login{ public partial class logout : Form { public logout() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { Login obj = new Login(); obj.Show(); this.Hide(); } }}****************************************************************************MULTI DOCUMENT INTERFACE-------------------------------------

FORM1.CS:::

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

private void form2ToolStripMenuItem_Click(object sender, EventArgs e) { Form2 obj = new Form2(); obj.MdiParent = this; obj.Show(); } }}******************************************************************MENUS AND TOOLBOX-----------------------------------FORM1.CS:::

namespace menus_ and_ toolbox{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void imageToolStripMenuItem_Click(object sender, EventArgs e) {

Page 14

Page 15: Net Programs

NET PROGRAMS.txt this.BackgroundImage=Image.FromFile("D:\raji\menus and toolbox\menus andtoolbox\images\Lighthouse.jpg"); }

private void clearToolStripMenuItem_Click(object sender, EventArgs e) { this.BackgroundImage=null; }

private void form2ToolStripMenuItem_Click(object sender, EventArgs e) { Form2 obj=new Form2(); obj.Show(); }

private void form3ToolStripMenuItem_Click(object sender, EventArgs e) { Form3 obj=new Form3(); obj.Show(); }

private void existToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit(); } }}*************************************************************************************************************MULTITHREADING-------------------------------------

FORM1.CS:::

using System.Threading;

namespace multithreading{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } void f1() { for (int i = 1; i <= 100; i++) { listBox1.Items.Add("list 1:" + i); } } Thread th1, th2;

private void button1_Click(object sender, EventArgs e) {

Page 15

Page 16: Net Programs

NET PROGRAMS.txt th1 = new Thread(f1); th2 = new Thread(f1); th1.Priority = ThreadPriority.Highest; th2.Priority = ThreadPriority.Lowest; th1.Start(); th2.Start(); }

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

namespace WindowsFormsApplication31{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } public delegate double calculatearea(int a); public double calculate(int r) { return 3.14 * r * r; }

private void button1_Click(object sender, EventArgs e) { calculatearea obj=new calculatearea(); MessageBox.Show(obj(12).ToString());

} }}

*********************************************************************************************NOTIFY CONTROL--------------------------------FORM1.CS:::

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

private void Form1_Load(object sender, EventArgs e) { notifyIcon1.ShowBalloonTip(1000); }

Page 16

Page 17: Net Programs

NET PROGRAMS.txt }}********************************************************************************OPEN FILE DAILOG BOX------------------------------------------FORM1.CS:::

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

private void Form1_Load(object sender, EventArgs e) {

}

private void button1_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); pictureBox1.Image = Image.FromFile(openFileDialog1.FileName); } }}*********************************************************************************************

using System.Data.SqlClient;

namespace register{ public partial class Form1 : Form { SqlConnection con = new SqlConnection(); public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { con.ConnectionString = @"data source=ADMIN-PC;initial catalog=howell;integrated security=true"; con.Open(); SqlCommand cm = new SqlCommand("insert into register values('"+textBox1.Text+"','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')", con); cm.ExecuteNonQuery(); MessageBox.Show("inserted successfully","success"); con.Close(); }

private void button2_Click(object sender, EventArgs e) { if (textBox5.Text == "admin" && textBox6.Text == "ahbi") { MessageBox.Show("login successfully");

Page 17

Page 18: Net Programs

NET PROGRAMS.txt } else { MessageBox.Show("login failed"); } } } }

**************************************************************************************SAVE FILE DAILOG--------------------------FORM1.CS:::

using System.IO;

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

private void button1_Click(object sender, EventArgs e) { saveFileDialog1.ShowDialog(); textBox1.Text = saveFileDialog1.FileName; }

private void button2_Click(object sender, EventArgs e) { string filename = textBox1.Text; fileinfo obj = new fileinfo(filename); if (!obj.exists) { StreamWriter sw = new StreamWriter(filename); sw.write(textBox2.Text); sw.close(); MessageBox.Show("file saved successfully"); } else { MessageBox.Show("the file is already existed"); }

} }}******************************************************************************TAB CONTROLS----------------------FORM1.CS:::

namespace tab_controls{ public partial class Form1 : Form { public Form1() {

Page 18

Page 19: Net Programs

NET PROGRAMS.txt InitializeComponent(); }

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

private void tabPage1_Click(object sender, EventArgs e) {

}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { tabControl1.SelectedTab = tabPage1; tabControl1.SelectedTab = tabPage2; tabControl1.SelectedTab = tabPage3; tabControl1.SelectedTab = tabPage4;

tabControl1.SelectedTab.BackColor = Color.Red; tabPage1.BackColor = Color.Green; tabPage2.BackColor = Color.Yellow; tabPage3.BackColor = Color.Blue; tabPage4.BackColor = Color.Pink; tabPage5.BackColor = Color.Purple; }

private void tabPage2_Click(object sender, EventArgs e) { if (uname == "sunsoft" && password == "solution") { MessageBox.Show("login successfully"); } else { MessageBox.Show("login failed"); } }

public string uname { get; set; }

public string password { get; set; } }}

***********************************************************************************TAB CONTROLS-----------------------------FORM1.CS::::

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

Page 19

Page 20: Net Programs

NET PROGRAMS.txt }

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { tabControl1.SelectedTab = tabPage4; } }}*****************************************************************************THREAD EXAMPLE------------------------------FORM1.CS:::

using System.Threading;

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

private void Form1_Load(object sender, EventArgs e) { Form1.CheckForIllegalCrossThreadCalls = false; } void m1() { for (int i = 0; i <= 100; i++) { listBox1.Items.Add(i); Thread.Sleep(1000); } } Thread th;

private void button1_Click(object sender, EventArgs e) { th = new Thread(m1); th.Start(); }

private void button2_Click(object sender, EventArgs e) { th.Suspend(); }

private void button3_Click(object sender, EventArgs e) { th.Resume(); }

private void button4_Click(object sender, EventArgs e) { th.Abort();

Page 20

Page 21: Net Programs

NET PROGRAMS.txt } }}**********************************************************************TIMER CONTROL EX--------------------------FORM1.CS::::

namespace timercontrolex{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } int n = 0; private void timer1_Tick(object sender, EventArgs e) { n = n + 1; switch (n) { case 1: this.BackColor = Color.Red; break; case 2: this.BackColor = Color.Blue; break; case 3: this.BackColor = Color.Green; break; case 4: this.BackColor = Color.Yellow; break; default: n = 0; break; } }

}}***********************************************************************TIMER CONTROL-------------------------------FORM1.CS:::

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

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

Page 21

Page 22: Net Programs

NET PROGRAMS.txt private void Form1_Load(object sender, EventArgs e) { label1.Text = DateTime.Now.ToLongTimeString(); }

}}*************************************************************************TRACKBAR----------------------------

FORM1.CS:::

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

private void trackBar1_Scroll(object sender, EventArgs e) { int n = trackBar1.Value; label1.Font = new Font("tahoma", n); } }}**************************************************************************

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

private void button1_MouseEnter(object sender, EventArgs e) { button1.BackColor = Color.Red; button1.ForeColor=Color.Yellow; }

private void button1_MouseLeave(object sender, EventArgs e) { button1.BackColor = Color.Blue; button1.ForeColor = Color.Brown; } }}*************************************************************************

namespace WindowsFormsApplication4{ public partial class Form1 : Form {

Page 22

Page 23: Net Programs

NET PROGRAMS.txt public Form1() { InitializeComponent(); }

private void Form1_Load(object sender, EventArgs e) {

} private void btnblue_Click(object sender, EventArgs e) { textBox2.BackColor = Color.Blue; }

private void btngreen_Click(object sender, EventArgs e) { textBox3.BackColor = Color.Green; }

private void btnred_Click(object sender, EventArgs e) { textBox1.BackColor = Color.Red; }

}}*********************************************************************

namespace WindowsFormsApplication6{ public partial class LOGINPAGE : Form { public LOGINPAGE() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { if (txtusername.Text == "bhagya" && txtpassword.Text == "xyz") { MessageBox.Show("login successfully"); } else { MessageBox.Show("login failed"); } }

}}***********************************************************************

namespace WindowsFormsApplication7{ public partial class Form1 : Form { public Form1() {

Page 23

Page 24: Net Programs

NET PROGRAMS.txt InitializeComponent(); }

private void button1_MouseEnter(object sender, EventArgs e) { button1.BackColor = Color.Red; button1.ForeColor = Color.Blue; }

private void button1_MouseLeave(object sender, EventArgs e) { button1.BackColor = Color.Yellow; button1.ForeColor = Color.Orange; }

}}*************************************************************************CLASS1.CS:::

namespace WindowsFormsApplication8{ class Class1 { public int add(int a, int b) { return a + b; } public int mul(int a, int b) { return a * b; } }}

FORM1.CS:::

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

private void button1_Click(object sender, EventArgs e) { Class1 obj = new Class1(); int result = obj.add(int.Parse(textBox1.Text), int.Parse(textBox2.Text)); textBox3.Text = result.ToString();

}

private void button2_Click(object sender, EventArgs e) { Class1 obj = new Class1(); int result = obj.mul(int.Parse(textBox1.Text), int.Parse(textBox2.Text)); textBox3.Text = result.ToString(); }

Page 24

Page 25: Net Programs

NET PROGRAMS.txt }}****************************************************************************************using System.Data;using System.Data.SqlClient;

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

private void button1_Click(object sender, EventArgs e) { SqlConnection cn = new SqlConnection("Data Source=ADMIN-PC\SQLEXPRESS;Initial Catalog=sunsoft;Integrated Security=True"); cn.Open(); MessageBox.Show("connection established");

} }}******************************************************************************using System.Data.SqlClient;namespace WindowsFormsApplication10{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { SqlConnection cn=new SqlConnection("

}

private void Form1_Load(object sender, EventArgs e) {// TODO: This line of code loads data into the 'bhagyaDataSet.dept' table. You can move, or remove it, as needed.this.deptTableAdapter.Fill(this.bhagyaDataSet.dept); }

private void button1_Click_1(object sender, EventArgs e) { } }}******************************************************************************using System.Data.SqlClient;

namespace WindowsFormsApplication11{ public partial class Form1 : Form

Page 25

Page 26: Net Programs

NET PROGRAMS.txt { public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { SqlConnection cn=new SqlConnection("Initial Catalog=bhagya;Integrated Security=true;server=ADMIN-PC\SQLEXPRESS"); cn.Open(); SqlCommand cmd=new SqlCommand("insert into empdetails values(666,'balaji',8000)",cn); int i=cmd.ExecuteNonQuery(); MessageBox.Show(i+ "record added"); } }}**************************************************************************using System.Windows.Forms;using System.Data.OleDb;

namespace WindowsFormsApplication14{ public partial class Form1 : Form { OleDbConnection con = new OleDbConnection(); public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { con.ConnectionString = @"Integrated Security=true;server=ADMIN-PC\SQLEXPRESS;Provider= OleDb"; con.Open(); MessageBox.Show("connection established"); } }}*****************************************************************************using System.Data.SqlClient;

namespace WindowsFormsApplication15{ public partial class Form1 : Form { SqlConnection cn = new SqlConnection(); public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { cn.ConnectionString = @"Initial Catalog=bhagya;integrated security=true;server=ADMIN-PC"; cn.Open(); SqlDataReader dr = new SqlDataReader("select*from emp", cn);

dr.execue DataSet ds=new DataSet();

Page 26

Page 27: Net Programs

NET PROGRAMS.txt

dataGridView1.DataSource = ds.Tables["emp"]; }

}}*******************************************************************************using System.Data.SqlClient;

namespace WindowsFormsApplication20{ public partial class Form1 : Form { SqlConnection cn = new SqlConnection(); public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { cn.ConnectionString = @"Initial Catalog=bhagya;Integrated Security=true;server=ADMIN-PC"; cn.Open(); SqlCommand cmd = new SqlCommand("insert into empdetails values("+textBox1.Text+",'"+textBox2.Text+"',"+textBox3.Text+",'"textBox4.Text+"')",cn); int i=cmd.ExecuteNonQuery(); MessageBox.Show(i+"record added");

}

}}**************************************************************************using System.Data.SqlClient;

namespace WindowsFormsApplication21{ public partial class Form1 : Form { SqlConnection cn = new SqlConnection(); public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { cn.ConnectionString = @"Initial Catalog=bhagya;Integrated Security=true;Server=ADMIN-PC"; SqlDataAdapter da = new SqlDataAdapter("select*from empdetailes", cn); DataSet ds = new DataSet(); da.Fill(ds, "empdetailes"); dataGridView1.DataSource = ds.Tables["empdetailes"];

} }}

Page 27

Page 28: Net Programs

NET PROGRAMS.txt******************************************************************sing System.Data.SqlClient;

namespace WindowsFormsApplication22{ public partial class Form1 : Form { SqlConnection cn = new SqlConnection(); public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { cn.ConnectionString = @"Initial Catalog=bhagya;Integrated Security=true;Server=ADMIN-PC"; cn.Open(); SqlDataAdapter da1 = new SqlDataAdapter("select*from empdetailes", cn); SqlDataAdapter da2 = new SqlDataAdapter("select*from deptdetailes", cn); DataSet ds = new DataSet(); da1.Fill(ds, "empdetailes"); da2.Fill(ds, "deptdetailes"); dataGridView1.DataSource = ds.Tables["empdetailes"]; dataGridView1.DataSource = ds.Tables["deptdetailes"];

} }}************************************************************** PROJECT CODING BY USING WINDOWS@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@FORM1.CS::::

using System.Data.SqlClient;namespace WindowsFormsApplication23{ public partial class Form1 : Form { SqlConnection con = new SqlConnection();

public Form1() { InitializeComponent(); } private void textBox1_TextChanged(object sender, EventArgs e) {

}

private void textBox2_TextChanged(object sender, EventArgs e) {

}

private void textBox4_TextChanged(object sender, EventArgs e) {

}

private void label2_Click(object sender, EventArgs e) {

Page 28

Page 29: Net Programs

NET PROGRAMS.txt

}

private void label3_Click(object sender, EventArgs e) {

}

private void Form1_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'bhagyaDataSet1.reg' table. You can move, or remove it, as needed. this.regTableAdapter.Fill(this.bhagyaDataSet1.reg);

}

private void button1_Click(object sender, EventArgs e) { con.ConnectionString = @"data source=ADMIN-PC;initial catalog=bhagya;integrated security=true"; con.Open(); if (MessageBox.Show("sure to insert your data", "insert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { SqlCommand cmd = new SqlCommand("insert into reg values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')", con); cmd.ExecuteNonQuery(); if (MessageBox.Show("inserted successfully", "success", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK) { // TODO: This line of code loads data into the 'bhagyaDataSet1.reg' table. You can move, or remove it, as needed. this.regTableAdapter.Fill(this.bhagyaDataSet1.reg); } } else { MessageBox.Show("cannot insert your data","cancel"); } con.Close(); }

private void button2_Click(object sender, EventArgs e) { if ((textBox5.Text == "admin") && (textBox6.Text == "password")) { view v = new view(); this.Hide(); v.Show();

} }

private void button3_Click(object sender, EventArgs e) { con.ConnectionString = @"data source=ADMIN-PC;initial catalog=bhagya;integrated security=true"; con.Open(); if (MessageBox.Show("sure to DELETE your data", "insert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

Page 29

Page 30: Net Programs

NET PROGRAMS.txt { SqlCommand c = new SqlCommand("delete from reg where name='"+textBox7.Text+"'",con); c.ExecuteNonQuery(); if (MessageBox.Show("deleted successfully", "success", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK) { // TODO: This line of code loads data into the 'bhagyaDataSet1.reg' table. You can move, or remove it, as needed. this.regTableAdapter.Fill(this.bhagyaDataSet1.reg); } } else { MessageBox.Show("cannot delete your data", "cancel"); } con.Close(); } }}

SHOW.CS:::

using System.Data.SqlClient;

namespace WindowsFormsApplication23{ public partial class show : Form { SqlConnection con = new SqlConnection(); public show() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { con.ConnectionString = @"data source=ADMIN-PC;initial catalog=bhagya;integrated security=true"; con.Open(); SqlCommand cmd = new SqlCommand("select*from reg", con); cmd.ExecuteNonQuery(); } }}

VIEW.CS:::

namespace WindowsFormsApplication23{ public partial class view : Form { public view() { InitializeComponent(); }

private void view_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'bhagyaDataSet2.reg'

Page 30

Page 31: Net Programs

NET PROGRAMS.txttable. You can move, or remove it, as needed. this.regTableAdapter.Fill(this.bhagyaDataSet2.reg); // TODO: This line of code loads data into the 'bhagyaDataSet.empdetailes' table. You can move, or remove it, as needed. this.empdetailesTableAdapter.Fill(this.bhagyaDataSet.empdetailes); } }}

*****************************************************************************************DISCONNECTED ORIENTED ARCHITECTURE-----------------------------------------------

using System.Data.SqlClient;

namespace WindowsFormsApplication24{ public partial class Form1 : Form { SqlConnection cn = new SqlConnection(); public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { cn.ConnectionString = @"Initial Catalog=bhagya;integrated security=true;server=ADMIN-PC"; SqlDataAdapter da = new SqlDataAdapter ("select*from empdetailes", cn); DataSet ds = new DataSet(); da.Fill(ds, "empdetailes"); dataGridView1.DataSource = ds.Tables["empdetailes"];

}

private void Form1_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'bhagyaDataSet.emp' table. You can move, or remove it, as needed. this.empTableAdapter.Fill(this.bhagyaDataSet.emp);

} }}***********************************************************************************************

using System.Data.SqlClient;

namespace WindowsFormsApplication25{ public partial class Form1 : Form { SqlConnection cn=new SqlConnection(); SqlDataAdapter da;

Page 31

Page 32: Net Programs

NET PROGRAMS.txt DataSet ds; int i = 0; public Form1() { InitializeComponent(); }

private void Form1_Load(object sender, EventArgs e) { cn.ConnectionString = @"Initial Catalog=bhagya;integrated security=true;server=ADMIN-PC"; da = new SqlDataAdapter("select*from empdetailes", cn); ds = new DataSet();

da.Fill(ds, "empdetailes"); } void getdata() { textBox1.Text = ds.Tables[0].Rows[i][0].ToString(); textBox2.Text = ds.Tables[0].Rows[i][1].ToString(); textBox3.Text = ds.Tables[0].Rows[i][2].ToString(); textBox4.Text = ds.Tables[0].Rows[i][3].ToString(); }

private void button1_Click(object sender, EventArgs e) { i=0; getdata(); }

private void button2_Click(object sender, EventArgs e) { i=i+1; getdata();

}

private void button3_Click(object sender, EventArgs e) { i=i-1; getdata(); }

private void button4_Click(object sender, EventArgs e) { i=ds.Tables[0].Rows.Count-1; getdata();

}

} }

************************************************************************************* PROJECT PROGRAM CODING@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@LOGINFORM.CS:::

Page 32

Page 33: Net Programs

NET PROGRAMS.txt

namespace WindowsFormsApplication26{ public partial class Loginform : Form { public Loginform() { InitializeComponent(); }

private void button2_Click(object sender, EventArgs e) { if ((textBox5.Text == "admin") && (textBox6.Text == "password")) { view v = new view(); this.Hide(); v.Show();

} } }}

CANDIDATELIST.CS:::

using System.Data.SqlClient;

namespace WindowsFormsApplication26{ public partial class candidatelist : Form { SqlConnection con = new SqlConnection(); public candidatelist() { InitializeComponent(); }

private void button2_Click(object sender, EventArgs e) { con.ConnectionString = @"data source=ADMIN-PC;initial catalog=bhagya;integrated security=true"; con.Open(); if (MessageBox.Show("sure to DELETE your data", "insert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { SqlCommand c = new SqlCommand("delete from giitcandidatelist where Candidate Name='" + textBox1.Text + "'", con); c.ExecuteNonQuery(); if (MessageBox.Show("deleted successfully", "success", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK) { // TODO: This line of code loads data into the 'bhagyaDataSet4.giitcandidatelist' table. You can move, or remove it, as needed. this.giitcandidatelistTableAdapter1.Fill(this.bhagyaDataSet4.giitcandidatelist); } } else { MessageBox.Show("cannot delete your data", "cancel");

Page 33

Page 34: Net Programs

NET PROGRAMS.txt } con.Close();

candidatelist can = new candidatelist(); this.Hide(); can.Show(); }

private void candidatelist_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'bhagyaDataSet4.giitcandidatelist' table. You can move, or remove it, as needed. this.giitcandidatelistTableAdapter1.Fill(this.bhagyaDataSet4.giitcandidatelist);

}

private void label1_Click(object sender, EventArgs e) { sunsoft ss = new sunsoft(); this.Hide(); ss.Show(); }

}}

REGISTRATION.CS:::

using System.Data.SqlClient;

namespace WindowsFormsApplication26{ public partial class Rrgistration_form : Form { SqlConnection con = new SqlConnection(); public Rrgistration_form() { InitializeComponent(); }

private void textBox1_TextChanged(object sender, EventArgs e) {

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

}

private void textBox3_TextChanged(object sender, EventArgs e) {

}

private void textBox4_TextChanged(object sender, EventArgs e) {

}

private void Rrgistration_form_Load(object sender, EventArgs e)Page 34

Page 35: Net Programs

NET PROGRAMS.txt { // TODO: This line of code loads data into the 'bhagyaDataSet2.giitcandidatelist' table. You can move, or remove it, as needed. this.giitcandidatelistTableAdapter2.Fill(this.bhagyaDataSet2.giitcandidatelist); } private void button1_Click(object sender, EventArgs e) { con.ConnectionString = @"data source=ADMIN-PC;initial catalog=bhagya;integrated security=true"; con.Open(); if (MessageBox.Show("sure to insert your data", "insert", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { SqlCommand cmd = new SqlCommand("insert into giitcandidatelist values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "'," + textBox5.Text + ",'" + textBox6.Text + "'," + textBox7.Text +",'" + textBox8.Text + "','" + textBox9 + "')", con); cmd.ExecuteNonQuery(); candidatelist obj = new candidatelist(); this.Hide(); obj.Show(); MessageBox.Show("registration successfully completed"); } else { MessageBox.Show("cannot insert your data", "cancel"); } }

private void button3_Click(object sender, EventArgs e) { view v = new view(); this.Hide(); v.Show(); }

private void button4_Click(object sender, EventArgs e) { candidatelist cl = new candidatelist(); this.Hide(); cl.Show(); }

private void button5_Click(object sender, EventArgs e) { sunsoft ss = new sunsoft(); this.Hide(); ss.Show(); }

private void button6_Click(object sender, EventArgs e) { sunlist sl = new sunlist(); this.Hide(); sl.Show(); }

Page 35

Page 36: Net Programs

NET PROGRAMS.txt}}

SUNLIST.CS:::

using System.Data.SqlClient;

namespace WindowsFormsApplication26{ public partial class sunlist : Form { SqlConnection conn = new SqlConnection(); public sunlist() { InitializeComponent(); }

private void sunlist_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'bhagyaDataSet5.sunsoftsolutions' table. You can move, or remove it, as needed. this.sunsoftsolutionsTableAdapter.Fill(this.bhagyaDataSet5.sunsoftsolutions);

}

private void sunsoftlist_Click_1(object sender, EventArgs e) {

conn.ConnectionString = @"data source=ADMIN-PC;initial catalog=bhagya;integrated security=true";

SqlDataAdapter da = new SqlDataAdapter("select*from sunsoftsolutions", conn); DataSet ds = new DataSet(); da.Fill(ds, "sunsoftsolutions");

dataGridView1.DataSource = ds.Tables["sunsoftsolutions"]; } }}

SUNSOFT.CS:::

namespace WindowsFormsApplication26{ public partial class sunsoft : Form { public sunsoft() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { sunlist sl = new sunlist(); this.Hide(); sl.Show();

Page 36

Page 37: Net Programs

NET PROGRAMS.txt } }}

VIEW.CS:::

namespace WindowsFormsApplication26{ public partial class view : Form { public view() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { Rrgistration_form r = new Rrgistration_form(); this.Hide(); r.Show(); }}}

********************************************************************************************************

using System.Data.SqlClient;

namespace WindowsFormsApplication27{ public partial class Form1 : Form { SqlConnection cn = new SqlConnection(); SqlDataAdapter da; DataSet ds = new DataSet("mydataset"); public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { da = new SqlDataAdapter("select *from empdetailes", cn); da.Fill(ds, "empdetailes"); dataGridView1.DataSource = ds.Tables["empdetailes"];

}

private void button2_Click(object sender, EventArgs e) { ds.WriteXml(textBox1.Text); MessageBox.Show("serialization process successfully"); }

private void button3_Click(object sender, EventArgs e)Page 37

Page 38: Net Programs

NET PROGRAMS.txt { ds.ReadXml(textBox1.Text); dataGridView1.DataSource = ds.Tables[0]; }

}}******************************************************************************using System.Xml;

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

XmlTextWriter xmlw;

private void button2_Click_1(object sender, EventArgs e) { openFileDialog1.ShowDialog(); string FileName = openFileDialog1.FileName; textBox1.Text = FileName; xmlw = new XmlTextWriter(textBox1.Text, System.Text.Encoding.UTF8); xmlw.WriteStartDocument(); xmlw.WriteStartElement("rootdata"); }

private void button3_Click_1(object sender, EventArgs e) { xmlw.WriteStartElement("products");

xmlw.WriteElementString("pno", textBox2.Text); xmlw.WriteElementString("pname", textBox3.Text); xmlw.WriteElementString("price", textBox4.Text); xmlw.WriteElementString("quantity", textBox5.Text); xmlw.WriteEndElement(); MessageBox.Show("product addede");

}

private void button4_Click(object sender, EventArgs e) { xmlw.WriteEndElement(); xmlw.WriteEndDocument(); xmlw.Close(); MessageBox.Show("file closed successfully"); } }}*****************************************************************************************

namespace WindowsFormsApplication29{

Page 38

Page 39: Net Programs

NET PROGRAMS.txt public partial class Form1 : Form { public Form1() { InitializeComponent(); } List<int> listobj = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; private void button1_Click(object sender, EventArgs e) { var x = from n in listobj where n > 5 select n; foreach(var num in x) { listBox1.Items.Add(num);

} }}*********************************************************************************************using System.Xml;

namespace WindowsFormsApplication30{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } XmlDocument xdoc = new XmlDocument(); private void button2_Click(object sender, EventArgs e) { xdoc.Load(textBox1.Text); MessageBox.Show("file loaded successfully"); }

private void button1_Click(object sender, EventArgs e) { XmlElement product = xdoc.CreateElement("product"); XmlElement pno = xdoc.CreateElement("pno"); pno.InnerText = textBox2.Text; XmlElement pname = xdoc.CreateElement("pname"); pname.InnerText = textBox3.Text; XmlElement price = xdoc.CreateElement("price"); price.InnerText = textBox4.Text; XmlElement quantity = xdoc.CreateElement("quantity"); quantity.InnerText = textBox5.Text; product.AppendChild(pno); product.AppendChild(pname); product.AppendChild(price); product.AppendChild(quantity); xdoc.DocumentElement.AppendChild(product); XmlTextWriter xmlw = new XmlTextWriter(textBox1.Text, System.Text.Encoding.UTF8); xdoc.WriteContentTo(xmlw); xmlw.Close(); MessageBox.Show("file saved to:" + textBox1.Text);

} }}

Page 39

Page 40: Net Programs

NET PROGRAMS.txt***********************************************************************************************namespace WindowsFormsApplication33{ class calculatearea { private int p;

public calculatearea(int p) { // TODO: Complete member initialization this.p = p; } }}*************************************************************************************************namespace WindowsFormsApplication33{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } public delegate double calculatearea(int a); public double calculate(int r) { return 3.14 * r * r; } private void button1_Click(object sender, EventArgs e) { calculatearea obj = new calculatearea(0); MessageBox.Show(obj(12).ToString()); } }}******************************************************************************************namespace WindowsFormsApplication34{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } public delegate int callmethods(int a, int b); public int add(int a,int b) { return(a+b); } public int mul(int a,int b) { return a*b; } callmethods obj;

Page 40

Page 41: Net Programs

NET PROGRAMS.txt private void button1_Click(object sender, EventArgs e) { obj=new callmethods(add); obj=new callmethods(mul); int c=obj(10,20); MessageBox.Show(c.ToString()); } }}******************************************************************************************namespace WindowsFormsApplication35{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } public delegate void call(); public class sample { public void m1() { MessageBox.Show("first"); } public void m2() { MessageBox.Show("second"); } }

private void button1_Click(object sender, EventArgs e) { sample s = new sample(); call c1 = new call(s.m1); call c2 = new call(s.m2); call c3 = c1 + c2; c3(); } }}******************************************************************************************BALUSERS:::

namespace WindowsFormsApplication36{ class balusers { int eno, sal;

public int Sal { get { return sal; } set { sal = value; } }

public int Eno { get { return eno; } set { eno = value; }

Page 41

Page 42: Net Programs

NET PROGRAMS.txt } string ename;

public string Ename { get { return ename; } set { ename = value; } } public void insertdata() { Dalusers.getmanipulations(eno, ename, sal); }

}}

DALUSERS:::

using System.Data;using System.Data.SqlClient;using System.Configuration;

namespace WindowsFormsApplication36{ class Dalusers { public static void getmanipulations(int a, string b, int c) { SqlConnection cn = new SqlConnection(ConfigurationSettings.AppSettings["conn"]); SqlCommand cmd = new SqlCommand("spinsertemp11", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@eno", a); cmd.Parameters.AddWithValue("@ename", b); cmd.Parameters.AddWithValue("@sal", c); cmd.ExecuteNonQuery(); } }} FORM1.CS::: using System.Data.SqlClient;using System.Configuration;

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

private void button1_Click(object sender, EventArgs e) { balusers obj = new balusers(); obj.Eno = int.Parse(textBox1.Text); obj.Ename = textBox2.Text; obj.Sal = int.Parse(textBox3.Text);

Page 42

Page 43: Net Programs

NET PROGRAMS.txt obj.insertdata(); MessageBox.Show("record added"); }

}}

***************************************************************

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

private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == " ") { MessageBox.Show("enter any item"); return; } listBox1.Items.Add(textBox1.Text); textBox1.Clear(); textBox1.Focus(); } }}

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

private void button1_Click(object sender, EventArgs e) { folderBrowserDialog1.ShowDialog(); string folderpath = folderBrowserDialog1.SelectedPath; label1.Text = "selected folder" + folderpath; directory } }}************************************************************************ using System.Data.SqlClient;

namespace WindowsFormsApplication41{ public partial class Form1 : Form { public Form1() {

Page 43

Page 44: Net Programs

NET PROGRAMS.txt InitializeComponent(); } SqlConnection cn = new SqlConnection(); private void button1_Click(object sender, EventArgs e) { cn.ConnectionString = @"Initial Catalog=bhagya;Integrated Security=true;server=ADMIN-PC\SQLEXPRESS"; cn.Open(); MessageBox.Show("connection established");

} }}*******************************************************************************ss

Page 44