public void ChangeItemTest() { var repo = new MarksRepository(_context); var item = new Mark { Student = _context.Students.FirstOrDefault(), TeachSubj = _context.TeachSubjs.FirstOrDefault(), StudentsMark = 77 }; repo.AddItem(item); int Id = _context.Marks.FirstOrDefault(x => x.Student.Id == item.Student.Id && x.TeachSubj.Id == item.TeachSubj.Id && x.StudentsMark == item.StudentsMark).Id; var newitem = repo.GetItem(Id); newitem.StudentsMark = 83; repo.ChangeItem(newitem); var gotitem = repo.GetItem(Id); Assert.AreEqual(newitem.Student.Id, gotitem.Student.Id); Assert.AreEqual(newitem.StudentsMark, gotitem.StudentsMark); Assert.AreEqual(newitem.TeachSubj.TeacherId, gotitem.TeachSubj.TeacherId); Assert.AreEqual(newitem.TeachSubj.SubjId, gotitem.TeachSubj.SubjId); _context.Marks.Remove(newitem); }
public AkademineisScreen(Student student)//constructor, when going to this screen we can provide values/objects to this screen { InitializeComponent(); this.student = student; repository = new MarksRepository();//initialize repository StudentNameLabel.Text = student.FirstName + " " + student.LastName; }
public StaffMainScreen(Staff staff)//when going to this screen you have to provide staff object { InitializeComponent(); this.staff = staff; repository = new MarksRepository(); subteachRepository = new SubjectsTeachersRepository(); if (staff.TypeId == 2)//if staff is ADMIN then show these panels, otherwise dont { TvarkytiNaudotojusPanel.Visible = true; SubjectTeacherPanel.Visible = true; } groupsList = subteachRepository.GetGroupsOfStaff(staff.StaffId); subjectsList = subteachRepository.GetSubjectsOfStaff(staff.StaffId); for (int a = 0; a < subjectsList.Count; a++) { SubjectNameDisplaycomboBox.Items.Add(subjectsList[a].Title); } for (int a = 0; a < groupsList.Count; a++) { GroupNameDisplaycomboBox.Items.Add(groupsList[a].Name); } UserName.Text = staff.Username + "" + staff.Password; }
public StudentService() { _context = new SchoolContext(); _subjectRepository = new SubjectRepository(_context); _studentRepository = new StudentRepository(_context); _markRepository = new MarksRepository(_context); _subjectService = new SubjectService(_subjectRepository); }
public SubjectService(SubjectRepository subjectRepository) { _markRepository = new MarksRepository(new SchoolContext()); _database = new SchoolContext(); // _studentService = new StudentService(); _subjectRepository = subjectRepository; _markService = new MarkService(); }
public override void InitParams() { dbSet = _context.Marks; r = new MarksRepository(_context); model1 = new Mark { MarkStud = 1, Student = _context.Students.FirstOrDefault(), TeachSubj = _context.TeachSubjs.FirstOrDefault() }; model2 = new Mark { MarkStud = 2, Student = _context.Students.FirstOrDefault(), TeachSubj = _context.TeachSubjs.FirstOrDefault() }; }
private void AddMarkButton_Click(object sender, EventArgs e) { int mark = int.Parse(MarkComboBox.SelectedItem.ToString()); Student student = CurrentStudent(); int studentId = StudentRepository.GetIdByJmbg(student.Jmbg); int courseId = CoursesRepository.GetIdByTitle(GetCurrentCourse()); bool isMarkAdded = MarksRepository.InsertMark(mark, studentId, courseId); if (isMarkAdded) { FillStudentMarks(); } }
public WorksService( WorksRepository worksRepository, MarksRepository marksRepository, WorkTypesRepository workTypesRepository, PersonsRepository personsRepository, IMemoryCache memoryCache) { _worksRepository = worksRepository; _marksRepository = marksRepository; _workTypesRepository = workTypesRepository; _personsRepository = personsRepository; _memoryCache = memoryCache; }
static Unit() { _context = new MyAppDbContext("MyAppConnStr"); DepartmentsRepository = new DepartmentsRepository(_context); TeachersRepository = new TeachersRepository(_context); SubjectsRepository = new SubjectsRepository(_context); SpecialitiesRepository = new SpecialitiesRepository(_context); GroupsRepository = new GroupsRepository(_context); PhonesRepository = new PhonesRepository(_context); StudentsRepository = new StudentsRepository(_context); AudiencesRepository = new AudiencesRepository(_context); AudLectRepository = new AudLectRepository(_context); LectionsRepository = new LectionsRepository(_context); MarksRepository = new MarksRepository(_context); TeachSubjRepository = new TeachSubjRepository(_context); }
public void AllItemsTest() { var repo = new MarksRepository(_context); Assert.AreEqual(_context.Marks.Count(), repo.AllItems.Count()); var item1 = new Mark { Student = _context.Students.FirstOrDefault(), TeachSubj = _context.TeachSubjs.FirstOrDefault(), StudentsMark = 55 }; repo.AddItem(item1); Assert.AreEqual(_context.Marks.Count(), repo.AllItems.Count()); _context.Marks.Remove(item1); }
static Unit() { _context = new MyAppDbContext("MyAppConnStr"); AddressesRepository = new AddressesRepository(_context); ClassroomsRepository = new ClassroomsRepository(_context); DepartmentsRepository = new DepartmentsRepository(_context); GroupsRepository = new GroupsRepository(_context); GroupTimetablesRepository = new GroupTimetablesRepository(_context); MarksRepository = new MarksRepository(_context); PairTimetablesRepository = new PairTimetablesRepository(_context); PhonesRepository = new PhonesRepository(_context); SpecialitiesRepository = new SpecialitiesRepository(_context); StudentsRepository = new StudentsRepository(_context); SubjectsRepository = new SubjectsRepository(_context); TeachSubjsRepository = new TeachSubjsRepository(_context); TeachersRepository = new TeachersRepository(_context); TimetablesRepository = new TimetablesRepository(_context); }
private void FillStudentMarks() { try { Student student = CurrentStudent(); int studentId = StudentRepository.GetIdByJmbg(student.Jmbg); int courseId = CoursesRepository.GetIdByTitle(GetCurrentCourse()); string marks = MarksRepository.GetMarks(studentId, courseId); MarksLabel.Text = marks; string[] parts = marks.Split(','); if (parts.Length > 0) { AverageMarkLabel.Text = CalculateAverageGrade(parts); } } catch (Exception e) { MessageBox.Show(e.Message); } }
public void AddItemTest() { var repo = new MarksRepository(_context); var item = new Mark { Student = _context.Students.FirstOrDefault(), TeachSubj = _context.TeachSubjs.FirstOrDefault(), StudentsMark = 55 }; repo.AddItem(item); var newitem = _context.Marks.FirstOrDefault(x => x.Student.Id == item.Student.Id && x.TeachSubj.Id == item.TeachSubj.Id && x.StudentsMark == item.StudentsMark); Assert.AreEqual(item.Student.Id, newitem.Student.Id); Assert.AreEqual(item.StudentsMark, newitem.StudentsMark); Assert.AreEqual(item.TeachSubj.TeacherId, newitem.TeachSubj.TeacherId); Assert.AreEqual(item.TeachSubj.SubjId, newitem.TeachSubj.SubjId); _context.Marks.Remove(item); }
public void AddItemsTest() { var repo = new MarksRepository(_context); var item1 = new Mark { Student = _context.Students.FirstOrDefault(), TeachSubj = _context.TeachSubjs.FirstOrDefault(x => x.Subject.Id == 1), StudentsMark = 55 }; var item2 = new Mark { Student = _context.Students.FirstOrDefault(), TeachSubj = _context.TeachSubjs.FirstOrDefault(x => x.Subject.Id == 2), StudentsMark = 55 }; Mark[] items = new Mark[] { item1, item2 }; repo.AddItems(items); var newitem1 = _context.Marks.FirstOrDefault(x => x.Student.Id == item1.Student.Id && x.TeachSubj.Id == item1.TeachSubj.Id && x.StudentsMark == item1.StudentsMark); var newitem2 = _context.Marks.FirstOrDefault(x => x.Student.Id == item2.Student.Id && x.TeachSubj.Id == item2.TeachSubj.Id && x.StudentsMark == item2.StudentsMark); Assert.AreEqual(items[0].StudentsMark, newitem1.StudentsMark); Assert.AreEqual(items[0].Student.Id, newitem1.Student.Id); Assert.AreEqual(items[0].TeachSubj.TeacherId, newitem1.TeachSubj.TeacherId); Assert.AreEqual(items[0].TeachSubj.SubjId, newitem1.TeachSubj.SubjId); Assert.AreEqual(items[1].StudentsMark, newitem2.StudentsMark); Assert.AreEqual(items[1].Student.Id, newitem2.Student.Id); Assert.AreEqual(items[1].TeachSubj.TeacherId, newitem2.TeachSubj.TeacherId); Assert.AreEqual(items[1].TeachSubj.SubjId, newitem2.TeachSubj.SubjId); _context.Marks.Remove(item1); _context.Marks.Remove(item2); }
public void GetItemExceptionTest() { var repo = new MarksRepository(_context); var item1 = repo.GetItem(-1).StudentsMark; }
public MarksController() { dbContext = new StudentsEntities(); this.repository = new MarksRepository(dbContext); }
private void PrintStatisticTeacherRoundedButton_Click(object sender, EventArgs e) { int columnNumber = 6; PdfPTable table = new PdfPTable(columnNumber) { //actual width of table in points TotalWidth = 400f, //fix the absolute width of the table LockedWidth = true }; //relative col widths in proportions - 1/3 and 2/3 float[] widths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f }; table.SetWidths(widths); table.HorizontalAlignment = 0; //leave a gap before and after the table table.SpacingBefore = 20f; table.SpacingAfter = 30f; PdfPCell cell = new PdfPCell(new Phrase("Ucenici")) { Colspan = columnNumber, Border = 0, HorizontalAlignment = 1 }; table.AddCell(cell); table.AddCell("Ime"); table.AddCell("Prezime"); table.AddCell("Odsustva(U)"); table.AddCell("Odsustva(O)"); table.AddCell("Odsustva(N)"); table.AddCell("Prosjek"); int TeacherId = CurrentTeacher.Id; int DepartmentId = DepartmentsRepository.GetIdByTeacherId(TeacherId); string StudentsQuery = StudentRepository.GetQuery(DepartmentId); SqlCeCommand cmd = new SqlCeCommand(StudentsQuery, Connection); SqlCeDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) { int justifiedAbsents = AbsentsRepository.GetAbsents((int)reader["Id"], 1); int unJustifiedAbsents = AbsentsRepository.GetAbsents((int)reader["Id"], 0); int sum = justifiedAbsents + unJustifiedAbsents; string CoursesId = CoursesRepository.GetCoursesId(); string[] parts = CoursesId.Split(','); int suum = 0; for (int i = 0; i < parts.Length; i++) { string marks = MarksRepository.GetMarks((int)reader["Id"]); string[] particles = marks.Split(','); double mark = Math.Round(float.Parse(CalculateAverageGrade(particles)), MidpointRounding.AwayFromZero); suum += (int)mark; } float average = suum / (parts.Length); string averageMark = average.ToString("0.00") + "(" + Math.Round(average, MidpointRounding.AwayFromZero) + ")"; table.AddCell(reader["Name"].ToString()); table.AddCell(reader["Surname"].ToString()); table.AddCell(sum.ToString()); table.AddCell(justifiedAbsents.ToString()); table.AddCell(unJustifiedAbsents.ToString()); table.AddCell(averageMark); } } catch (Exception ex) { MessageBox.Show(ex.Message); } LoginForm logf = new LoginForm(); string Dir = logf.GetHomeDirectory(); FileStream fs = new FileStream("report.pdf", FileMode.Create); Document doc = new Document(PageSize.A4); PdfWriter pdfWriter = PdfWriter.GetInstance(doc, fs); doc.Open(); doc.Add(table); while (reader.Read()) { doc.Add(new Paragraph(reader[0].ToString() + reader[1].ToString() + reader[2].ToString())); } pdfWriter.CloseStream = true; doc.Close(); Process.Start("report.pdf"); }
public MarksController(MarksRepository marksRepository, CourseRepository courseRepository, StudentRepository studentRepository) { this.marksRepository = marksRepository; this.courseRepository = courseRepository; this.studentRepository = studentRepository; }
public MarkService() { _database = new SchoolContext(); _markRepository = new MarksRepository(new SchoolContext()); }
public StudentMarkManagement() { repository = new MarksRepository(); }