Example #1
0
 protected void mvTeacherSubjects_ActiveViewChanged(object sender, EventArgs e)
 {
     ControlManager.hidePanels(mvTeacherSubjects);
 }
Example #2
0
        //--------------------- Form View Start -----------------------//

        protected void btnSubjectCancel_Click(object sender, EventArgs e)
        {
            ControlManager.clearTextBoxes(vForm);
            mvTeacherSubjects.ActiveViewIndex = 0;
        }
Example #3
0
 protected void mvLogin_ActiveViewChanged(object sender, EventArgs e)
 {
     ControlManager.hidePanels(mvLogin);
 }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
            }

            using (DatabaseDataContext db = new DatabaseDataContext())
            {
                var list = db.tblStudents.Join(
                    db.tblStudentSubjects,
                    x => x.studentID,
                    y => y.studentID,
                    (x, y) => new { tblStudent = x, tblStudentSubject = y }).Join(
                    db.tblSubjects,
                    y => y.tblStudentSubject.subjectCode,
                    z => z.subjectCode,
                    (y, z) => new { tblStudentSubject = y, tblSubject = z }
                    ).Where(x => x.tblStudentSubject.tblStudentSubject.isVisible && x.tblStudentSubject.tblStudent.studentID == SessionManager.StudentID).Select(s => new
                {
                    s.tblSubject.subjectCode,
                    s.tblSubject.subjectGroup,
                    s.tblSubject.subjectDescription,
                    s.tblSubject.subjectTitle
                });

                ControlManager.populateControl(list, subjectsCatalogRepeater);

                tblUser user = (tblUser)Session["User"];

                var studentSubjects = db.tblStudentSubjects.Where(x => x.studentID == SessionManager.StudentID).ToList();

                for (int i = 0; i < subjectsCatalogRepeater.Items.Count; i++)
                {
                    Label label = (Label)subjectsCatalogRepeater.Items[i].FindControl("lblSubjectCode");

                    if (studentSubjects.Where(x => x.subjectCode == Convert.ToInt32(label.Text) && x.isVisible).FirstOrDefault() == null)
                    {
                        MultiView mv = (MultiView)subjectsCatalogRepeater.Items[i].FindControl("mvPanelFooter");

                        mv.ActiveViewIndex = 1;
                    }
                    else
                    {
                        MultiView mv = (MultiView)subjectsCatalogRepeater.Items[i].FindControl("mvPanelFooter");

                        Button button = (Button)subjectsCatalogRepeater.Items[i].FindControl("btnChangeTeacher");

                        if (studentSubjects.Where(x => x.subjectCode == Convert.ToInt32(label.Text) && x.isVisible && x.studentID == SessionManager.StudentID && x.teacherID != null).FirstOrDefault() == null)
                        {
                            button = (Button)subjectsCatalogRepeater.Items[i].FindControl("btnChangeTeacher");

                            button.Text      = "Choose teacher";
                            button.CssClass += "btn btn-info";
                        }
                        else
                        {
                            button.CssClass += "btn btn-orange";
                        }

                        mv.ActiveViewIndex = 0;
                    }

                    MultiView mvBody = (MultiView)subjectsCatalogRepeater.Items[i].FindControl("mvPanelBody");
                    mvBody.ActiveViewIndex = 0;
                }
            }
        }
Example #5
0
        protected void btnStudentNext_Click(object sender, EventArgs e)
        {
            tblUser user = new tblUser
            {
                userEmail    = txtRegisterEmail.Text,
                userPassword = txtRegisterPassword.Text,
                userType     = 'S'
            };

            using (DatabaseDataContext db = new DatabaseDataContext())
            {
                //Check if the field that has been entered already exists
                if (db.tblUsers.Where(x => x.userEmail.Equals(txtRegisterEmail.Text)).FirstOrDefault() != null)
                {
                    //Make the label visible and break the onClick() function
                    lblRegisterEmail.Visible = true;
                    return;
                }

                lblRegisterEmail.Visible = false;

                db.tblUsers.InsertOnSubmit(user);
                db.SubmitChanges();

                tblStudent student = new tblStudent
                {
                    studentFullName = txtRegisterName.Text,

                    userID = db.tblUsers.Where(x => x.userEmail == txtRegisterEmail.Text).FirstOrDefault().userID
                };

                db.tblStudents.InsertOnSubmit(student);
                db.SubmitChanges();

                //Populating the Repeater in the next View


                //for (int i = 0; i < rRegisterTeachers.Items.Count; i++)
                //{
                //    DropDownList ddl = (DropDownList)rRegisterTeachers.Items[i].FindControl("ddlRegisterTeacher");

                //    Label label = (Label)rRegisterTeachers.Items[i].FindControl("lblSubjectName");
                //    int subjectCode = Convert.ToInt32(label.Text.Substring(label.Text.Length - 4));

                //    var teachers = db.tblTeachers.Where(x => x.subjectCode == subjectCode);

                //    ddl.DataTextField = "teacherFullName";
                //    ddl.DataValueField = "teacherID";

                //    ControlManager.populateControl(teachers, ddl);

                //    if (teachers.FirstOrDefault() == null)
                //    {
                //        ddl.Items.Insert(0, new ListItem("There are no teachers available for this subject", "0"));
                //        ddl.Enabled = false;
                //    }
                //}



                ControlManager.populateControl(getSubjectsQuery(db), rRegisterSubjects);

                mvRegister.ActiveViewIndex = 2;
                mvRegisterStudentButton.ActiveViewIndex = 0;
            }
        }