User talk:Shalmick

C#.Net 18MCA56 Lab Programs PART – B

'''1) Consider the Database db_EMS (Employee Management System) consisting of the following tables : tbl_Designations (IdDesignation: int, Designation: string) tbl_EmployeeDetails(IdEmployee: int, EmployeeName: string, ContactNumber: string, IdDesignation: int, IdReportingTo: int) Develop a suitable window application using C#.NET having following options. 1. Enter new Employee details with designation & Reporting Manager. 2. Display all the Project Leaders (In a Grid) reporting to selected Project Managers (In a Combo box). 3. Display all the Engineers (In a Grid) reporting to selected Project Leader (In a Combo box). 4. Display all the Employees (In a Grid) with their reporting Manager (No Value for PM). NOTE: tbl_Designation is a static table containing the following Rows in it. 1 Project Manager 2 Project Leader 3 Engineer'''

Main Form – Code

using System; using System.Text; using System.Windows.Forms; namespace EmployeeManagementSystem { public partial class Form1 : Form { public Form1 { InitializeComponent; } private void button2_Click(object sender, EventArgs e) { Display_Project_Leaders obj = new Display_Project_Leaders; obj.Show; } private void button1_Click(object sender, EventArgs e) { NewEmployee obj = new NewEmployee; obj.Show; } private void button3_Click(object sender, EventArgs e) { Display_Engineers obj=new Display_Engineers; obj.Show; 3 18MCA56 - .Net Laboratory - Lab Manual – PART – B AMC Engineering College Dept. of MCA 2020 – 21 } private void button4_Click(object sender, EventArgs e) { Display_All_Employees obj = new Display_All_Employees; obj.Show; } } }

New Employee Form – Code:

using System; using System.Windows.Forms; using System.Data.SqlClient; namespace EmployeeManagementSystem { public partial class NewEmployee : Form { public NewEmployee { InitializeComponent; } private void button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_EMS.mdf;Inte grated Security=True;Connect Timeout=30;User Instance=True"); con.Open; int iddesignation = comboBox1.SelectedIndex+1; int idreport=0; if (comboBox2.SelectedValue != null) idreport =int.Parse( comboBox2.SelectedValue.ToString); string query = "insert into tbl_EmployeeDetails (IdEmployee,EmployeeName,ContactNumber,IdDesignation,IdReportingTo) values(" + textBox1.Text + ",'" + textBox2.Text + "','" + textBox3.Text + "'," + iddesignation + "," + idreport + ")"; SqlCommand cmd = new SqlCommand(query, con); int i = cmd.ExecuteNonQuery; if (i > 0) { MessageBox.Show("New Emplyee'" + textBox2.Text + "' Added Sucessfully"); } else { MessageBox.Show("INSERTION FAILED"); } con.Close; } private void button2_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; comboBox1.SelectedIndex = -1; comboBox2.SelectedIndex = -1; } private void NewEmployee_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_EMS.mdf;Inte grated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string sqlstr = "select IdDesignation from tbl_Designations "; SqlDataAdapter sda = new SqlDataAdapter(sqlstr, con); DataSet ds = new DataSet; sda.Fill(ds); comboBox1.DataSource = ds.Tables[0]; comboBox1.ValueMember = "IdDesignation"; comboBox1.DisplayMember = "IdDesignation"; string sqlstr1 = "select IdEmployee from tbl_EmployeeDetails where IdDesignation=" + comboBox1.SelectedIndex + " "; SqlDataAdapter sda1 = new SqlDataAdapter(sqlstr1, con); DataSet ds1 = new DataSet; sda1.Fill(ds1); comboBox2.DataSource = ds1.Tables[0]; comboBox2.ValueMember = "IdEmployee"; comboBox2.DisplayMember = "IdEmployee"; con.Close; } private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\adminz1\\Documents\\db_EMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string sqlstr1 = "select IdEmployee from tbl_EmployeeDetails where IdDesignation=" + comboBox1.SelectedIndex + " "; SqlDataAdapter sda1 = new SqlDataAdapter(sqlstr1, con); DataSet ds1 = new DataSet; sda1.Fill(ds1); comboBox2.DataSource = ds1.Tables[0]; comboBox2.ValueMember = "IdEmployee"; comboBox2.DisplayMember = "IdEmployee"; con.Close; } private void button3_Click(object sender, EventArgs e) { this.Close; } } }

Display all the Project Leaders Form – Code:

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 EmployeeManagementSystem { public partial class Display_Project_Leaders : Form { public Display_Project_Leaders { InitializeComponent; } private void Display_Project_Leaders_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_EMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string sqlstr = "select IdEmployee from tbl_EmployeeDetails where IdDesignation=" + 1 + " "; SqlDataAdapter sda = new SqlDataAdapter(sqlstr, con); DataSet ds = new DataSet; sda.Fill(ds); comboBox1.DataSource = ds.Tables[0]; comboBox1.ValueMember = "IdEmployee"; comboBox1.DisplayMember = "IdEmployee"; string sqlstr1 = "select * from tbl_EmployeeDetails where tbl_EmployeeDetails.IdReportingTo=" + comboBox1.SelectedValue + ""; SqlDataAdapter sda1 = new SqlDataAdapter(sqlstr1, con); DataSet ds1 = new DataSet; sda1.Fill(ds1); dataGridView1.DataSource = ds1.Tables[0]; } private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\adminz1\\Documents\\db_EMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string sqlstr1 = "select * from tbl_EmployeeDetails where tbl_EmployeeDetails.IdReportingTo=" + comboBox1.SelectedValue + ""; SqlDataAdapter sda1 = new SqlDataAdapter(sqlstr1, con); 7 18MCA56 - .Net Laboratory - Lab Manual – PART – B AMC Engineering College Dept. of MCA 2020 – 21 DataSet ds1 = new DataSet; sda1.Fill(ds1); dataGridView1.DataSource = ds1.Tables[0]; con.Close; } } }

