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 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 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";
                }
            }
        }
Exemplo n.º 5
0
        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) { }
            }
        }
Exemplo n.º 6
0
        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) { }
            }
        }
Exemplo n.º 7
0
        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 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) { }
         }
     }
 }
Exemplo n.º 9
0
        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) { }
            }
        }
Exemplo n.º 10
0
        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 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) { }
                }
            }
        }
Exemplo n.º 12
0
 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 btnadd_Click(object sender, EventArgs e)
        {
            using (DepartmentPortalDataContext db = new DepartmentPortalDataContext())
            {
                try
                {
                    var id = (from i in db.Students
                              select i.Id).ToList().LastOrDefault();
                    id++;
                    string  stid = txtsnewbatch.Text.Substring(2) + txtsnewbranch.Text + "U" + txtsnewseat.Text + "0" + id;
                    decimal yoc1 = Convert.ToDecimal(txtsnewbatch.Text) + 4;
                    Student s    = new Student()
                    {
                        student_id  = stid,
                        password    = txtsnewfname.Text,
                        full_name   = txtsnewfname.Text,
                        branch      = txtsnewbranch.Text,
                        batch       = Convert.ToDecimal(txtsnewbatch.Text),
                        seat        = txtsnewseat.Text,
                        current_sem = 1,
                        yoc         = yoc1,
                        birthdate   = Convert.ToDateTime(txtsnewbdate.Text),
                        email_id    = txtsnewemail.Text,
                        contact_no  = Convert.ToDecimal(txtsnewcontact.Text),
                        address     = txtsnewaddress.Text,
                    };

                    db.Students.InsertOnSubmit(s);
                    db.SubmitChanges();

                    lbladderror.Text = "Student has been added. ID = " + stid;
                }
                catch (Exception ex)
                {
                    lbladderror.Text = "Could not add student. please try again later";
                }
            }
        }
        protected void btnfadd_Click(object sender, EventArgs e)
        {
            using (DepartmentPortalDataContext db = new DepartmentPortalDataContext())
            {
                try
                {
                    var id = (from i in db.Faculties
                              select i.id).ToList().LastOrDefault();
                    id++;
                    string ftid = txtfbranch.Text + id;

                    Faculty f = new Faculty()
                    {
                        faculty_id   = ftid,
                        password     = txtfnewname.Text,
                        faculty_name = txtfnewname.Text,
                        user_type    = Convert.ToChar(txtfnewtype.Text),
                        branch       = txtfbranch.Text,
                        Designation  = txtfnewdesig.Text,
                        birthdate    = Convert.ToDateTime(txtfnewbdate.Text),
                        email_id     = txtfnewemail.Text,
                        contact_no   = Convert.ToDecimal(txtfnewcontact.Text),
                        address      = txtfnewadd.Text,
                    };

                    db.Faculties.InsertOnSubmit(f);
                    db.SubmitChanges();

                    lblfadderror.Text = "Faculty has been added. ID = " + ftid;
                }
                catch (Exception ex)
                {
                    lblfadderror.Text = "Could not add faculty. Please try again later";
                }
            }
        }
        protected void btnsubmit_Click(object sender, EventArgs e)
        {
            using (DepartmentPortalDataContext db = new DepartmentPortalDataContext())
            {
                try
                {
                    var q = from i in db.DailyTTs
                            where i.sem == Convert.ToInt32(ddlsem.SelectedItem.Value) &&
                            i.branch == ddlbranch.SelectedItem.Value &&
                            i.division == txtdiv.Text
                            select i;

                    if (!q.Any())
                    {
                        DailyTT dtt = new DailyTT()
                        {
                            sem      = Convert.ToInt32(ddlsem.SelectedItem.Value),
                            branch   = ddlbranch.SelectedItem.Value,
                            division = txtdiv.Text,
                            s1_dur   = txts1durfrom.Text + "-" + txts1durto.Text,
                            s2_dur   = txts2durfrom.Text + "-" + txts2durto.Text,
                            s3_dur   = txts3durfrom.Text + "-" + txts3durto.Text,
                            s4_dur   = txts4durfrom.Text + "-" + txts4durto.Text,
                            s5_dur   = txts5durfrom.Text + "-" + txts5durto.Text,
                            s6_dur   = txts6durfrom.Text + "-" + txts6durto.Text,
                            s7_dur   = txts7durfrom.Text + "-" + txts7durto.Text,
                            s1_type  = txts1subname.Text == "" ? null : (cbks1lab.Checked ? "b" : "l"),
                            s2_type  = txts2subname.Text == "" ? null : (cbks2lab.Checked ? "b" : "l"),
                            s3_type  = txts3subname.Text == "" ? null : (cbks3lab.Checked ? "b" : "l"),
                            s4_type  = txts4subname.Text == "" ? null : (cbks4lab.Checked ? "b" : "l"),
                            s5_type  = txts5subname.Text == "" ? null : (cbks5lab.Checked ? "b" : "l"),
                            s6_type  = txts6subname.Text == "" ? null : (cbks6lab.Checked ? "b" : "l"),
                            s7_type  = txts7subname.Text == "" ? null : (cbks7lab.Checked ? "b" : "l"),
                        };
                        db.DailyTTs.InsertOnSubmit(dtt);
                        db.SubmitChanges();
                    }
                    else
                    {
                        lblsubmiterror.Text = "TimeTable already exists.";
                    }

                    var ttid = Convert.ToInt32((from i in db.DailyTTs
                                                where i.sem == Convert.ToInt32(ddlsem.SelectedItem.Value) &&
                                                i.branch == ddlbranch.SelectedItem.Value &&
                                                i.division == txtdiv.Text
                                                select i.tt_Id).ToList().Last());


                    var q1 = from i in db.lecTTs
                             where i.tt_id == ttid && i.day == ddlday.SelectedItem.Value
                             select i;

                    if (!q1.Any())
                    {
                        lecTT ltt = new lecTT()
                        {
                            tt_id = ttid,
                            day   = ddlday.SelectedItem.Value,
                            s1    = cbks1lab.Checked ? null : txts1subname.Text,
                            f1    = cbks1lab.Checked ? null : txts1facname.Text,
                            s2    = cbks2lab.Checked ? null : txts2subname.Text,
                            f2    = cbks2lab.Checked ? null : txts2facname.Text,
                            s3    = cbks3lab.Checked ? null : txts3subname.Text,
                            f3    = cbks3lab.Checked ? null : txts3facname.Text,
                            s4    = cbks4lab.Checked ? null : txts4subname.Text,
                            f4    = cbks4lab.Checked ? null : txts4facname.Text,
                            s5    = cbks5lab.Checked ? null : txts5subname.Text,
                            f5    = cbks5lab.Checked ? null : txts5facname.Text,
                            s6    = cbks6lab.Checked ? null : txts6subname.Text,
                            f6    = cbks6lab.Checked ? null : txts6facname.Text,
                            s7    = cbks7lab.Checked ? null : txts7subname.Text,
                            f7    = cbks7lab.Checked ? null : txts7facname.Text
                        };

                        db.lecTTs.InsertOnSubmit(ltt);

                        List <string> lecs = new List <string>();
                        List <string> facs = new List <string>();

                        if (cbks1lab.Checked)
                        {
                            lecs.Add(txts1subname.Text); facs.Add(txts1facname.Text);
                        }
                        if (cbks2lab.Checked)
                        {
                            lecs.Add(txts2subname.Text); facs.Add(txts2facname.Text);
                        }
                        if (cbks3lab.Checked)
                        {
                            lecs.Add(txts3subname.Text); facs.Add(txts3facname.Text);
                        }
                        if (cbks4lab.Checked)
                        {
                            lecs.Add(txts4subname.Text); facs.Add(txts4facname.Text);
                        }
                        if (cbks5lab.Checked)
                        {
                            lecs.Add(txts5subname.Text); facs.Add(txts5facname.Text);
                        }
                        if (cbks6lab.Checked)
                        {
                            lecs.Add(txts6subname.Text); facs.Add(txts6facname.Text);
                        }
                        if (cbks7lab.Checked)
                        {
                            lecs.Add(txts7subname.Text); facs.Add(txts7facname.Text);
                        }

                        int    n = lecs.Count();
                        lab_tt btt;
                        for (int i = 0; i < n; i++)
                        {
                            btt = new lab_tt()
                            {
                                tt_id = ttid,
                                day   = ddlday.SelectedItem.Value,
                                s1    = "LAB - " + lecs[i],
                                f1    = facs[i],
                                b1    = txtbatch.Text,
                            };
                            db.lab_tts.InsertOnSubmit(btt);
                        }

                        db.SubmitChanges();
                        lblsubmiterror.Text = "TimeTable has been successfully generated.";
                    }
                    else
                    {
                        lblsubmiterror.Text = "TimeTable already exists.";
                    }
                }
                catch (Exception ex)
                {
                    lblsubmiterror.Text = "TimeTable could not be generated.";
                }
            }
        }
