Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. PROGRAM TO ACCEPT STUDENTS REGNO,NAME AND MARKS AND DISPLAY THE REQUIRED DETAILS OF THE STUDENT
- using System;
- using System.Collections.Generic;
- using System.Collections;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] rno = new int[20];
- int i = 0, hm = 0, pos = 0, ch = 0, cnt = 0;
- ArrayList name = new ArrayList();
- int[] m1 = new int[20];
- int[] m2 = new int[20];
- int[] m3 = new int[20];
- int[] total = new int[20];
- char ans;
- do
- {
- Console.Clear();
- cnt = cnt + 1;
- Console.WriteLine("ENTER REGNO AND NAME");
- rno[i] = int.Parse(Console.ReadLine());
- name.Add(Console.ReadLine());
- Console.WriteLine("ENTER THREE SUB MARKS");
- m1[i] = int.Parse(Console.ReadLine());
- m2[i] = int.Parse(Console.ReadLine());
- m3[i] = int.Parse(Console.ReadLine());
- total[i] = m1[i] + m2[i] + m3[i];
- if (total[i] > hm)
- {
- hm = total[i];
- pos = i;
- }
- Console.WriteLine("DO YOU WANT TO CONTINUE ? (Y/N)");
- ans = char.Parse(Console.ReadLine());
- i = i + 1;
- }
- while (ans == 'y');
- while (ch != 4)
- {
- Console.Clear();
- Console.WriteLine("MENU");
- Console.WriteLine("1.DISPLAY ALL STUDENTS DETAILS");
- Console.WriteLine("2.DISPLAY SYUDENTS WHO OBTAINED HIGHEST MARKS");
- Console.WriteLine("3.DISPLAY STUDENTS NAME IN ASCENDING OEDER");
- Console.WriteLine("4.EXIT");
- Console.WriteLine("ENTER YOUR CHOISE");
- ch = int.Parse(Console.ReadLine());
- switch (ch)
- {
- case 1:
- Console.WriteLine("REGNO NAME M1 M2 M3 TOTALMARKS");
- for (i = 0; i < cnt; i++)
- Console.WriteLine("{0,9} {1,-10} {2,-8} {3,-8} {4,-8} {5}", rno[i], name[i], m1[i], m2[i], m3[i], total[i]);
- break;
- case 2:
- Console.WriteLine("STUDENTS WHO SCORED HIGHEST MARKS");
- Console.WriteLine("REGNO:{0} \n NAME:{1} \n TOTALMARKS:{2}", rno[pos], name[pos], total[pos]);
- break;
- case 3:
- name.Sort();
- Console.WriteLine("STUDENTS NAME IN ASCENDING ORDER");
- for (i = 0; i < cnt; i++)
- Console.WriteLine(name[i]);
- break;
- case 4:
- break;
- }
- Console.ReadKey();
- }
- }
- }
- }
- 2. PROGRAM TO DEMONSTRATE THE ACTIVITIES PERFORMED BY A SHOP KEEPER IN A BOOK SHOP
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ConsoleApplication2
- {
- class Book
- {
- string title;
- string author;
- int price;
- int sp;
- int noc;
- public Book()
- {
- sp = 0;
- }
- public void Addnew()
- {
- Console.WriteLine("ENTER TITLE OF THE BOOK AND AUTHOR NAME");
- title = Console.ReadLine();
- author = Console.ReadLine();
- Console.WriteLine("ENTER BOOK PRICE");
- price = int.Parse(Console.ReadLine());
- Console.WriteLine("ENTER NO OF COPIES");
- noc = int.Parse(Console.ReadLine());
- sp = sp + noc;
- }
- public void Addexist(string name, string athr, int n)
- {
- if (name == title && author == athr)
- sp = sp + n;
- }
- public int search(string name, string athr, int n)
- {
- if (name == title && author == athr)
- {
- int total = n * price;
- if (n > sp)
- Console.WriteLine("BOOK IS OUT OF STOCK");
- else
- Console.WriteLine("TOTAL AMOUNT" + total);
- return 1;
- }
- else return 0;
- }
- public void Disp()
- {
- Console.WriteLine("{0,-10} {1,-10} {2,-4} {3,6}", title, author, price, sp);
- }
- class Program2
- {
- static void Main(string[] args)
- {
- Book[] b = new Book[20];
- string t, a;
- int ch = 0, count = 1, flag, cs, n;
- while (ch != 5)
- {
- Console.Clear();
- Console.WriteLine("MENU");
- Console.WriteLine("1.ADD NEW BOOKS.\n2.ADD EXISTING \n3.SEARCH\n4.DISPLAY ALL\n 5.EXIT \n");
- Console.WriteLine("ENTER YOUR CHOICE");
- ch = int.Parse(Console.ReadLine());
- switch (ch)
- {
- case 1:
- b[count] = new Book();
- b[count].Addnew();
- count++;
- break;
- case 2:
- Console.WriteLine("ENTER BOOK TITLE,AUTHOR,NUMBER OF COPIES");
- t = Console.ReadLine();
- a = Console.ReadLine();
- n = int.Parse(Console.ReadLine());
- for (int i = 1; i < count; i++)
- b[i].Addexist(t, a, n);
- break;
- case 3:
- flag = 0;
- Console.WriteLine("ENTER BOOK TITLE,AUTHOR,NUMBER OF COPIES");
- t = Console.ReadLine();
- a = Console.ReadLine();
- n = int.Parse(Console.ReadLine());
- for (int i = 1; i < count; i++)
- {
- cs = b[i].search(t, a, n);
- if (cs == 1)
- flag++;
- }
- if (flag == 0)
- Console.WriteLine("BOOK NOT FOUND");
- break;
- case 4:
- Console.WriteLine("-----------------BOOK DETAILS---------------");
- Console.WriteLine("TITLE AUTHOR PRICE NO-OF-COPIES");
- for (int i = 1; i < count; i++)
- b[i].Disp();
- break;
- }
- Console.ReadKey();
- }
- }
- }
- }
- }
- 3. PROGRAM TO DISPLAY STUDENT DETAILS USING INDEXERS
- using System;
- using System.Collections.Generic;
- using System.Collections;
- using System.Text;
- namespace ConsoleApplication3
- {
- class Program
- {
- static void Main(string[] args)
- {
- string name, regno, result;
- int m1, m2, m3, total;
- double avg;
- Console.WriteLine("ENTER THE NAME AND REGISTERNO");
- name = Console.ReadLine();
- regno = Console.ReadLine();
- Console.WriteLine("ENTER 3 SUBJECTS MARKS");
- m1 = int.Parse(Console.ReadLine());
- m2 = int.Parse(Console.ReadLine());
- m3 = int.Parse(Console.ReadLine());
- sample s = new sample();
- s["name"] = name;
- s["regno"] = regno;
- s[3] = m1;
- s[4] = m2;
- s[5] = m3;
- total = s[3] + s[4] + s[5];
- avg = total / 3;
- if (s[3] < 35 || s[4] < 35 || s[5] < 35 || avg < 40)
- result = "FAIL";
- else if (avg >= 80 && avg <= 100)
- result = "DISTINCTION";
- else if (avg >= 60 && avg <= 79)
- result = "FIRST CLASS";
- else if (avg >= 50 && avg <= 59)
- result = "SECOND CLASS";
- else
- result = "THIRD CLASS";
- Console.Clear();
- Console.WriteLine("STUDENT INFORMATION");
- Console.WriteLine("\n REGISTERNO:" + s["regno"]);
- Console.WriteLine("\n name:{0,-10}", s["name"]);
- Console.WriteLine("\n marks1:" + s[3]);
- Console.WriteLine("\n marks2:" + s[4]);
- Console.WriteLine("\n marks3:" + s[5]);
- Console.WriteLine("\n Total marks:" + total);
- Console.WriteLine("\n percentage:" + avg);
- Console.WriteLine("\n class:" + result);
- Console.ReadLine();
- }
- }
- }
- class sample
- {
- private string name, regno;
- private int m1, m2, m3;
- public string this[string index]
- {
- get
- {
- if (index == "name")
- return name;
- if (index == "regno")
- return regno;
- return null;
- }
- set
- {
- if (index == "name")
- name = value;
- else if (index == "regno")
- regno = value;
- }
- }
- public int this[int index1]
- {
- get
- {
- if (index1 == 3)
- return m1;
- else if (index1 == 4)
- return m2;
- else
- return m3;
- }
- set
- {
- if (index1 == 3)
- m1 = value;
- else if (index1 == 4)
- m2 = value;
- else m3 = value;
- }
- }
- }
- 4. PROGRAM TO FIND DIFFERENCE AND SUM OF TWO MATRICIES USING DELEGATES
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ConsoleApplication1
- {
- delegate void mcast_del();
- public class add_sub
- {
- static int n;
- static int[,]matrix1=new int [10,10];
- static int[,]matrix2=new int [10,10];
- public void inputs()
- {
- Console.WriteLine("enter the ordr of matrix");
- n=int.Parse(Console.ReadLine());
- Console.WriteLine("enter the first matrix elements");
- for(int i=0;i<n;i++)
- for(int j=0;j<n;j++)
- matrix1[i,j]=int.Parse(Console.ReadLine());
- Console.WriteLine("enter the second elements of matrix");
- for(int i=0;i<n;i++)
- for(int j=0;j<n;j++)
- matrix2[i,j]=int.Parse(Console.ReadLine());
- }
- public static void addition()
- {
- int[,] add=new int[10,10];
- for(int i=0;i<n;i++)
- for(int j=0;j<n;j++)
- add[i,j]=matrix1[i,j]+matrix2[i,j];
- Console.WriteLine("sum of two matrixes \n\n");
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<n;j++)
- {
- Console.Write("\t"+add[i,j]);
- }
- Console.WriteLine("\n");
- }
- }
- public static void subtraction()
- {
- int[,] sub=new int[10,10];
- for(int i=0;i<n;i++)
- for(int j=0;j<n;j++)
- sub[i,j]=matrix1[i,j]-matrix2[i,j];
- Console.WriteLine("subtraction of two matrixes \n\n");
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<n;j++)
- {
- Console.Write("\t"+sub[i,j]);
- }
- Console.WriteLine("\n");
- }
- }
- class program
- {
- static void Main(string[] args)
- {
- mcast_del m1=new mcast_del(add_sub.addition);
- mcast_del m2=new mcast_del(add_sub.subtraction);
- mcast_del m3=m1+m2;
- add_sub obj=new add_sub();
- obj.inputs();
- m3();//invoking the multicast delegate
- Console.ReadKey();
- }
- }
- }
- }
- 5. PROGRAM TO GENERATE ānā EVEN NUMBERS AND FIBONACCI NUMBERS USING EVENTS
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ConsoleApplication1
- {
- public delegate void edel(int n);
- class event_class
- {
- public event edel status;
- public void event_triggared()
- {
- int n;
- Console.WriteLine("enter the value for N");
- n = int.Parse(Console.ReadLine());
- status(n);
- }
- }
- class program
- {
- static void Main(string[] args)
- {
- program p = new program();
- event_class e = new event_class();
- e.status += new edel(p.event_catch);
- e.status += new edel(p.event_catch1);
- e.event_triggared();
- Console.ReadKey();
- }
- public void event_catch(int n)
- {
- Console.Clear();
- Console.WriteLine("the first {0} even numbers are",n);
- int count=2;
- for(int i=0;i<n;i++)
- {
- Console.WriteLine("\n"+count);
- count+=2;
- }
- }
- public void event_catch1(int n)
- {
- Console.WriteLine("\n \n the first {0} fibonacci numbers are", n);
- int f1 = 0, f2 = 1, f, count;
- Console.WriteLine("\n" + f1);
- Console.WriteLine("\n" + f2);
- for (count = 3; count <= n; count++)
- {
- f = f1 + f2;
- Console.WriteLine("\n" + f);
- f1 = f2;
- f2 = f;
- }
- }
- }
- }
- 6. PROGRAM TO CREATE A BANK DATABASE SYSTEM
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data.SqlClient;
- class Program
- {
- static void Main(string[] args)
- {
- string source = "Data Source=VISHNU-PC;Initial Catalog=bank;Integrated Security=True";
- string qur1 = "SELECT * FROM customer";
- string qur2 = "SELECT acno,name FROM customer WHERE actype='sb'";
- string qur3 = "UPDATE customer SET balance=balance+500 WHERE balance>=10000";
- int choice;
- SqlConnection con = new SqlConnection(source);
- SqlCommand cmd1 = new SqlCommand(qur1, con);
- SqlCommand cmd2 = new SqlCommand(qur2, con);
- SqlCommand cmd3 = new SqlCommand(qur3, con);
- do
- {
- Console.Clear();
- Console.WriteLine("\t\t\t\t\n MENU ");
- Console.WriteLine("\t\t\n 1.Display all the records.");
- Console.WriteLine("\t\t\n 2.Display the information whose account type is SB.");
- Console.WriteLine("\t\t\n 3.Updating the record whose balance >=10000");
- Console.WriteLine("\t\t\n 4.Exit");
- Console.Write("\t\t\n\n Enter ur choice:");
- choice = int.Parse(Console.ReadLine());
- Console.Clear();
- switch (choice)
- {
- case 1: con.Open();
- SqlDataReader rd = cmd1.ExecuteReader();
- Console.WriteLine("Acc_no\t\tNAME\t\tAc- TYPE\t\tBALANCE\n\n");
- while (rd.Read())
- {
- Console.Write(rd[0]);
- Console.Write("\t\t" + rd[1]);
- Console.Write("\t\t" + rd[2]);
- Console.Write("\t\t" + rd[3]);
- Console.WriteLine("\n");
- }
- con.Close();
- Console.ReadKey();
- break;
- case 2: con.Open();
- SqlDataReader rd1 = cmd2.ExecuteReader();
- Console.WriteLine("Acc_no\tNAME\n\n");
- while (rd1.Read())
- {
- Console.Write(" " + rd1[0]);
- Console.Write("\t" + rd1[1]);
- //Console.Write("\t " + rd1[2]);
- Console.WriteLine("\n");
- }
- con.Close();
- Console.ReadKey();
- break;
- case 3: con.Open();
- int count = cmd3.ExecuteNonQuery();
- Console.WriteLine("No of Rows updated:" + count);
- Console.ReadKey();
- con.Close();
- break;
- }
- }
- while (choice != 4);
- }
- }
- 7. VALIDATE FORM FOR REGISTERED USERS TO ENTER DETAILS LIKE NAME,ADDRESS,GENDER AND DISPLAY THE DETAILS IN RICH TEXT BOX
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace WindowsApplication2
- {
- public partial class Form1 : Form
- {
- SqlConnection con = new SqlConnection("Data Source=VISHNU-PC;Initial Catalog=student;Integrated Security=True");
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void button2_Click(object sender, EventArgs e)
- {
- int a = int.Parse(textBox3.Text);
- int b = int.Parse(textBox4.Text);
- int c = int.Parse(textBox5.Text);
- int d = (a + b + c) / 3;
- textBox6.Text = d.ToString();
- if ((d >= 35) && (d <= 50))
- textBox7.Text = "pass class";
- else if ((d >= 51) && (d <= 60))
- textBox7.Text = "second class";
- else if ((d >= 61) && (d <= 75))
- textBox7.Text = "First class";
- else
- textBox7.Text = "distinction";
- }
- private void button3_Click(object sender, EventArgs e)
- {
- con.Open();
- SqlCommand cmd = new SqlCommand("insert into stud values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "')", con);
- cmd.ExecuteNonQuery();
- MessageBox.Show("successfully inserted");
- con.Close();
- richTextBox1.Text = ("regno:" + textBox1.Text + "\n" + "name:" + textBox2.Text + "\n" + "m1" + textBox3.Text + "\n" + "m2" + textBox4.Text + "\n" + "m3" + textBox5.Text + "\n" + "percentage" + textBox6.Text + "\n" + "result:" + textBox7.Text);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- printDialog1.AllowSomePages = true;
- printDialog1.AllowCurrentPage = true;
- if(printDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK)
- {
- printDocument1.PrinterSettings = printDialog1.PrinterSettings;
- printDocument1.Print();
- }
- }
- private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs i)
- {
- i.Graphics.DrawString(richTextBox1.Text,richTextBox1.Font,new SolidBrush(Color.Red),new Rectangle(50,50,i.PageBounds.Height
- ,i.PageBounds.Width));
- }
- private void richTextBox1_TextChanged(object sender, EventArgs e)
- {
- }
- }
- }
- 8. FORM TO DISPLAY STUDENT DETAILS FROM THE DATABASE
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace WindowsApplication3
- {
- public partial class Form1 : Form
- {
- SqlConnection con;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- // TODO: This line of code loads data into the 'studentDataSet.stud' table. You can move, or remove it, as needed.
- this.studTableAdapter.Fill(this.studentDataSet.stud);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- con = new SqlConnection("Data Source=VISHNU-PC;Initial Catalog=student;Integrated Security=True");
- con.Open();
- string sel = this.comboBox1.GetItemText(this.comboBox1.SelectedItem);
- SqlCommand cmd = new SqlCommand("select * from stud where regno='" + sel + "'", con);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- textBox1.Text = dr[1].ToString();
- textBox2.Text = dr[5].ToString();
- textBox3.Text = dr[6].ToString();
- }
- dr.Close();
- con.Close();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- textBox1.Text = "";
- textBox2.Text = "";
- textBox3.Text = "";
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox3_TextChanged(object sender, EventArgs e)
- {
- }
- }
- }
- 9.PROGRAM TO VALIDATE USER LOGIN
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsApplication4
- {
- public partial class Form1 : Form
- {
- Form2 f2 = new Form2();
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void label1_Click(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (textBox1.Text == "admin" && textBox2.Text == "admin")
- button2.Visible = true;
- else
- DialogResult = MessageBox.Show("Invalid User ID & Password", "Message", MessageBoxButtons.YesNo);
- if (DialogResult == DialogResult.Yes)
- {
- textBox1.Text = " ";
- textBox2.Text = " ";
- textBox1.Focus();
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- f2.Show();
- }
- }
- }
- //FORM2
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace WindowsApplication4
- {
- public partial class Form2 : Form
- {
- SqlConnection con;
- public Form2()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (textBox2.Text == textBox3.Text)
- {
- con.Open();
- SqlCommand cmd = new SqlCommand("insert into login values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "')", con);
- cmd.ExecuteNonQuery();
- MessageBox.Show("Registration Successful");
- con.Close();
- }
- else
- MessageBox.Show("password Not Match");
- textBox2.Text = " ";
- textBox3.Text = " ";
- textBox2.Focus();
- }
- private void Form2_Load(object sender, EventArgs e)
- {
- con = new SqlConnection("Data Source=VISHNU-PC;Initial Catalog=admin;Integrated Security=True");
- }
- }
- }
- 10.COMPANY WEBSITE TO DEMONSTRATE STATE MANAGEMENT
- //default//
- using System;
- using System.Data;
- using System.Configuration;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Application["view"] = ((int)(Application["view"])) + 1;
- TextBox1.Text = Application["view"].ToString();
- }
- protected void TextBox1_TextChanged(object sender, EventArgs e)
- {
- }
- }
- //DEFAULT2
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class Default2 : System.Web.UI.Page
- {
- public double a, da, ta, hra, pf, loan, gs, ns;
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- if (TextBox1.Text == "111".ToString())
- Panel1.Visible = true;
- else
- {
- TextBox1.Text = "";
- Session["s"] = ((int)(Session["s"])) + 1;
- int a1 = ((int)(Session["s"]));
- if (a1 == 3)
- Response.Redirect("Default3.aspx");
- }
- }
- protected void Button2_Click(object sender, EventArgs e)
- {
- a = double.Parse(TextBox2.Text);
- hra = (a * 0.08);
- da = (a * 0.05);
- ta = (a * 0.05);
- pf = (a * 0.12);
- loan = (a * 0.04);
- gs = (a + hra + da + ta);
- ns = gs - (pf + loan);
- TextBox3.Text = da.ToString();
- TextBox4.Text = hra.ToString();
- TextBox5.Text = ta.ToString();
- TextBox6.Text = loan.ToString();
- TextBox7.Text = pf.ToString();
- TextBox8.Text = gs.ToString();
- TextBox9.Text = ns.ToString();
- }
- }
- //GLOBAL
- <%@ Application Language="C#" %>
- <script runat="server">
- void Application_Start(object sender, EventArgs e)
- {
- // Code that runs on application startup
- Application["view"] = 0;
- }
- void Application_End(object sender, EventArgs e)
- {
- // Code that runs on application shutdown
- }
- void Application_Error(object sender, EventArgs e)
- {
- // Code that runs when an unhandled error occurs
- }
- void Session_Start(object sender, EventArgs e)
- {
- // Code that runs when a new session is started
- Session["s"] = 0;
- }
- void Session_End(object sender, EventArgs e)
- {
- // Code that runs when a session ends.
- // Note: The Session_End event is raised only when the sessionstate mode
- // is set to InProc in the Web.config file. If session mode is set to StateServer
- // or SQLServer, the event is not raised.
- }
- </script>
- 11. ASP.NET APPLICATION TO DEMONSTRATE LOGIN CONTROL AND GRIDVIEW CONTROL
- using System;
- using System.Data;
- using System.Configuration;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
- {
- if (Login1.UserName == "admin" && Login1.Password == "admin")
- e.Authenticated = true;
- else
- e.Authenticated = false;
- }
- }
- //DEFAULT2
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class Default2 : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- GridView1.Visible = true;
- }
- protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
- {
- }
- }
- 12.WEBSITE TO APPLY FOR A JOB USING VALIDATION CONTROL
- using System;
- using System.Data;
- using System.Configuration;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Data.SqlClient;
- public partial class _Default : System.Web.UI.Page
- {
- SqlConnection con;
- SqlCommand cmd;
- public string s1, s2, s3, s4, s5, s6, s7;
- public void Data()
- {
- s1 = TextBox1.Text;
- s2 = TextBox2.Text;
- s3 = TextBox3.Text;
- s4 = TextBox4.Text;
- s5 = DropDownList1.SelectedItem.ToString();
- if (RadioButton1.Checked)
- s6 = "experienced";
- else
- s6 = "fresher";
- s7 = TextBox5.Text;
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- con = new SqlConnection("Data Source=VISHNU-PC;Initial Catalog=employer;Integrated Security=True");
- }
- protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- Data();
- con.Open();
- cmd=new SqlCommand("insert into register values('"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s5+"','"+s6+"','"+s7+"')",con);
- cmd.ExecuteNonQuery();
- con.Close();
- Response.Write("record sucessfully inserted....");
- TextBox1.Text = "";
- TextBox2.Text = "";
- TextBox3.Text = "";
- TextBox4.Text = "";
- TextBox5.Text = "";
- }
- protected void Button2_Click(object sender, EventArgs e)
- {
- }
- }
- 13. WEB PAGE OF A FRUITSHOP THAT ALLOWS USER TO EDIT THEIR RECORDS
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Data.SqlClient;
- public partial class Default3 : System.Web.UI.Page
- {
- SqlConnection con;
- protected void Page_Load(object sender, EventArgs e)
- {
- con = new SqlConnection("Data Source=VISHNU-PC;Initial Catalog=employee;Integrated Security=True");
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- con.Open();
- SqlCommand cmd = new SqlCommand("insert into emp values ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "')", con);
- cmd.ExecuteNonQuery();
- Response.Write("RECORD SAVED SUCESSFULLY");
- con.Close();
- TextBox1.Text = "";
- TextBox2.Text = "";
- TextBox3.Text = "";
- TextBox4.Text = "";
- TextBox5.Text = "";
- TextBox6.Text = "";
- }
- protected void Button2_Click(object sender, EventArgs e)
- {
- con.Open();
- SqlCommand cmd = new SqlCommand("delete from emp where emp_id='" + TextBox1.Text + "'", con);
- cmd.ExecuteNonQuery();
- Response.Write("record deleted sucessfully");
- con.Close();
- TextBox1.Text = "";
- }
- protected void Button3_Click(object sender, EventArgs e)
- {
- con.Open();
- SqlCommand cmd = new SqlCommand("update emp set emp_name='" + TextBox2.Text + "',emp_age='" + TextBox3.Text + "',emp_deg='" + TextBox4.Text + "',emp_add='" + TextBox5.Text + "',emp_salary='" + TextBox6.Text +"'where emp_id='"+TextBox1.Text+ "'", con);
- cmd.ExecuteNonQuery();
- Response.Write("employee record updated sucessfully");
- con.Close();
- TextBox1.Text = "";
- TextBox2.Text = "";
- TextBox3.Text = "";
- TextBox4.Text = "";
- TextBox5.Text = "";
- TextBox6.Text = "";
- }
- protected void Button4_Click(object sender, EventArgs e)
- {
- con.Open();
- SqlCommand cmd = new SqlCommand("select * from emp where emp_id='" + TextBox1.Text + "'", con);
- SqlDataReader reader = cmd.ExecuteReader();
- while (reader.Read())
- {
- TextBox2.Text = reader[1].ToString();
- TextBox3.Text = reader[2].ToString();
- TextBox4.Text = reader[3].ToString();
- TextBox5.Text = reader[4].ToString();
- TextBox6.Text = reader[5].ToString();
- }
- con.Close();
- }
Add Comment
Please, Sign In to add comment