17
PART-B 1) Consider the Database STUDENT consisting of following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string, StudName: string, Address: string,CourseID: int, YrOfAdmsn: int) Develop suitable windows application using C#.NET having following options: 1. Entering new course details. 2. Entering new student details. 3. Display the details of students (in a Grid) who belong to a particular course. 4. Display the details the students who have taken admission in a particular year.

Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

Embed Size (px)

Citation preview

Page 1: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

PART-B1)

Consider the Database STUDENT consisting of

following tables:

tbl_Course (CourseID:int, CourseName: string)

tbl_Student (USN: string, StudName: string, Address: string,CourseID: int, YrOfAdmsn: int)

Develop suitable windows application using C#.NET having following options:

1. Entering new course details.

2. Entering new student details.

3. Display the details of students (in a Grid) who belong to a particular course.

4. Display the details the students who have taken admission in a particular year.

Page 2: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

Database Design:

Tbl_Course:

Page 3: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

Tbl_Student:

Page 4: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string
Page 5: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

Main Form:

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

private void button1_Click(object sender, EventArgs e) {

Page 6: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

NewCourse ns = new NewCourse(); ns.Show(); }

private void button2_Click(object sender, EventArgs e) { NewStudent ns1 = new NewStudent(); ns1.Show(); }

private void button3_Click(object sender, EventArgs e) { Display_Students_Coursewise dsc = new Display_Students_Coursewise(); dsc.Show(); }

private void button4_Click(object sender, EventArgs e) { Display_Students_Yearwise dsy=new Display_Students_Yearwise(); dsy.Show(); }

private void Form1_Load(object sender, EventArgs e) {

} }}

Page 7: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

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.Data.SqlClient;

namespace STUDENT{ public partial class NewCourse : Form { SqlConnection con; SqlCommand cmd; SqlDataAdapter da; DataSet ds; public NewCourse() { InitializeComponent(); }

private void btn_AddCourse_Click(object sender, EventArgs e) { con = new SqlConnection("user id=sa;password=123;database=STUDENT");

Page 8: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

con.Open(); string query="insert into tbl_Course (CourseID,CourseName) values (" + txt_CouseID.Text + ",'" + txt_CourseName.Text + "')"; cmd = new SqlCommand(query, con); //cmd.CommandType = CommandType.Text; int j = cmd.ExecuteNonQuery(); if (j > 0) { MessageBox.Show("New Couse'"+txt_CourseName.Text+"' Added Sucessfully"); } else {

MessageBox.Show("INSERTION FAILED");

}

con.Close(); }

private void NewCourse_Load(object sender, EventArgs e) {

}

}}

Page 9: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string
Page 10: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

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.Data.SqlClient;

namespace STUDENT{ public partial class NewStudent : Form { SqlConnection con; SqlCommand cmd; SqlDataAdapter da; DataSet ds; public NewStudent() { InitializeComponent(); }

private void NewStudent_Load(object sender, EventArgs e) { con = new SqlConnection("user id=sa;password=123;database=STUDENT"); con.Open(); string sqlstr = "select CourseID from tbl_Course"; da = new SqlDataAdapter(sqlstr, con); ds = new DataSet(); da.Fill(ds); cmb_CourseID.DataSource = ds.Tables[0]; cmb_CourseID.ValueMember = "CourseID"; //cmb_YrOfAdmsn.SelectedItem = 6; }

private void btn_AddStudent_Click(object sender, EventArgs e) { cmd = new SqlCommand("insert into tbl_Student (USN,StudName,Address,CourseID,YrOfAdmsn) values ('" + txt_StudUSN.Text + "','" + txt_StudName.Text+ "','"+txt_Address.Text+"',"+cmb_CourseID.SelectedValue+","+cmb_YrOfAdmsn.SelectedItem+")", con); //cmd.CommandType = CommandType.Text; int j = cmd.ExecuteNonQuery(); if (j > 0) { MessageBox.Show("New Student'" + txt_StudName.Text + "' Added Sucessfully"); } else {

Page 11: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

MessageBox.Show("INSERTION FAILED");

} } }}

Page 12: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string
Page 13: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

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.Data.SqlClient;

namespace STUDENT{ public partial class Display_Students_Coursewise : Form { SqlConnection con; SqlCommand cmd; SqlDataAdapter da,da1; DataSet ds; DataSet ds1; public Display_Students_Coursewise() { InitializeComponent(); }

private void Display_Students_Coursewise_Load(object sender, EventArgs e) { con = new SqlConnection("user id=sa;password=123;database=STUDENT"); con.Open(); string sqlstr = "select CourseName from tbl_Course"; da = new SqlDataAdapter(sqlstr, con); ds = new DataSet(); da.Fill(ds); cmb_CourseID.DataSource = ds.Tables[0]; cmb_CourseID.ValueMember = "CourseName"; cmb_CourseID.DisplayMember = "CourseName"; string sqlstr1 = "select * from tbl_Student,tbl_Course where tbl_Course.CourseID=tbl_Student.CourseID and tbl_Course.CourseName='" + cmb_CourseID.SelectedValue + "'"; da1 = new SqlDataAdapter(sqlstr1, con); ds1 = new DataSet(); da1.Fill(ds1); dataGridView1.DataSource = ds1.Tables[0];

}

private void cmb_CourseID_SelectionChangeCommitted(object sender, EventArgs e) { con = new SqlConnection("user id=sa;password=123;database=STUDENT"); con.Open();

Page 14: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

string sqlstr1 = "select * from tbl_Student,tbl_Course where tbl_Course.CourseID=tbl_Student.CourseID and tbl_Course.CourseName='" + cmb_CourseID.SelectedValue + "'"; da1 = new SqlDataAdapter(sqlstr1, con); ds1 = new DataSet(); da1.Fill(ds1); dataGridView1.DataSource = ds1.Tables[0];

} }}

Page 15: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string
Page 16: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string

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.Data.SqlClient;

namespace STUDENT{ public partial class Display_Students_Yearwise : Form { SqlConnection con; SqlCommand cmd; SqlDataAdapter da, da1; DataSet ds; DataSet ds1; public Display_Students_Yearwise() { InitializeComponent(); }

private void Display_Students_Yearwise_Load(object sender, EventArgs e) { con = new SqlConnection("user id=sa;password=123;database=STUDENT"); con.Open(); string sqlstr = "select YrOfAdmsn from tbl_Student"; da = new SqlDataAdapter(sqlstr, con); ds = new DataSet(); da.Fill(ds); cmb_SelectYear.DataSource = ds.Tables[0]; cmb_SelectYear.ValueMember = "YrOfAdmsn"; cmb_SelectYear.DisplayMember = "YrOfAdmsn"; string sqlstr1 = "select * from tbl_Student where YrOfAdmsn=" +cmb_SelectYear.SelectedValue+ ""; da1 = new SqlDataAdapter(sqlstr1, con); ds1 = new DataSet(); da1.Fill(ds1); dgw_YearwiseStudents.DataSource = ds1.Tables[0]; }

private void cmb_SelectYear_SelectionChangeCommitted(object sender, EventArgs e) { string sqlstr1 = "select * from tbl_Student where YrOfAdmsn=" + cmb_SelectYear.SelectedValue + ""; da1 = new SqlDataAdapter(sqlstr1, con); ds1 = new DataSet(); da1.Fill(ds1); dgw_YearwiseStudents.DataSource = ds1.Tables[0]; } }}

Page 17: Web view13.09.2015 · PART-B. 1) Consider the Database STUDENT consisting of. following tables: tbl_Course (CourseID:int, CourseName: string) tbl_Student (USN: string