protected CourseDetails() { displayTypes = new Dictionary<string, DisplayMetadata>(); displayTypes.Add("Course_ID", new DisplayMetadata(DisplayMetadata.FieldTypes.ID, "Course ID")); displayTypes.Add("Course_Code", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Course Code")); displayTypes.Add("Course_Title", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Course Title")); displayTypes.Add("Staff_Name", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Course Coordinator")); displayTypes.Add("Course_Type_Name", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Course Type Name")); displayTypes.Add("Course_Type_Credit_Points", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Course Type Credit Points")); displayTypes.Add("Course_Type_Duration_Months", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Course Type Duration Months")); validationTypes = new Dictionary<string, EditMetadata>(); validationTypes.Add("Course_ID", new EditMetadata(EditMetadata.FieldTypes.ID, "", "Course ID")); validationTypes.Add("Course_Code", new EditMetadata("^[A-Z][0-9]{2}$", "A course code must be a capital letter followed by 2 numbers.", "Course Code")); validationTypes.Add("Course_Title", new EditMetadata("^[a-zA-Z\\s0-9]{5}([a-zA-Z\\s0-9]*)?$", "You must enter a course title at least 5 characters with only letters, numbers, and spaces.", "Course Title")); Dictionary<string, string> staff = new Dictionary<string, string>(); foreach (Dictionary<string, object> staffData in StudentRecordsDAL.Query("SELECT * FROM Staff")) staff.Add(staffData["Staff_ID"].ToString(), staffData["Staff_Name"].ToString()); EditMetadata staf = new EditMetadata(EditMetadata.FieldTypes.Dropdown, "You must add an entry to the staff table.", "Course Coordinator"); staf.SetDropdownValues(staff); validationTypes.Add("Course_Coordinator", staf); Dictionary<string, string> courseTypes = new Dictionary<string, string>(); foreach (Dictionary<string, object> courseTypeData in StudentRecordsDAL.Query("SELECT * FROM Course_Type")) courseTypes.Add(courseTypeData["Course_Type_ID"].ToString(), courseTypeData["Course_Type_Name"].ToString()); EditMetadata course = new EditMetadata(EditMetadata.FieldTypes.Dropdown, "You must add an entry to the course type table.", "Course Type"); course.SetDropdownValues(courseTypes); validationTypes.Add("Course_Type", course); }
protected UnitDetails() { displayTypes = new Dictionary <string, DisplayMetadata>(); displayTypes.Add("Unit_ID", new DisplayMetadata(DisplayMetadata.FieldTypes.ID, "Unit ID")); displayTypes.Add("Unit_Code", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Unit Code")); displayTypes.Add("Unit_Title", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Unit Title")); displayTypes.Add("Staff_Name", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Unit Coordinator")); displayTypes.Add("Unit_Credit_Points", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Unit Credit Points")); displayTypes.Add("Postgrad_Unit", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Postgrad Unit")); validationTypes = new Dictionary <string, EditMetadata>(); validationTypes.Add("Unit_ID", new EditMetadata(EditMetadata.FieldTypes.ID, "", "Unit ID")); validationTypes.Add("Unit_Code", new EditMetadata("^[A-Z]{3}[0-9]{4}$", "A course code must be 3 capital letter followed by 4 numbers.", "Unit Code")); validationTypes.Add("Unit_Title", new EditMetadata("^[a-zA-Z\\s0-9]{5}([a-zA-Z\\s0-9]*)?$", "You must enter a unit title at least 5 characters with only letters, numbers, and spaces.", "Unit Title")); Dictionary <string, string> staff = new Dictionary <string, string>(); foreach (Dictionary <string, object> staffData in StudentRecordsDAL.Query("SELECT * FROM Staff")) { staff.Add(staffData["Staff_ID"].ToString(), staffData["Staff_Name"].ToString()); } EditMetadata staf = new EditMetadata(EditMetadata.FieldTypes.Dropdown, "You must add an entry to the staff table.", "Unit Coordinator"); staf.SetDropdownValues(staff); validationTypes.Add("Unit_Coordinator", staf); validationTypes.Add("Unit_Credit_Points", new EditMetadata("^(15|20|60)$", "Credit points can be either 15, 20, or 60.", "Credit Points")); }
private void updateDB(Dictionary<string, string> data, bool update) { if (update) { StudentRecordsDAL.Command("UPDATE Course SET Course_Code='" + data["Course_Code"] + "', Course_Title='" + data["Course_Title"] + "', " + " Course_Coordinator=" + data["Course_Coordinator"] + ", Course_Type=" + data["Course_Type"] + " WHERE Course_ID=" + data["Course_ID"]); } else StudentRecordsDAL.Command("INSERT INTO Course (Course_Code, Course_Title, Course_Coordinator, Course_Type) VALUES ('" + data["Course_Code"] + "', '" + data["Course_Title"] + "', " + data["Course_Coordinator"] + ", " + data["Course_Type"] + ")"); }
private void updateDB(Dictionary <string, string> data, bool update) { if (update) { StudentRecordsDAL.Command("UPDATE Course_Attempt SET Student_ID=" + data["Student_ID"] + ", Course_ID=" + data["Course_ID"] + " WHERE Attempt_ID=" + data["Attempt_ID"]); } else { StudentRecordsDAL.Command("INSERT INTO Course_Attempt (Student_ID, Course_ID) VALUES (" + data["Student_ID"] + ", " + data["Course_ID"] + ")"); } }
private void updateDB(Dictionary <string, string> data, bool update) { if (update) { StudentRecordsDAL.Command("UPDATE Gender SET Gender_Name='" + data["Gender_Name"] + "' WHERE Gender_ID=" + data["Gender_ID"]); } else { StudentRecordsDAL.Command("INSERT INTO Gender (Gender_Name) VALUES ('" + data["Gender_Name"] + "')"); } }
protected StudentDetails() { displayTypes = new Dictionary <string, DisplayMetadata>(); displayTypes.Add("Student_ID", new DisplayMetadata(DisplayMetadata.FieldTypes.ID, "Student ID")); displayTypes.Add("Student_Number", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Student Number")); displayTypes.Add("Student_Name", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Student Name")); displayTypes.Add("Student_Email", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Student Email")); displayTypes.Add("Student_Password", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Student Passsword")); displayTypes.Add("Gender_Name", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Student Gender")); displayTypes.Add("Date_Of_Birth", new DisplayMetadata(DisplayMetadata.FieldTypes.Date, true, "Date of Birth")); displayTypes.Add("Phone_Number", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Phone Number")); displayTypes.Add("Address_Line_One", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Address Line 1")); displayTypes.Add("Address_Line_Two", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Address Line 2")); displayTypes.Add("City", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "City")); displayTypes.Add("State_Name", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "State")); displayTypes.Add("Postcode", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Postcode")); validationTypes = new Dictionary <string, EditMetadata>(); validationTypes.Add("Student_ID", new EditMetadata(EditMetadata.FieldTypes.ID, "", "Student ID")); validationTypes.Add("Student_Number", new EditMetadata(EditMetadata.FieldTypes.ReadOnly, "", "Student Number")); validationTypes.Add("Student_Name", new EditMetadata("^[a-zA-Z]+ [a-zA-Z]+([a-z\\sA-Z]+)?$", "You must enter a first name and a last name with only letters.", "Student Name")); validationTypes.Add("Student_Email", new EditMetadata(EditMetadata.FieldTypes.ReadOnly, "", "Student Email")); validationTypes.Add("Student_Password", new EditMetadata("^(?=(.*[A-Z]){2})(?=(.*\\d){2})[a-zA-Z\\d]{8,}$", "You must enter an alphanumeric password that is at least 8 characters, with at least 2 upper case letters and 2 numbers.", "Student Password")); Dictionary <string, string> genders = new Dictionary <string, string>(); foreach (Dictionary <string, object> stateData in StudentRecordsDAL.Query("SELECT * FROM Gender")) { genders.Add(stateData["Gender_ID"].ToString(), stateData["Gender_Name"].ToString()); } EditMetadata gender = new EditMetadata(EditMetadata.FieldTypes.Dropdown, "You must add an entry to the gender table.", "Student Gender"); gender.SetDropdownValues(genders); validationTypes.Add("Gender", gender); validationTypes.Add("Date_Of_Birth", new EditMetadata(EditMetadata.FieldTypes.Date, "You must enter a date in the format DD/MM/YYYY.", "Date of Birth")); validationTypes.Add("Phone_Number", new EditMetadata("^[0-9]{10}$", "You must enter a 10 digit phone number (including area code).", "Phone Number")); validationTypes.Add("Address_Line_One", new EditMetadata(EditMetadata.FieldTypes.Text, "You must enter an address.", "Address Line 1")); validationTypes.Add("Address_Line_Two", new EditMetadata("^[a-zA-Z 0-9]*$", "You must enter only letters numbers and spaces.", "Address Line 2")); validationTypes.Add("City", new EditMetadata(EditMetadata.FieldTypes.Text, "You must enter a city.", "City")); Dictionary <string, string> states = new Dictionary <string, string>(); foreach (Dictionary <string, object> stateData in StudentRecordsDAL.Query("SELECT * FROM State")) { states.Add(stateData["State_ID"].ToString(), stateData["State_Name"].ToString()); } EditMetadata state = new EditMetadata(EditMetadata.FieldTypes.Dropdown, "You must add an entry to the state table.", "State"); state.SetDropdownValues(states); validationTypes.Add("State", state); validationTypes.Add("Postcode", new EditMetadata("^[0-9]{4}$", "You must enter a valid postcode.", "Postcode")); }
private void updateDB(Dictionary <string, string> data, bool update) { if (update) { StudentRecordsDAL.Command("UPDATE Staff SET Staff_Name='" + data["Staff_Name"] + "' WHERE Staff_ID=" + data["Staff_ID"]); } else { StudentRecordsDAL.Command("INSERT INTO Staff (Staff_Name) VALUES ('" + data["Staff_Name"] + "')"); } }
private void updateDB(Dictionary <string, string> data, bool update) { if (update) { StudentRecordsDAL.Command("UPDATE Unit SET Unit_Code='" + data["Unit_Code"] + "', Unit_Title='" + data["Unit_Title"] + "', Unit_Coordinator=" + data["Unit_Coordinator"] + ", Unit_Credit_Points=" + data["Unit_Credit_Points"] + " WHERE Unit_ID=" + data["Unit_ID"]); } else { StudentRecordsDAL.Command("INSERT INTO Unit (Unit_Code, Unit_Title, Unit_Coordinator, Unit_Credit_Points) VALUES ('" + data["Unit_Code"] + "', '" + data["Unit_Title"] + "', " + data["Unit_Coordinator"] + ", " + data["Unit_Credit_Points"] + ")"); } }
private void updateDB(Dictionary <string, string> data, bool update) { if (update) { StudentRecordsDAL.Command("UPDATE Course_Type SET Course_Type_Name='" + data["Course_Type_Name"] + "', Course_Type_Credit_Points=" + data["Course_Type_Credit_Points"] + ", Course_Type_Duration_Months=" + data["Course_Type_Duration_Months"] + " WHERE Course_Type_ID=" + data["Course_Type_ID"]); } else { StudentRecordsDAL.Command("INSERT INTO Course_Type (Course_Type_Name, Course_Type_Credit_Points, Course_Type_Duration_Months) VALUES ('" + data["Course_Type_Name"] + "', " + data["Course_Type_Credit_Points"] + ", " + data["Course_Type_Duration_Months"] + ")"); } }
private void updateDB(Dictionary <string, string> data, bool update) { if (update) { StudentRecordsDAL.Command("UPDATE Unit_Attempt SET Attempt_ID=" + data["Attempt_ID"] + ", Unit_ID=" + data["Unit_ID"] + ", Semester_Attempted=" + data["Semester_Attempted"] + ", Attempt_Mark=" + data["Attempt_Mark"] + " WHERE Unit_Att_ID=" + data["Unit_Att_ID"]); } else { StudentRecordsDAL.Command("INSERT INTO Unit_Attempt (Attempt_ID, Unit_ID, Semester_Attempted, Attempt_Mark) VALUES (" + data["Attempt_ID"] + ", " + data["Unit_ID"] + ", " + data["Semester_Attempted"] + ", " + data["Attempt_Mark"] + ")"); } }
protected void Page_Load(object sender, EventArgs e) { ((HtmlControl)Master.FindControl("Cor")).Attributes.Add("class", "active"); ((HtmlControl)Master.FindControl("CorS")).Attributes.Add("class", "active"); ((Literal)Master.FindControl("pagetitle")).Text = " - Staff Details"; RecordsDataControl.BindViewData(StudentRecordsDAL.Query("SELECT * FROM Staff")); RecordsDataControl.BindEditData(StudentRecordsDAL.Query("SELECT * FROM Staff")); RecordsDataControl.SetTableName("Staff"); RecordsDataControl.SetDisplayMetadata(displayTypes); RecordsDataControl.SetEditMetadata(validationTypes); RecordsDataControl.SetFunction(updateDB); RecordsDataControl.BuildControl(); }
protected void Page_Load(object sender, EventArgs e) { ((HtmlControl)Master.FindControl("Cor")).Attributes.Add("class", "active"); ((HtmlControl)Master.FindControl("CorU")).Attributes.Add("class", "active"); ((Literal)Master.FindControl("pagetitle")).Text = " - Unit Details"; RecordsDataControl.BindViewData(StudentRecordsDAL.Query("SELECT * FROM Unit_Coord")); RecordsDataControl.BindEditData(StudentRecordsDAL.Query("SELECT * FROM Unit")); RecordsDataControl.SetTableName("Unit"); RecordsDataControl.SetDisplayMetadata(displayTypes); RecordsDataControl.SetEditMetadata(validationTypes); RecordsDataControl.SetFunction(updateDB); RecordsDataControl.AddValidationMethod("Unit_ID", setID); RecordsDataControl.AddValidationMethod("Unit_Code", unitCodeUnique); RecordsDataControl.BuildControl(); }
protected void Page_Load(object sender, EventArgs e) { ((HtmlControl)Master.FindControl("Stu")).Attributes.Add("class", "active"); ((HtmlControl)Master.FindControl("StuR")).Attributes.Add("class", "active"); ((Literal)Master.FindControl("pagetitle")).Text = " - Student Results"; RecordsDataControl.BindViewData(StudentRecordsDAL.Query("SELECT * FROM Course_Attempt_Details")); RecordsDataControl.BindEditData(StudentRecordsDAL.Query("SELECT * FROM Course_Attempt")); RecordsDataControl.SetTableName("Course_Attempt"); RecordsDataControl.SetDisplayMetadata(displayTypes); RecordsDataControl.SetEditMetadata(validationTypes); RecordsDataControl.AddValidationMethod("Attempt_ID", setAttemptID); RecordsDataControl.AddValidationMethod("Student_ID", setStudentID); RecordsDataControl.AddValidationMethod("Course_ID", checkEnrolment); RecordsDataControl.SetFunction(updateDB); RecordsDataControl.BuildControl(); }
protected void Page_Load(object sender, EventArgs e) { ((HtmlControl)Master.FindControl("StuL")).Attributes.Add("class", "active"); if (!IsPostBack) { data.Visible = false; } else { if (Regex.Match(Request.Form["usernameinput"], "^[a-zA-Z]+[0-9]*@our\\.ecu\\.edu\\.au").Success) { if (Regex.Match(Request.Form["passwordinput"], "^(?=(.*[A-Z]){2})(?=(.*\\d){2})[a-zA-Z\\d]{8,}$").Success) { if (StudentRecordsDAL.Query("SELECT * FROM Student WHERE UCASE(Student_Email)='" + Request.Form["usernameinput"].ToUpper() + "' AND Student_Password='******'").Count > 0) { login.Visible = false; data.Visible = true; stunam.InnerText = ((Dictionary <string, object>)StudentRecordsDAL.Query("SELECT * FROM Student WHERE UCASE(Student_Email)='" + Request.Form["usernameinput"].ToUpper() + "' AND Student_Password='******'")[0])["Student_Name"].ToString(); stunum.InnerText = ((Dictionary <string, object>)StudentRecordsDAL.Query("SELECT * FROM Student WHERE UCASE(Student_Email)='" + Request.Form["usernameinput"].ToUpper() + "' AND Student_Password='******'")[0])["Student_Number"].ToString(); RecordsDataViewCourses.BindViewData(StudentRecordsDAL.Query("SELECT * FROM Course_Attempt_Details WHERE UCASE(Student_Email)='" + Request.Form["usernameinput"].ToUpper() + "'")); RecordsDataViewCourses.SetFieldTypes(displayTypesCourses); RecordsDataViewCourses.IsEditable(false); RecordsDataViewCourses.SetTableName("Course"); RecordsDataViewCourses.BuildTable(); RecordsDataViewUnits.BindViewData(StudentRecordsDAL.Query("SELECT * FROM Unit_Attempt_Details WHERE UCASE(Student_Email)='" + Request.Form["usernameinput"].ToUpper() + "'")); RecordsDataViewUnits.SetFieldTypes(displayTypesUnits); RecordsDataViewUnits.IsEditable(false); RecordsDataViewUnits.SetTableName("Unit"); RecordsDataViewUnits.BuildTable(); return; } } } data.Visible = false; login.Visible = true; invalidup.Text = "Invalid username or password."; } }
public void updateDB(Dictionary <string, string> data, bool update) { string studentEmail = data["Student_Name"].Substring(0, 1) + data["Student_Name"].Split(' ')[1].Substring(0, Math.Min(4, data["Student_Name"].Split(' ')[1].Length)); string counter = ""; int counterint = 0; while (StudentRecordsDAL.Query("SELECT * FROM Student_State WHERE Student_Email='" + studentEmail + counter + "@our.ecu.edu.au'").Count != 0) { counterint++; counter = counterint.ToString(); } if (update) { StudentRecordsDAL.Command("UPDATE Student SET Student_Name='" + data["Student_Name"] + "', Student_Email='" + studentEmail + counter + "@our.ecu.edu.au', " + " Student_Password='******', Gender=" + data["Gender"] + ", Date_Of_Birth=#" + data["Date_Of_Birth"] + "#, Phone_Number='" + data["Phone_Number"] + "', Address_Line_One='" + data["Address_Line_One"] + "', Address_Line_Two='" + data["Address_Line_Two"] + "', City='" + data["City"] + "', State=" + data["State"] + ", Postcode='" + data["Postcode"] + "' WHERE Student_ID=" + data["Student_ID"]); } else { Random rand = new Random(); int studentNumber = rand.Next(); string studentNumberStr = "10000000"; studentNumber = rand.Next(); studentNumberStr = studentNumberStr.Substring(0, 8 - Math.Min(8, studentNumber.ToString().Length)); studentNumberStr = studentNumberStr + studentNumber.ToString().Substring(0, Math.Min(8, studentNumber.ToString().Length)); while (StudentRecordsDAL.Query("SELECT * FROM Student_State WHERE Student_Number='" + studentNumberStr + "'").Count != 0) { studentNumber = rand.Next(); studentNumberStr = studentNumberStr.Substring(0, Math.Min(8, studentNumber.ToString().Length)); studentNumberStr = studentNumberStr + studentNumber.ToString().Substring(0, Math.Min(8, studentNumber.ToString().Length)); } StudentRecordsDAL.Command("INSERT INTO Student (Student_Number, Student_Name, Student_Email, Student_Password, Gender, Date_Of_Birth, Phone_Number, Address_Line_One, " + "Address_Line_Two, City, State, Postcode) VALUES ('" + studentNumberStr + "', '" + data["Student_Name"] + "', '" + studentEmail + counter + "@our.ecu.edu.au', '" + data["Student_Password"] + "', " + data["Gender"] + ", #" + data["Date_Of_Birth"] + "#, '" + data["Phone_Number"] + "', '" + data["Address_Line_One"] + "', '" + data["Address_Line_Two"] + "', '" + data["City"] + "', " + data["State"] + ", '" + data["Postcode"] + "')"); } }
protected StudentResults() { displayTypes = new Dictionary <string, DisplayMetadata>(); displayTypes.Add("Attempt_ID", new DisplayMetadata(DisplayMetadata.FieldTypes.ID, "Attempt ID")); displayTypes.Add("Student_Number", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Student Number")); displayTypes.Add("Student_Name", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Student Name")); displayTypes.Add("Course_Code", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Course Code")); displayTypes.Add("Course_Average", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Course Average")); displayTypes.Add("Credit_Points", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Credit Points Earned")); displayTypes.Add("Credit_Points_Required", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Credit Points Required")); displayTypes.Add("Course_Status", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Course Status")); displayTypes.Add("Units_Attempted", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Units Attempted")); displayTypes.Add("Highest_Mark", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Highest Mark")); displayTypes.Add("Lowest_Mark", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Lowest Mark")); validationTypes = new Dictionary <string, EditMetadata>(); validationTypes.Add("Attempt_ID", new EditMetadata(EditMetadata.FieldTypes.ID, "", "Attempt ID")); Dictionary <string, string> students = new Dictionary <string, string>(); foreach (Dictionary <string, object> studentData in StudentRecordsDAL.Query("SELECT * FROM Student")) { students.Add(studentData["Student_ID"].ToString(), studentData["Student_Name"].ToString()); } EditMetadata student = new EditMetadata(EditMetadata.FieldTypes.Dropdown, "You must add an entry to the student table.", "Student"); student.SetDropdownValues(students); validationTypes.Add("Student_ID", student); Dictionary <string, string> courses = new Dictionary <string, string>(); foreach (Dictionary <string, object> courseData in StudentRecordsDAL.Query("SELECT * FROM Course")) { courses.Add(courseData["Course_ID"].ToString(), courseData["Course_Title"].ToString()); } EditMetadata course = new EditMetadata(EditMetadata.FieldTypes.Dropdown, "You must add an entry to the course table.", "Course"); course.SetDropdownValues(courses); validationTypes.Add("Course_ID", course); }
protected Students_UnitAttempts() { displayTypes = new Dictionary <string, DisplayMetadata>(); displayTypes.Add("Unit_Att_ID", new DisplayMetadata(DisplayMetadata.FieldTypes.ID, "Unit Attempt ID")); displayTypes.Add("Student_Number", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Student Number")); displayTypes.Add("Student_Name", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Student Name")); displayTypes.Add("Course_Code", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Course Code")); displayTypes.Add("Unit_Code", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Unit Code")); displayTypes.Add("Semester_Attempted", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, "Semester Attempted")); displayTypes.Add("Attempt_Mark", new DisplayMetadata(DisplayMetadata.FieldTypes.Text, true, "Attempt Mark")); validationTypes = new Dictionary <string, EditMetadata>(); validationTypes.Add("Unit_Att_ID", new EditMetadata(EditMetadata.FieldTypes.ID, "", "Unit Attempt ID")); Dictionary <string, string> courseAttempts = new Dictionary <string, string>(); foreach (Dictionary <string, object> attemptData in StudentRecordsDAL.Query("SELECT * FROM Attempt_Lookup")) { courseAttempts.Add(attemptData["Attempt_ID"].ToString(), attemptData["Attempt"].ToString()); } EditMetadata attempt = new EditMetadata(EditMetadata.FieldTypes.Dropdown, "You must add an entry to the student results table.", "Course Attempt"); attempt.SetDropdownValues(courseAttempts); validationTypes.Add("Attempt_ID", attempt); Dictionary <string, string> units = new Dictionary <string, string>(); foreach (Dictionary <string, object> unitData in StudentRecordsDAL.Query("SELECT * FROM Unit")) { units.Add(unitData["Unit_ID"].ToString(), unitData["Unit_Code"].ToString()); } EditMetadata unit = new EditMetadata(EditMetadata.FieldTypes.Dropdown, "You must add an entry to the unit table.", "Unit"); unit.SetDropdownValues(units); validationTypes.Add("Unit_ID", unit); validationTypes.Add("Semester_Attempted", new EditMetadata("^[0-9]{2}(1|2)$", "You must enter 2 numbers followed by a 1 or a 2.", "Semester Attempted")); validationTypes.Add("Attempt_Mark", new EditMetadata("^([0-9]{1,2}|100)$", "You must enter a mark between 0 and 100.", "Attempt Mark")); }
protected void delete_button(object sender, EventArgs e) { ArrayList deleteQueue = new ArrayList(); foreach (string key in Request.Form) { Match match = Regex.Match(key, "^check([0-9]+)$"); if (match.Success) { deleteQueue.Add(Request.Form["rowid" + match.Groups[1]]); } } ArrayList deleteErr = new ArrayList(); string errTable = ""; foreach (string id in deleteQueue) { try { StudentRecordsDAL.Command("DELETE FROM " + table + " WHERE " + idCol + " = " + id); } catch (OleDbException ex) { errTable = Regex.Match(ex.Message, "'([a-z_A-Z]+)' includes related records\\.$").Groups[1].ToString(); deleteErr.Add(id); } } errTable = errTable.Replace("_", " "); errTable += "s"; if (errTable != "s") { ScriptManager.RegisterStartupScript(this, this.GetType(), "KeyClient", "alert('Unable to delete " + deleteErr.Count + " row(s) due to related entries in " + errTable + ".'); reloadAsGet();", true); } else { Response.Redirect(Request.RawUrl); } }
private void btnDeleteClick(object sender, EventArgs e) { string id; Match match = Regex.Match(((Button)sender).ID, "^delete([0-9]+)$"); if (match.Success) { id = match.Groups[1].ToString(); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "KeyClient", "alert('Unable to delete row due to unknown error')", true); return; } string errTable = ""; try { StudentRecordsDAL.Command("DELETE FROM " + table + " WHERE " + idCol + " = " + id); } catch (OleDbException ex) { errTable = Regex.Match(ex.Message, "'([a-z_A-Z]+)' includes related records\\.$").Groups[1].ToString(); } errTable = errTable.Replace("_", " "); errTable += "s"; if (errTable != "s") { ScriptManager.RegisterStartupScript(this, this.GetType(), "KeyClient", "alert('Unable to delete row due to related entries in " + errTable + ".'); reloadAsGet();", true); } else { Response.Redirect(Request.RawUrl); } }
private string unitAttemptChecks(object unitcode) { this.unitcode = unitcode.ToString(); if (uattemptid == "") { uattemptid = "0"; } int count = StudentRecordsDAL.Query("SELECT * FROM Unit_Attempt WHERE Attempt_ID=" + attemptid + " AND Unit_ID=" + unitcode.ToString() + " AND Unit_Att_ID<>" + uattemptid).Count; int passed = StudentRecordsDAL.Query("SELECT * FROM Unit_Attempt WHERE Attempt_ID=" + attemptid + " AND Unit_ID=" + unitcode.ToString() + " AND Unit_Att_ID<>" + uattemptid + " AND Attempt_Mark>49").Count; if (passed > 0) { return("Unit cannot be passed twice."); } else if (count > 2) { return("Unit cannot be enrolled in a 4th time."); } else { return(null); } }
protected void Page_Load(object sender, EventArgs e) { ((HtmlControl)Master.FindControl("Stu")).Attributes.Add("class", "active"); ((HtmlControl)Master.FindControl("StuU")).Attributes.Add("class", "active"); ((Literal)Master.FindControl("pagetitle")).Text = " - Unit Attempts"; Dictionary <string, string> students = new Dictionary <string, string>(); students.Add("0", "All Students"); foreach (Dictionary <string, object> studentsData in StudentRecordsDAL.Query("SELECT * FROM Student")) { students.Add(studentsData["Student_ID"].ToString(), studentsData["Student_Number"].ToString() + " - " + studentsData["Student_Name"]); } filterBox.ID = "filterdrop_"; filterBox.DataSource = students; filterBox.DataValueField = "Key"; filterBox.DataTextField = "Value"; filterBox.DataBind(); if (IsPostBack) { foreach (string key in Request.Form) { if (key.EndsWith("addButton") || Regex.Match(key, "edit([0-9]+)$").Success || key.EndsWith("editRow")) { filterBox.Visible = false; } else { if (key.EndsWith("filterdrop_")) { filterBox.SelectedValue = Request.Form[key]; } } } if (filterBox.SelectedValue != "0") { RecordsDataControl.BindViewData(StudentRecordsDAL.Query("SELECT * FROM Unit_Attempt_Details WHERE Student_ID=" + filterBox.SelectedValue)); } else { RecordsDataControl.BindViewData(StudentRecordsDAL.Query("SELECT * FROM Unit_Attempt_Details")); } } else { filterBox.SelectedValue = "0"; RecordsDataControl.BindViewData(StudentRecordsDAL.Query("SELECT * FROM Unit_Attempt_Details")); } RecordsDataControl.BindEditData(StudentRecordsDAL.Query("SELECT * FROM Unit_Attempt")); RecordsDataControl.SetTableName("Unit_Attempt"); RecordsDataControl.SetDisplayMetadata(displayTypes); RecordsDataControl.SetEditMetadata(validationTypes); RecordsDataControl.AddValidationMethod("Unit_Att_ID", setUnitAttemptID); RecordsDataControl.AddValidationMethod("Attempt_ID", setAttemptID); RecordsDataControl.AddValidationMethod("Unit_ID", unitAttemptChecks); RecordsDataControl.AddValidationMethod("Semester_Attempted", multipleSemesterAttempts); RecordsDataControl.SetFunction(updateDB); RecordsDataControl.BuildControl(); }
private string checkEnrolment(object courseid) { return(StudentRecordsDAL.Query("SELECT * FROM Course_Attempt WHERE Attempt_ID<>" + attemptID + " AND Student_ID=" + studentID + " AND Course_ID=" + courseid.ToString()).Count == 0 ? null : "Course already enrolled in."); }
private string courseCodeUnique(object code) { return StudentRecordsDAL.Query("SELECT * FROM Course WHERE Course_Code='" + code.ToString() + "' AND Course_ID<>" + id).Count == 0 ? null : "Course code not unique."; }
private string multipleSemesterAttempts(object semester) { return(StudentRecordsDAL.Query("SELECT * FROM Unit_Attempt WHERE Attempt_ID=" + attemptid + " AND Unit_ID=" + unitcode + " AND Semester_Attempted=" + semester.ToString() + " AND Unit_Att_ID<>" + uattemptid).Count == 0 ? null : "Unit already enrolled in semester."); }
private string unitCodeUnique(object code) { return(StudentRecordsDAL.Query("SELECT * FROM Unit WHERE Unit_Code='" + code.ToString() + "' AND Unit_ID<>" + id).Count == 0 ? null : "Unit code not unique."); }