Example #1
0
 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++;
 }
Example #2
0
        public void AddTicket(string fio, int specialtyID)
        {
            ReadersTicket rt = GetTicketByParams(fio, specialtyID);

            if (rt == null)
            {
                rt = new ReadersTicket(maxID++, fio, specialtyID);
                ticketList.Add(rt);
            }
        }
Example #3
0
 public Formular GetFormularByLinks(Book bookLink, ReadersTicket ticketLink)
 {
     foreach (Formular frm in formularList)
     {
         if (frm.BookLink == bookLink && frm.ReaderLink == ticketLink)
         {
             return(frm);
         }
     }
     return(null);
 }
Example #4
0
        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);
            }
        }
Example #5
0
        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);
            }
        }
Example #6
0
        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);
        }
Example #7
0
 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);
     }
 }
Example #8
0
 public Formular(Book bookLink, ReadersTicket readerLink, DateTime returnDate)
 {
     BookLink   = bookLink;
     ReaderLink = readerLink;
     ReturnDate = returnDate;
 }
Example #9
0
 public Formular(Book bookLink, ReadersTicket readerLink, DateTime currentDate, int returnDays)
 {
     BookLink   = bookLink;
     ReaderLink = readerLink;
     ReturnDate = currentDate.AddDays(returnDays);
 }