Exemplo n.º 16
0
        protected void btnlogin_Click(object sender, EventArgs e)
        {
            if (txtid.Text == "" || txtpass.Text == "")
            {
                lblerror.Text = "All details are mandatory.";
                return;
            }
            else
            {
                ExampleCaptcha.UserInputID = CaptchaCodeTextBox.ClientID;
                if (IsPostBack)
                {
                    bool isHuman = ExampleCaptcha.Validate(CaptchaCodeTextBox.Text);
                    CaptchaCodeTextBox.Text = null;
                    if (!isHuman)
                    {
                        lblerror.Text = "Incorrect Captcha.";
                    }
                    else
                    {
                        try
                        {
                            using (DepartmentPortalDataContext db = new DepartmentPortalDataContext())
                            {
                                if (!idflag)
                                {
                                    var q = from i in db.Students
                                            where i.student_id == txtid.Text && i.password == txtpass.Text
                                            select i;

                                    if (q.Any())
                                    {
                                        foreach (var i in q)
                                        {
                                            Session["id"]       = i.student_id;
                                            Session["username"] = i.full_name;
                                            Session["sem"]      = i.current_sem;
                                            Session["branch"]   = i.branch;

                                            DateTime today = DateTime.Now;
                                            today = today.AddDays(-1);

                                            var ev = from j in db.Events
                                                     where today.CompareTo(j.date) < 0
                                                     select j;

                                            var notifs = (from j in db.notifications
                                                          where today.CompareTo(j.notifdate) < 0
                                                          select j.notif).ToList();

                                            foreach (var k in ev)
                                            {
                                                string msg = "Tomorrow is " + k.name;
                                                if (!notifs.Contains(msg))
                                                {
                                                    notification n = new notification()
                                                    {
                                                        notifdate = DateTime.Now,
                                                        notif     = msg
                                                    };
                                                    db.notifications.InsertOnSubmit(n);
                                                    db.SubmitChanges();
                                                }
                                            }


                                            Response.Redirect("studenthome.aspx");
                                        }
                                    }
                                    else
                                    {
                                        lblerror.Text = "Incorrect Credentials. Please try again.";
                                    }
                                }
                                else
                                {
                                    var q = from i in db.Faculties
                                            where i.faculty_id == txtid.Text && i.password == txtpass.Text
                                            select i;

                                    if (q.Any())
                                    {
                                        foreach (var i in q)
                                        {
                                            Session["id"]       = i.faculty_id;
                                            Session["username"] = i.faculty_name;
                                            Session["type"]     = i.user_type;

                                            Response.Redirect("facultyprofile.aspx");
                                        }
                                    }
                                    else
                                    {
                                        lblerror.Text = "Incorrect Credentials. Please try again.";
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            lblerror.Text = "Exception";
                        }
                    }
                }
            }
        }
        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)
                        {
                            var q = (from i in db.Faculties
                                     where i.faculty_id == Session["id"].ToString()
                                     select i).Single();
                            txtbdate.Text       = q.birthdate.ToString().Remove(10);
                            txtbranch.Text      = q.branch.ToString();
                            txtcontact.Text     = q.contact_no.ToString();
                            txtdesignation.Text = q.Designation.ToString();
                            txtemail.Text       = q.email_id.ToString();
                            txtfullname.Text    = q.faculty_name.ToString();
                            txtid.Text          = q.faculty_id.ToString();
                            txtadd.Text         = q.address.ToString();


                            var la = from i in db.m_lastaccesseds
                                     where i.student_id == Session["id"].ToString()
                                     select i;

                            if (!la.Any())
                            {
                                m_lastaccessed mla = new m_lastaccessed()
                                {
                                    student_id    = Session["id"].ToString(),
                                    lastaccesssed = DateTime.Now
                                };
                                db.m_lastaccesseds.InsertOnSubmit(mla);
                                db.SubmitChanges();
                            }

                            var      la1 = la.Single();
                            DateTime lat = Convert.ToDateTime(la1.lastaccesssed);

                            Session["messagecount"] = (from i in db.messages
                                                       where lat.CompareTo(i.sent_time) < 0
                                                       select i).Count();
                        }

                        if (Session["type"].ToString() == "f")
                        {
                            mvbutton.ActiveViewIndex = 0;
                            mvsearch.ActiveViewIndex = 0;
                            mvaddnew.ActiveViewIndex = 0;
                        }
                        else if (Session["type"].ToString() == "a")
                        {
                            mvbutton.ActiveViewIndex = 1;
                            mvsearch.ActiveViewIndex = 1;
                            mvaddnew.ActiveViewIndex = 1;

                            txtbdate.ReadOnly       = false;
                            txtbranch.ReadOnly      = false;
                            txtcontact.ReadOnly     = false;
                            txtdesignation.ReadOnly = false;
                            txtemail.ReadOnly       = false;
                            txtfullname.ReadOnly    = false;
                            txtadd.ReadOnly         = false;
                        }
                    }
                    catch (Exception ex) { }
                }
            }
        }
