protected void btnUpdateCriteria_Click(object sender, EventArgs e) { // need to add grading criteria DatabaseOperations db = new DatabaseOperations(); SPParameters parameters; DataTable dt = (DataTable)ViewState["CurrentTable"]; string courseID = hfCourseID.Value, categoryDescription; double categoryWeight; for (int n = 0; n < dt.Rows.Count; n++) { TextBox box1 = (TextBox)Gridview1.Rows[n].Cells[0].FindControl("TextBox1"); TextBox box2 = (TextBox)Gridview1.Rows[n].Cells[1].FindControl("TextBox2"); categoryDescription = box1.Text; categoryWeight = double.Parse(box2.Text) / 100; parameters = new SPParameters(); parameters.AddParameter("@CourseID", courseID); parameters.AddParameter("@CategoryDescription", categoryDescription); parameters.AddParameter("@CategoryWeight", categoryWeight.ToString()); parameters.AddParameter("@Message", "", true); db.ExecuteSP("dbo.AddGradingCategory", ref parameters); lblGradingMessage.Text = ""; } }
protected void btnUpdateRubric_Click(object sender, EventArgs e) { DatabaseOperations db = new DatabaseOperations(); SPParameters parameters = new SPParameters(); string courseID = hfCourseID.Value, output = ""; double a, am, bp, b, bm, cp, c, cm, d, f; a = double.Parse(txtA.Text) / 100; am = double.Parse(txtAMinus.Text) / 100; bp = double.Parse(txtBPlus.Text) / 100; b = double.Parse(txtB.Text) / 100; bm = double.Parse(txtBMinus.Text) / 100; cp = double.Parse(txtCPlus.Text) / 100; c = double.Parse(txtC.Text) / 100; cm = double.Parse(txtCMinus.Text) / 100; d = double.Parse(txtD.Text) / 100; f = double.Parse(txtF.Text) / 100; parameters.AddParameter("@CourseID", courseID); parameters.AddParameter("@A", a.ToString()); parameters.AddParameter("@AMinus", am.ToString()); parameters.AddParameter("@BPlus", bp.ToString()); parameters.AddParameter("@B", b.ToString()); parameters.AddParameter("@BMinus", bm.ToString()); parameters.AddParameter("@CPlus", cp.ToString()); parameters.AddParameter("@C", c.ToString()); parameters.AddParameter("@CMinus", cm.ToString()); parameters.AddParameter("@D", d.ToString()); parameters.AddParameter("@F", f.ToString()); parameters.AddParameter("@Message", output, true); db.ExecuteSP("UpdateCourseRubric", ref parameters); lblRubricMessage.Text = output; }
private void loginRegister(bool isRegister) { DatabaseOperations db = new DatabaseOperations(); SPParameters parameters = new SPParameters(); string userName, password, spName, result = ""; try { userName = txtUserName.Text; password = txtPassword.Text; spName = isRegister ? "AddUser" : "ValidateUser"; parameters.AddParameter("@UserName", userName); parameters.AddParameter("@UserPassHash", password); parameters.AddParameter("@Message", "0", true); if (userName.Equals("") || password.Equals("")) { throw new ArgumentException("Both fields are required."); } if (password.Length < 6) { throw new ArgumentException("Password must be 6 characters or more."); } db.ExecuteSP(spName, ref parameters, ref result); switch (result.ToLower()) { case "success": Session["isValidated"] = true; Session["userName"] = userName.ToUpper(); Response.Redirect("UserSplash.aspx", false); break; case "wrong password": lblMessage.Text = "Incorrect password."; break; case "invalid user": lblMessage.Text = "User not registered."; break; default: lblMessage.Text = result; break; } } catch (ArgumentException ex) { } catch (Exception ex) { } }
private void getCoursesForSemester() { DatabaseOperations db = new DatabaseOperations(); SPParameters parameters = new SPParameters(); DataTable dt = new DataTable(); parameters.AddParameter("@UserName", Session["userName"].ToString()); parameters.AddParameter("@Semester", ddlSemester.SelectedValue); db.ExecuteSP("dbo.GetCourses", ref parameters, ref dt); //if(dt!=null && dt.Rows.Count > 0) { gvCourses.DataSource = dt; gvCourses.DataBind(); // } }
private void getGradingCategories() { DatabaseOperations db = new DatabaseOperations(); SPParameters parameters = new SPParameters(); DataTable dt = new DataTable(); string courseID = Request.QueryString["cid"].ToString(); parameters.AddParameter("@CourseAcronym", courseID); db.ExecuteSP("dbo.GetGradingCategories", ref parameters, ref dt); if (dt != null && dt.Rows.Count > 0) { ddlCategory.Items.Clear(); for (int n = 0; n < dt.Rows.Count; n++) { ddlCategory.Items.Add(new ListItem(dt.Rows[n][1].ToString(), dt.Rows[n][0].ToString())); } } }
protected void btnAdd_Click(object sender, EventArgs e) { DatabaseOperations db = new DatabaseOperations(); SPParameters parameters = new SPParameters(); string courseID = Request.QueryString["cid"].ToString(); string gradeName = txtName.Text; string courseCategoryID = ddlCategory.SelectedValue; double actualScore, maxScore; actualScore = double.Parse(txtReceived.Text) / 100; maxScore = double.Parse(txtMaximum.Text) / 100; parameters.AddParameter("@CourseCategoryID", courseCategoryID); parameters.AddParameter("@GradeName", gradeName); parameters.AddParameter("@ActualScore", actualScore.ToString()); parameters.AddParameter("@MaxScore", maxScore.ToString()); parameters.AddParameter("@Message", "", true); db.ExecuteSP("dbo.AddGrade", ref parameters); lblMessage.Text = "Grade added successfully!"; }
protected void btnAdd_Click(object sender, EventArgs e) { try { DatabaseOperations db = new DatabaseOperations(); SPParameters parameters = new SPParameters(); string userName = Session["userName"].ToString(); string semester = Session["selectedSemester"].ToString(); string courseAcronym, courseDescription; string courseID = ""; courseAcronym = txtCourseID.Text; courseDescription = txtCourseDescription.Text; if (courseAcronym == "" || courseDescription == "") { // issues } parameters.AddParameter("@UserName", userName); parameters.AddParameter("@Semester", semester); parameters.AddParameter("@CourseAcronym", courseAcronym); parameters.AddParameter("@CourseDescription", courseDescription); parameters.AddParameter("@Message", courseID, true); db.ExecuteSP("AddCourse", ref parameters, ref courseID); lblMessage.Text = "Course added successfully!"; // now go get rubric DataTable dt = new DataTable(); parameters = new SPParameters(); parameters.AddParameter("@CourseID", courseID); db.ExecuteSP("GetCourseRubric", ref parameters, ref dt); if (dt != null && dt.Rows.Count > 0) { hfCourseID.Value = dt.Rows[0][0].ToString(); TextBox tb = null; for (int n = 0; n < dt.Rows.Count; n++) { switch (dt.Rows[n][1].ToString().ToLower()) { case "a": tb = txtA; break; case "aminus": tb = txtAMinus; break; case "bplus": tb = txtBPlus; break; case "b": tb = txtB; break; case "bminus": tb = txtBMinus; break; case "cplus": tb = txtCPlus; break; case "c": tb = txtC; break; case "cminus": tb = txtCMinus; break; case "d": tb = txtD; break; case "f": tb = txtF; break; } tb.Text = int.Parse((double.Parse(dt.Rows[n][2].ToString()) * 100).ToString()).ToString(); } } } catch (Exception ex) { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = ex.Message; } }