Display all the Project Engineers Form – Code:

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 EmployeeManagementSystem { public partial class Display_Engineers : Form { public Display_Engineers { InitializeComponent; }

private void Display_Engineers_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_EMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string sqlstr = "select IdEmployee from tbl_EmployeeDetails where IdDesignation=" + 2 + " "; SqlDataAdapter sda = new SqlDataAdapter(sqlstr, con); DataSet ds = new DataSet; sda.Fill(ds); comboBox1.DataSource = ds.Tables[0]; comboBox1.ValueMember = "IdEmployee"; comboBox1.DisplayMember = "IdEmployee"; string sqlstr1 = "select * from tbl_EmployeeDetails where tbl_EmployeeDetails.IdReportingTo=" + comboBox1.SelectedValue + ""; SqlDataAdapter sda1 = new SqlDataAdapter(sqlstr1, con); DataSet ds1 = new DataSet; sda1.Fill(ds1); dataGridView1.DataSource = ds1.Tables[0]; } private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\adminz1\\Documents\\db_EMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string sqlstr1 = "select * from tbl_EmployeeDetails where tbl_EmployeeDetails.IdReportingTo=" + comboBox1.SelectedValue + ""; SqlDataAdapter sda1 = new SqlDataAdapter(sqlstr1, con); DataSet ds1 = new DataSet; sda1.Fill(ds1); dataGridView1.DataSource = ds1.Tables[0]; } } }

Display all the Employees Form – Code:

using System; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace EmployeeManagementSystem { public partial class Display_All_Employees : Form { public Display_All_Employees { InitializeComponent; } private void Display_All_Employees_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_EMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string sqlstr1 = "select * from tbl_EmployeeDetails"; SqlDataAdapter sda1 = new SqlDataAdapter(sqlstr1, con); DataSet ds1 = new DataSet; sda1.Fill(ds1); dataGridView1.DataSource = ds1.Tables[0]; } } }

2)

Consider the Database db_LSA (Lecturer Subject Allocation) consisting of the following tables: tbl_Subjects(IdSubject: int, SubjectCode: string, SubjectName: string) tbl_Lecturers(IdLecturer: int, LecturerName: string, ContactNumber: string) tbl_LecturerSubjects(IdSubject: int, SubjectCode: string, IdLecturer: int) Develop a suitable window application using C#.NET having following options. 1. Enter new Subject Details. 2. Enter New Lecturer Details. 3. Subject Allocation with Lecturer Name in a Combo box and subjects to be allocated in Grid with checkboxColumn. 4. Display all the subjects allocated (In a Grid) to the selected Lecturer (In a Combo Box). 1) tbl_Subjects – Table Design 2) tbl_Lectures – Table Design 3) tbl_LecturerSubjects – Table Design

