コード例 #1
0
ファイル: Login.aspx.cs プロジェクト: shehryar37/etaleem
        protected void btnRegisterTeacher_Click(object sender, EventArgs e)
        {
            tblUser user = new tblUser
            {
                userEmail    = txtRegisterEmail.Text,
                userPassword = txtRegisterPassword.Text,
                userType     = 'T'
            };

            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;
                }

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

                int subjectCode = cbNoSubject.Checked ? 0 : Convert.ToInt32(ddlRegisterSubject.SelectedValue);

                tblTeacher teacher = new tblTeacher
                {
                    teacherFullName = txtRegisterName.Text,
                    subjectCode     = subjectCode,
                    userID          = db.tblUsers.Where(x => x.userEmail == txtRegisterEmail.Text).FirstOrDefault().userID
                };

                db.tblTeachers.InsertOnSubmit(teacher);
                db.SubmitChanges();
            }

            ControlManager.clearTextBoxes(vRegisterForm);

            lblRegisterEmail.Visible = false;
            mvLogin.ActiveViewIndex  = 0;
            pRegister.Visible        = true;
        }
コード例 #2
0
        protected void btnNewSubjectAdd_Click(object sender, EventArgs e)
        {
            using (DatabaseDataContext db = new DatabaseDataContext())
            {
                if (db.tblSubjects.Where(x => x.subjectCode == Convert.ToInt32(txtSubjectCode.Text)).FirstOrDefault() != null)
                {
                    lblSubjectCode.Visible = true;
                    return;
                }
            }


            tblSubject subject = new tblSubject
            {
                subjectCode        = Convert.ToInt32(txtSubjectCode.Text),
                subjectTitle       = txtSubjectTitle.Text,
                subjectGroup       = ddlSubjectGroup.SelectedItem.Text,
                subjectDescription = txtSubjectDescription.Text,
                isVisible          = true
            };

            using (DatabaseDataContext db = new DatabaseDataContext())
            {
                db.tblSubjects.InsertOnSubmit(subject);
                db.SubmitChanges();

                List <tblSubject> subjects = db.tblSubjects.SortBy("subjectTitle").Where(x => x.isVisible).ToList();

                ControlManager.populateControl(subjects, subjectListRepeater);
            }


            ControlManager.clearTextBoxes(vForm);
            lblSubjectCode.Visible = false;

            mvTeacherSubjects.ActiveViewIndex = 0;
            pAdd.Visible = true;
        }
コード例 #3
0
        protected void btnNewSubjectEdit_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(txtSubjectCode.Text);

            using (DatabaseDataContext db = new DatabaseDataContext())
            {
                tblSubject subject = db.tblSubjects.Where(x => x.subjectCode == id).FirstOrDefault();
                subject.subjectTitle       = txtSubjectTitle.Text;
                subject.subjectGroup       = ddlSubjectGroup.SelectedValue;
                subject.subjectDescription = txtSubjectDescription.Text;

                db.SubmitChanges();

                List <tblSubject> subjects = db.tblSubjects.SortBy("subjectTitle").Where(x => x.isVisible).ToList();

                ControlManager.populateControl(subjects, subjectListRepeater);
            }

            ControlManager.clearTextBoxes(vForm);

            mvTeacherSubjects.ActiveViewIndex = 0;
            pEdit.Visible = true;
        }
コード例 #4
0
        // -------------- Form View --------------- //

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (DateTime.Parse(dtStartDate.Text).Date <= DateTime.Now.Date)
            {
                regStartDate.Visible = true;
                return;
            }
            else
            {
                regStartDate.Visible = false;
            }

            if (DateTime.Parse(dtStartDate.Text).Date >= DateTime.Parse(dtEndDate.Text).Date)
            {
                regEndDate.Visible = true;
                return;
            }
            else
            {
                regEndDate.Visible = false;
            }

            string extension;

            var postedFileExtension = Path.GetExtension(fuSupplementaryFiles.FileName);

            if (!string.Equals(postedFileExtension, ".pdf", StringComparison.OrdinalIgnoreCase) &&
                !string.Equals(postedFileExtension, ".docx", StringComparison.OrdinalIgnoreCase))
            {
                lSupplementaryFiles.Visible = true;

                return;
            }
            else
            {
                if (string.Equals(postedFileExtension, ".pdf", StringComparison.OrdinalIgnoreCase))
                {
                    extension = ".pdf";
                }
                else
                {
                    extension = ".docx";
                }

                lSupplementaryFiles.Visible = false;
            }

            using (DatabaseDataContext db = new DatabaseDataContext())
            {
                string fileName = fuSupplementaryFiles.HasFile ? (txtAssignmentTitle.Text + SessionManager.TeacherID + extension) : null;

                tblAssignment assignment = new tblAssignment
                {
                    assignmentQuestionStatement = txtQuestionStatement.Text,
                    assignmentTitle             = txtAssignmentTitle.Text,
                    assignmentStartDate         = DateTime.Parse(dtStartDate.Text),
                    assignmentEndDate           = DateTime.Parse(dtEndDate.Text),
                    isGraded               = false,
                    isArchived             = false,
                    assignmentMaximumMarks = Convert.ToInt32(txtMaximumMarks.Text),
                    teacherID              = SessionManager.TeacherID,
                    fileName               = fileName
                };

                db.tblAssignments.InsertOnSubmit(assignment);

                if (assignment.fileName != null)
                {
                    //Saves file to a folder located inside the server
                    string savePath = Server.MapPath("~/Files/SupplementaryFiles");

                    //Renames the file such that there cannot be any duplicates
                    string saveFileName = fileName;

                    string imgSavePath = Path.Combine(savePath, saveFileName);
                    fuSupplementaryFiles.SaveAs(imgSavePath);
                }

                db.SubmitChanges();

                //assignment = (tblAssignment)db.GetChangeSet().Inserts.FirstOrDefault();

                var assignments  = db.tblAssignments.ToList();
                int assignmentID = assignments.LastOrDefault().assignmentID;

                var students = db.tblStudentSubjects.Where(x => x.teacherID == SessionManager.TeacherID && x.isVisible);

                int userID;

                foreach (tblStudentSubject student in students)
                {
                    userID = db.tblStudents.Where(x => x.studentID == student.studentID).FirstOrDefault().userID;

                    tblStudentAssignment studentAssignment = new tblStudentAssignment
                    {
                        studentID               = student.studentID,
                        assignmentID            = assignmentID,
                        studentAssignmentStatus = false,
                        studentAssignmentMarks  = null
                    };

                    db.tblStudentAssignments.InsertOnSubmit(studentAssignment);
                    db.SubmitChanges();

                    NotificationManager.assignmentCreateNotification(userID);
                }

                var list = db.tblAssignments.Where(x => x.teacherID == SessionManager.TeacherID).SortBy("assignmentEndDate");

                assignments = db.tblAssignments.Where(x => x.teacherID == SessionManager.TeacherID && x.isArchived == false).SortBy("assignmentEndDate").ToList();

                Session["assignmentList"] = assignments;

                ControlManager.populateControl(assignments, rAssignment);
            }

            ControlManager.clearTextBoxes(vForm);
            mvTeacherAssignments.ActiveViewIndex = 0;
            pCreate.Visible = true;
        }
コード例 #5
0
        //--------------------- Form View Start -----------------------//

        protected void btnSubjectCancel_Click(object sender, EventArgs e)
        {
            ControlManager.clearTextBoxes(vForm);
            mvTeacherSubjects.ActiveViewIndex = 0;
        }