Part 10. Teacher Panel (Checking Taken Lectures) Part - III
In this Attendance Management System project video's, we are going to see how a teacher can check taken lectures of students for a particular class and for a particular date in teacher panel/teacher module.
Source Code Starts From Here :-
Teacher_Lectures.aspx
<center>
<div style="background-image: url('Images/background1.jpg'); width: 1200px">
<table align="center" style="width: 1200px; height: 366px">
<tr style="width: 1200px;">
<td>
<b>Course: </b>
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" Height="40px" Width="115px" AutoPostBack="true">
</asp:DropDownList>
</td>
<td>
</td>
<td>
<b>Year: </b>
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" Height="40px" Width="125px" AutoPostBack="true">
<asp:ListItem>Select Year</asp:ListItem>
<asp:ListItem>First Year</asp:ListItem>
<asp:ListItem>Second Year</asp:ListItem>
<asp:ListItem>Third Year</asp:ListItem>
</asp:DropDownList>
</td>
<td>
</td>
<td>
<b>Semester: </b>
</td>
<td>
<asp:DropDownList ID="DropDownList5" runat="server" Height="40px" Width="125px" OnSelectedIndexChanged="DropDownList5_SelectedIndexChanged"
AutoPostBack="true">
<asp:ListItem>Select Semester</asp:ListItem>
<asp:ListItem>Sem I</asp:ListItem>
<asp:ListItem>Sem II</asp:ListItem>
<asp:ListItem>Sem III</asp:ListItem>
<asp:ListItem>Sem IV</asp:ListItem>
<asp:ListItem>Sem V</asp:ListItem>
<asp:ListItem>Sem VI</asp:ListItem>
</asp:DropDownList>
</td>
<td>
</td>
<td>
<b>Subject: </b>
</td>
<td>
<asp:DropDownList ID="DropDownList3" runat="server" Height="40px" Width="215px" AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
<tr style="width: 1200px;">
<td colspan="11" align="center">
<b>Date:</b>
<asp:TextBox ID="TextBox1" runat="server" TextMode="Date" placeholder="Select Date"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="11" align="center">
<asp:Button ID="Button1" runat="server" Text="Select" Font-Bold="True" Height="40px"
Width="92px" OnClick="Button1_Click" />
</td>
</tr>
<tr>
<td colspan="11" align="center">
<asp:Label ID="Label1" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td colspan="11" align="center">
<asp:GridView ID="GridView1" runat="server"
EmptyDataText="No Such Records Found">
</asp:GridView>
</td>
</tr>
</table>
</div>
</center>
Teacher_Lectures.aspx.cs
string str = ConfigurationManager.ConnectionStrings["connection"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DrpCourse();
}
}
private void DrpCourse()
{
SqlConnection con = new SqlConnection(str);
con.Open();
SqlCommand cmd = new SqlCommand("select * from Course", con);
DropDownList1.DataSource = cmd.ExecuteReader();
DropDownList1.DataTextField = "CourseName";
DropDownList1.DataValueField = "CID";
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, "Select Course");
con.Close();
}
protected void DropDownList5_SelectedIndexChanged(object sender, EventArgs e)
{
int courseID = Convert.ToInt32(DropDownList1.SelectedValue);
string year = DropDownList2.SelectedItem.Text;
string sem = DropDownList5.SelectedItem.Text;
SqlConnection con = new SqlConnection(str);
con.Open();
SqlCommand cmd = new SqlCommand("select * from Subject where CID='" + courseID + "' and Year='" + year + "' and Sem='" + sem + "'", con);
DropDownList3.DataSource = cmd.ExecuteReader();
DropDownList3.DataTextField = "SubjectName";
DropDownList3.DataValueField = "SID";
DropDownList3.DataBind();
DropDownList3.Items.Insert(0, "Select Subject");
con.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
if (DropDownList1.SelectedValue == "Select Course" && DropDownList2.SelectedValue == "Select Year" && DropDownList5.SelectedValue == "Select Semester" && DropDownList3.SelectedValue == "Select Subject" && TextBox1.Text == "")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList1.SelectedValue == "Select Course")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (TextBox1.Text == "")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList2.SelectedValue == "Select Year")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList3.SelectedValue == "Select Subject")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList5.SelectedValue == "Select Semester")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList1.SelectedValue == "Select Course" && DropDownList2.SelectedValue == "Select Year")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList1.SelectedValue == "Select Course" && DropDownList5.SelectedValue == "Select Semester")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList1.SelectedValue == "Select Course" && DropDownList3.SelectedValue == "Select Subject")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList1.SelectedValue == "Select Course" && TextBox1.Text == " ")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList2.SelectedValue == "Select Year" && DropDownList5.SelectedValue == "Select Semester")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList2.SelectedValue == "Select Year" && TextBox1.Text == " ")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList2.SelectedValue == "Select Year" && DropDownList3.SelectedValue == "Select Subject")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList5.SelectedValue == "Select Semester" && TextBox1.Text == " ")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (DropDownList5.SelectedValue == "Select Semester" && DropDownList3.SelectedValue == "Select Subject")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (TextBox1.Text == " " && DropDownList3.SelectedValue == "Select Subject")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else if (TextBox1.Text == " " && DropDownList3.SelectedValue == "Select Subject")
{
Label1.Text = "Plz Select All The Fields.";
Label1.ForeColor = System.Drawing.Color.Red;
}
else
{
string date = TextBox1.Text;
string course = DropDownList1.SelectedItem.Text;
string year = DropDownList2.SelectedItem.Text;
string subject = DropDownList3.SelectedItem.Text;
string sem = DropDownList5.SelectedItem.Text;
if (Session["TeacherID"] != null)
{
string teacherID = Session["TeacherID"].ToString();
SqlConnection con = new SqlConnection(str);
SqlDataAdapter sda = new SqlDataAdapter("select Date as Lecture_Date,LTaken as Lecture_Taken from T_Lectures where TID='" + teacherID + "' and Course='" + course + "' and Year='" + year + "' and Sem='" + sem + "' and Subject='" + subject + "' and Date='" + date + "' ", con);
DataSet ds = new DataSet();
sda.Fill(ds, "T_Lectures");
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
}
Thanks for Visiting:)
No comments
Please do not enter any spam link in the comment box.