Exemplo n.º 18
0
        protected void btnsave_Click(object sender, EventArgs e)
        {
            using (DepartmentPortalDataContext db = new DepartmentPortalDataContext())
            {
                try
                {
                    var q1 = (from i in db.InternalMarks
                              where i.session_id == sessid && i.subject.subject_name == subname[0]
                              select i).SingleOrDefault();
                    q1.marks1 = Convert.ToInt32(txts1m1.Text == ""?"-1":txts1m1.Text);
                    q1.marks2 = Convert.ToInt32(txts1m2.Text == "" ? "-1" : txts1m2.Text);
                    q1.marks3 = Convert.ToInt32(txts1m3.Text == "" ? "-1" : txts1m3.Text);
                    q1.bmarks = Convert.ToInt32(txts1bm.Text == "" ? "-1" : txts1bm.Text);
                    q1.rmarks = Convert.ToInt32(txts1rm.Text == "" ? "-1" : txts1rm.Text);

                    var q2 = (from i in db.InternalMarks
                              where i.session_id == sessid && i.subject.subject_name == subname[1]
                              select i).SingleOrDefault();
                    q2.marks1 = Convert.ToInt32(txts2m1.Text == "" ? "-1" : txts2m1.Text);
                    q2.marks2 = Convert.ToInt32(txts2m2.Text == "" ? "-1" : txts2m2.Text);
                    q2.marks3 = Convert.ToInt32(txts2m3.Text == "" ? "-1" : txts2m3.Text);
                    q2.bmarks = Convert.ToInt32(txts2bm.Text == "" ? "-1" : txts2bm.Text);
                    q2.rmarks = Convert.ToInt32(txts2rm.Text == "" ? "-1" : txts2rm.Text);

                    var q3 = (from i in db.InternalMarks
                              where i.session_id == sessid && i.subject.subject_name == subname[2]
                              select i).SingleOrDefault();
                    q3.marks1 = Convert.ToInt32(txts3m1.Text == "" ? "-1" : txts3m1.Text);
                    q3.marks2 = Convert.ToInt32(txts3m2.Text == "" ? "-1" : txts3m2.Text);
                    q3.marks3 = Convert.ToInt32(txts3m3.Text == "" ? "-1" : txts3m3.Text);
                    q3.bmarks = Convert.ToInt32(txts3bm.Text == "" ? "-1" : txts3bm.Text);
                    q3.rmarks = Convert.ToInt32(txts3rm.Text == "" ? "-1" : txts3rm.Text);

                    var q4 = (from i in db.InternalMarks
                              where i.session_id == sessid && i.subject.subject_name == subname[3]
                              select i).SingleOrDefault();
                    q4.marks1 = Convert.ToInt32(txts4m1.Text == "" ? "-1" : txts4m1.Text);
                    q4.marks2 = Convert.ToInt32(txts4m2.Text == "" ? "-1" : txts4m2.Text);
                    q4.marks3 = Convert.ToInt32(txts4m3.Text == "" ? "-1" : txts4m3.Text);
                    q4.bmarks = Convert.ToInt32(txts4bm.Text == "" ? "-1" : txts4bm.Text);
                    q4.rmarks = Convert.ToInt32(txts4rm.Text == "" ? "-1" : txts4rm.Text);

                    var q5 = (from i in db.InternalMarks
                              where i.session_id == sessid && i.subject.subject_name == subname[4]
                              select i).SingleOrDefault();
                    q5.marks1 = Convert.ToInt32(txts5m1.Text == "" ? "-1" : txts5m1.Text);
                    q5.marks2 = Convert.ToInt32(txts5m2.Text == "" ? "-1" : txts5m2.Text);
                    q5.marks3 = Convert.ToInt32(txts5m3.Text == "" ? "-1" : txts5m3.Text);
                    q5.bmarks = Convert.ToInt32(txts5bm.Text == "" ? "-1" : txts5bm.Text);
                    q5.rmarks = Convert.ToInt32(txts5rm.Text == "" ? "-1" : txts5rm.Text);

                    if (count == 6)
                    {
                        var q6 = (from i in db.InternalMarks
                                  where i.session_id == sessid && i.subject.subject_name == subname[5]
                                  select i).SingleOrDefault();
                        q6.marks1 = Convert.ToInt32(txts6m1.Text == "" ? "-1" : txts6m1.Text);
                        q6.marks2 = Convert.ToInt32(txts6m2.Text == "" ? "-1" : txts6m2.Text);
                        q6.marks3 = Convert.ToInt32(txts6m3.Text == "" ? "-1" : txts6m3.Text);
                        q6.bmarks = Convert.ToInt32(txts6bm.Text == "" ? "-1" : txts6bm.Text);
                        q6.rmarks = Convert.ToInt32(txts6rm.Text == "" ? "-1" : txts6rm.Text);
                    }

                    db.SubmitChanges();

                    lblsaveerror.Text = "Changes have been made.";
                    loadresults();
                }
                catch (Exception ex) { }
            }
        }