Main Form – Code:

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 PART_B_2_LSB { public partial class MainForm : Form { public MainForm { InitializeComponent; } private void button1_Click(object sender, EventArgs e) { AddingNewSubject obj = new AddingNewSubject; obj.Show; } private void button2_Click(object sender, EventArgs e) { Adding_Lecturer obj = new Adding_Lecturer; obj.Show; } private void button3_Click(object sender, EventArgs e) { Subject_Allocation obj = new Subject_Allocation; obj.Show; } private void button4_Click(object sender, EventArgs e) { Display_All_Subjects_Alloted_to_a_Faculty obj = new Display_All_Subjects_Alloted_to_a_Faculty; obj.Show; } } }

Adding New Subject Form – Code:

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 PART_B_2_LSB { public partial class AddingNewSubject : Form { public AddingNewSubject { InitializeComponent; } private void button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_LSA.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string query = "insert into tbl_Subjects (SubjectCode,SubjectName) values ('" + textBox2.Text + "','" + textBox3.Text + "')"; SqlCommand cmd = new SqlCommand(query, con); int j = cmd.ExecuteNonQuery; 16 17MCA57 - .Net Laboratory - Lab Manual – PART – B AMC Engineering College Dept. of MCA 2019 – 20 if (j > 0) MessageBox.Show("New Subject '" + textBox3.Text + "' Added Sucessfully"); else MessageBox.Show("Insertion Failed"); con.Close; } private void button2_Click(object sender, EventArgs e) { textBox2.Text = ""; textBox3.Text = ""; } private void button3_Click(object sender, EventArgs e) { this.Close; } } }

Adding Faculty Form – Code:

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 PART_B_2_LSB { public partial class Adding_Lecturer : Form { public Adding_Lecturer { InitializeComponent; } private void button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_LSA.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string query = "insert into tbl_Lecturers (LecturerName,ContactNumber) values ('" + textBox2.Text + "','" + textBox3.Text + "')"; SqlCommand cmd = new SqlCommand(query, con); int j = cmd.ExecuteNonQuery; if (j > 0) MessageBox.Show("New Lecturer '" + textBox2.Text + "' Added Sucessfully"); else MessageBox.Show("Insertion Failed"); con.Close; } private void button2_Click(object sender, EventArgs e) { textBox2.Text = ""; textBox3.Text = ""; } private void button3_Click(object sender, EventArgs e) { this.Close; } } }

Subject Mapping Form – Code:

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 PART_B_2_LSB { public partial class Subject_Allocation : Form { public Subject_Allocation { InitializeComponent; } private void Subject_Allocation_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_LSA.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string query = "select LecturerName from tbl_Lecturers"; SqlDataAdapter sda = new SqlDataAdapter(query, con); DataTable dt = new DataTable; sda.Fill(dt); 19 17MCA57 - .Net Laboratory - Lab Manual – PART – B AMC Engineering College Dept. of MCA 2019 – 20 comboBox1.DataSource = dt; comboBox1.DisplayMember = "LecturerName"; comboBox1.ValueMember = "LecturerName"; string query1 = "select * from tbl_Subjects"; SqlDataAdapter sda1 = new SqlDataAdapter(query1, con); DataTable dt1 = new DataTable; sda1.Fill(dt1); dataGridView1.DataSource = dt1; con.Close; } private void button1_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridView1.Rows) { bool isSelected=Convert.ToBoolean(row.Cells["Select"].Value); if (isSelected) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_LSA.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string query = "select IdLecturer from tbl_Lecturers where LecturerName='"+comboBox1.SelectedValue+"'"; SqlDataAdapter sda=new SqlDataAdapter (query,con); DataTable dt = new DataTable; sda.Fill(dt); int lectr_id = int.Parse(dt.Rows[0][0].ToString); int sub_id = int.Parse(row.Cells[1].Value.ToString); string sub_code = row.Cells[2].Value.ToString; string query1 = "insert into tbl_LecturerSubjects(IdSubject,SubjectCode,IdLecturer) values (" + sub_id + ",'" + sub_code + "'," + lectr_id + ")"; SqlCommand cmd = new SqlCommand(query1, con); int j = cmd.ExecuteNonQuery; if (j > 0) MessageBox.Show("Subject Mapped Sucessfully"); else MessageBox.Show("Maping Failed"); con.Close; } } } } }

