Пример #1
0
        public void loadReservationFile(string postfix)
        {
            var filename         = $"reservations{postfix}.xml";
            var currentDirectory = Directory.GetCurrentDirectory();
            var reservationsFile = Path.Combine(currentDirectory, filename);

            if (!File.Exists(reservationsFile))
            {
                XDocument doc = new XDocument(
                    new XElement(BookReservationRecord.RESERVATIONS_TAG, XElement.EmptySequence)
                    );
                doc.Save(reservationsFile);
            }


            XDocument xdoc           = XDocument.Load(reservationsFile);
            XElement  recordsElement = xdoc.Root;
            var       elements       = xdoc.Element(BookReservationRecord.RESERVATIONS_TAG).Elements("BookReservation");

            foreach (XElement xelement in elements)
            {
                var record = BookReservationRecord.fromXElement(xelement);
                records.Add(record);
                filteredRecords.Add(record);
            }
        }
Пример #2
0
        private void addReservation(
            int ticketNumber,
            string readerFirstName,
            string readerSecondName,
            string takeoutDate,
            int returnDays,
            string author,
            string name,
            int publishYear,
            string publisher,
            int cost
            )
        {
            try
            {
                var record = new BookReservationRecord(
                    ticketNumber,
                    readerFirstName,
                    readerSecondName,
                    DateTime.Parse(takeoutDate),
                    returnDays,
                    author,
                    name,
                    publishYear,
                    publisher,
                    cost
                    );

                controller.addRecord(record);
                updateList();
            }
            catch (FormatException exception)
            {
                MessageBox.Show("Неверный формат записи", "Ошибка");
            }
        }
Пример #3
0
 internal void addRecord(BookReservationRecord record)
 {
     records.Add(record);
 }