Exemplo n.º 19
0
        protected void btncreate_Click(object sender, EventArgs e)
        {
            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();


                    int   newsemid, newcount;
                    int[] newsubs;

                    if (cbkattempt.Checked == false)
                    {
                        Semester s = new Semester()
                        {
                            student_id = stid,
                            sem        = sem + 1,
                            roll_no    = Convert.ToInt32(txtrollno.Text),
                            attempt    = 0,
                            division   = txtdiv.Text,
                            batch      = txtbatch.Text
                        };
                        db.Semesters.InsertOnSubmit(s);
                        var q = (from i in db.Students
                                 where i.student_id == stid
                                 select i).SingleOrDefault();

                        int cursem = Convert.ToInt32(q.current_sem) + 1;
                        q.current_sem++;
                        db.SubmitChanges();

                        newsemid = (from i in db.Semesters
                                    where i.student_id == stid
                                    select i.sem_id).ToList().LastOrDefault();

                        newsubs = (from i in db.subjects
                                   where i.allotted_sem == cursem
                                   select i.subject_id).ToArray();
                        newcount = newsubs.Length;
                    }
                    else
                    {
                        int at = Convert.ToInt32((from i in db.Semesters
                                                  where i.sem_id == semid
                                                  select i.attempt).SingleOrDefault());

                        Semester s = new Semester()
                        {
                            student_id = stid,
                            sem        = sem,
                            roll_no    = Convert.ToInt32(txtrollno.Text),
                            attempt    = at + 1,
                            division   = txtdiv.Text,
                            batch      = txtbatch.Text
                        };
                        db.Semesters.InsertOnSubmit(s);

                        newsemid = (from i in db.Semesters
                                    where i.student_id == stid
                                    select i.sem_id).ToList().LastOrDefault();

                        newsubs = (from i in db.subjects
                                   where i.allotted_sem == sem && i.course == branch
                                   select i.subject_id).ToArray();

                        newcount = newsubs.Length;
                    }



                    ExternalMark ex;

                    for (int j = 0; j < newcount; j++)
                    {
                        ex = new ExternalMark()
                        {
                            sem_id      = newsemid,
                            subject_id  = newsubs[j],
                            marks       = -1,
                            pract_marks = -1,
                            rem_1       = -1,
                            rem_2       = -1,
                            grade       = "-1",
                            status      = "-1"
                        };
                        db.ExternalMarks.InsertOnSubmit(ex);
                        db.SubmitChanges();
                    }



                    session ss = new session()
                    {
                        sem_id         = newsemid,
                        session_type   = 'n',
                        attendance     = 0,
                        est_attendance = 0
                    };
                    db.sessions.InsertOnSubmit(ss);
                    db.SubmitChanges();

                    var newsessid = (from i in db.sessions
                                     where i.sem_id == newsemid
                                     select i.session_id).ToList().LastOrDefault();

                    InternalMark m;

                    for (int j = 0; j < newcount; j++)
                    {
                        m = new InternalMark()
                        {
                            subject_id = newsubs[j],
                            session_id = newsessid,
                            marks1     = -1,
                            marks2     = -1,
                            marks3     = -1,
                            rmarks     = -1,
                            bmarks     = -1,
                        };
                        db.InternalMarks.InsertOnSubmit(m);
                        db.SubmitChanges();
                    }

                    lblcreateerror.Text = "Student's semester has been incremented.";
                }
                catch (Exception ex) { }
            }
        }