Display Mapped Subject Alloted to Faculty Form – Code:

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 PART_B_2_LSB { public partial class Display_All_Subjects_Alloted_to_a_Faculty : Form { public Display_All_Subjects_Alloted_to_a_Faculty { InitializeComponent; } private void Display_All_Subjects_Alloted_to_a_Faculty_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_LSA.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string query = "select LecturerName from tbl_Lecturers"; SqlDataAdapter sda = new SqlDataAdapter(query, con); DataTable dt = new DataTable; 21 17MCA57 - .Net Laboratory - Lab Manual – PART – B AMC Engineering College Dept. of MCA 2019 – 20 sda.Fill(dt); comboBox1.DataSource = dt; comboBox1.DisplayMember = "LecturerName"; comboBox1.ValueMember = "LecturerName"; string query1 = "select distinct IdLecturer from tbl_Lecturers where LecturerName='" + comboBox1.SelectedValue + "'"; SqlDataAdapter sda1 = new SqlDataAdapter(query1, con); DataTable dt1 = new DataTable; sda1.Fill(dt1); int lectid = int.Parse(dt1.Rows[0][0].ToString); string query2 = "select distinct * from tbl_LecturerSubjects where IdLecturer= "+lectid +" "; SqlDataAdapter sda2 = new SqlDataAdapter(query2, con); DataTable dt2 = new DataTable; sda2.Fill(dt2); dataGridView1.DataSource = dt2; con.Close; } private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_LSA.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string query1 = "select distinct IdLecturer from tbl_Lecturers where LecturerName='" + comboBox1.SelectedValue + "'"; SqlDataAdapter sda1 = new SqlDataAdapter(query1, con); DataTable dt1 = new DataTable; sda1.Fill(dt1); int lectid = int.Parse(dt1.Rows[0][0].ToString); string query2 = "select distinct * from tbl_LecturerSubjects where IdLecturer= " + lectid + " "; SqlDataAdapter sda2 = new SqlDataAdapter(query2, con); DataTable dt2 = new DataTable; sda2.Fill(dt2); dataGridView1.DataSource = dt2; con.Close; } } }

3)

Consider the database db_VSS (Vehicle Service Station) consisting of the following tables: tbl_VehicleTypes(IdVehicleType: int, VehicleType: string, ServiceCharge: int) tbl_ServiceDetails(IdService: int, VehicleNumber: string, ServiceDetails: string, IdVehicleType: int) Develop a suitable window application using C#.NET having following options. 1. Enter new Service Details for the Selected Vehicle Type (In a Combo Box). 2. Update the Existing Service Charges to Database. 3. Total Service Charges Collected for the Selected Vehicle (In a Combo box) with total amount displayed in a text box. NOTE: tbl_VehicleType is a static table containing the following Rows in it. 1 - Two Wheeler - 500 2 - Four Wheeler - 1000 3 - Three Wheeler - 700

MainForm – Code:

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 PARTB_3_Vehicle_Service_Station { public partial class MainForm : Form { public MainForm { InitializeComponent; } private void button1_Click(object sender, EventArgs e) { NewServiceDetails obj = new NewServiceDetails; obj.Show; } private void button3_Click(object sender, EventArgs e) { TotalServiceChargesCollected obj = new TotalServiceChargesCollected; obj.Show; } private void button2_Click(object sender, EventArgs e) { UpdaingExistingServiceCharges obj = new UpdaingExistingServiceCharges; obj.Show; } } }

