public bool Addmarks(markingscheme m) { DatabaseInsertQuery newmarks = new DatabaseInsertQuery("markingscheme"); newmarks.AddData("name", m.name); newmarks.AddData("createdby", m.createdby); newmarks.AddData("mscheme", m.mscheme); return(newmarks.RunQuery()); }
public bool Addstud(student s) { DatabaseInsertQuery newstudent = new DatabaseInsertQuery("student"); newstudent.AddData("name", s.name); newstudent.AddData("dip", s.dip); newstudent.AddData("matricno", s.matricno); newstudent.AddData("mschemeassigned", s.mschemeassigned); return(newstudent.RunQuery()); }
public bool Addassignment(assignment a) { DatabaseInsertQuery newassignment = new DatabaseInsertQuery("markingassign"); newassignment.AddData("studid", a.studid.ToString()); newassignment.AddData("staffid", a.staffid.ToString()); newassignment.AddData("mschemeid", a.mschemeid.ToString()); newassignment.AddData("componentid", a.componentid.ToString()); newassignment.AddData("assessmsub", a.assessmsub.ToString()); return(newassignment.RunQuery()); }
public bool Addstaff(staff s) { DatabaseInsertQuery newstaff = new DatabaseInsertQuery("staff"); String newSalt = SIPGradingHelper.generateSalt(10); String password = SIPGradingHelper.getSHA512(newSalt + "" + s.passw); newstaff.AddData("username", s.username); newstaff.AddData("name", s.name); newstaff.AddData("passw", password); newstaff.AddData("salt", newSalt); newstaff.AddData("permssn", s.permssn); return(newstaff.RunQuery()); }
public bool ProcessNewAssignment(newAssignment assignment) { for (int x = 0; x < assignment.assignedStaff.Count; x++) { DatabaseRetriveQuery countofstaff = new DatabaseRetriveQuery("markingassign"); countofstaff.AddRestriction("studid", "=", assignment.studentId.ToString()); countofstaff.AddRestriction("staffid", "=", assignment.assignedStaff[x].staffId.ToString()); countofstaff.AddRestriction("mschemeid", "=", assignment.markingschemeId.ToString()); int count = countofstaff.NumRows(); if (count == 0) { DatabaseInsertQuery insertAssessment = new DatabaseInsertQuery("markingassign"); insertAssessment.AddData("studid", assignment.studentId.ToString()); insertAssessment.AddData("staffid", assignment.assignedStaff[x].staffId.ToString()); insertAssessment.AddData("mschemeid", assignment.markingschemeId.ToString()); insertAssessment.AddData("componentid", assignment.assignedStaff[x].componentsAssigned); insertAssessment.RunQuery(); } else { DatabaseUpdateQuery updateAssessment = new DatabaseUpdateQuery("markingassign", "studid = '" + assignment.studentId + "' AND staffid = '" + assignment.assignedStaff[x].staffId + "' AND mschemeid = '" + assignment.markingschemeId + "'"); updateAssessment.AddData("componentid", assignment.assignedStaff[x].componentsAssigned); updateAssessment.AddData("assessmsub", ""); updateAssessment.RunQuery(); } } DatabaseRetriveQuery listOfStaffAssigned = new DatabaseRetriveQuery("markingassign"); listOfStaffAssigned.AddRestriction("studid", "=", assignment.studentId.ToString()); listOfStaffAssigned.AddRestriction("mschemeid", "=", assignment.markingschemeId.ToString()); SqlDataReader dr = listOfStaffAssigned.RunQuery(); List <newAssignmentAssignedStaff> listOfStaffAssignedNow = new List <newAssignmentAssignedStaff>(); while (dr.Read()) { newAssignmentAssignedStaff tmp = new newAssignmentAssignedStaff(); tmp.staffId = (int)dr["staffid"]; tmp.componentsAssigned = (string)dr["componentid"]; listOfStaffAssignedNow.Add(tmp); } for (int x = 0; x < listOfStaffAssignedNow.Count; x++) { bool found = false; for (int y = 0; y < assignment.assignedStaff.Count; y++) { if (listOfStaffAssignedNow[x].staffId == assignment.assignedStaff[y].staffId) { found = true; break; } } if (!found) { DatabaseDeleteQuery deleteAssignment = new DatabaseDeleteQuery("markingassign", "studid = '" + assignment.studentId + "' AND staffid = '" + listOfStaffAssignedNow[x].staffId + "'"); deleteAssignment.RunQuery(); } } return(true); }