Exemplo n.º 20
0
        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
            {
                lblday.Text = DateTime.Now.DayOfWeek.ToString() + ", " + DateTime.Now.Date.ToString().Substring(0, 9);
                sem         = Convert.ToInt32(Session["sem"]);
                branch      = Session["branch"].ToString();
                id          = Session["id"].ToString();

                try
                {
                    using (DepartmentPortalDataContext db = new DepartmentPortalDataContext())
                    {
                        if (!this.IsPostBack)
                        {
                            lbtnskip.Visible     = false;
                            lblskippederror.Text = "";

                            var lat = from i in db.n_lastaccesseds
                                      where i.student_id == id
                                      select i.lastaccessed;

                            var mlat = from i in db.m_lastaccesseds
                                       where i.student_id == id
                                       select i.lastaccesssed;

                            if (!mlat.Any())
                            {
                                m_lastaccessed m = new m_lastaccessed()
                                {
                                    student_id    = id,
                                    lastaccesssed = DateTime.Now
                                };
                                db.m_lastaccesseds.InsertOnSubmit(m);
                                db.SubmitChanges();
                            }


                            if (!lat.Any())
                            {
                                n_lastaccessed n = new n_lastaccessed()
                                {
                                    student_id   = id,
                                    lastaccessed = DateTime.Now
                                };
                                db.n_lastaccesseds.InsertOnSubmit(n);
                                db.SubmitChanges();
                            }

                            DateTime la = Convert.ToDateTime(lat.Single());
                            DateTime ma = Convert.ToDateTime(mlat.Single());

                            Session["messagecount"] = (from i in db.messages
                                                       where i.student_id == id && ma.CompareTo(i.sent_time) < 0
                                                       select i).Count();

                            Session["notifcount"] = (from i in db.notifications
                                                     where i.sem == sem && Convert.ToDateTime(i.notifdate).CompareTo(la) > 0
                                                     select i).Count();
                        }


                        cs = (from i in db.Semesters
                              where i.student_id == id && i.sem == sem
                              select i.division).Single().ToString();

                        batch = (from i in db.Semesters
                                 where i.student_id == id && i.sem == sem
                                 select i.batch).Single().ToString();

                        var q = (from i in db.DailyTTs
                                 where i.sem == sem && i.branch == branch && i.division == cs
                                 select new
                        {
                            a = i.s1_dur,
                            b = i.s2_dur,
                            c = i.s3_dur,
                            d = i.s4_dur,
                            e = i.s5_dur,
                            f = i.s6_dur,
                            g = i.s7_dur
                        }).Single();

                        head = new String[7];

                        head[0] = q.a;
                        head[1] = q.b;
                        head[2] = q.c;
                        head[3] = q.d;
                        head[4] = q.e;
                        head[5] = q.f;
                        head[6] = q.g;

                        int ttid = 0;
                        int lab  = 0;

                        var q1 = (from i in db.DailyTTs
                                  where i.sem == sem && i.branch == branch && i.division == cs
                                  select i).Single();

                        if (q1.s1_type.Contains("b"))
                        {
                            lab = 1;
                        }
                        else if (q1.s2_type.Contains("b"))
                        {
                            lab = 2;
                        }
                        else if (q1.s3_type.Contains("b"))
                        {
                            lab = 3;
                        }
                        else if (q1.s4_type.Contains("b"))
                        {
                            lab = 4;
                        }
                        else if (q1.s5_type.Contains("b"))
                        {
                            lab = 5;
                        }
                        else if (q1.s6_type.Contains("b"))
                        {
                            lab = 6;
                        }
                        else if (q1.s7_type.Contains("b"))
                        {
                            lab = 7;
                        }
                        else
                        {
                            lab = 0;
                        }
                        ttid = q1.tt_Id;

                        var q2 = from i in db.lab_tts
                                 join j in db.lecTTs on i.tt_id equals j.tt_id
                                 where i.tt_id == ttid && i.b1 == batch && i.day == j.day
                                 select new
                        {
                            i.day,
                            a = (lab == 1) ? i.s1 + "\n" + i.f1 : j.s1 + "\n" + j.f1,
                            b = (lab == 2) ? i.s1 + "\n" + i.f1 : j.s2 + "\n" + j.f2,
                            c = (lab == 3) ? i.s1 + "\n" + i.f1 : j.s3 + "\n" + j.f3,
                            d = (lab == 4) ? i.s1 + "\n" + i.f1 : j.s4 + "\n" + j.f4,
                            e = (lab == 5) ? i.s1 + "\n" + i.f1 : j.s5 + "\n" + j.f5,
                            f = (lab == 6) ? i.s1 + "\n" + i.f1 : j.s6 + "\n" + j.f6,
                            g = (lab == 7) ? i.s1 + "\n" + i.f1 : j.s7 + "\n" + j.f7,
                        };

                        gvtimetable.DataSource = q2;
                        gvtimetable.DataBind();

                        TimeSpan[] timeslot = new TimeSpan[7];
                        int        z        = 0;
                        for (int i = 0; i < timeslot.Length; i++)
                        {
                            if (head[i] != "")
                            {
                                string s = head[i].Substring(0, head[i].IndexOf('-'));
                                timeslot[i] = TimeSpan.Parse(s);
                                z           = i;
                            }
                        }
                        TimeSpan endtime = TimeSpan.Parse(head[z].Substring(head[z].IndexOf('-') + 1));
                        //TimeSpan now = TimeSpan.Parse("8:30");
                        TimeSpan now = TimeSpan.Parse(DateTime.Now.TimeOfDay.ToString());

                        var c = (from j in db.DailyTTs
                                 where j.tt_Id == ttid
                                 select j).Single();

                        string[] t = { c.s1_type, c.s2_type, c.s3_type, c.s4_type, c.s5_type, c.s6_type, c.s7_type };

                        var d = (from k in db.lecTTs
                                 where k.tt_id == ttid && k.day == DateTime.Now.DayOfWeek.ToString()
                                 select k).Single();


                        string[] a =
                        {
                            d.s1 + ", " + d.f1,
                            d.s2 + ", " + d.f2,
                            d.s3 + ", " + d.f3,
                            d.s4 + ", " + d.f4,
                            d.s5 + ", " + d.f5,
                            d.s6 + ", " + d.f6,
                            d.s7 + ", " + d.f7
                        };

                        var f = from k in db.lab_tts
                                where k.tt_id == ttid && k.b1 == batch && k.day == DateTime.Now.DayOfWeek.ToString()
                                select new { a = k.s1 + ", " + k.f1 };

                        if (timeslot[0].CompareTo(now) > 0)
                        {
                            lblcurlec.Text = "-------------";
                        }
                        else if (timeslot[z].CompareTo(now) < 0 && now.CompareTo(endtime) < 0)
                        {
                            if (t[z].Contains("l"))
                            {
                                lblcurlec.Text = a[z];
                            }
                            else
                            {
                                lblcurlec.Text = f.Single().ToString();
                            }
                            lbtnskip.Visible = true;
                        }
                        else if (now.CompareTo(endtime) > 0)
                        {
                            lblcurlec.Text = "-------------";
                        }
                        else
                        {
                            for (int i = 0; i < 6; i++)
                            {
                                if (timeslot[i].CompareTo(now) <= 0 && timeslot[i + 1].CompareTo(now) > 0)
                                {
                                    string pos = t[i];

                                    if (pos.Contains("l"))
                                    {
                                        lblcurlec.Text = a[i];
                                    }
                                    else
                                    {
                                        lblcurlec.Text = f.Single().ToString().Remove(0, 5).Replace('}', ' ');
                                    }
                                    lbtnskip.Visible = true;
                                }
                            }
                        }

                        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();

                        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();

                        lblestattendance.Text = "Est. Attendance : " + attendance + "%";
                        lblskipped.Text       = "You have skipped " + nl + " sessions today.";

                        var skips = (from i in db.skippeds
                                     where i.student_id == id && i.sem == sem
                                     select new
                        {
                            i.skipped1,
                            d = i.skipdate.ToString().Remove(10)
                        }).OrderByDescending(j => j.d);

                        gvskipedsessions.DataSource = skips;
                        gvskipedsessions.DataBind();
                    }
                }
                catch (Exception ex)
                {
                    lblcurlec.Text = "-------------";
                }
            }
        }
