Académique Documents
Professionnel Documents
Culture Documents
ON
ATTENDANCE ANALYSIS SYSTEM
IN PARTIAL FULFILLMENT OF THE REQUIREMENT
FOR THE AWARD OF
(INFORMATION TECHNOLOGY)
SESSION: 2007-2008
(.NET TECHNOLOGY BASED MAJOR PROJECT)
SUBMITTED BY:
LINGAYA’S INSTITUTE
OF
MANAGEMENT & TECHNOLOGY
FARIDABAD (HARYANA)
MAHARISHI DAYANAND UNIVERSITY
ROHTAK
ACKNOWLEDGEMENT
Team Members:
VARTIKA PAUL
SONALI KHURANA
RENU YADAV
1. Abstract
3. System specifications
7. References
Brief Description About Project
HARDWARE REQUIREMENTS
SYSTEM
MINIMUM 256MB RAM
SOFTWARE REQUIREMENTS
You can run .NET client applications and services on Windows 98,
98 SE, Millennium Edition (Me), NT 4.0, 2000, or XP. Beginning in
late 2002, you will be able to run .NET applications and services
on Windows CE .NET products, such as the Pocket PC and
Microsoft Smart Phone, as well. On the server; you can use
Windows NT 4.0, 2000, or .NET Server.
Scope
Objective
FORM-1
namespace Attendance
{
// Form1: Display Menustrip (which include Department menu, class
menu, Lecturer menu, Subject menu, Student Menu, Registration Menu,
attendance Menu and About Menu)
//Department Menu
private void newDepartmentToolStripMenuItem_Click(object
sender, EventArgs e)
{
//Display New Department Name form
Form2 a = new Form2();
a.Show();
}
private void
displayDepartmentListToolStripMenuItem_Click(object sender, EventArgs
e)
{
//Display Department Names form
Form5 a = new Form5();
a.Show();
}
//Class Menu
private void newClassNameToolStripMenuItem_Click(object sender,
EventArgs e)
{
//Display New Class Name form
Form6 a = new Form6();
a.Show();
}
//Lecturer Menu
private void
addNewLecturerInDepartmentToolStripMenuItem_Click(object sender,
EventArgs e)
{
//Display New Lecturer Name form
Form10 a = new Form10();
a.Show();
}
private void
displayListOfLecturerInDepartmentToolStripMenuItem_Click(object sender,
EventArgs e)
{
//Display Lecturer Names form
Form13 a = new Form13();
a.Show();
}
//Subject Menu
private void addNewStudentInClassToolStripMenuItem_Click(object
sender, EventArgs e)
{
//Display New Subject Name form
Form14 a = new Form14();
a.Show();
}
private void
deleteStudentNameFromClassToolStripMenuItem_Click(object sender,
EventArgs e)
{
//Display Delete Subject Name form
Form16 a = new Form16();
a.Show();
}
//Student Menu
private void
addNewStudentInClassToolStripMenuItem1_Click(object sender, EventArgs
e)
{
//Display "New Student Name" form
Form18 a = new Form18();
a.Show();
}
private void
displayListOfStudentInClassToolStripMenuItem_Click(object sender,
EventArgs e)
{
//Display "Display Student Names" form
Form21 a = new Form21();
a.Show();
}
//Registration Menu
//Lecturer Registration Menu
private void
registerLecturerNameForASubjectToolStripMenuItem_Click(object sender,
EventArgs e)
{
//Display "Register Lecturer Name for a Subject" form
Form22 a = new Form22();
a.Show();
}
private void
deRegisterLecturerNameForASubjectToolStripMenuItem_Click(object sender,
EventArgs e)
{
//Display "DeRegister Lecturer Name for a Subject" form
Form23 a = new Form23();
a.Show();
}
private void
displayListOfRegisteredSubjectInSemesterToolStripMenuItem_Click(object
sender, EventArgs e)
{
//Display "Display List of Registered Subject in Semester"
form
Form24 a = new Form24();
a.Show();
}
//Studentt Registration Menu
private void registerStudentsNameToolStripMenuItem_Click(object
sender, EventArgs e)
{
//Display "Register Student Name for a subject" form
Form25 a = new Form25();
a.Show();
}
private void
displayListOfStudentRegisterForASubjectToolStripMenuItem_Click(object
sender, EventArgs e)
{
//Display "Display List of student register for a subject"
form
Form27 a = new Form27();
a.Show();
}
//Attendance Menu
private void addAttendanceToolStripMenuItem_Click(object
sender, EventArgs e)
{
//Display "Add Attendance (Subject wise)" form
Form28 a = new Form28();
a.Show();
}
//About Menu
private void creditsToolStripMenuItem_Click(object sender,
EventArgs e)
{
//Show Message
MessageBox.Show("\nOur Special Thanks To Mr. Vijay Mukhi
Sir & entire VMCI staff \n\nAttendance Analysis Software is developed
by \nDhiraj Vanmali, \nAniket Vanmali, \nRohan Shringarpure, \nSainath
Patil"," Credits");
}
}
FORM-2
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.OleDb;
namespace Attendance
{
//Form2: Display "New Departemnt Name" form
public Form2()
{
InitializeComponent();
~Form2()
{
//Close DataBase Connection
DBCon1.Close();
}
//Database Reader 2
OleDbDataReader DBRead2;
//Database Command 3
OleDbCommand DBcom3 = new OleDbCommand(SCom1,
DBCon1);
}
}
}
}
}
FORM-3
namespace Attendance
{
//Form3: Display "Modify Department Name" form.
public partial class Form3 : Form
{
OleDbConnection DBCon1; // Database Connection 1
public Form3()
{
InitializeComponent();
~Form3()
{
//Close DataBase Connection 1
DBCon1.Close();
}
//Clear TextBox1
textBox1.Text = "";
}
}
}
FORM-4:
namespace Attendance
{
//Form4: Display "Delete Departemnt Name" form.
public partial class Form4 : Form
{
OleDbConnection DBCon1; // Database Connection 1
}
FORM-5
namespace Attendance
{
//Form5: Display "Display Department Names" form.
public partial class Form5 : Form
{
OleDbConnection DBCon1; // Database Connection 1
public Form5()
{
InitializeComponent();
~Form5()
{
//Close DataBase Connection 1
DBCon1.Close();
}
}
FORM-6
FORM-7
If you want to modify the existing class name then click "Modify
Class Name" from "Class" menu as shown in Figure. Now a "Modify
Class Name" form appears on the screen. Here select an existing
department name, class name and type the required new class
name as shown in Figure and click "Modify".
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.OleDb;
namespace Attendance
{
//Form7: Display "Modify Class Name" form.
public partial class Form7 : Form
{
OleDbConnection DBCon1;
bool BDept;
public Form7()
{
InitializeComponent();
//Intialise New DataBase Connection 1
DBCon1 = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=MonthlyReport.mdb");
//Open DataBase Connection 1
DBCon1.Open();
//Set Department Flag to false
BDept = false;
}
~Form7()
{
//Close DataBase Connection 1
DBCon1.Close();
}
FORM-8
namespace Attendance
{
//Form8: Display "Delete Class Name" form.
public partial class Form8 : Form
{
OleDbConnection DBCon1;
bool BDept;
public Form8()
{
InitializeComponent();
~Form8()
{
//Close DataBase Connection 1
DBCon1.Close();
}
}
FORM-9
namespace Attendance
{
//Form9: Display "Display Class Names" form.
public partial class Form9 : Form
{
OleDbConnection DBCon1;
bool BDept;
public Form9()
{
InitializeComponent();
~Form9()
{
//Close DataBase Connection 1
DBCon1.Close();
}
//This method will load Department and class list in combobox1
and datagridview1 respectively.
private void Form9_Load(object sender, EventArgs e)
{
//Load List of Department in Combobox1
//Get DataBase Adapter
OleDbDataAdapter DBAdapter1 = new OleDbDataAdapter("select
* from department", DBCon1);
//Declare Data Set1
DataSet DS1 = new DataSet();
//Intialise IRecordCount to 0; IRecordCount is use to store
no. of record afected
int IRecordCount = 0;
//Fill DataBase Adapter1 and set IRecordCount
IRecordCount = DBAdapter1.Fill(DS1, "Department");
//Set Data Table1
DataTable DT1 = DS1.Tables["Department"];
//Set Data View1
DataView DV1 = DT1.DefaultView;
//set Combobox Data source to Data View 1
comboBox1.DataSource = DV1;
//Set DisplayMember and ValueMember of Combobox1
comboBox1.DisplayMember = "DEPT_NAME";
comboBox1.ValueMember = "DEPT_ID";
//Dispose DataTable1, DataSet1, DataBase Adapter 1
DT1.Dispose();
DS1.Dispose();
DBAdapter1.Dispose();
}
FORM-10
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.OleDb;
namespace Attendance
{
//Form10: Display "New Lecturer Name" form.
public partial class Form10 : Form
{
OleDbConnection DBCon1; // Database Connection 1
int IMLect_ID;
public Form10()
{
InitializeComponent();
~Form10()
{
//Close DataBase Connection 1
DBCon1.Close();
}
//This method will load Department List in Combobox1 & retrive
Max Lecturer Id from database
private void Form10_Load(object sender, EventArgs e)
{
//Load List of Department in Combobox1
//Get DataBase Adapter
OleDbDataAdapter DBAdapter1 = new OleDbDataAdapter("select
* from department", DBCon1);
//Declare Data Set1
DataSet DS1 = new DataSet();
//Intialise IRecordCount to 0; IRecordCount is use to store
no. of record afected
int IRecordCount = 0;
//Fill DataBase Adapter1 and set IRecordCount
IRecordCount = DBAdapter1.Fill(DS1, "Department");
//Set Data Table1
DataTable DT1 = DS1.Tables["Department"];
//Set Data View1
DataView DV1 = DT1.DefaultView;
//set Combobox Data source to Data View 1
comboBox1.DataSource = DV1;
//Set DisplayMember and ValueMember of Combobox1
comboBox1.DisplayMember = "DEPT_NAME";
comboBox1.ValueMember = "DEPT_ID";
//Dispose DataTable1, DataSet1, DataBase Adapter 1
DT1.Dispose();
DS1.Dispose();
DBAdapter1.Dispose();
IMLect_ID++;
}
}
if (string.Compare(richTextBox1.Lines[IRTBLine], "") !=
0)
{
OleDbCommand DBCom1;
DBCom1 = new OleDbCommand("select lect_name from
lecturer where lect_name='" + richTextBox1.Lines[IRTBLine] + "' and
dept_id =" + comboBox1.SelectedValue.ToString(), DBCon1);
string SLect_name;
SLect_name = (string)DBCom1.ExecuteScalar();
DBCom1.Dispose();
if (string.Compare(SLect_name,
richTextBox1.Lines[IRTBLine].ToString()) == 0)
{
MessageBox.Show("Lecturer Name =" +
richTextBox1.Lines[IRTBLine] + " is skiped because it is already
exist");
}
else
{
//MessageBox.Show("insert into Lecturer
values(" + comboBox1.SelectedValue.ToString() + "," + IMLect_ID + ",'"
+ richTextBox1.Lines[IRTBLine].ToString() + "')");
OleDbCommand DBCom2 = new OleDbCommand("insert
into Lecturer values(" + comboBox1.SelectedValue.ToString() + "," +
IMLect_ID + ",'" + richTextBox1.Lines[IRTBLine].ToString() + "')",
DBCon1);
DBCom2.ExecuteNonQuery();
DBCom2.Dispose();
IMLect_ID++;
}
}
}
//Clear RichTextBox1
richTextBox1.ResetText();
}
}
}
Form-11
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.OleDb;
namespace Attendance
{
//Form11: Display "Modify Lecturer Name" form.
public partial class Form11 : Form
{
OleDbConnection DBCon1; // Database Connection 1
bool BDept;
public Form11()
{
InitializeComponent();
~Form11()
{
//Close DataBase Connection 1
DBCon1.Close();
}
}
}
Form-12
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.OleDb;
namespace Attendance
{
//Form12: Display "Delete Lecturer Name" form
public partial class Form12 : Form
{
OleDbConnection DBCon1;
bool BDept;
public Form12()
{
InitializeComponent();
~Form12()
{
//Close DataBase Connection 1
DBCon1.Close();
}
comboBox2.ValueMember = "LECT_ID";
//Dispose DataTable1, DataSet1, DataBase Adapter1
DT2.Dispose();
DS2.Dispose();
DBAdapter2.Dispose();
}
}
}
Form-13
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.OleDb;
namespace Attendance
{
//Form 13: Display " Display Lecturer Name form".
public partial class Form13 : Form
{
OleDbConnection DBCon1;
bool BDept;
public Form13()
{
InitializeComponent();
~Form13()
{
//Close DataBase Connection 1
DBCon1.Close();
}
}
}
Form-14
To add new subjects we click the “Subject” menu & click on the
“New Subject Name”. Next, you can see “New Subject Name
form in which you have to select Department Name, Class Name
and Semester, and then enter the Subjects to be added, each on
a new line. Finally click “Add” to add the new subject(s). As shown
in Figure.
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.OleDb;
namespace Attendance
{
//Form14: Display " New Subject Name" form.
public partial class Form14 : Form
{
OleDbConnection DBCon1;
bool BDept;
int ISub_Ind;
public Form14()
{
InitializeComponent();
~Form14()
{
//Close DataBase Connection 1
DBCon1.Close();
}
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.OleDb;
namespace Attendance
{
//Form15: Display "Modify Subject Name" form.
public partial class Form15 : Form
{
OleDbConnection DBCon1;
bool BDept;
bool BClass;
bool BSem;
public Form15()
{
InitializeComponent();
~Form15()
{
//Close DataBase Connection 1
DBCon1.Close();
}
BClass = true;
//This method will load Class and Subject List in combobox2 &
combobox4 respectively if department name is changed
private void comboBox1_SelectedIndexChanged(object sender,
EventArgs e)
{
if (comboBox1.SelectedValue != null && BDept == true)
{
//set Class flag to false
BClass = false;
//Load Class List in Combobox2
//Get DataBase Adapter2
OleDbDataAdapter DBAdapter2 = new
OleDbDataAdapter("select * from Class where dept_id =" +
comboBox1.SelectedValue.ToString(), DBCon1);
//Declare Data Set2
DataSet DS2 = new DataSet();
//Intialise IRecordCount to 0; IRecordCount is use to
store no. of record afected
int IRecordCount2 = 0;
//Fill DataBase Adapter1 and set IRecordCount
IRecordCount2 = DBAdapter2.Fill(DS2, "Class");
//Set Data Table1
DataTable DT2 = DS2.Tables["Class"];
//Set Data View1
DataView DV2 = DT2.DefaultView;
//set Combobox Data source to Data View 1
comboBox2.DataSource = DV2;
//Set DisplayMember and ValueMember of Combobox1
comboBox2.DisplayMember = "CLASS_NAME";
comboBox2.ValueMember = "CLASS_ID";
//Dispose DataTable1, DataSet1, DataBase Adapter 1
DT2.Dispose();
DS2.Dispose();
DBAdapter2.Dispose();
Form-16
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.OleDb;
namespace Attendance
{
//Form16: Display "Delete Subject Name" form.
public partial class Form16 : Form
{
OleDbConnection DBCon1;
bool BDept;
bool BClass;
public Form16()
{
InitializeComponent();
~Form16()
{
//Close DataBase Connection 1
DBCon1.Close();
}
//This method will load Class & Subject List in combobox2 &
combobox4 if another department name is selected
private void comboBox1_SelectedIndexChanged(object sender,
EventArgs e)
{
if (comboBox1.SelectedValue != null && BDept == true)
{
//Set Class Flag to false
BClass = false;
//Get DataBase Adapter2
OleDbDataAdapter DBAdapter2 = new
OleDbDataAdapter("select * from Class where dept_id =" +
comboBox1.SelectedValue.ToString(), DBCon1);
//Declare Data Set2
DataSet DS2 = new DataSet();
//Intialise IRecordCount to 0; IRecordCount is use to
store no. of record afected
int IRecordCount2 = 0;
//Fill DataBase Adapter1 and set IRecordCount
IRecordCount2 = DBAdapter2.Fill(DS2, "Class");
//Set Data Table1
DataTable DT2 = DS2.Tables["Class"];
//Set Data View1
DataView DV2 = DT2.DefaultView;
//set Combobox Data source to Data View 1
comboBox2.DataSource = DV2;
//Set DisplayMember and ValueMember of Combobox1
comboBox2.DisplayMember = "CLASS_NAME";
comboBox2.ValueMember = "CLASS_ID";
//Dispose DataTable1, DataSet1, DataBase Adapter 1
DT2.Dispose();
DS2.Dispose();
DBAdapter2.Dispose();
//Set Class Flag to true
BClass = true;
}
else if (comboBox1.SelectedValue == null && BDept == true)
{
MessageBox.Show("No Department Exist");
}
//This Method will delete Subject name from database & reload
subject list in combobox4
private void button1_Click(object sender, EventArgs e)
{
if (comboBox4.SelectedValue != null)
{
OleDbCommand DBCom1 = new OleDbCommand("Delete from
Subject where Dept_id =" + comboBox1.SelectedValue.ToString() + " and
Class_id =" + comboBox2.SelectedValue.ToString() + " and sem_id =" +
comboBox3.SelectedValue.ToString() + " and sub_ind=" +
comboBox4.SelectedValue.ToString(), DBCon1);
DBCom1.ExecuteNonQuery();
MessageBox.Show("Subject is Delated");
}
else
{
MessageBox.Show("No Subject Exist");
}
}
}
}
Form-17
namespace Attendance
{
//Form17: Display "Display Subject Names" form.
public partial class Form17 : Form
{
OleDbConnection DBCon1;
bool BDept;
bool BClass;
public Form17()
{
InitializeComponent();
//Intialise New DataBase Connection 1
DBCon1 = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=MonthlyReport.mdb");
//Open DataBase Connection 1
DBCon1.Open();
//Set Department Flag to false
BDept = false;
//Set Class Flag to false
BClass = false;
}
~Form17()
{
//Close DataBase Connection 1
DBCon1.Close();
}
//This method will load Class and subject List in combobox2 &
datagridview1 respectively if another department name is selected
private void comboBox1_SelectedIndexChanged(object sender,
EventArgs e)
{
if (comboBox1.SelectedValue != null && BDept == true)
{
//Set Class Flag to flass
BClass = false;
}
else if(comboBox1.SelectedValue == null && BDept == true)
{
MessageBox.Show("No Department Exist");
}
//This method will load Class and subject List in combobox2 &
datagridview1 respectively if another class name is selected
//This method will load Class and subject List in combobox2 &
datagridview1 respectively if another semester name is selected
private void comboBox3_SelectedIndexChanged(object sender,
EventArgs e)
{
//Load Subject List in Data Grid View 1
if (comboBox1.SelectedValue != null &&
comboBox2.SelectedValue != null && comboBox3.SelectedValue != null &&
BClass == true)
{
//Get DataBase Adapter4
OleDbDataAdapter DBAdapter4 = new
OleDbDataAdapter("select Sub_name from Subject where Dept_id =" +
comboBox1.SelectedValue.ToString() + " and Class_id =" +
comboBox2.SelectedValue.ToString() + " and sem_id =" +
comboBox3.SelectedValue.ToString(), DBCon1);
//Declare Data Set4
DataSet DS4 = new DataSet();
//Intialise IRecordCount4 to 0; IRecordCount3 is use to
store no. of record afected
int IRecordCount4 = 0;
//Fill DataBase Adapter4 and set IRecordCount4
IRecordCount4 = DBAdapter4.Fill(DS4, "Subject");
//Set Data Table4
DataTable DT4 = DS4.Tables["Subject"];
//Set Data View4
DataView DV4 = DT4.DefaultView;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Attendance
{
public Form18()
{
InitializeComponent();
~Form18()
{
//Close DataBase Connection 1
DBCon1.Close();
}
int IStud_ID=0;
try
{
IStud_ID = (int) DBCom1.ExecuteScalar();
}
catch (System.InvalidCastException)
{
IStud_ID = 0;
}
label7.Text = IStud_ID.ToString();
IMStu_ID = IStud_ID + 1;
}
//
}
int IStud_ID = 0;
try
{
IStud_ID = (int)DBCom1.ExecuteScalar();
}
catch (System.InvalidCastException)
{
IStud_ID = 0;
}
label7.Text = IStud_ID.ToString();
IMStu_ID = IStud_ID + 1;
}
//Set Class Flag to True
BClass = true;
}
int IRTB_Linec = 0;
int ICount = 0;
int ICNum = 0;
for (IRTB_Linec = 0; IRTB_Linec <
richTextBox1.Lines.Length; IRTB_Linec++)
{
if (string.Compare(richTextBox1.Lines[IRTB_Linec],
"") != 0)
{
ICount = IMStu_ID + ICNum;
label5.Text = ICount.ToString();
ICNum++;
}
}
}
label7.Text = IStud_ID.ToString();
IMStu_ID = IStud_ID + 1;
}
}
If required, now you can also modify a student name for this,
click “Modify Student Name” in the “Student” menu. As shown in
Figure. A “Modify Student Name” form appears on the screen. In
this form you have to select the Department Name, Class Name
and then enter the Roll No. of the existing student. The name of
existing student is automatically displayed. Then type in the New
Student Name and click “Modify”, as shown in Figure.
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.OleDb;
namespace Attendance
{
//Form19: Display "Modify Student Name" form
public partial class Form19 : Form
{
OleDbConnection DBCon1;
bool BDept;
public Form19()
{
InitializeComponent();
//Intialise New DataBase Connection 1
DBCon1 = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=MonthlyReport.mdb");
//Set Depatment Flag to false
BDept = false;
//Open DataBase Connection 1
DBCon1.Open();
}
~Form19()
{
//Close DataBase Connection 1
DBCon1.Close();
}
try
{
SStud_Name = (string)DBCom1.ExecuteScalar();
}
catch (System.NullReferenceException)
{
SStud_Name= "";
}
DBCom1.Dispose();
}
if (string.Compare(SStud_Name, "") != 0)
{
textBox1.Text = SStud_Name;
}
else
{
textBox1.Text = "";
}
}
Form-20
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.OleDb;
namespace Attendance
{
//Form20: Display "Delete Student Name" form
public partial class Form20 : Form
{
OleDbConnection DBCon1;
bool BDept;
public Form20()
{
InitializeComponent();
~Form20()
{
//Close DataBase Connection 1
DBCon1.Close();
}
try
{
SStud_Name = (string)DBCom1.ExecuteScalar();
}
catch (System.NullReferenceException)
{
SStud_Name = "";
}
DBCom1.Dispose();
}
if (string.Compare(SStud_Name, "") != 0)
{
textBox1.Text = SStud_Name;
}
else
{
textBox1.Text = "";
}
}
if (string.Compare(textBox1.Text.Trim(), "") != 0)
{
OleDbCommand DBCom1 = new OleDbCommand("Delete from
student where student_id=" + maskedTextBox1.Text.Trim() + "and
dept_id=" + comboBox1.SelectedValue.ToString() + "and class_id=" +
comboBox2.SelectedValue.ToString(), DBCon1);
DBCom1.ExecuteNonQuery();
MessageBox.Show("Student Name is Deleted");
maskedTextBox1.Text = "";
textBox1.Text = "";
}
else
{
MessageBox.Show("No Student Selected (Invalid Student
ID)");
}
}
}
}
Form-21
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.OleDb;
namespace Attendance
{
//Form21: Display "Display Student Names" form
public partial class Form21 : Form
{
OleDbConnection DBCon1;
bool BDept;
static bool BClass;
public Form21()
{
InitializeComponent();
~Form21()
{
//Close DataBase Connection 1
DBCon1.Close();
}
dataGridView1.DataSource = DV3;
dataGridView1.Columns[0].HeaderText = "Student Roll
No.";
dataGridView1.Columns[1].HeaderText = "Student Name";
dataGridView1.Columns[0].Width = 150;
dataGridView1.Columns[1].Width = 225;
}
}
//This method will load class and student list in comboboc2 and
datagridview1 respectively if another department is selected
private void comboBox1_SelectedIndexChanged(object sender,
EventArgs e)
{
//Set Class Flag to false
BClass = false;
dataGridView1.DataSource = DV3;
dataGridView1.Columns[0].HeaderText = "Student Roll
No.";
dataGridView1.Columns[1].HeaderText = "Student Name";
dataGridView1.Columns[0].Width = 150;
dataGridView1.Columns[1].Width = 225;
BClass = true;
}
dataGridView1.DataSource = DV3;
dataGridView1.Columns[0].HeaderText = "Student Roll
No.";
dataGridView1.Columns[1].HeaderText = "Student Name";
dataGridView1.Columns[0].Width = 150;
dataGridView1.Columns[1].Width = 225;
Form-22
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.OleDb;
namespace Attendance
{
//Form22: Display "Register Lecturer Name for a Subject" form
public partial class Form22 : Form
{
OleDbConnection DBCon1;
bool BDept;
bool BClass;
bool BSem;
bool BSub;
bool BLect;
int IMRegSInd;
public Form22()
{
InitializeComponent();
~Form22()
{
//Close DataBase Connection 1
DBCon1.Close();
}
if (comboBox1.SelectedValue != null)
{
//Get DataBase Adapter2
OleDbDataAdapter DBAdapter2 = new
OleDbDataAdapter("select * from Class where dept_id =" +
comboBox1.SelectedValue.ToString(), DBCon1);
//Declare Data Set2
DataSet DS2 = new DataSet();
//Intialise IRecordCount to 0; IRecordCount is use to
store no. of record afected
int IRecordCount2 = 0;
//Fill DataBase Adapter1 and set IRecordCount
IRecordCount2 = DBAdapter2.Fill(DS2, "Class");
//Set Data Table1
DataTable DT2 = DS2.Tables["Class"];
//Set Data View1
DataView DV2 = DT2.DefaultView;
//set Combobox Data source to Data View 1
comboBox2.DataSource = DV2;
//Set DisplayMember and ValueMember of Combobox1
comboBox2.DisplayMember = "CLASS_NAME";
comboBox2.ValueMember = "CLASS_ID";
//Dispose DataTable1, DataSet1, DataBase Adapter 1
DT2.Dispose();
DS2.Dispose();
DBAdapter2.Dispose();
}
//set BClass to true
BClass = true;
IMRegSInd = (int)DBCom1.ExecuteScalar();
DBCom1.Dispose();
}
catch (System.NullReferenceException)
{
IMRegSInd = 0;
}
catch (System.InvalidCastException)
{
IMRegSInd = 0;
}
IMRegSInd++;
}
//This method will load Class and Subject List in combobox2 and
combobox4 respectively if department name is changed
private void comboBox1_SelectedIndexChanged(object sender,
EventArgs e)
{
if (BDept == true)
{
//Load List of Class in Combobox2
BClass = false;
if (comboBox1.SelectedValue != null)
{
//Get DataBase Adapter2
OleDbDataAdapter DBAdapter2 = new
OleDbDataAdapter("select * from Class where dept_id =" +
comboBox1.SelectedValue.ToString(), DBCon1);
//Declare Data Set2
DataSet DS2 = new DataSet();
//Intialise IRecordCount to 0; IRecordCount is use
to store no. of record afected
int IRecordCount2 = 0;
//Fill DataBase Adapter1 and set IRecordCount
IRecordCount2 = DBAdapter2.Fill(DS2, "Class");
//Set Data Table1
DataTable DT2 = DS2.Tables["Class"];
//Set Data View1
DataView DV2 = DT2.DefaultView;
//set Combobox Data source to Data View 1
comboBox2.DataSource = DV2;
//Set DisplayMember and ValueMember of Combobox1
comboBox2.DisplayMember = "CLASS_NAME";
comboBox2.ValueMember = "CLASS_ID";
//Dispose DataTable1, DataSet1, DataBase Adapter 1
DT2.Dispose();
DS2.Dispose();
DBAdapter2.Dispose();
}
//set BClass to true
BClass = true;
}
}
DBCom2.Dispose();
if (ISub_Ind != 0)
{
OleDbCommand DBCom3 = new OleDbCommand("select
SUB_IND from REG_LECT where SUB_IND=" + ISub_Ind.ToString() + "and
lect_id =" + comboBox5.SelectedValue.ToString(), DBCon1);
int ITSub_ind = 0;
try
{
ITSub_ind = (int)DBCom3.ExecuteScalar();
}
catch (System.NullReferenceException)
{
ITSub_ind = 0;
}
DBCom3.Dispose();
if (ITSub_ind != 0)
{
MessageBox.Show("The Lecturer is already
Registered for this Subject");
}
else
{
OleDbCommand DBCom4 = new OleDbCommand("insert
into reg_lect values (" + IMRegSInd.ToString() + "," +
ISub_Ind.ToString() + "," + comboBox5.SelectedValue.ToString() + ")",
DBCon1);
DBCom4.ExecuteNonQuery();
DBCom4.Dispose();
}
}
}
Form-23
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.OleDb;
namespace Attendance
{
//Form23: Display "UnRegister Lecturer Name for a Subject" form
public partial class Form23 : Form
{
OleDbConnection DBCon1;
bool BDept;
bool BClass;
bool BSem;
bool BSub;
bool BLect;
public Form23()
{
InitializeComponent();
~Form23()
{
//Close DataBase Connection 1
DBCon1.Close();
}
if (comboBox1.SelectedValue != null)
{
//Get DataBase Adapter2
OleDbDataAdapter DBAdapter2 = new
OleDbDataAdapter("select * from Class where dept_id =" +
comboBox1.SelectedValue.ToString(), DBCon1);
//Declare Data Set2
DataSet DS2 = new DataSet();
//Intialise IRecordCount to 0; IRecordCount is use to
store no. of record afected
int IRecordCount2 = 0;
//Fill DataBase Adapter1 and set IRecordCount
IRecordCount2 = DBAdapter2.Fill(DS2, "Class");
//Set Data Table1
DataTable DT2 = DS2.Tables["Class"];
//Set Data View1
DataView DV2 = DT2.DefaultView;
//set Combobox Data source to Data View 1
comboBox2.DataSource = DV2;
//Set DisplayMember and ValueMember of Combobox1
comboBox2.DisplayMember = "CLASS_NAME";
comboBox2.ValueMember = "CLASS_ID";
//Dispose DataTable1, DataSet1, DataBase Adapter 1
DT2.Dispose();
DS2.Dispose();
DBAdapter2.Dispose();
}
//set BClass to true
BClass = true;
BLect = true;
}
if (comboBox1.SelectedValue != null)
{
//Get DataBase Adapter2
OleDbDataAdapter DBAdapter2 = new
OleDbDataAdapter("select * from Class where dept_id =" +
comboBox1.SelectedValue.ToString(), DBCon1);
//Declare Data Set2
DataSet DS2 = new DataSet();
//Intialise IRecordCount to 0; IRecordCount is use
to store no. of record afected
int IRecordCount2 = 0;
//Fill DataBase Adapter1 and set IRecordCount
IRecordCount2 = DBAdapter2.Fill(DS2, "Class");
//Set Data Table1
DataTable DT2 = DS2.Tables["Class"];
//Set Data View1
DataView DV2 = DT2.DefaultView;
//set Combobox Data source to Data View 1
comboBox2.DataSource = DV2;
//Set DisplayMember and ValueMember of Combobox1
comboBox2.DisplayMember = "CLASS_NAME";
comboBox2.ValueMember = "CLASS_ID";
//Dispose DataTable1, DataSet1, DataBase Adapter 1
DT2.Dispose();
DS2.Dispose();
DBAdapter2.Dispose();
}
//set BClass to true
BClass = true;
BSub = true;
BLect = true;
}
}
BLect = true;
}
}
BLect = true;
}
}
BLect = true;
}
}
//remove Table
OleDbCommand DBCom3 = new OleDbCommand("DROP TABLE
RSUBJECT" + IRLC_INDEX, DBCon1);
DBCom3.ExecuteNonQuery();
DBCom3.Dispose();
BLect = true;
}
}
}
Form-24
namespace Attendance
{
//Form24: Display "Display List of registered subject in semester"
form
public partial class Form24 : Form
{
OleDbConnection DBCon1;
bool BDept;
bool BClass;
bool BSem;
public Form24()
{
InitializeComponent();
~Form24()
{
//Close DataBase Connection 1
DBCon1.Close();
}
if (comboBox1.SelectedValue != null)
{
//Get DataBase Adapter2
OleDbDataAdapter DBAdapter2 = new
OleDbDataAdapter("select * from Class where dept_id =" +
comboBox1.SelectedValue.ToString(), DBCon1);
//Declare Data Set2
DataSet DS2 = new DataSet();
//Intialise IRecordCount to 0; IRecordCount is use to
store no. of record afected
int IRecordCount2 = 0;
//Fill DataBase Adapter1 and set IRecordCount
IRecordCount2 = DBAdapter2.Fill(DS2, "Class");
//Set Data Table1
DataTable DT2 = DS2.Tables["Class"];
//Set Data View1
DataView DV2 = DT2.DefaultView;
//set Combobox Data source to Data View 1
comboBox2.DataSource = DV2;
//Set DisplayMember and ValueMember of Combobox1
comboBox2.DisplayMember = "CLASS_NAME";
comboBox2.ValueMember = "CLASS_ID";
//Dispose DataTable1, DataSet1, DataBase Adapter 1
DT2.Dispose();
DS2.Dispose();
DBAdapter2.Dispose();
}
//set BClass to true
BClass = true;
if (comboBox1.SelectedValue != null)
{
//Get DataBase Adapter2
OleDbDataAdapter DBAdapter2 = new
OleDbDataAdapter("select * from Class where dept_id =" +
comboBox1.SelectedValue.ToString(), DBCon1);
//Declare Data Set2
DataSet DS2 = new DataSet();
//Intialise IRecordCount to 0; IRecordCount is use
to store no. of record afected
int IRecordCount2 = 0;
//Fill DataBase Adapter1 and set IRecordCount
IRecordCount2 = DBAdapter2.Fill(DS2, "Class");
//Set Data Table1
DataTable DT2 = DS2.Tables["Class"];
//Set Data View1
DataView DV2 = DT2.DefaultView;
//set Combobox Data source to Data View 1
comboBox2.DataSource = DV2;
//Set DisplayMember and ValueMember of Combobox1
comboBox2.DisplayMember = "CLASS_NAME";
comboBox2.ValueMember = "CLASS_ID";
//Dispose DataTable1, DataSet1, DataBase Adapter 1
DT2.Dispose();
DS2.Dispose();
DBAdapter2.Dispose();
}
//set BClass to true
BClass = true;
//Fill DataGridView1
dataGridView1.DataSource = DV4;
dataGridView1.Columns[0].HeaderText = "Subject
Name";
dataGridView1.Columns[1].HeaderText = "Lecturer
Name";
dataGridView1.Columns[0].Width = 175;
dataGridView1.Columns[1].Width = 175;
}
}
}
//Fill DataGridView1
dataGridView1.DataSource = DV4;
dataGridView1.Columns[0].HeaderText = "Subject
Name";
dataGridView1.Columns[1].HeaderText = "Lecturer
Name";
dataGridView1.Columns[0].Width = 175;
dataGridView1.Columns[1].Width = 175;
}
}
}
//Fill DataGridView1
dataGridView1.DataSource = DV4;
dataGridView1.Columns[0].HeaderText = "Subject
Name";
dataGridView1.Columns[1].HeaderText = "Lecturer
Name";
dataGridView1.Columns[0].Width = 175;
dataGridView1.Columns[1].Width = 175;
}
}
}
}
form-25
The "Select Student by Roll No." option will display one Text Box
where you have to manually enter the student roll numbers for
registration for the selected subject by the selected lecturer, as
shown in Figure.
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.OleDb;
namespace Attendance
{
//Form25: Display "Register Student Name for a Subject" form
public partial class Form25 : Form
{
OleDbConnection DBCon1;
bool BDept;
bool BClass;
bool BSem;
bool BSub;
bool BLect;
public Form25()
{
InitializeComponent();
~Form25()
{
//Close DataBase Connection 1
DBCon1.Close();
}
BLect = true;
BClass = true;
}
}
richTextBox1.Lines[i].Remove(0);
count = 0;
}
}
}
}
if (Reg_Sub_Ind > 0)
{
if (radioButton1.Checked == true)
{
OleDbCommand DBCom2 = new OleDbCommand("select
distinct student_id, student_name from student where dept_id=" +
comboBox1.SelectedValue.ToString() + " and class_id=" +
comboBox2.SelectedValue.ToString() + " order by student_id asc",
DBCon1);
OleDbDataReader DBReader2;
DBReader2 = DBCom2.ExecuteReader();
DBCom2.Dispose();
if (DBReader2.HasRows)
{
while (DBReader2.Read())
{
OleDbCommand DBCom6 = new
OleDbCommand("SELECT Student_id FROM RSUBJECT" + Reg_Sub_Ind + " where
student_id =" + DBReader2.GetValue(0).ToString(), DBCon1);
int TStu_no=0;
try
{
TStu_no =
(int)DBCom6.ExecuteScalar();
DBCom6.Dispose();
}
catch(System.NullReferenceException)
{
TStu_no=0;
DBCom6.Dispose();
}
if(TStu_no==0)
{
OleDbCommand DBCom3 = new
OleDbCommand("Insert into RSUBJECT" + Reg_Sub_Ind + " values(" +
DBReader2.GetValue(0).ToString() + ",'" +
DBReader2.GetValue(1).ToString() + "',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 )",
DBCon1);
try
{
DBCom3.ExecuteNonQuery();
BReg_stu = true;
DBCom3.Dispose();
}
catch
(System.Data.OleDb.OleDbException)
{
MessageBox.Show("Student Roll
No. " + DBReader2.GetValue(0).ToString() + " already register for this
Subject");
DBCom3.Dispose();
}
}
}
}
}
else if (radioButton2.Checked == true)
{
bool BStu = true;
int i = 0;
int ICur_Stu_no = 0;
else
MessageBox.Show("No Lecturer Registered for this
Subject");
{
richTextBox1.ResetText();
MessageBox.Show("Registration Completed");
}
else
MessageBox.Show("Registration Already Completed");
}
}
} }
Form-26
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.OleDb;
namespace Attendance
{
//Form26: Display "UnRegister Student Name for a Subject" form
public partial class Form26 : Form
{
OleDbConnection DBCon1;
bool BDept;
bool BClass;
bool BSem;
bool BSub;
bool BLect;
public Form26()
{
InitializeComponent();
//Intialise New DataBase Connection 1
DBCon1 = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=MonthlyReport.mdb");
~Form26()
{
//Close DataBase Connection 1
DBCon1.Close();
}
BClass = true;
BClass = true;
}
}
}
if (comboBox1.SelectedValue != null &&
comboBox2.SelectedValue != null && comboBox3.SelectedValue != null &&
comboBox4.SelectedValue != null && comboBox5.SelectedValue != null)
{
if (string.Compare(textBox1.Text.ToString(), "") != 0)
{
OleDbCommand DBCom1 = new OleDbCommand("select
rlc_index from reg_lect where sub_ind=" +
comboBox4.SelectedValue.ToString() + " and lect_id =" +
comboBox5.SelectedValue.ToString(), DBCon1);
int Reg_Sub_Ind = 0;
try
{
Reg_Sub_Ind = (int)DBCom1.ExecuteScalar();
}
catch (System.NullReferenceException)
{
Reg_Sub_Ind = 0;
}
if (Reg_Sub_Ind > 0)
{
OleDbCommand DBCom = new OleDbCommand("select
student_id from RSUBJECT"+ Reg_Sub_Ind.ToString()+ " Where
Student_id="+ textBox1.Text ,DBCon1);
int ISTu_ID=0;
try
{
ISTu_ID = (int)DBCom.ExecuteScalar();
DBCom.Dispose();
}
catch (System.NullReferenceException)
{
ISTu_ID = 0;
DBCom.Dispose();
}
if (ISTu_ID > 0)
{
OleDbCommand DBCom3 = new
OleDbCommand("select student_name from student where dept_id=" +
comboBox1.SelectedValue.ToString() + " and class_id=" +
comboBox2.SelectedValue.ToString() + " and student_id=" +
textBox1.Text.ToString(), DBCon1);
try
{
textBox2.Text = "";
textBox2.Text =
(string)DBCom3.ExecuteScalar();
DBCom3.Dispose();
}
catch (System.NullReferenceException)
{
textBox2.Text = "";
}
}
else
textBox2.Text = "";
}
}
else
textBox2.Text = "";
}
}
if (Reg_Sub_Ind > 0)
{
if (string.Compare(textBox2.Text.ToString(), "") !=
0)
{
OleDbCommand DBCom2 = new OleDbCommand("Delete
from RSUBJECT" + Reg_Sub_Ind.ToString() + " where Student_id=" +
textBox1.Text, DBCon1);
DBCom2.ExecuteNonQuery();
textBox1.Text = "";
textBox2.Text = "";
DBCom2.Dispose();
}
else
MessageBox.Show("Invalid Student Roll No.");
} } } } }
Form-27
namespace Attendance
{
//Form27: Display "Display List of registered Student for a
subject" form
public partial class Form27 : Form
{
OleDbConnection DBCon1;
bool BDept;
bool BClass;
bool BSem;
bool BSub;
bool BLect;
public Form27()
{
InitializeComponent();
~Form27()
{
//Close DataBase Connection 1
DBCon1.Close();
}
BClass = true;
BLect = true;
if (comboBox1.SelectedValue != null &&
comboBox2.SelectedValue != null && comboBox3.SelectedValue != null &&
comboBox4.SelectedValue != null && comboBox5.SelectedValue != null)
{
OleDbCommand DBCom1 = new OleDbCommand("select
rlc_index from reg_lect where sub_ind=" +
comboBox4.SelectedValue.ToString() + " and lect_id =" +
comboBox5.SelectedValue.ToString(), DBCon1);
int Reg_Sub_Ind = 0;
try
{
Reg_Sub_Ind = (int)DBCom1.ExecuteScalar();
}
catch (System.NullReferenceException)
{
Reg_Sub_Ind = 0;
}
if (Reg_Sub_Ind > 0)
{
OleDbDataAdapter DBAdapter2 = new
OleDbDataAdapter("Select Student_id, Student_name from Student where
student_id in(select student_id from RSUBJECT" + Reg_Sub_Ind + ") and
dept_id=" + comboBox1.SelectedValue.ToString() + " and class_id=" +
comboBox2.SelectedValue.ToString() + " order by student_id", DBCon1);
DataSet DS = new DataSet();
int i = DBAdapter2.Fill(DS, "Student");
DataTable DT = DS.Tables["Student"];
DataView DV = DT.DefaultView;
dataGridView1.DataSource = DV;
dataGridView1.Columns[0].HeaderText = "Student Roll
No.";
dataGridView1.Columns[1].HeaderText = "Student
Name";
DBAdapter2.Dispose();
}
else
dataGridView1.DataSource = null;
}
}
BClass = true;
}
}
}
}
//This method will load Subject and Lecturer List in combobox4
& combobox5 respectively if semester is Changed
//This method will also load Register Student list in
datagridview1
private void comboBox3_SelectedIndexChanged(object sender,
EventArgs e)
{
if (BSem == true)
{
//Load Registerd subject List in Combobox4
BSub = false;
//Get DataBase Adapter4
if (comboBox1.SelectedValue != null &&
comboBox2.SelectedValue != null && comboBox3.SelectedValue != null)
{
OleDbDataAdapter DBAdapter4 = new
OleDbDataAdapter("SELECT sub_ind, sub_name from subject where sub_ind
in(select sub_ind from reg_lect) and Dept_id=" +
comboBox1.SelectedValue.ToString() + " and class_id= " +
comboBox2.SelectedValue.ToString() + " and sem_id=" +
comboBox3.SelectedValue.ToString(), DBCon1);
//Declare Data Set4
}
}
}
}
//This method will load Register Student list in datagridview1
private void comboBox5_SelectedIndexChanged(object sender,
EventArgs e)
{
if (BLect == true)
{
if (comboBox1.SelectedValue != null &&
comboBox2.SelectedValue != null && comboBox3.SelectedValue != null &&
comboBox4.SelectedValue != null && comboBox5.SelectedValue != null)
{
OleDbCommand DBCom1 = new OleDbCommand("select
rlc_index from reg_lect where sub_ind=" +
comboBox4.SelectedValue.ToString() + " and lect_id =" +
comboBox5.SelectedValue.ToString(), DBCon1);
int Reg_Sub_Ind = 0;
try
{
Reg_Sub_Ind = (int)DBCom1.ExecuteScalar();
}
catch (System.NullReferenceException)
{
Reg_Sub_Ind = 0;
}
if (Reg_Sub_Ind > 0)
{
OleDbDataAdapter DBAdapter1 = new
OleDbDataAdapter("Select Student_id, Student_name from Student where
student_id in(select student_id from RSUBJECT" + Reg_Sub_Ind + ") and
dept_id=" + comboBox1.SelectedValue.ToString() + " and class_id=" +
comboBox2.SelectedValue.ToString() + " order by student_id", DBCon1);
DataSet DS = new DataSet();
int i = DBAdapter1.Fill(DS, "Student");
DataTable DT = DS.Tables["Student"];
DataView DV = DT.DefaultView;
dataGridView1.DataSource = DV;
dataGridView1.Columns[0].HeaderText = "Student
Roll No.";
dataGridView1.Columns[1].HeaderText = "Student
Name";
DBAdapter1.Dispose();
}
else
dataGridView1.DataSource = null;
}
}
}
}
}
Form28
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.OleDb;
namespace Attendance
{
//Form28: Display "Add Attendance (Subjectwise)" form
public partial class Form28 : Form
{
OleDbConnection DBCon1;
bool BDept;
bool BClass;
bool BSem;
bool BSub;
bool BLect;
bool BMonth;
bool BIsGridDisplay;
public Form28()
{
InitializeComponent();
~Form28()
{
//Close DataBase Connection 1
DBCon1.Close();
}
///////////////////////////////////////////////////////////
/
BMonth = false;
string SMonth;
if (comboBox3.SelectedValue != null)
{
//Get DataBase Adapter6
if(int.Parse(comboBox3.SelectedValue.ToString())%2==0)
{
SMonth="select * from amonth where month_id between
1 and 6";
}
else
{
SMonth = "select * from amonth where month_id
between 7 and 12";
}
OleDbDataAdapter DBAdapter6 = new
OleDbDataAdapter(SMonth, DBCon1);
//Declare Data Set6
DataSet DS6 = new DataSet();
//Intialise IRecordCount6 to 0; IRecordCount is use to
store no. of record afected
int IRecordCount6 = 0;
//Fill DataBase Adapter6 and set IRecordCount6
IRecordCount6 = DBAdapter6.Fill(DS6, "DMonth");
//Set Data Table6
DataTable DT6 = DS6.Tables["DMonth"];
//Set Data View6
DataView DV6 = DT6.DefaultView;
//set Combobox Data source to Data View 6
comboBox6.DataSource = DV6;
//Set DisplayMember and ValueMember of Combobox6
comboBox6.DisplayMember = "MONTH_NAME";
comboBox6.ValueMember = "MONTH_ID";
//Dispose DataTable6, DataSet6, DataBase Adapter6
DT6.Dispose();
DS6.Dispose();
DBAdapter6.Dispose();
}
else
comboBox6.DataSource = null;
BMonth = true;
///////////////////////////////////////////////////////////
/
///////////////////////////////////////////////////////
/////
BMonth = false;
string SMonth;
if (comboBox3.SelectedValue != null)
{
//Get DataBase Adapter6
if (int.Parse(comboBox3.SelectedValue.ToString()) %
2 == 0)
{
SMonth = "select * from amonth where month_id
between 1 and 6";
}
else
{
SMonth = "select * from amonth where month_id
between 7 and 12";
}
BMonth = true;
}
}
}
}
if (Reg_Sub_Ind > 0)
{
OleDbDataAdapter DBAdapter7 = new
OleDbDataAdapter("Select student_id, student_name, month" +
comboBox6.SelectedValue.ToString() + "la from RSUBJECT" +
Reg_Sub_Ind.ToString() + " order by student_id", DBCon1);
DataSet DS7 = new DataSet();
int i7 = DBAdapter7.Fill(DS7, "Student");
DataTable DT7 = DS7.Tables["Student"];
DataView DV7 = DT7.DefaultView;
dataGridView1.DataSource = DV7;
dataGridView1.Columns[0].HeaderText = "Student
Roll No.";
dataGridView1.Columns[1].HeaderText = "Student
Name";
dataGridView1.Columns[0].ReadOnly = true;
dataGridView1.Columns[1].ReadOnly = true;
dataGridView1.Columns[0].Width = 125;
dataGridView1.Columns[1].Width = 300;
DBAdapter7.Dispose();
DS7.Dispose();
DT7.Dispose();
try
{
IDGMLA =
int.Parse(dataGridView1.Rows[IDGRows].Cells[2].Value.ToString());
}
catch (System.FormatException)
{
IDGMLA = 0;
dataGridView1.Rows[IDGRows].Cells[2].Value = 0;
if (BDataGrid == true)
BDataGrid = false;
}
if (BDataGrid == true)
BDataGrid = false;
}
else
{
dataGridView1.Rows[IDGRows].Cells[2].Style.BackColo
r = Color.White;
}
}
if (BDataGrid == false)
MessageBox.Show("Invalid Entry");
}
}
Form-29
Display "Build Attendance Document (subject wise)" form.
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.OleDb;
using Word = Microsoft.Office.Interop.Word;
using System.Reflection;
namespace Attendance
{
//Form29: Display "Build Attendance Document (subject wise)" form
public partial class Form29 : Form
{
OleDbConnection DBCon1;
bool BDept;
bool BClass;
bool BSem;
bool BSub;
bool BLect;
bool BIsGridDisplay;
public Form29()
{
InitializeComponent();
~Form29()
{
//Close DataBase Connection 1
DBCon1.Close();
}
}
}
if (Reg_Sub_Ind > 0)
{
string s;
bool BMonth = false;
if (int.Parse(comboBox3.SelectedValue.ToString()) %
2 == 0)
{
s = "Select student_id, student_name,
Month1LA,Month2LA,Month3LA,Month4LA,Month5LA,Month6LA,
Totallc,Totalla,Percentage from RSUBJECT" + Reg_Sub_Ind.ToString() + "
order by student_id";
BMonth = false;
}
else
{
s = "Select student_id, student_name,
Month7LA,Month8LA,Month9LA,Month10LA,Month11LA,Month12LA,
Totallc,Totalla,Percentage from RSUBJECT" + Reg_Sub_Ind.ToString() + "
order by student_id";
BMonth = true;
}
OleDbDataAdapter DBAdapter7 = new
OleDbDataAdapter(s, DBCon1);
DataSet DS7 = new DataSet();
int i7 = DBAdapter7.Fill(DS7, "Student");
DataTable DT7 = DS7.Tables["Student"];
DataView DV7 = DT7.DefaultView;
dataGridView1.DataSource = DV7;
dataGridView1.Columns[0].HeaderText = "Student Roll
No.";
dataGridView1.Columns[1].HeaderText = "Student
Name";
dataGridView1.Columns[0].ReadOnly = true;
dataGridView1.Columns[1].ReadOnly = true;
dataGridView1.Columns[0].Width = 50;
dataGridView1.Columns[1].Width = 150;
dataGridView1.Columns[2].Width = 75;
dataGridView1.Columns[3].Width = 75;
dataGridView1.Columns[4].Width = 75;
dataGridView1.Columns[5].Width = 75;
dataGridView1.Columns[6].Width = 75;
dataGridView1.Columns[7].Width = 75;
dataGridView1.Columns[8].Width = 75;
dataGridView1.Columns[9].Width = 75;
dataGridView1.Columns[10].Width = 75;
if (BMonth == true)
{
dataGridView1.Columns[2].HeaderText = "July";
dataGridView1.Columns[3].HeaderText = "August";
dataGridView1.Columns[4].HeaderText =
"September";
dataGridView1.Columns[5].HeaderText =
"October";
dataGridView1.Columns[6].HeaderText =
"November";
dataGridView1.Columns[7].HeaderText =
"December";
}
else
{
dataGridView1.Columns[2].HeaderText =
"January";
dataGridView1.Columns[3].HeaderText =
"February";
dataGridView1.Columns[4].HeaderText = "March";
dataGridView1.Columns[5].HeaderText = "April";
dataGridView1.Columns[6].HeaderText = "May";
dataGridView1.Columns[7].HeaderText = "June";
}
dataGridView1.Columns[8].HeaderText = "Total
Lectures Conducted";
dataGridView1.Columns[9].HeaderText = "Total
Lectures Attended";
DBAdapter7.Dispose();
DS7.Dispose();
DT7.Dispose();
BIsGridDisplay = true;
}
else
BIsGridDisplay = false;
}
}
if (BIsGridDisplay == true)
{
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; // endofdoc is a
predefined bookmark
oDoc.PageSetup.PaperSize =
Word.WdPaperSize.wdPaperLegal;
oDoc.PageSetup.Orientation =
Word.WdOrientation.wdOrientLandscape;
oPara2.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphLeft;
oPara2.Format.SpaceAfter = 6;
oPara2.Range.InsertParagraphAfter();
//Insert another paragraph.
Word.Paragraph oPara3;
oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oPara3 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara3.Range.Text = "Lecturer Name: " +
comboBox5.Text.ToString();
oPara3.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphLeft;
oPara3.Format.SpaceAfter = 24;
oPara3.Range.InsertParagraphAfter();
object Ot;
Ot = Word.WdTableFormat.wdTableFormatGrid1;
oTable.Cell(1, 1).Range.Text =
dataGridView1.Columns[0].HeaderText.ToString();
oTable.Cell(1, 2).Range.Text =
dataGridView1.Columns[1].HeaderText.ToString();
oTable.Cell(1, 3).Range.Text =
dataGridView1.Columns[2].HeaderText.ToString();
oTable.Cell(1, 4).Range.Text =
dataGridView1.Columns[3].HeaderText.ToString();
oTable.Cell(1, 5).Range.Text =
dataGridView1.Columns[4].HeaderText.ToString();
oTable.Cell(1, 6).Range.Text =
dataGridView1.Columns[5].HeaderText.ToString();
oTable.Cell(1, 7).Range.Text =
dataGridView1.Columns[6].HeaderText.ToString();
oTable.Cell(1, 8).Range.Text =
dataGridView1.Columns[7].HeaderText.ToString();
oTable.Cell(1, 9).Range.Text =
dataGridView1.Columns[8].HeaderText.ToString();
oTable.Cell(1, 10).Range.Text =
dataGridView1.Columns[9].HeaderText.ToString();
oTable.Cell(1, 11).Range.Text =
dataGridView1.Columns[10].HeaderText.ToString();
int r, c;
string strText;
for (r = 0; r < dataGridView1.RowCount; r++)
for (c = 0; c < 11; c++)
{
strText =
dataGridView1.Rows[r].Cells[c].Value.ToString();
oTable.Cell(r + 2, c + 1).Range.Text = strText;
}
oTable.Rows[1].Range.Font.Bold = 1;
oTable.Rows[1].Range.Font.Italic = 1;
}
else
{
MessageBox.Show("Please Show attendance first");
}
}
}}
REFERENCES
1. BOOKS NAME
2. Websites used:
• www.google .com
• www.wikipedia.org