Ejemplo n.º 1
0
        private void buttonReLoan_Click(object sender, EventArgs e)
        {
            LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();

            List<int> books = new List<int>();

            foreach (DataGridViewRow row in dataGridViewLoaned.SelectedRows)
            {
                if (row.Cells[0].Value != null)
                {
                    books.Add(Convert.ToInt32(row.Cells[0].Value));
                }
            }

            if (books.Count > 0)
            {

                var client = (from c in context.Clients
                              where c.ClientID == id
                              select c).SingleOrDefault();

                foreach (LibraryReader.ClientsBook cBook in client.ClientsBooks)
                {
                    if (books.Contains(cBook.BookID))
                    {
                        cBook.DateLoaned = DateTime.Now;
                        cBook.DateReturned = DateTime.Now.AddMonths(1);
                        MessageBox.Show("Презаписването е успешно!");
                    }
                }

                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        private void buttonReLoan_Click(object sender, EventArgs e)
        {
            LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();

            List <int> books = new List <int>();

            foreach (DataGridViewRow row in dataGridViewLoaned.SelectedRows)
            {
                if (row.Cells[0].Value != null)
                {
                    books.Add(Convert.ToInt32(row.Cells[0].Value));
                }
            }

            if (books.Count > 0)
            {
                var client = (from c in context.Clients
                              where c.ClientID == id
                              select c).SingleOrDefault();

                foreach (LibraryReader.ClientsBook cBook in client.ClientsBooks)
                {
                    if (books.Contains(cBook.BookID))
                    {
                        cBook.DateLoaned   = DateTime.Now;
                        cBook.DateReturned = DateTime.Now.AddMonths(1);
                        MessageBox.Show("Презаписването е успешно!");
                    }
                }

                context.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        private void buttonReserve_Click(object sender, EventArgs e)
        {
            LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();

            List<int> books = new List<int>();

            foreach (DataGridViewRow row in dataGridViewBooks.SelectedRows)
            {
                if (row.Cells[0].Value != null)
                {
                    books.Add(Convert.ToInt32(row.Cells[0].Value));
                }
            }

            if (books.Count > 0)
            {

                var client = (from c in context.Clients
                              where c.ClientID == id
                              select c).SingleOrDefault();

                foreach (LibraryReader.ClientsBook cBook in client.ClientsBooks)
                {
                    if (books.Contains(cBook.BookID))
                    {
                        cBook.Reservation = true;
                        MessageBox.Show("Резервирането е успешно!");
                    }
                }

                context.SaveChanges();
            }
        }
Ejemplo n.º 4
0
        private void CurrentClient_Load(object sender, EventArgs e)
        {
            LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();
            LibraryReader.Client          clients = GetClientByID(context, id);

            textBoxFName.Text   = clients.FName;
            textBoxSName.Text   = clients.SName;
            textBoxLName.Text   = clients.LName;
            textBoxEGN.Text     = clients.EGN;
            textBoxAdress.Text  = clients.Adress;
            textBoxPhone.Text   = clients.Phone;
            textBoxEmail.Text   = clients.Email;
            textBoxLeaving.Text = clients.Leaving.ToString();;

            var books =
                from cl in context.ClientsBooks
                join book in context.Books on cl.BookID equals book.BookID
                where (cl.ClientID == id) && (cl.Returned == false) && (cl.Reservation == false)
                select book;

            if (books != null)
            {
                dataGridViewLoaned.AutoGenerateColumns = false;
                dataGridViewLoaned.DataSource          = books;
            }
        }
Ejemplo n.º 5
0
        private void buttonReserve_Click(object sender, EventArgs e)
        {
            LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();

            List <int> books = new List <int>();

            foreach (DataGridViewRow row in dataGridViewBooks.SelectedRows)
            {
                if (row.Cells[0].Value != null)
                {
                    books.Add(Convert.ToInt32(row.Cells[0].Value));
                }
            }

            if (books.Count > 0)
            {
                var client = (from c in context.Clients
                              where c.ClientID == id
                              select c).SingleOrDefault();

                foreach (LibraryReader.ClientsBook cBook in client.ClientsBooks)
                {
                    if (books.Contains(cBook.BookID))
                    {
                        cBook.Reservation = true;
                        MessageBox.Show("Резервирането е успешно!");
                    }
                }

                context.SaveChanges();
            }
        }
Ejemplo n.º 6
0
 private void buttonRefresh_Click(object sender, EventArgs e)
 {
     LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();
     var books =
         from cl in context.ClientsBooks
         join book in context.Books on cl.BookID equals book.BookID
         where (cl.ClientID == id) && (cl.Returned == false) && (cl.Reservation == false)
         select book;
     if (books!=null )
     {
         dataGridViewLoaned.AutoGenerateColumns = false;
         dataGridViewLoaned.DataSource = books;
     }
 }
Ejemplo n.º 7
0
        private void buttonRefresh_Click(object sender, EventArgs e)
        {
            LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();
            var books =
                from cl in context.ClientsBooks
                join book in context.Books on cl.BookID equals book.BookID
                where (cl.ClientID == id) && (cl.Returned == false) && (cl.Reservation == false)
                select book;

            if (books != null)
            {
                dataGridViewLoaned.AutoGenerateColumns = false;
                dataGridViewLoaned.DataSource          = books;
            }
        }
Ejemplo n.º 8
0
        private void CurrentClient_Load(object sender, EventArgs e)
        {
            LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();
            LibraryReader.Client clients = GetClientByID(context, id);

            textBoxFName.Text = clients.FName;
            textBoxSName.Text = clients.SName;
            textBoxLName.Text = clients.LName;
            textBoxEGN.Text = clients.EGN;
            textBoxAdress.Text = clients.Adress;
            textBoxPhone.Text = clients.Phone;
            textBoxEmail.Text = clients.Email;
            textBoxLeaving.Text = clients.Leaving.ToString(); ;

            var books =
                from cl in context.ClientsBooks
                join book in context.Books on cl.BookID equals book.BookID
                where (cl.ClientID == id) && (cl.Returned == false) && (cl.Reservation == false)
                select book;
            if (books != null)
            {
                dataGridViewLoaned.AutoGenerateColumns = false;
                dataGridViewLoaned.DataSource = books;
            }
        }
Ejemplo n.º 9
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            if (id == 0) buttonReserve.Visible = false;
            if (al == 0)
            {

                LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();
                if (comboBoxSearch.SelectedItem.ToString().Trim() == "Автор")
                {
                    string authorLName = textBoxSearch.Text.Trim();
                    LibraryReader.Author author = context.Authors.FirstOrDefault(p => p.LName == authorLName);

                    if (author != null)
                    {
                        var books = context.Books.ToList();

                        var datasource = (from b in books
                                          where b.Authors.Contains(author)
                                          select b).ToList();

                        dataGridViewBooks.AutoGenerateColumns = false;
                        dataGridViewBooks.DataSource = datasource;
                    }
                    else
                    {
                        MessageBox.Show("Грешка! Няма автор с това име!");
                    }
                }

                else if (comboBoxSearch.SelectedItem.ToString().Trim() == "Заглавие")
                {
                    var books =
                        from book in context.Books
                        where book.Title.Trim() == textBoxSearch.Text.Trim()
                        select book;
                    if (books != null)
                    {
                        dataGridViewBooks.AutoGenerateColumns = false;
                        dataGridViewBooks.DataSource = books;
                    }
                    else
                    {
                        MessageBox.Show("Грешка! Няма книга с това заглавие!");
                    }

                }
                else if (comboBoxSearch.SelectedItem.ToString().Trim() == "Инвентарен номер")
                {
                    var books =
                        from book in context.Books
                        where book.InvNum.Trim() == textBoxSearch.Text.Trim()
                        select book;
                    if (books != null)
                    {
                        dataGridViewBooks.AutoGenerateColumns = false;
                        dataGridViewBooks.DataSource = books;
                    }
                    else
                    {
                        MessageBox.Show("Грешка! Няма книга с този инвентарен номер!");
                    }
                }
                else if (comboBoxSearch.SelectedItem.ToString().Trim() == "ISBN")
                {
                    var books =
                        from book in context.Books
                        where book.ISBN.Trim() == textBoxSearch.Text.Trim()
                        select book;
                    if (books != null)
                    {
                        dataGridViewBooks.AutoGenerateColumns = false;
                        dataGridViewBooks.DataSource = books;
                    }
                    else
                    {
                        MessageBox.Show("Грешка! Няма книга с този ISBN!");
                    }
                }

            }
        }
Ejemplo n.º 10
0
 static LibraryReader.Client GetClientByID(LibraryReader.LibraryEntities context, int clientID)
 {
     LibraryReader.Client cl = context.Clients.FirstOrDefault(
         p => p.ClientID == clientID);
     return(cl);
 }
Ejemplo n.º 11
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            if (id == 0)
            {
                buttonReserve.Visible = false;
            }
            if (al == 0)
            {
                LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();
                if (comboBoxSearch.SelectedItem.ToString().Trim() == "Автор")
                {
                    string authorLName          = textBoxSearch.Text.Trim();
                    LibraryReader.Author author = context.Authors.FirstOrDefault(p => p.LName == authorLName);

                    if (author != null)
                    {
                        var books = context.Books.ToList();

                        var datasource = (from b in books
                                          where b.Authors.Contains(author)
                                          select b).ToList();

                        dataGridViewBooks.AutoGenerateColumns = false;
                        dataGridViewBooks.DataSource          = datasource;
                    }
                    else
                    {
                        MessageBox.Show("Грешка! Няма автор с това име!");
                    }
                }

                else if (comboBoxSearch.SelectedItem.ToString().Trim() == "Заглавие")
                {
                    var books =
                        from book in context.Books
                        where book.Title.Trim() == textBoxSearch.Text.Trim()
                        select book;
                    if (books != null)
                    {
                        dataGridViewBooks.AutoGenerateColumns = false;
                        dataGridViewBooks.DataSource          = books;
                    }
                    else
                    {
                        MessageBox.Show("Грешка! Няма книга с това заглавие!");
                    }
                }
                else if (comboBoxSearch.SelectedItem.ToString().Trim() == "Инвентарен номер")
                {
                    var books =
                        from book in context.Books
                        where book.InvNum.Trim() == textBoxSearch.Text.Trim()
                        select book;
                    if (books != null)
                    {
                        dataGridViewBooks.AutoGenerateColumns = false;
                        dataGridViewBooks.DataSource          = books;
                    }
                    else
                    {
                        MessageBox.Show("Грешка! Няма книга с този инвентарен номер!");
                    }
                }
                else if (comboBoxSearch.SelectedItem.ToString().Trim() == "ISBN")
                {
                    var books =
                        from book in context.Books
                        where book.ISBN.Trim() == textBoxSearch.Text.Trim()
                        select book;
                    if (books != null)
                    {
                        dataGridViewBooks.AutoGenerateColumns = false;
                        dataGridViewBooks.DataSource          = books;
                    }
                    else
                    {
                        MessageBox.Show("Грешка! Няма книга с този ISBN!");
                    }
                }
            }
        }