Exemplo n.º 21
0
        protected void btnsaveex_Click(object sender, EventArgs e)
        {
            using (DepartmentPortalDataContext db = new DepartmentPortalDataContext())
            {
                try
                {
                    var q1 = (from i in db.ExternalMarks
                              where i.sem_id == semid && i.subject.subject_name == subname[0]
                              select i).SingleOrDefault();
                    q1.marks       = Convert.ToInt32(txts1m.Text == "" ? "-1" : txts1m.Text);
                    q1.pract_marks = Convert.ToInt32(txts1pm.Text == "" ? "-1" : txts1pm.Text);
                    q1.rem_1       = Convert.ToInt32(txts1r1.Text == "" ? "-1" : txts1r1.Text);
                    q1.rem_2       = Convert.ToInt32(txts1r2.Text == "" ? "-1" : txts1r2.Text);
                    q1.grade       = txts1grade.Text == "" ? "-1" : txts1grade.Text;
                    q1.status      = txts1stat.Text == "" ? "-1" : txts1stat.Text;
                    db.SubmitChanges();

                    q1 = (from i in db.ExternalMarks
                          where i.sem_id == semid && i.subject.subject_name == subname[1]
                          select i).SingleOrDefault();
                    q1.marks       = Convert.ToInt32(txts2m.Text == "" ? "-1" : txts2m.Text);
                    q1.pract_marks = Convert.ToInt32(txts2pm.Text == "" ? "-1" : txts2pm.Text);
                    q1.rem_1       = Convert.ToInt32(txts2r1.Text == "" ? "-1" : txts2r1.Text);
                    q1.rem_2       = Convert.ToInt32(txts2r2.Text == "" ? "-1" : txts2r2.Text);
                    q1.grade       = txts2grade.Text == "" ? "-1" : txts2grade.Text;
                    q1.status      = txts2stat.Text == "" ? "-1" : txts2stat.Text;
                    db.SubmitChanges();

                    q1 = (from i in db.ExternalMarks
                          where i.sem_id == semid && i.subject.subject_name == subname[2]
                          select i).SingleOrDefault();
                    q1.marks       = Convert.ToInt32(txts3m.Text == "" ? "-1" : txts3m.Text);
                    q1.pract_marks = Convert.ToInt32(txts3pm.Text == "" ? "-1" : txts3pm.Text);
                    q1.rem_1       = Convert.ToInt32(txts3r1.Text == "" ? "-1" : txts3r2.Text);
                    q1.rem_2       = Convert.ToInt32(txts3r2.Text == "" ? "-1" : txts3r2.Text);
                    q1.grade       = txts3grade.Text == "" ? "-1" : txts3grade.Text;
                    q1.status      = txts3stat.Text == "" ? "-1" : txts3stat.Text;
                    db.SubmitChanges();

                    q1 = (from i in db.ExternalMarks
                          where i.sem_id == semid && i.subject.subject_name == subname[3]
                          select i).SingleOrDefault();
                    q1.marks       = Convert.ToInt32(txts4m.Text == "" ? "-1" : txts4m.Text);
                    q1.pract_marks = Convert.ToInt32(txts4pm.Text == "" ? "-1" : txts4pm.Text);
                    q1.rem_1       = Convert.ToInt32(txts4r1.Text == "" ? "-1" : txts4r1.Text);
                    q1.rem_2       = Convert.ToInt32(txts4r2.Text == "" ? "-1" : txts4r2.Text);
                    q1.grade       = txts4grade.Text == "" ? "-1" : txts4grade.Text;
                    q1.status      = txts4stat.Text == "" ? "-1" : txts4stat.Text;
                    db.SubmitChanges();

                    q1 = (from i in db.ExternalMarks
                          where i.sem_id == semid && i.subject.subject_name == subname[4]
                          select i).SingleOrDefault();
                    q1.marks       = Convert.ToInt32(txts5m.Text == "" ? "-1" : txts5m.Text);
                    q1.pract_marks = Convert.ToInt32(txts5pm.Text == "" ? "-1" : txts5pm.Text);
                    q1.rem_1       = Convert.ToInt32(txts5r1.Text == "" ? "-1" : txts5r1.Text);
                    q1.rem_2       = Convert.ToInt32(txts5r2.Text == "" ? "-1" : txts5r2.Text);
                    q1.grade       = txts5grade.Text == "" ? "-1" : txts5grade.Text;
                    q1.status      = txts5stat.Text == "" ? "-1" : txts5stat.Text;
                    db.SubmitChanges();

                    if (count == 6)
                    {
                        q1 = (from i in db.ExternalMarks
                              where i.sem_id == semid && i.subject.subject_name == subname[5]
                              select i).SingleOrDefault();
                        q1.marks       = Convert.ToInt32(txts6m.Text == "" ? "-1" : txts6m.Text);
                        q1.pract_marks = Convert.ToInt32(txts6pm.Text == "" ? "-1" : txts6pm.Text);
                        q1.rem_1       = Convert.ToInt32(txts6r1.Text == "" ? "-1" : txts6r1.Text);
                        q1.rem_2       = Convert.ToInt32(txts6r2.Text == "" ? "-1" : txts6r2.Text);
                        q1.grade       = txts6grade.Text == "" ? "-1" : txts6grade.Text;
                        q1.status      = txts6stat.Text == "" ? "-1" : txts6stat.Text;
                        db.SubmitChanges();
                    }
                    lblsaveexerror.Text = "Changes have been made.";
                    loadextresults();
                }
                catch (Exception ex) { }
            }
        }