New Service Form – Code:

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 PARTB_3_Vehicle_Service_Station { public partial class NewServiceDetails : Form { public NewServiceDetails { InitializeComponent; } private void button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_VSS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; int idvechtype = comboBox1.SelectedIndex + 1; string query = "insert into tbl_ServiceDetails (VehicleNumber,ServiceDetails,IdVehicleType) values ('" + textBox2.Text + "','" + textBox3.Text + "',"+idvechtype+")"; SqlCommand cmd = new SqlCommand(query, con); int j = cmd.ExecuteNonQuery; if (j > 0) MessageBox.Show("Service Done for '" + textBox2.Text + "' Sucessfully"); else MessageBox.Show("Insertion Failed"); con.Close; } private void button2_Click(object sender, EventArgs e) { textBox2.Text = ""; textBox3.Text = ""; comboBox1.SelectedIndex= -1; } private void button3_Click(object sender, EventArgs e) { this.Close; } } }

Update Service Charge Form – Code:

using System; using System.Collections.Generic; using System.ComponentModel; 28 17MCA57 - .Net Laboratory - Lab Manual – PART – B AMC Engineering College Dept. of MCA 2019 – 20 using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace PARTB_3_Vehicle_Service_Station { public partial class UpdaingExistingServiceCharges : Form { public UpdaingExistingServiceCharges { InitializeComponent; } private void UpdaingExistingServiceCharges_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_VSS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string query = "select * from tbl_VehicleTypes"; SqlDataAdapter sda = new SqlDataAdapter(query, con); DataTable dt = new DataTable; sda.Fill(dt); dataGridView1.DataSource = dt; dataGridView1.Columns[0].ReadOnly = true; dataGridView1.Columns[1].ReadOnly = true; con.Close; } private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_VSS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; DialogResult result; result = MessageBox.Show("Are You sure want to update?", "Conformation", MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { // for (int i = 0; i < dataGridView1.Rows.Count; i++) SqlCommand command = new SqlCommand("UPDATE tbl_VehicleTypes SET ServiceCharge = " + dataGridView1.SelectedCells[0].Value.ToString + " Where IdVehicleType = '" + dataGridView1.CurrentRow.Cells[0].Value.ToString + "' ", con); command.ExecuteNonQuery; MessageBox.Show("Updated Sucessfully"); } con.Close; } } }

Toatl Service Charges Collected Form – Code:

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 PARTB_3_Vehicle_Service_Station { public partial class TotalServiceChargesCollected : Form { public TotalServiceChargesCollected { InitializeComponent; } private void comboBox1_SelectedValueChanged(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\RAJESH\\Documents\\db_VSS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string query = "select IdVehicleType from tbl_ServiceDetails where IdVehicleType=" + (comboBox1.SelectedIndex + 1) + ""; SqlDataAdapter sda = new SqlDataAdapter(query, con); DataTable dt = new DataTable; sda.Fill(dt); string query1 = "select ServiceCharge from tbl_VehicleTypes where IdVehicleType=" + (comboBox1.SelectedIndex + 1) + ""; SqlDataAdapter sda1 = new SqlDataAdapter(query1, con); DataTable dt1 = new DataTable; sda1.Fill(dt1); int samt=int.Parse(dt1.Rows[0][0].ToString); int totamt = (dt.Rows.Count) * samt; textBox1.Text = totamt.ToString; } } }

-

4) Develop a web application using C#.NET and ASP.NET for the Postal System Management. The master page should contain the hyper links for adding Area Details, Postman details, Letter distributions and View Letters. Consider the database db_PSM (Postal System Management) consisting of the following tables: tbl_AreaDetails(IdArea: int, AreaName: string) tbl_PostmanDetails(IdPostman: int, PostmanName: string, ContactNumber: string, IdArea: int) tbl_AreaLetters(IdLetter: int, LetterAddress: string, IdArea: int) Develop the suitable content pages for the above created 4 hyper links with the following details: 1. Enter New Area Details 2. Enter New Postman Details with the Area he/she is in-charge of (display Area in a Combo box) 3. Enter all the Letters distributed to the selected Area (display Area in a Combo box) 4. Display all the Letter addresses (In a Grid) to be distributed by the selected Postman (In a Combo box

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient;

public partial class Adding_New_Area_Details : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\adminz1\\Documents\\db_PSM.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; string query="insert into tbl_AreaDetails(IdArea,AreaName)values("+TextBox1.Text+",'"+TextBox2.Text+"')"; SqlCommand cmd=new SqlCommand (query,con); int j = cmd.ExecuteNonQuery; if(j>=1) Response.Write(" alert('successfuly Insretd'); "); else Response.Write(" alert(' Insretion Failed'); "); con.Close; } protected void Button2_Click(object sender, EventArgs e) { TextBox1.Text = ""; TextBox2.Text = ""; } protected void Button3_Click(object sender, EventArgs e) { Response.Write(" window.close; "); } } using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; public partial class Adding__New_Postman_Details : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button4_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\adminz1\\Documents\\db_PSM.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; int idarea = int.Parse(DropDownList1.SelectedValue.ToString); string query = "insert into tbl_PostmanDetails(IdPostman,PostmanName,ContactNumber,IdArea)values(" + TextBox1.Text + ",'" + TextBox2.Text + "','" + TextBox3.Text + "',"+idarea+")"; SqlCommand cmd = new SqlCommand(query, con); int j = cmd.ExecuteNonQuery; if (j >= 1) Response.Write(" alert('successfuly Insretd'); "); else Response.Write(" alert(' Insretion Failed'); "); con.Close; } }

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; public partial class Letters_distributed_to_the_selected_Area : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\adminz1\\Documents\\db_PSM.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; int idarea = int.Parse(DropDownList1.SelectedValue.ToString); string query = "insert into tbl_AreaLetters(IdLetter,LetterAddress,IdArea)values(" + TextBox1.Text + ",'" + TextBox2.Text + "'," + idarea + ")"; SqlCommand cmd = new SqlCommand(query, con); int j = cmd.ExecuteNonQuery; if (j >= 1) Response.Write(" alert('successfuly Distribted'); "); else Response.Write(" alert(' Distribution Failed'); "); con.Close; } }

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; public partial class Display_all_the_Letter_addresses : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\adminz1\\Documents\\db_PSM.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; int idarea = int.Parse(DropDownList1.SelectedValue.ToString); string query = "select LetterAddress from tbl_AreaLetters where IdArea=" + idarea + ""; SqlDataAdapter sda = new SqlDataAdapter(query, con); DataSet ds = new DataSet; sda.Fill(ds); GridView1.DataSource = ds.Tables[0]; GridView1.DataBind; con.Close; } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { } }

