public void LoadFromFile(string filename) { try { using (var fs = File.OpenRead(filename)) using (var reader = new StreamReader(fs)) { while (!reader.EndOfStream) { string[] strArray = reader.ReadLine().Split('|'); ReadersTicket rt = new ReadersTicket(Convert.ToInt32(strArray[0]), strArray[1], Convert.ToInt32(strArray[2])); ticketList.Add(rt); if (rt.Id > maxID) { maxID = rt.Id; } } } } catch (FileNotFoundException) { } maxID++; }
public void AddTicket(string fio, int specialtyID) { ReadersTicket rt = GetTicketByParams(fio, specialtyID); if (rt == null) { rt = new ReadersTicket(maxID++, fio, specialtyID); ticketList.Add(rt); } }
public Formular GetFormularByLinks(Book bookLink, ReadersTicket ticketLink) { foreach (Formular frm in formularList) { if (frm.BookLink == bookLink && frm.ReaderLink == ticketLink) { return(frm); } } return(null); }
private void buttonTicketAdd_Click(object sender, EventArgs e) { string fio = textTicketSearchName.Text; int spec = comboTicketSearchSpecialty.SelectedIndex; ReadersTicket rt = linkedModel.FindMatchingTicket(fio, spec); if (rt != null) { notify("Билет с указанными параметрами уже находится в базе."); } else { notify("Билет добавлен в базу и выбран в панели."); selectedTicket = linkedModel.AddTicket(fio, spec); OnChangingSelectedTicket?.Invoke(this, null); } }
private void buttonTicketSearch_Click(object sender, EventArgs e) { string fio = textTicketSearchName.Text; int spec = comboTicketSearchSpecialty.SelectedIndex; ReadersTicket rt = linkedModel.FindMatchingTicket(fio, spec); if (rt == null) { notify("Не найдено ни одного билета с указанными параметрами"); } else { notify("Билет найден."); selectedTicket = rt; OnChangingSelectedTicket?.Invoke(this, null); } }
public void AddFormular(Book b, ReadersTicket rt) { if (b.FreeExemplarsCount == 0) { throw new ReturningException("У этой книги больше нет свободных экземпляров."); } if (rt.Quote == 0) { throw new ReturningException("У этого читателя закончилась квота, он не может брать больше книг."); } Formular frm = new Formular(b, rt, DateTime.Now, rt.GiveDays); linkedFC.AddFormular(frm); b.AddFormular(frm); rt.AddFormular(frm); OnChangingBookList?.Invoke(null, null); OnChangingTicket?.Invoke(null, null); }
private void buildFormularsFromData() { foreach (Tuple <int, int, DateTime> tup in linkedFC.LoadDataFromFile(filenameFormulars)) { Book b = linkedBC.GetBookByID(tup.Item1); if (b == null) { throw new WrongIDException("Loading formulars: no such book in catalog", tup.Item1); } ReadersTicket rt = linkedTC.GetTicketByID(tup.Item2); if (rt == null) { throw new WrongIDException("Loading formulars: no such ticket in catalog", tup.Item2); } Formular frm = new Formular(b, rt, tup.Item3); b.AddFormular(frm); rt.AddFormular(frm); linkedFC.AddFormular(frm); } }
public Formular(Book bookLink, ReadersTicket readerLink, DateTime returnDate) { BookLink = bookLink; ReaderLink = readerLink; ReturnDate = returnDate; }
public Formular(Book bookLink, ReadersTicket readerLink, DateTime currentDate, int returnDays) { BookLink = bookLink; ReaderLink = readerLink; ReturnDate = currentDate.AddDays(returnDays); }