public string SaveResult(Resultsrb aResultsrb) { EnrollCourseGAtewaysrb aenrollAtewaysrb = new EnrollCourseGAtewaysrb(); EnrollCourse aEnrollCourse = new EnrollCourse(); aEnrollCourse.StudentId = aResultsrb.StudentId; aEnrollCourse.CourseId = aResultsrb.CourseId; bool isenrolled = aenrollAtewaysrb.IsExist(aEnrollCourse); if (isenrolled) { ResultGatewaysrb aGatewaysrb = new ResultGatewaysrb(); bool Isexist = aGatewaysrb.isexist(aResultsrb); if (Isexist) { return("Sorry This Course is Graded Before.Try a new One"); } else { int rowaffected = aGatewaysrb.SaveResult(aResultsrb); if (rowaffected > 0) { return("Result has been Saved"); } else { return("Save Failed"); } } } else { return("This Course is not Enrolled by this Student"); } }
public int SaveResult(Resultsrb aResultsrb) { Query = "INSERT INTO StudentResult VALUES('" + aResultsrb.StudentId + "','" + aResultsrb.CourseId + "','" + aResultsrb.Grade + "')"; Command = new SqlCommand(Query, Connection); Connection.Open(); int rowaffected = Command.ExecuteNonQuery(); Connection.Close(); return(rowaffected); }
public bool isexist(Resultsrb aResultsrb) { Query = "SELECT* FROM StudentResult WHERE StudentId='" + aResultsrb.StudentId + "' AND CourseId='" + aResultsrb.CourseId + "'"; Command = new SqlCommand(Query, Connection); Connection.Open(); Reader = Command.ExecuteReader(); if (Reader.HasRows) { Connection.Close(); Reader.Close(); return(true); } else { Connection.Close(); Reader.Close(); return(false); } }
public ActionResult GenerateResult(Resultsrb aResultsrb) { aStudentGom.StudentId = aResultsrb.StudentId; StudentsManagersrb aManagersrb = new StudentsManagersrb(); ViewBag.students = aManagersrb.GetallStudent(); ResultManagersrb aResultManagersrb = new ResultManagersrb(); string result = aResultManagersrb.SaveResult(aResultsrb); if (result == "Sorry This Course is Graded Before.Try a new One" || result == "This Course is not Enrolled by this Student") { ViewBag.failed = result; } else if (result == "Result has been Saved") { ViewBag.success = result; } return(View()); }