public void AddStudentResultMogels() { foreach (var testSession in testSessions) { StudentResultModel studentResultModel = new StudentResultModel(); studentResultModel.TestName = client.GetTestName(testSession.TestId); studentResultModel.StartTime = testSession.StartTime; studentResultModel.EndTime = testSession.EndTime; List <DTOAnswer> answers = client.GetAnswersForTestSession(testSession.TestSessionId).ToList(); studentResultModel.QuestionCount = answers.Count; answers = answers.Where(x => x.AnswerCorrects == true).ToList(); studentResultModel.CountCorrectAnswers = answers.Count; studentResultModel.CountInCorrectAnswers = studentResultModel.QuestionCount - studentResultModel.CountCorrectAnswers; foreach (var item in answers) { studentResultModel.CountScores += questions.FirstOrDefault(q => q.Id == item.QuestionId).QuestionCountScores; } studentResultModels.Add(studentResultModel); } if (studentResultModels.Count != 0) { resultsGrid.ItemsSource = studentResultModels; } }
public string StudentResultSaveManager(StudentResultModel studentResultModel) { if (studentResultGateway.IsExistNotEnorllResult(studentResultModel) != null) { if (studentResultGateway.IsExistResult(studentResultModel) == null) { if (studentResultGateway.StudentResultSaveGateway(studentResultModel) > 0) { return("Save Successfull"); } else { return("Save Fail"); } } else { return(studentResultGateway.IsExistResult(studentResultModel)); } } else { return("This Student are Not Enroll !"); } }
public ActionResult Save(StudentResultModel studentResult) { ViewBag.studentRegNos = enrollCoursesManager.RegNoDropdown(); ViewBag.gradeLetter = studentResultManager.GradeLetter(); ViewBag.Title = "Save Student Rsult"; ViewBag.message = studentResultManager.Save(studentResult); return(View()); }
public string SaveAResult(StudentResultModel studentResultModel) { if (_studentResultGateway.SaveAResult(studentResultModel) == 1) { return("Result Successfully Saved"); } else { return("Failed"); } }
public int SaveAResult(StudentResultModel studentResultModel) { string query = "UPDATE AssignStudentTable SET GradeId = '" + studentResultModel.GradeId + "' where StudentID ='" + studentResultModel.StudentId + "' AND CourseID='" + studentResultModel.CourseId + "' AND Status ='0'"; _command = new SqlCommand(query, _connection); _connection.Open(); int rowAffect = _command.ExecuteNonQuery(); _connection.Close(); return(rowAffect); }
public int SaveResult(StudentResultModel student) { int rowAffected; SqlConnection connection = new SqlConnection(connectionDB); string qurey = "INSERT INTO [StudentResult] (StudentId,CourseId,GradeLaterId,InsertDate) VALUES('" + student.StudentId + "','" + student.CourseId + "','" + student.GradeLaterId + "',GETDATE())"; SqlCommand command = new SqlCommand(qurey, connection); connection.Open(); rowAffected = command.ExecuteNonQuery(); connection.Close(); return(rowAffected); }
//----------------------------------------------------------- public string Save(StudentResultModel studentResult) { int rowEffect = studentResultGateway.Save(studentResult); if (rowEffect > 0) { return("Save Successful"); } else { return("Save Faild"); } }
public ActionResult StudentResult(StudentResultModel student) { ViewBag.RegNo = StudentResultManager.GetAllRegNo(); //ViewBag.Courses = StudentResultManager.GetAllCoursesByRegNo( StudentRegId); ViewBag.GetAllGradeLater = StudentResultManager.GetAllGradeLetter(); if (StudentResultManager.SaveResult(student) > 0) { ViewBag.message = "Saved"; } //ViewBag.Departments = departmentManager.GetDepartment(); ViewBag.PostBack = true; return(View()); }
public int StudentResultSaveGateway(StudentResultModel studentResultModel) { SqlConnection con = new SqlConnection(connectionString); string query = "insert into Result values('" + studentResultModel.StudentId + "','" + studentResultModel.CourseId + "','" + studentResultModel.GradeId + "')"; SqlCommand cmd = new SqlCommand(query, con); con.Open(); int rowAffect = cmd.ExecuteNonQuery(); con.Close(); return(rowAffect); }
//----------------------------------------------------------- public int Save(StudentResultModel studentResult) { query = "INSERT INTO StudentResultTable VALUES(@CourseId,@GradeId)"; Command = new SqlCommand(query, Connection); Command.Parameters.AddWithValue("@CourseId", studentResult.EnrollCourseId); Command.Parameters.AddWithValue("@GradeId", studentResult.GradeLetterId); Connection.Open(); int rowEffect = Command.ExecuteNonQuery(); Connection.Close(); return(rowEffect); }
public string IsExistNotEnorllResult(StudentResultModel studentResultModel) { string message = null; SqlConnection con = new SqlConnection(connectionString); string query = "select * from EnrollCourse Where StudentId='" + studentResultModel.StudentId + "' AND CourseId ='" + studentResultModel.CourseId + "' "; SqlCommand cmd = new SqlCommand(query, con); con.Open(); SqlDataReader dataReader = cmd.ExecuteReader(); if (dataReader.HasRows) { message = "This Student are not Enroll"; } con.Close(); return(message); }
public ActionResult StudentResult(StudentResultModel studentResultModel) { if (ModelState.IsValid) { ViewBag.StudentsRegNo = GetAllStudentForDropDown(); ViewBag.Grades = GetAllGradesForDropDown(); string result = new StudentResultManager().SaveAResult(studentResultModel); ViewData["Message"] = result; ModelState.Clear(); return(View()); } else { ViewData["Message"] = ""; ViewBag.StudentsRegNo = GetAllStudentForDropDown(); ViewBag.Grades = GetAllGradesForDropDown(); return(View()); } }
public string IsExistResult(StudentResultModel studentResultModel) { string message = null; SqlConnection con = new SqlConnection(connectionString); string query = "select * from Result Where StudentId='" + studentResultModel.StudentId + "' AND CourseId='" + studentResultModel.CourseId + "' "; SqlCommand cmd = new SqlCommand(query, con); con.Open(); SqlDataReader dataReader = cmd.ExecuteReader(); if (dataReader.HasRows) { message = "Sorry, Already Result Assigned."; } con.Close(); return(message); }
public List <StudentResultModel> GetAllResultForView(int studentId) { string query = "SELECT CourseTable.CourseCode,CourseTable.CourseName,GradeTable.Grade from AssignStudentTable " + "Inner JOIN CourseTable ON CourseTable.id=AssignStudentTable.CourseID " + "Inner JOIN GradeTable On AssignStudentTable.GradeID=GradeTable.id " + "where AssignStudentTable.StudentID='" + studentId + "' and AssignStudentTable.Status=0"; _command = new SqlCommand(query, _connection); _connection.Open(); _sqlDataReader = _command.ExecuteReader(); List <StudentResultModel> listOfItems = new List <StudentResultModel>(); while (_sqlDataReader.Read()) { StudentResultModel item = new StudentResultModel(); item.CourseCode = _sqlDataReader["CourseCode"].ToString(); item.CourseName = _sqlDataReader["CourseName"].ToString(); item.Grade = _sqlDataReader["Grade"].ToString(); listOfItems.Add(item); } _connection.Close(); return(listOfItems); }
public ActionResult StudentResultSave(StudentResultModel studentResultModel) { ViewBag.message = studentResultManager.StudentResultSaveManager(studentResultModel); TempData["Msg"] = ViewBag.message; return(RedirectToAction("StudentResultSave")); }
public int SaveResult(StudentResultModel student) { return(StudentResultGateway.SaveResult(student)); }
public void SetModel(StudentResultModel model) { Model = model; }