--

5) '''Develop a web application using C#.NET and ASP.NET for the Complaint Management System. The master page should contain the hyper links for Add Engineer, Complaint Registration, Complaint Allocation and View Complaints. Consider the database db_CMS (Complaint Management System) consisting of the following tables: tbl_Departments(IdDepartment: int, DepartmentName: string) tbl_Engineers(IdEngineer: int, EngineerName: string, ContactNumber: string, IdDepartment: int) tbl_RegisteredComplaints(IdComplaint: int, ComplaintDescription: string) tbl_DepartmentComplaints(IdDepartment: int, IdComplaint: int) Develop the suitable content pages for the above created 4 hyper links with the following details: 1. Enter New Engineers belonging to the selected department (displayed in a combo box) 2. Register a new Complaint with a submit button. 3. View all registered complaints & allocate to the corresponding department (displayed in a combo box) 4. Display all the Complaints (In a Grid) to be handled by the selected Engineer (In a Combo box) ''' NOTE: Consider the table tbl_Departments as a static table containing some pre-entered departments, which are displayed in all the remaining modules.

using System; using System.Collections.Generic; using System.Linq; using System.Web.UI.WebControls; using System.Data.SqlClient; public partial class Adding_New_Engineers : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\adminz1\\Documents\\db_CMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); con.Open; int iddept = int.Parse(DropDownList1.SelectedValue.ToString); string query = "insert into tbl_Engineers(IdEngineer,EngineerName,ContactNumber,IdDepartment )values("+TextBox1.Text+".'"+TextBox2.Text+"','"+TextBox3.Text+"',"+iddept+") "; SqlCommand cmd = new SqlCommand(query, con); int j = cmd.ExecuteNonQuery; if (j >= 1) Response.Write(" alert(New Engineer " + TextBox2.Text + "Addeed Sucessfully) "); else Response.Write(" alert(Insretion Failed) "); con.Close; } }