protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null || Session["id"] == null || Session["type"] == null) { Session.RemoveAll(); Response.Redirect("expired.aspx"); } else { if (!this.IsPostBack) { mvedit.ActiveViewIndex = 0; } using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = (from i in db.Events select new { i.event_id, i.name, date = i.date.ToString() }).OrderBy(d => d.date); gvcalendar.DataSource = q; gvcalendar.DataBind(); } catch (Exception ex) { } } } }
protected void btnback_Click(object sender, EventArgs e) { mvsearch.ActiveViewIndex = 0; mvchats.ActiveViewIndex = 0; string id = Session["id"].ToString(); using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = (from i in db.messages join j in db.Students on i.student_id equals j.student_id where i.faculty_id == id select new { j.student_id, j.full_name, }).Distinct(); gvchats.DataSource = q; gvchats.DataBind(); } catch (Exception ex) { } } }
protected void btnadd_Click(object sender, EventArgs e) { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = from i in db.subjects where i.subject_name == txtname.Text && i.course == branch select i; if (q.Any()) { lbladderror.Text = "Subject already exists."; return; } subject s = new subject() { subject_name = txtnewname.Text, subject_description = txtnewdesc.Text, subject_credit = Convert.ToDecimal(txtnewcredit.Text), allotted_sem = Convert.ToInt32(txtnewsem.Text), course = branch }; db.subjects.InsertOnSubmit(s); db.SubmitChanges(); lbladderror.Text = "Subject Added Successfully."; Page_Load(sender, e); } catch (Exception ex) { } } }
protected void btnremove_Click(object sender, EventArgs e) { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var a = from i in db.Events where i.event_id == Convert.ToInt32(txtid.Text) && i.name == txtname.Text && i.date == Convert.ToDateTime(txtdate.Text) select i; if (!a.Any()) { lblediterror.Text = "Event doesn't exist."; return; } var q = (from i in db.Events where i.event_id == Convert.ToInt32(txtid.Text) select i).Single(); db.Events.DeleteOnSubmit(q); db.SubmitChanges(); lblediterror.Text = "Event Removed Successfully."; Page_Load(sender, e); } catch (Exception ex) { lblediterror.Text = "Event Removal Unsuccessful"; } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null || Session["id"] == null || Session["type"] == null) { Session.RemoveAll(); Response.Redirect("expired.aspx"); } else { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { if (!this.IsPostBack) { mvresults.ActiveViewIndex = 0; mvsearhbtn.ActiveViewIndex = 0; mvextrasubinternal.ActiveViewIndex = 0; mvexternalsubject.ActiveViewIndex = 0; mvnewsem.ActiveViewIndex = 0; mvadvancesemester.ActiveViewIndex = 0; btnsearch.Enabled = false; branch = (from i in db.Faculties where i.faculty_id == Session["id"].ToString() select i.branch).Single(); } } catch (Exception ex) { } } } }
protected void btnsend_Click(object sender, EventArgs e) { if (txtsem.Text == string.Empty || txtmessage.Text == string.Empty) { lblsenderror.Text = "All details are mandatory."; return; } else { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { notification n = new notification() { sem = Convert.ToInt32(txtsem.Text), notifdate = DateTime.Now, notif = txtmessage.Text }; db.notifications.InsertOnSubmit(n); db.SubmitChanges(); lblsenderror.Text = "Notification has been sent"; } catch (Exception ex) { } } } }
protected void btnsavedetails_Click(object sender, EventArgs e) { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = (from i in db.Students where i.student_id == stid select i).SingleOrDefault(); q.full_name = txtsfullname.Text; q.branch = txtsbranch.Text; q.batch = Convert.ToDecimal(txtsbatch.Text); q.seat = txtsseat.Text; q.yoc = Convert.ToDecimal(txtsyoc.Text); q.birthdate = Convert.ToDateTime(txtsbdate.Text); q.email_id = txtsemail.Text; q.contact_no = Convert.ToDecimal(txtscontact.Text); q.address = txtsaddress.Text; db.SubmitChanges(); lblsavedetailserror.Text = "Details successfully updated."; } catch (Exception ex) { } } }
protected void txtsem_TextChanged(object sender, EventArgs e) { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { sem = Convert.ToInt32(txtsem.Text); var q = (from i in db.Students join j in db.Semesters on i.student_id equals j.student_id where i.branch == branch && i.current_sem == j.sem && j.sem == sem select j.division).ToList(); q.Insert(0, "--select--"); ddlclass.DataSource = q; ddlclass.DataBind(); q.Clear(); q.Insert(0, "--select--"); ddlbatch.DataSource = q; ddlbatch.DataBind(); btnsearch.Enabled = true; } catch (Exception ex) { } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null || Session["id"] == null || Session["sem"] == null || Session["branch"] == null) { Session.RemoveAll(); Response.Redirect("expired.aspx"); } else { try { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { var q = (from i in db.Faculties where i.branch == "CE" select new { i.faculty_id, i.faculty_name, i.Designation, i.email_id }).OrderBy(d => d.faculty_name); gvprofs.DataSource = q; gvprofs.DataBind(); } } catch (Exception ex) { } } }
protected void btnsearch_Click(object sender, EventArgs e) { if (txtsearch.Text == "") { lblsearcherror.Text = "Search field empty."; return; } using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = (from i in db.Faculties where i.faculty_name.Equals(txtsearch.Text) || i.faculty_id.Equals(txtid.Text) select i).First(); txtid.Text = q.faculty_id.ToString(); txtfullname.Text = q.faculty_name.ToString(); txtemail.Text = q.email_id.ToString(); txtdesignation.Text = q.Designation.ToString(); txtcontact.Text = q.contact_no.ToString(); txtbranch.Text = q.branch.ToString(); txtbdate.Text = q.birthdate.ToString(); txtadd.Text = q.address.ToString(); } catch (Exception ex) { } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null || Session["id"] == null || Session["sem"] == null || Session["branch"] == null) { Session.RemoveAll(); Response.Redirect("expired.aspx"); } else { try { string id = Session["id"].ToString(); using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { var q = (from i in db.Students where i.student_id == id select i).Single(); lblname.Text = q.full_name.ToString(); lblid.Text = id; lblbranch.Text = q.branch.ToString(); lblbatch.Text = q.batch.ToString(); lblsem.Text = q.current_sem.ToString(); lblseat.Text = q.seat.ToString(); lblyoc.Text = (q.yoc.ToString() == "") ? "-------" : q.yoc.ToString(); lblbdate.Text = q.birthdate.ToString().Remove(11); lblcontact.Text = q.contact_no.ToString(); lbladdr.Text = q.address.ToString(); lblemail.Text = q.email_id.ToString(); } } catch (Exception ex) { } } }
protected void btnadd_Click(object sender, EventArgs e) { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = from i in db.Events where i.name == txtname.Text && i.date == Convert.ToDateTime(txtdate.Text) select i; if (q.Any()) { lbladderror.Text = "Event already exists."; return; } Event ev = new Event() { date = Convert.ToDateTime(txtdate.Text), name = txtnewevent.Text }; db.Events.InsertOnSubmit(ev); db.SubmitChanges(); lbladderror.Text = "Event Added Successfully."; Page_Load(sender, e); } catch (Exception ex) { } } }
protected void btnchange_Click(object sender, EventArgs e) { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = (from i in db.Faculties where i.faculty_id == txtid.Text select i).Single(); q.faculty_name = txtfullname.Text; q.branch = txtbranch.Text; q.Designation = txtdesignation.Text; q.birthdate = Convert.ToDateTime(txtbdate.Text); q.email_id = txtemail.Text; q.contact_no = Convert.ToDecimal(txtcontact.Text); q.address = txtadd.Text; db.SubmitChanges(); lblchangeerror.Text = "Changes have been made successfully"; } catch (Exception ex) { lblchangeerror.Text = "Changes could not be made. Please try again later."; } } }
protected void btnedit_Click(object sender, EventArgs e) { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = (from i in db.subjects where i.course == branch select i).Single(); q.subject_name = txtname.Text; q.subject_description = txtdesc.Text; q.subject_credit = Convert.ToDecimal(txtcredit.Text); q.allotted_sem = Convert.ToInt32(txtsem.Text); db.SubmitChanges(); lblediterror.Text = "Subject Modification Successful."; Page_Load(sender, e); } catch (Exception ex) { lblediterror.Text = "Subject Modification Unsuccessful"; } } }
protected void btnsearch_Click(object sender, EventArgs e) { if (txtsearch.Text == String.Empty) { lblerror.Text = "No text entered."; return; } else { string id = Session["id"].ToString(); using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = (from i in db.Students where (i.student_id.Contains(txtsearch.Text) || i.student_id.Contains(txtsearch.Text)) select new { i.student_id, i.full_name }).OrderBy(d => d.student_id).OrderBy(d => d.full_name); gvsearch.DataSource = q; gvsearch.DataBind(); mvsearch.ActiveViewIndex = 1; } catch (Exception ex) { } } } }
protected void btnsearch_Click(object sender, EventArgs e) { int sem = Convert.ToInt32(ddlsem.SelectedValue); int type = ddltype.SelectedItem.Text == "Internal" ? 0 : 1; string id = Session["id"].ToString(); using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { int sid = Convert.ToInt32((from i in db.Semesters where i.student_id == id && i.sem == sem select i.sem_id).Single()); if (type == 0) { var q = from i in db.sessions join j in db.InternalMarks on i.session_id equals j.session_id join k in db.subjects on j.subject_id equals k.subject_id where i.sem_id == sid select new { k.subject_id, k.subject_name, j.marks1, j.marks2, j.marks3, j.bmarks, j.rmarks }; gvinternal.DataSource = q; gvinternal.DataBind(); mvres.ActiveViewIndex = 1; } else if (type == 1) { var q = from i in db.ExternalMarks join j in db.subjects on i.subject_id equals j.subject_id where i.sem_id == sid select new { i.subject_id, j.subject_name, i.pract_marks, j.subject_credit, i.grade, i.status, }; gvexternal.DataSource = q; gvexternal.DataBind(); mvres.ActiveViewIndex = 2; } } catch (Exception ex) { } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null || Session["id"] == null || Session["type"] == null) { Session.RemoveAll(); Response.Redirect("expired.aspx"); } else { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { if (!this.IsPostBack) { mvsearhbtn.ActiveViewIndex = 0; mvresults.ActiveViewIndex = 0; btnsearch.Enabled = false; branch = (from i in db.Faculties where i.faculty_id == Session["id"].ToString() select i.branch).Single(); if (Session["type"].ToString() == "a") { txtsaddress.ReadOnly = false; txtsbatch.ReadOnly = false; txtsbdate.ReadOnly = false; txtsbranch.ReadOnly = false; txtscontact.ReadOnly = false; txtsfullname.ReadOnly = false; txtsemail.ReadOnly = false; txtsyoc.ReadOnly = false; txtsseat.ReadOnly = false; mvsavedetails.ActiveViewIndex = 1; } else { txtsaddress.ReadOnly = true; txtsbatch.ReadOnly = true; txtsbdate.ReadOnly = true; txtsbranch.ReadOnly = true; txtscontact.ReadOnly = true; txtsfullname.ReadOnly = true; txtsemail.ReadOnly = true; txtsyoc.ReadOnly = true; txtsseat.ReadOnly = true; mvsavedetails.ActiveViewIndex = 0; } } }catch (Exception ex) { } } } }
protected void btnsearch_Click(object sender, EventArgs e) { if (txtsem.Text == string.Empty) { lblsearcherror.Text = "Semester detail is compulsory."; return; } using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { sem = Convert.ToInt32(txtsem.Text); cs = (ddlclass.SelectedItem.Text == "--select--")?"":ddlclass.SelectedItem.Text; batch = (ddlbatch.SelectedItem.Text == "--select--")?"":ddlbatch.SelectedItem.Text; var q = (from i in db.Students join j in db.Semesters on i.student_id equals j.student_id where i.current_sem == j.sem && i.current_sem == sem && i.branch == branch select new { i.student_id, i.full_name, j.division, j.batch }).ToList(); if (cs != string.Empty) { foreach (var i in q) { if (i.division == cs) { if (batch != string.Empty) { if (i.batch != batch) { q.Remove(i); } } } else { q.Remove(i); } } } gvsearch.DataSource = q; gvsearch.DataBind(); mvresults.ActiveViewIndex = 1; } catch (Exception ex) { } } }
protected void LinkButton1_Click(object sender, EventArgs e) { try { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { var q = from i in db.skippeds where i.student_id == id && i.sem == sem && i.skipdate == DateTime.Now.Date && i.skipped1 == lblcurlec.Text select i; if (q.Any()) { lblskippederror.Text = "You have already skipped this session."; } else { skipped s = new skipped { student_id = id, sem = sem, skipdate = DateTime.Now.Date, skipped1 = lblcurlec.Text, }; db.skippeds.InsertOnSubmit(s); db.SubmitChanges(); var semid = (from i in db.Semesters where i.student_id == Session["id"].ToString() && i.sem == sem select i.sem_id).ToList().Last(); var eta = (from i in db.sessions where i.sem_id == semid select i).SingleOrDefault(); eta.est_attendance = eta.est_attendance - 1; db.SubmitChanges(); double attendance = Convert.ToDouble(eta.est_attendance) / 3; int nl = (from i in db.skippeds where i.student_id == id && i.sem == sem && i.skipdate == DateTime.Now.Date select i).Count(); lblskipped.Text = "You have skipped " + nl + " sessions today."; lblestattendance.Text = "Est. Attendance : " + attendance + "%"; } } } catch (Exception ex) { } }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null || Session["id"] == null || Session["type"] == null) { Session.RemoveAll(); Response.Redirect("expired.aspx"); } else { if (!this.IsPostBack) { mvchats.ActiveViewIndex = 0; mvsearch.ActiveViewIndex = 0; lblerror.Text = ""; lblnoresults.Text = ""; } string id = Session["id"].ToString(); using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = (from i in db.messages join j in db.Students on i.student_id equals j.student_id where i.faculty_id == id select new { j.student_id, j.full_name, }).Distinct(); var m = (from i in db.m_lastaccesseds where i.student_id == id select i).Single(); DateTime la = Convert.ToDateTime(m.lastaccesssed); m.lastaccesssed = DateTime.Now; names = (from i in db.messages where i.faculty_id == id && Convert.ToDateTime(i.sent_time).CompareTo(la) > 0 && i.type == 'r' select i.student_id).ToList(); gvchats.DataSource = q; gvchats.DataBind(); Session["messagecount"] = 0; } catch (Exception ex) { } } } }
protected void gvcalendar_SelectedIndexChanged(object sender, EventArgs e) { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { mvedit.ActiveViewIndex = 1; txtid.Text = gvcalendar.SelectedRow.Cells[1].Text; txtname.Text = gvcalendar.SelectedRow.Cells[2].Text; txteditdate.Text = gvcalendar.SelectedRow.Cells[3].Text; } catch (Exception ex) { } } }
protected void txtattendance_TextChanged(object sender, EventArgs e) { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = (from i in db.sessions where i.session_id == sessid select i).SingleOrDefault(); q.attendance = Convert.ToDecimal(txtattendance.Text); db.SubmitChanges(); } catch (Exception ex) { } } }
protected void gvsearch_SelectedIndexChanged(object sender, EventArgs e) { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { stid = gvsearch.SelectedRow.Cells[1].Text; mvresults.ActiveViewIndex = 2; mvsearhbtn.ActiveViewIndex = 1; mvadvancesemester.ActiveViewIndex = 1; loadresults(); loadextresults(); } catch (Exception ex) { } } }
protected void btnpass_Click(object sender, EventArgs e) { mvnewsem.ActiveViewIndex = 1; txtattendance.ReadOnly = true; btnpass.Visible = false; using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var qin = from i in db.InternalMarks where i.session_id == sessid select new { i.subject.subject_name, i.marks1, i.marks2, i.marks3, i.bmarks, i.rmarks }; gvinternals.DataSource = qin; gvinternals.DataBind(); var qex = from i in db.ExternalMarks where i.sem_id == semid select new { i.subject.subject_name, i.marks, i.pract_marks, i.rem_1, i.rem_2, i.grade, i.status }; gvexterals.DataSource = qex; gvexterals.DataBind(); } catch (Exception ex) { } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null || Session["id"] == null || Session["sem"] == null || Session["branch"] == null) { Session.RemoveAll(); Response.Redirect("expired.aspx"); } else { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { string id = Session["id"].ToString(); int sem = Convert.ToInt32(Session["sem"]); DateTime today = DateTime.Now.AddDays(-30); var la = (from i in db.n_lastaccesseds where i.student_id == id select i).Single(); date = Convert.ToDateTime(la.lastaccessed); var q = (from i in db.notifications where (i.sem == sem || i.sem == null) && Convert.ToDateTime(i.notifdate).CompareTo(today) > 0 select new { i.notif, i.notifdate }).OrderByDescending(d => d.notifdate); gvnotifications.DataSource = q; gvnotifications.DataBind(); la.lastaccessed = DateTime.Now; db.SubmitChanges(); Session["notifcount"] = 0; } catch (Exception ex) { } } } }
protected void loadresults() { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = (from i in db.Students where i.student_id == stid select i).SingleOrDefault(); txtsstid.Text = q.student_id.ToString(); txtsyoc.Text = q.yoc.ToString(); txtsfullname.Text = q.full_name.ToString(); txtsemail.Text = q.email_id.ToString(); txtscontact.Text = q.contact_no.ToString(); txtsbranch.Text = q.branch.ToString(); txtsbdate.Text = q.birthdate.ToString().Remove(10); txtsbatch.Text = q.batch.ToString(); txtsaddress.Text = q.address.ToString(); txtsseat.Text = q.seat.ToString(); mvres.ActiveViewIndex = 0; List <string> type = new List <string>() { "Internal", "External" }; ddltype.DataSource = type; ddltype.DataBind(); var q1 = from i in db.Semesters where i.student_id == stid select i.sem; ddlsem.DataSource = q1; ddlsem.DataBind(); } catch (Exception ex) { } } }
protected void btnsend_Click(object sender, EventArgs e) { string id = Session["id"].ToString(); if (txtmessage.Text == string.Empty) { return; } else { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { message m = new message() { faculty_id = id, student_id = fid, message1 = txtmessage.Text, sent_time = DateTime.Now, type = 'r' }; db.messages.InsertOnSubmit(m); db.SubmitChanges(); var q = (from i in db.messages where i.student_id == fid && i.faculty_id == id select new { a = (i.type == 'r') ? "Sent" : "Received", i.message1, i.sent_time }).OrderBy(d => d.sent_time); gvmessage.DataSource = q; gvmessage.DataBind(); } catch (Exception ex) { } } } }
protected void btnedit_Click(object sender, EventArgs e) { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { var q = (from i in db.Events where i.event_id == Convert.ToInt32(txtid.Text) select i).Single(); q.name = txtname.Text; q.date = Convert.ToDateTime(txteditdate.Text); db.SubmitChanges(); lblediterror.Text = "Event Modification Successful."; Page_Load(sender, e); } catch (Exception ex) { lblediterror.Text = "Event Modification Unsuccessful"; } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null || Session["id"] == null || Session["type"] == null) { Session.RemoveAll(); Response.Redirect("expired.aspx"); } else { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { branch = (from i in db.Faculties where i.faculty_id == Session["id"].ToString() select i.branch).SingleOrDefault(); } catch (Exception ex) { } } } }
protected void ddlclass_SelectedIndexChanged(object sender, EventArgs e) { using (DepartmentPortalDataContext db = new DepartmentPortalDataContext()) { try { cs = ddlclass.SelectedItem.Text; var q = (from i in db.Students join j in db.Semesters on i.student_id equals j.student_id where i.branch == branch && i.current_sem == j.sem && j.sem == sem && j.division == cs select j.batch).ToList(); q.Insert(0, "--select--"); ddlbatch.DataSource = q; ddlbatch.DataBind(); } catch (Exception ex) { } } }