public Student ReturnBook(Student student, Book book) { // TO DO CHECK FOR VALID ID var lookupId = book.Id; student.BookId.Remove(student.BookId.First(x => x.Equals(lookupId))); return student; }
public StudentsCard(int Id) { InitializeComponent(); var db = XmlHandler.GetDB(); presentedStudent = db.StudentsList.First(x => x.Id == Id); FillStudent(); }
public Student LendBook(Student student, Book book) { var newBook = book; //newBook.BorrowTime = DateTime.Now; student.BookId.Add(book.Id); return student; }
private Student getStudent() { // TO DO CHECK FOR VALID DATA var stud = new Student { Surname = surnameTextbox.Text, Name = nameTextbox.Text, Class = classTextbox.Text }; return stud; }
public AddStudent(Student student) { InitializeComponent(); addButton.Click -= addButton_Click; addButton.Click += editButton_Click; addButton.Text = "Edytuj"; nameTextbox.Text = student.Name; surnameTextbox.Text = student.Surname; classTextbox.Text = student.Class; editedStudent = student; }
public static void AddStudent(Student student) { // TO DO CHECK FOR DUPLICATE var db = XmlHandler.GetDB(); student.Id = db.StudentsList.OrderByDescending(x => x.Id).First().Id + 1; //Sorting by Id, getting highest and adding 1 db.StudentsList.Add(student); XmlHandler.SaveDB(db); MessageBox.Show("Uczeń " + student.Name + " " + student.Surname + " z klasy " + student.Class + " został dodany do bazy danych!"); }
private static DataGridViewRow FillRow(Student student, int indexNumber) { var row = new DataGridViewRow(); for (var i = 0; i < 5; i++) { row.Cells.Add(new DataGridViewTextBoxCell()); } row.Cells[0].Value = student.Id; row.Cells[1].Value = student.Surname; row.Cells[2].Value = student.Name; row.Cells[3].Value = student.Class; row.Cells[4].Value = student.BookId.Count; row.HeaderCell.Value = indexNumber.ToString(); return row; }
public StudentsCard(Student student) { InitializeComponent(); presentedStudent = student; FillStudent(); }
public static bool DeleteStudent(Student student, bool prompt) { if (prompt) { var confirmResult = MessageBox.Show("Czy na pewno skasować tego ucznia?", "Potwierdź usunięcie", MessageBoxButtons.YesNo); if (confirmResult != DialogResult.Yes) return false; } var db = XmlHandler.GetDB(); db.StudentsList.RemoveAll(x => x.Id == student.Id); XmlHandler.SaveDB(db); if (prompt) MessageBox.Show("Uczeń " + student.Name + " " + student.Surname + " z klasy " + student.Class + " został skasowany z bazy danych!"); return true; }
public static void EditStudent(Student original, Student edited) { var db = XmlHandler.GetDB(); // edited.id = original.id; remove original; add edited? original.Surname = edited.Surname; original.Name = edited.Name; original.Class = edited.Class; db.StudentsList.RemoveAll(x => x.Id == original.Id); db.StudentsList.Add(original); XmlHandler.SaveDB(db); MessageBox.Show("Uczeń " + edited.Name + " " + edited.Surname + " z klasy " + edited.Class + " został wyedytowany!"); }