コード例 #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
ファイル: Login.aspx.cs プロジェクト: ke5vmj/GradeBookNET
        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();
            }
        }
コード例 #3
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();
                   }
                }
            }
        }
コード例 #4
0
ファイル: Register.aspx.cs プロジェクト: ke5vmj/GradeBookNET
        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;
                }
            }
        }