public static void AddCourseStatus(string CourseCode, string Session, Boolean Status) { ProjectDB db = new ProjectDB(); Course Course = db.Courses.Where(dp => dp.Course_code == CourseCode).FirstOrDefault(); if (Course == null) { return; } CourseStatus OldCourseStatus = db.CourseStatus.Where(dp => dp.Course_code == Course.Course_code && dp.UnderSession == Session).FirstOrDefault(); if (OldCourseStatus != null) { return; } CourseStatus CourseStatus = new CourseStatus(); CourseStatus.Course_code = Course.Course_code; CourseStatus.Course_title = Course.Course_title; CourseStatus.Credit_hour = Course.Credit_hour; CourseStatus.Semester = Course.Semester; CourseStatus.UnderFaculty = Course.UnderFaculty; CourseStatus.UnderDepartment = Course.UnderDepartment; CourseStatus.CourseTeacherID = Course.CourseTeacherID; CourseStatus.CourseTeacherName = Course.CourseTeacherName; CourseStatus.CourseTeacherDepartment = Course.CourseTeacherDepartment; CourseStatus.CourseTeacherFaculty = Course.CourseTeacherFaculty; CourseStatus.UnderSession = Session; CourseStatus.Status = Status; db.CourseStatus.Add(CourseStatus); db.SaveChanges(); }
public static List <Result> GetResults(string Session, int Semester) { int batchId = Convert.ToInt32(Session.Substring(2, 2)); //startIndex, Length int startRange = batchId * 100000; int endRange = ((batchId + 1) * 100000) - 1; ProjectDB db = new ProjectDB(); List <Result> AllResults = new List <Result>(); AllResults = db.FinalResults.Where(fr => fr.StudentId >= startRange && fr.StudentId <= endRange && fr.Semester == Semester).ToList(); return(AllResults); }
public static Boolean UpdateCourseStatus(string CourseCode, string Session, Boolean Status) { ProjectDB db = new ProjectDB(); CourseStatus CourseStatus = db.CourseStatus.Where(dp => dp.Course_code == CourseCode && dp.UnderSession == Session).FirstOrDefault(); if (CourseStatus == null) { return(false); } CourseStatus.Status = Status; db.Entry(CourseStatus).State = EntityState.Modified; db.SaveChanges(); return(true); }
public static Boolean IsMarkSubmitted(Course Course, string Session) { if (Course == null || Session == null) { return(false); } ProjectDB db = new ProjectDB(); CourseStatus CourseStatus = db.CourseStatus.Where(cs => cs.Course_code == Course.Course_code && cs.UnderSession == Session).FirstOrDefault(); if (CourseStatus == null || CourseStatus.Status == false) { return(false); } return(true); }
public static List <Course> GetEnrollCourses(string Faculty, string Session, int Semester) { ProjectDB db = new ProjectDB(); List <Course> Courses = new List <Course>(); string tableName = (Semester % 2 == 0) ? "JulEnrollment" : "JanEnrollment"; SqlConnection myConn = new SqlConnectionGenerator().FromFaculty(Faculty); string SQLCmd = "select column_name from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='" + tableName + "'"; // * can be column_name, data_type, column_default, is_nullable SqlCommand myCommand = new SqlCommand(SQLCmd, myConn); try { myConn.Open(); SqlDataReader oReader = myCommand.ExecuteReader(); while (oReader.Read()) { string key = Convert.ToString(oReader.GetValue(0)); if (!(key.Equals("id") || key.Equals("Name") || key.Equals("StudentId") || key.Equals("RegNo") || key.Equals("Session") || key.Equals("Semester"))) { Course Course = db.Courses.Where(c => c.Course_code == key).FirstOrDefault(); if (Course != null) { int ObSem = Course.GetSemesterFromCourse(Course.Course_code); if (ObSem == Semester) { Courses.Add(Course); } } } } } catch (System.Exception ex) { } finally { if (myConn.State == ConnectionState.Open) { myConn.Close(); } } return(Courses); }
public static List <GradeSheetDataModel> GetResultsGradeSheet(string Faculty, string Session, int Semester) { List <int> StudentList = new GetEnrollment(Faculty).GetCurrentStudentBySemester(Semester); ProjectDB db = new ProjectDB(); List <Result> AllResults = new List <Result>(); foreach (int StudentId in StudentList) { AllResults.Add(db.FinalResults.Where(fr => fr.StudentId == StudentId && fr.Semester == Semester).FirstOrDefault()); } List <GradeSheetDataModel> gradeSheetData = new List <GradeSheetDataModel>(); JavaScriptSerializer js = new JavaScriptSerializer(); foreach (Result result in AllResults) { if (result != null) { GradeSheetDataModel gradeSheetDataModel = new GradeSheetDataModel(); gradeSheetDataModel.Name = result.Name; gradeSheetDataModel.StudentId = result.StudentId; gradeSheetDataModel.RegNo = result.RegNo; gradeSheetDataModel.Faculty = result.Faculty; gradeSheetDataModel.Session = result.Session; gradeSheetDataModel.Semester = result.Semester; gradeSheetDataModel.Degree = result.Degree; gradeSheetDataModel.CourseResults = js.Deserialize <List <CourseResult> >(result.CourseResults); gradeSheetDataModel.GPA = result.GPA; gradeSheetDataModel.PrevCGPA = result.PrevCGPA; gradeSheetDataModel.PrevCCH = result.PrevCCH; gradeSheetDataModel.CGPA = result.CGPA; gradeSheetDataModel.CCH = result.CCH; gradeSheetDataModel.Remarks = result.Remarks.Replace("_", "-"); gradeSheetData.Add(gradeSheetDataModel); } } return(gradeSheetData); }
public static List <StudentInfo> GetStudentInfo(List <CurrentSemester> CurrentSemester) { if (CurrentSemester == null) { return(null); } List <StudentInfo> AllStudents = new List <StudentInfo>(); ProjectDB db = new ProjectDB(); foreach (CurrentSemester cs in CurrentSemester) { StudentInfo Student = db.StudentInfo.Where(si => si.StudentId == cs.StudentId).FirstOrDefault(); if (Student != null) { AllStudents.Add(Student); } } return(AllStudents); }
public static Boolean CalculateResult(List <StudentInfo> Students, int Semester, List <Course> Courses) { if (Students == null || Semester == 0 || Courses == null) { return(false); } ProjectDB db = new ProjectDB(); JavaScriptSerializer js = new JavaScriptSerializer(); foreach (StudentInfo Student in Students) { Result Result = new Result(); Result.Name = Student.Name; Result.StudentId = Student.StudentId; Result.RegNo = Student.Reg; Result.Faculty = Student.Faculty; Result.Session = Student.Session; Result.Semester = Semester; Result.Degree = ""; float TotalCHGP = 0, TotalCH = 0; string Remarks = ""; List <CourseResult> CourseResults = new List <CourseResult>(); foreach (Course Course in Courses) { Marks mark = new Marks().GetMark(Course.UnderFaculty, Course.Course_code, Student.StudentId); if (mark != null) { float TotalMark = 0; if (mark.Mid != -1) { TotalMark += mark.Mid; } if (mark.Assignment != -1) { TotalMark += mark.Assignment; } if (mark.Attendence != -1) { TotalMark += mark.Attendence; } if (mark.Final != -1) { TotalMark += mark.Final; } CourseResult CourseResult = new CourseResult(); CourseResult.CourseCode = Course.Course_code; CourseResult.CourseTitle = Course.Course_title; CourseResult.CreditHours = Course.Credit_hour; CourseResult.TotalMark = TotalMark; CourseResult.LetterGrade = Marks.CalculateLetterGrade(TotalMark); float GP = Marks.WrapToFloatPoint3(Marks.CalculateGP(TotalMark)); CourseResult.GP = GP; Boolean IsPassed = Marks.IsPassed(TotalMark); CourseResult.IsPassed = IsPassed; CourseResults.Add(CourseResult); if (IsPassed) { TotalCHGP += (Course.Credit_hour * GP); TotalCH += Course.Credit_hour; } else { Remarks += Course.Course_code + ","; } } } float GPA = 0; if (CourseResults != null) { Result.CourseResults = js.Serialize(CourseResults); } if (TotalCHGP != 0 && TotalCH != 0) { GPA = Marks.WrapToFloatPoint3(TotalCHGP / TotalCH); } Result.GPA = GPA; if (Remarks != "") { Remarks = Remarks.Substring(0, Remarks.Length - 1); } if (Semester == 1) { Result.PrevCGPA = 0; Result.PrevCCH = 0; Result.CGPA = GPA; Result.CCH = TotalCH; Result.Remarks = Remarks; if (Remarks == "") { Result.IsMeritListed = true; } else { Result.IsMeritListed = false; } } else { int PrevSem = Semester - 1; Result PrevRes = db.FinalResults.Where(fr => fr.StudentId == Result.StudentId && fr.Semester == PrevSem).FirstOrDefault(); if (PrevRes != null) { Result.PrevCGPA = PrevRes.CGPA; Result.PrevCCH = PrevRes.CCH; Result.CGPA = Marks.WrapToFloatPoint3(Marks.CalculateCGPA(GPA, TotalCH, PrevRes.CGPA, PrevRes.CCH)); Result.CCH = TotalCH + PrevRes.CCH; if (PrevRes.Remarks == "") { Result.Remarks = Remarks; } else { string PrevRemarks = Course.CheckRemarks(Student.Faculty, Student.StudentId, PrevRes.Remarks); if (Remarks != "") { if (PrevRemarks != "" || PrevRemarks != null) { Result.Remarks = PrevRes.Remarks + "," + Remarks; } else { Result.Remarks = Remarks; } } else { Result.Remarks = PrevRes.Remarks; } } if (!PrevRes.IsMeritListed) { Result.IsMeritListed = false; } else { if (Remarks == "") { Result.IsMeritListed = true; } else { Result.IsMeritListed = false; } } } } Result OldRes = db.FinalResults.Where(fr => fr.StudentId == Result.StudentId && fr.Semester == Semester).FirstOrDefault(); if (OldRes != null) { db.FinalResults.Remove(OldRes); } db.FinalResults.Add(Result); db.SaveChanges(); } return(true); }
public static Result GetResult(int StudentId, int Semester) { Result Result = new ProjectDB().FinalResults.Where(fr => fr.StudentId == StudentId && fr.Semester == Semester).FirstOrDefault(); return(Result); }