예제 #1
0
        protected void AddAssignment(object sender, EventArgs e)
        {
            DataHandler db = new DataHandler();

            using (db.Connect())
            {
                int result;
                int finalized;
                db.Command("CheckTagSystem", true);
                db.Add("@course_id", SessionManager.Course.ID);
                db.AddIntReturn();

                db.Start();
                db.ExecNonQuery();
                result = db.ReturnValue();

                db.Command("CheckFinalized", true);
                db.Add("@course_id", SessionManager.Course.ID);
                db.AddIntReturn();

                db.ExecNonQuery();
                finalized = db.ReturnValue();

                if (result != 1)
                {
                    lblError.Text = "Grading System unbalanced. Could cause inaccurate reporting. Ensure total weights add up to 100%";
                    lblError.Visible = true;
                }
                else
                if(finalized != 1)
                {
                    lblError.Text = "Roster has not been finalized yet";
                    lblError.Visible = true;
                }
                else
                {
                    lblError.Visible = false;
                    db.Command("CreateNewAssignment", true);
                    db.Add("@course_id", SessionManager.Course.ID);
                    db.Add("@assignment_name", txtAssgnName.Text);
                    db.Add("@tag_id", drpTypeList.SelectedValue);
                    db.Add("@instructor_id", SessionManager.Instructor.ID);

                    db.ExecNonQuery();
                    db.Stop();
                    Response.Redirect(Request.RawUrl);
                }
            }
        }
예제 #2
0
        protected void CreateNewUser(object sender, EventArgs e)
        {
            DataHandler db = new DataHandler();

            using (db.Connect())
            {

                db.Command("UserExists", true);
                db.Add("@username", UserName.Text);
                db.AddIntReturn();
                db.Start();
                db.ExecNonQuery();
                db.Stop();

                int result;
                result = db.ReturnValue();

                if (result == 0)
                {
                    db.Start();
                    db.Command("INSERT INTO Instructor (f_name, l_name, login, password) VALUES (@fname, @lname, @login, @pass)", false);
                    db.Add("@fname", FirstName.Text);
                    db.Add("@lname", LastName.Text);
                    db.Add("@login", UserName.Text);
                    db.Add("@pass", Password.Text);
                    db.ExecNonQuery();
                    db.Stop();

                    lblComplete.Text = "Registration is complete.";
                    lblComplete.Visible = true;
                }
                else
                {
                    lblComplete.Text = "This user already exists.";
                    lblComplete.Visible = true;
                }
            }
        }
예제 #3
0
        protected void FinalizeRoster(object sender, EventArgs e)
        {
            DataHandler db = new DataHandler();

            using (db.Connect())
            {
                db.Command("FinalizeRoster", true);
                db.Add("@course_id", SessionManager.Course.ID);

                db.Start();
                db.ExecNonQuery();
                db.Stop();
                Response.Redirect(Request.RawUrl);
            }
        }
예제 #4
0
        protected void LoginBox_Authenticate(object sender, AuthenticateEventArgs e)
        {
            DataHandler db = new DataHandler();
            Instructor instructor = new Instructor();

            e.Authenticated = false;

            using (db.Connect())
            {
                int result;

                db.Command("Login", true);
                db.Add("@username", LoginBox.UserName);
                db.Add("@password", LoginBox.Password);
                db.AddIntReturn();

                db.Start();
                db.ExecNonQuery();
                result = db.ReturnValue();

                if (result > 0)
                {
                    db.Command("CollectSessionInfoInstructor", true);
                    db.Add("@username", LoginBox.UserName);
                    SqlDataReader reader = db.Exec();
                    reader.Read();                      //read the record, advance the cursor, etc.

                    e.Authenticated = true;
                    FormsAuthentication.RedirectFromLoginPage(LoginBox.UserName, true);
                    instructor.UserName = LoginBox.UserName;
                    instructor.ID = reader.GetInt32(0);             //Encapsulate my Session information for later use
                    instructor.FirstName = reader.GetString(1);
                    instructor.LastName = reader.GetString(2);

                    SessionManager.Instructor = instructor;
                }
                else
                {
                    e.Authenticated = false;

                }

                db.Stop();
            }
        }
예제 #5
0
        protected void AddType(object sender, EventArgs e)
        {
            DataHandler db = new DataHandler();
            int weight = int.Parse(txtTagWeight.Text);

            using (db.Connect())
            {
                db.Command("INSERT INTO Tag (tag_type, tag_weight, course_id) VALUES (@tag_type, CONVERT(DECIMAL(16,2), @tag_weight/100.0), @course_id)", false);
                db.Add("@tag_type", txtTagName.Text);
                db.Add("@tag_weight", weight);
                db.Add("@course_id", SessionManager.Course.ID);

                db.Start();
                db.ExecNonQuery();
                db.Stop();
            }

            Response.Redirect(Request.RawUrl);
        }
예제 #6
0
        protected void AddStudent(object sender, EventArgs e)
        {
            DataHandler db = new DataHandler();

            using (db.Connect())
            {
                db.Command("AddNewStudent", true);
                db.Add("@f_name", txtFirstName.Text);
                db.Add("@l_name", txtLastName.Text);
                db.Add("@instructor_id", SessionManager.Instructor.ID);
                db.Add("@course_id", SessionManager.Course.ID);

                db.Start();
                db.ExecNonQuery();
                db.Stop();
            }

            Response.Redirect(Request.RawUrl);
        }
예제 #7
0
        protected void AddCourse(object sender, EventArgs e)
        {
            DataHandler db = new DataHandler();

            using (db.Connect())
            {
                db.Command("INSERT INTO Course (course_name, start_date, end_date, instructor_id) VALUES (@c_name, @start_date, @end_date, @id)", false);
                db.Add("@c_name", txtCourseEntry.Text);
                db.Add("@start_date", txtStartDate.Text);
                db.Add("@end_date", txtEndDate.Text);
                db.Add("@id", SessionManager.Instructor.ID);
                db.Start();
                db.ExecNonQuery();

                db.Stop();

            }

            Response.Redirect(Request.RawUrl);
        }
예제 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                if (!IsPostBack)
                {
                    lblCourseName.Text = SessionManager.Course.Name;

                   DataHandler db = new DataHandler();

                   using (db.Connect())
                   {
                       int finalized;

                       db.Command("ListStudentsForCourse", true);
                       db.Add("@course_id", SessionManager.Course.ID);
                       db.Start();
                       rptStudents.DataSource = db.Exec();
                       rptStudents.DataBind();
                       db.Stop();                                           //Close the already used datareader

                       db.Command("CheckFinalized", true);
                       db.Add("@course_id", SessionManager.Course.ID);
                       db.AddIntReturn();

                       db.Start();
                       db.ExecNonQuery();
                       finalized = db.ReturnValue();

                       if (finalized != 0)
                       {
                           lnkAdd.Visible = false;
                           lblFinalized.Visible = true;
                           lnkFinalize.Visible = false;
                       }
                       db.Stop();
                   }
                }
            }
        }