Example #1
0
        public int insertBookReserved(int userId, string isbn, string reservedDate)
        {
            try
            {
                BookLogic bookLogic = new BookLogic();
                return(bookLogic.insertBookReserved(userId, isbn, reservedDate));
            }
            catch (BusinessLogicException ex)
            {
                HandleSoapException handleSoapExceptionnew = new HandleSoapException();
                SoapException       soapException          = new SoapException();
                soapException = handleSoapExceptionnew.CreateSoapException(Constants.faultUri,
                                                                           "insertBookReserved",
                                                                           ex.Message,
                                                                           AppEnum.FaultSourceWS.BusinessError.ToString(),
                                                                           Constants.faultBusinessError,
                                                                           AppEnum.FaultSourceWS.BusinessError);
                throw soapException;
            }
            catch (Exception ex)
            {
                HandleSoapException handleSoapExceptionnew = new HandleSoapException();
                SoapException       soapException          = new SoapException();

                soapException = handleSoapExceptionnew.CreateSoapException(Constants.faultUri,
                                                                           "insertBookReserved",
                                                                           ex.Message,
                                                                           AppEnum.FaultSourceWS.AplicationError.ToString(),
                                                                           Constants.faultAplicationError,
                                                                           AppEnum.FaultSourceWS.AplicationError);
                throw soapException;
            }
        }
Example #2
0
        private void buttonListAllBorrowedBooks_Click(object sender, EventArgs e)
        {
            try
            {
                textBoxBookName.Text    = null;
                labelSystemMessage.Text = null;
                BookLogic bookLogic = new BookLogic();
                dataGridViewBooksBorrowed.DataSource = bookLogic.GetAllBooksBorrowedWithUserView();
                dataGridViewBooksBorrowed.Columns[Constants.fieldUserId].Visible   = false;
                dataGridViewBooksBorrowed.Columns[Constants.fieldBorrowId].Visible = false;
                dataGridViewBooksBorrowed.Columns[Constants.fieldLatefee].Visible  = false;

                if (dataGridViewBooksBorrowed.RowCount == 0)
                {
                    labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                    labelSystemMessage.Text      = Constants.msgNoMatchesFound;
                }
            }
            catch (BusinessLogicException ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                labelSystemMessage.Text      = Constants.msgErrorBusinessToUser + ex.Message;
            }
            catch (Exception ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                labelSystemMessage.Text      = Constants.msgErrorSystemToUser;
            }
        }
Example #3
0
        //if update
        private void btnUpdateBook_Click(object sender, EventArgs e)
        {
            checkField();

            if (counterError > 0)
            {
                MessageBox.Show(errorReturn); counterError = 0;
            }
            else
            {
                try
                {
                    BookLogic bl     = new BookLogic();
                    int       result = bl.UpdateFromTabBook(BookName_txtBox.Text.Trim(), Int32.Parse(Author_List.SelectedValue.ToString()), Int32.Parse(Category_List.SelectedValue.ToString()), Int32.Parse(Language_List.SelectedValue.ToString()), Int32.Parse(PublisherYear_txtBox.Text.Trim()), Int32.Parse(Pages_txtBox.Text.Trim()), Publisher_txtBox.Text.Trim(), Isbn_txtBox.Text.Trim());
                    MessageBox.Show("Book Update to the database !\n---------------\nIsbn: " + Isbn_txtBox.Text.Trim() +
                                    "\nBook Name: " + BookName_txtBox.Text.Trim() +
                                    "\nAuthor: " + Author_List.Text +
                                    "\nCategory: " + Category_List.Text +
                                    "\nLanguage: " + Language_List.Text +
                                    "\nPublisher: " + Publisher_txtBox.Text.Trim() +
                                    "\nPublisher Year: " + Int32.Parse(PublisherYear_txtBox.Text.Trim()) +
                                    "\nPages: " + Int32.Parse(Pages_txtBox.Text.Trim()));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #4
0
        //Add author to tabBook
        private void btnAddAuthor_Click(object sender, EventArgs e)
        {
            //check the field Author
            if (!checkEmpty(authorName_add.Text, "Author Name", null))
            {
                bool authorNameCheck = checkIfProperWord(authorName_add.Text);
                if (!authorNameCheck)
                {
                    counterError++;
                    addAuthor_return.Visible = true;
                    addAuthor_return.Text    = "This Author Name is incorrect";
                }
            }
            else
            {
                counterError++;
                addAuthor_return.Visible = true;
                addAuthor_return.Text    = "This field is empty";
            }
            if (counterError == 0)
            {
                BookLogic bl = new BookLogic();

                int result = bl.InsertAuthorTabAuthor(authorName_add.Text);
                MessageBox.Show("New author added !", "A message from AIT Library");

                //refresh author list
                Author_List.DataSource    = bl.ListAuthor();
                Author_List.DisplayMember = "PairName";
                Author_List.ValueMember   = "PairID";
            }
        }
Example #5
0
        public int GetTotalBookReservedByIsbn(string isbn)
        {
            try
            {
                BookLogic bookLogic = new BookLogic();
                return(bookLogic.SelectCountBookReservedByIsbn(isbn));
            }
            catch (BusinessLogicException ex)
            {
                HandleSoapException handleSoapExceptionnew = new HandleSoapException();
                SoapException       soapException          = new SoapException();
                soapException = handleSoapExceptionnew.CreateSoapException(Constants.faultUri,
                                                                           "GetTotalBookReservedByIsbn",
                                                                           ex.Message,
                                                                           AppEnum.FaultSourceWS.BusinessError.ToString(),
                                                                           Constants.faultBusinessError,
                                                                           AppEnum.FaultSourceWS.BusinessError);
                throw soapException;
            }
            catch (Exception ex)
            {
                HandleSoapException handleSoapExceptionnew = new HandleSoapException();
                SoapException       soapException          = new SoapException();

                soapException = handleSoapExceptionnew.CreateSoapException(Constants.faultUri,
                                                                           "GetTotalBookReservedByIsbn",
                                                                           ex.Message,
                                                                           AppEnum.FaultSourceWS.AplicationError.ToString(),
                                                                           Constants.faultAplicationError,
                                                                           AppEnum.FaultSourceWS.AplicationError);
                throw soapException;
            }
        }
Example #6
0
        public DataTable GetAllBooksBorrowedWithUserViewByUserId(int userId)
        {
            try
            {
                BookLogic bookLogic = new BookLogic();
                return(bookLogic.GetAllBooksBorrowedWithUserViewByUserId(userId).ToDataTable());
            }
            catch (BusinessLogicException ex)
            {
                HandleSoapException handleSoapExceptionnew = new HandleSoapException();
                SoapException       soapException          = new SoapException();
                soapException = handleSoapExceptionnew.CreateSoapException(Constants.faultUri,
                                                                           "GetAllBooksBorrowedWithUserViewByUserId",
                                                                           ex.Message,
                                                                           AppEnum.FaultSourceWS.BusinessError.ToString(),
                                                                           Constants.faultBusinessError,
                                                                           AppEnum.FaultSourceWS.BusinessError);
                throw soapException;
            }
            catch (Exception ex)
            {
                HandleSoapException handleSoapExceptionnew = new HandleSoapException();
                SoapException       soapException          = new SoapException();

                soapException = handleSoapExceptionnew.CreateSoapException(Constants.faultUri,
                                                                           "GetAllBooksBorrowedWithUserViewByUserId",
                                                                           ex.Message,
                                                                           AppEnum.FaultSourceWS.AplicationError.ToString(),
                                                                           Constants.faultAplicationError,
                                                                           AppEnum.FaultSourceWS.AplicationError);
                throw soapException;
            }
        }
Example #7
0
 private void BookBrowseForm_Load(object sender, EventArgs e)
 {
     try
     {
         dataGridViewBookBrowse.DataSource = null;
         BookLogic bookLogic = new BookLogic();
         dataGridViewBookBrowse.DataSource = bookLogic.GetAllBooksView();
     }
     catch (BusinessLogicException ex)
     {
         //Error log simulate
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.GetBaseException().ToString());
         dataGridViewBookBrowse.DataSource = null;
         labelSystemMessage.ForeColor      = System.Drawing.Color.Red;
         labelSystemMessage.Text           = Constants.msgErrorBusinessToUser + ex.Message;
     }
     catch (Exception ex)
     {
         //Error log simulate
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.GetBaseException().ToString());
         dataGridViewBookBrowse.DataSource = null;
         labelSystemMessage.ForeColor      = System.Drawing.Color.Red;
         labelSystemMessage.Text           = Constants.msgErrorSystemToUser;
     }
 }
Example #8
0
        public HttpResponseMessage GetList()
        {
            var books  = new BookLogic();
            var result = books.GetBook();

            return(Request.CreateResponse(HttpStatusCode.OK, new { bookList = result }));
        }
Example #9
0
 private void buttonListAllBooks_Click(object sender, EventArgs e)
 {
     try
     {
         labelSystemMessage.Text          = null;
         textBoxBookName.Text             = null;
         textBoxAuthor.Text               = null;
         dataGridViewListBooks.DataSource = null;
         BookLogic bookLogic = new BookLogic();
         dataGridViewListBooks.DataSource = bookLogic.GetAllAvailableBooks();
     }
     catch (BusinessLogicException ex)
     {
         //Error log simulate
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.GetBaseException().ToString());
         dataGridViewListBooks.DataSource = null;
         labelSystemMessage.ForeColor     = System.Drawing.Color.Red;
         labelSystemMessage.Text          = Constants.msgErrorBusinessToUser + ex.Message;
     }
     catch (Exception ex)
     {
         //Error log simulate
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.GetBaseException().ToString());
         dataGridViewListBooks.DataSource = null;
         labelSystemMessage.ForeColor     = System.Drawing.Color.Red;
         labelSystemMessage.Text          = Constants.msgErrorSystemToUser;
     }
 }
Example #10
0
        private void radioButtonReserved_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                labelSystemMessage.Text                 = Constants.msgLabelDefault;
                labelSystemMessage.ForeColor            = System.Drawing.Color.Black;
                dataGridViewUserBookActivity.DataSource = null;

                BookLogic bookLogic = new BookLogic();
                dataGridViewUserBookActivity.DataSource = bookLogic.GetAllBooksReservedViewByUserId(staticUserID);
                dataGridViewUserBookActivity.Columns[Constants.fieldUser].Visible      = false;
                dataGridViewUserBookActivity.Columns[Constants.fieldReserveId].Visible = false;
                dataGridViewUserBookActivity.Columns[Constants.fieldUserId].Visible    = false;
            }
            catch (BusinessLogicException ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                dataGridViewUserBookActivity.DataSource = null;
                labelSystemMessage.ForeColor            = System.Drawing.Color.Red;
                labelSystemMessage.Text = Constants.msgErrorBusinessToUser + ex.Message;
            }
            catch (Exception ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                dataGridViewUserBookActivity.DataSource = null;
                labelSystemMessage.ForeColor            = System.Drawing.Color.Red;
                labelSystemMessage.Text = Constants.msgErrorSystemToUser;
            }
        }
Example #11
0
        public void FindCheapBooks_MoreBooksThanRequested_LimitedNumber()
        {
            var books = new List <Book>()
            {
                new Book()
                {
                    Id = 1
                },
                new Book()
                {
                    Id = 2
                },
                new Book()
                {
                    Id = 3
                }
            }.AsQueryable();

            var databaseContextMock = new Mock <IDatabaseContext>();
            var bookDbSetMock       = new Mock <DbSet <Book> >();

            bookDbSetMock.As <IQueryable <Book> >().Setup(m => m.Provider).Returns(books.Provider);
            bookDbSetMock.As <IQueryable <Book> >().Setup(m => m.Expression).Returns(books.Expression);
            bookDbSetMock.As <IQueryable <Book> >().Setup(m => m.ElementType).Returns(books.ElementType);
            bookDbSetMock.As <IQueryable <Book> >().Setup(m => m.GetEnumerator()).Returns(books.GetEnumerator());

            databaseContextMock.SetupGet(m => m.Books).Returns(bookDbSetMock.Object);

            var bookLogic = new BookLogic(databaseContextMock.Object);

            var actualCheapBooks = bookLogic.FindCheapBooks(2);

            actualCheapBooks.Length.Should().Be(2);
        }
Example #12
0
        public void GetBookById_Existing_ReturnsBookWithId()
        {
            var books = new List <Book>()
            {
                new Book()
                {
                    Id = 1
                },
                new Book()
                {
                    Id = 2
                },
                new Book()
                {
                    Id = 3
                }
            }.AsQueryable();

            var databaseContextMock = new Mock <IDatabaseContext>();
            var bookDbSetMock       = new Mock <DbSet <Book> >();

            bookDbSetMock.As <IQueryable <Book> >().Setup(m => m.Provider).Returns(books.Provider);
            bookDbSetMock.As <IQueryable <Book> >().Setup(m => m.Expression).Returns(books.Expression);
            bookDbSetMock.As <IQueryable <Book> >().Setup(m => m.ElementType).Returns(books.ElementType);
            bookDbSetMock.As <IQueryable <Book> >().Setup(m => m.GetEnumerator()).Returns(books.GetEnumerator());

            databaseContextMock.SetupGet(m => m.Books).Returns(bookDbSetMock.Object);

            var bookLogic = new BookLogic(databaseContextMock.Object);

            var actualBook = bookLogic.GetBookById(2);

            actualBook.Id.Should().Be(2);
        }
Example #13
0
        public virtual List <Book> GetBooks()
        {
            var logic  = new BookLogic();
            var result = logic.Search();

            return(result);
        }
Example #14
0
        public int UpdateBook(string updatedIsbn, string bookName, int author, int category, int language, int publishYear,
                              int pages, string publisher, string isbn)
        {
            try
            {
                BookLogic bookLogic = new BookLogic();
                return(bookLogic.UpdateBook(updatedIsbn, bookName, author, category, language, publishYear, pages, publisher, isbn));
            }
            catch (BusinessLogicException ex)
            {
                HandleSoapException handleSoapExceptionnew = new HandleSoapException();
                SoapException       soapException          = new SoapException();
                soapException = handleSoapExceptionnew.CreateSoapException(Constants.faultUri,
                                                                           "UpdateBook",
                                                                           ex.Message,
                                                                           AppEnum.FaultSourceWS.BusinessError.ToString(),
                                                                           Constants.faultBusinessError,
                                                                           AppEnum.FaultSourceWS.BusinessError);
                throw soapException;
            }
            catch (Exception ex)
            {
                HandleSoapException handleSoapExceptionnew = new HandleSoapException();
                SoapException       soapException          = new SoapException();

                soapException = handleSoapExceptionnew.CreateSoapException(Constants.faultUri,
                                                                           "UpdateBook",
                                                                           ex.Message,
                                                                           AppEnum.FaultSourceWS.AplicationError.ToString(),
                                                                           Constants.faultAplicationError,
                                                                           AppEnum.FaultSourceWS.AplicationError);
                throw soapException;
            }
        }
Example #15
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var confirmResult = MessageBox.Show("¿Desea eliminar?", "Confirmar operación", MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    Cursor.Current = Cursors.WaitCursor;

                    ///Instancia de capa logica
                    var logic = new BookLogic();


                    if (logic.DeleteBook(CurrentBook.IdBook))
                    {
                        ClearForm();
                        MessageBox.Show("Libro Eliminado");
                    }
                    else
                    {
                        MessageBox.Show("Ups! se ha generado un error");
                    }
                }
                else
                {
                    //TO DO
                }
            }
            catch (Exception ex)
            {
                Logger.logger.Error(ex.Message);
                //Logger.logger.Info(ex.Message);
                Logger.loggerDataBase.Error(ex);
            }
        }
Example #16
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         var confirmResult = MessageBox.Show("¿Desea eliminar'", "confirmar operacion", MessageBoxButtons.YesNo);
         if (confirmResult == DialogResult.Yes)
         {
             var logic = new BookLogic();
             if (logic.DeleteBook(CurrentBook.IdBook))
             {
                 ClearForm();
                 LoadData();
                 MessageBox.Show("Libro eliminado!");
             }
             else
             {
                 MessageBox.Show("Ocurrio un error");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ups! se ha generado un error, Favor de validar con el adminsitrador");
         Logger.logger.Error(ex);// se nanda la excepcion al log
     }
 }
Example #17
0
        //Show all books
        public void btnShowBooks_Click(object sender, EventArgs e)
        {
            //panelSearch.Visible = false;
            BookLogic bl = new BookLogic();

            dataGridView1.DataSource = bl.ListBooks();
        }
Example #18
0
        public int DeleteBook(string isbn)
        {
            try
            {
                BookLogic bookLogic = new BookLogic();
                return(bookLogic.DeleteBook(isbn));
            }
            catch (BusinessLogicException ex)
            {
                HandleSoapException handleSoapExceptionnew = new HandleSoapException();
                SoapException       soapException          = new SoapException();
                soapException = handleSoapExceptionnew.CreateSoapException(Constants.faultUri,
                                                                           "DeleteBook",
                                                                           ex.Message,
                                                                           AppEnum.FaultSourceWS.BusinessError.ToString(),
                                                                           Constants.faultBusinessError,
                                                                           AppEnum.FaultSourceWS.BusinessError);
                throw soapException;
            }
            catch (Exception ex)
            {
                HandleSoapException handleSoapExceptionnew = new HandleSoapException();
                SoapException       soapException          = new SoapException();

                soapException = handleSoapExceptionnew.CreateSoapException(Constants.faultUri,
                                                                           "DeleteBook",
                                                                           ex.Message,
                                                                           AppEnum.FaultSourceWS.AplicationError.ToString(),
                                                                           Constants.faultAplicationError,
                                                                           AppEnum.FaultSourceWS.AplicationError);
                throw soapException;
            }
        }
Example #19
0
        //Add language to tabLanguage
        private void btnAddLanguage_Click(object sender, EventArgs e)
        {
            //check the field Category
            if (!checkEmpty(language_add.Text, "Language Name", null))
            {
                bool languageNameCheck = checkIfProperWord(language_add.Text);
                if (!languageNameCheck)
                {
                    addLanguage_return.Visible = true;
                    addLanguage_return.Text    = "This Language Name is incorrect";
                    counterError++;
                }
            }
            else
            {
                counterError++;
                addLanguage_return.Visible = true;
                addLanguage_return.Text    = "This field is empty";
            }
            if (counterError == 0)
            {
                BookLogic bl = new BookLogic();

                int result = bl.InsertLanguageTabLanguage(language_add.Text);

                MessageBox.Show("New language added !", "A message from AIT Library");

                //refresh author list
                Language_List.DataSource    = bl.ListLanguage();
                Language_List.DisplayMember = "PairName";
                Language_List.ValueMember   = "PairID";
            }
        }
Example #20
0
        public DataTable BookSearch(string bookISBN, string bookName, string author)
        {
            try
            {
                BookLogic bookLogic = new BookLogic();
                return(bookLogic.BookSearch(bookISBN, bookName, author).ToDataTable());
            }
            catch (BusinessLogicException ex)
            {
                HandleSoapException handleSoapExceptionnew = new HandleSoapException();
                SoapException       soapException          = new SoapException();
                soapException = handleSoapExceptionnew.CreateSoapException(Constants.faultUri,
                                                                           "BookSearch",
                                                                           ex.Message,
                                                                           AppEnum.FaultSourceWS.BusinessError.ToString(),
                                                                           Constants.faultBusinessError,
                                                                           AppEnum.FaultSourceWS.BusinessError);
                throw soapException;
            }
            catch (Exception ex)
            {
                HandleSoapException handleSoapExceptionnew = new HandleSoapException();
                SoapException       soapException          = new SoapException();

                soapException = handleSoapExceptionnew.CreateSoapException(Constants.faultUri,
                                                                           "BookSearch",
                                                                           ex.Message,
                                                                           AppEnum.FaultSourceWS.AplicationError.ToString(),
                                                                           Constants.faultAplicationError,
                                                                           AppEnum.FaultSourceWS.AplicationError);
                throw soapException;
            }
        }
Example #21
0
        public virtual bool Update(string id, Book info)
        {
            var logic = new BookLogic();

            logic.Update(id, info);
            return(true);
        }
Example #22
0
        private void LoadData()
        {
            var list = new BookLogic().GetAllBooks();

            Books = list;

            dataBooksGridView.DataSource = Books;
        }
Example #23
0
 static DependencyResolver()
 {
     UserDAL        = new UserDAL();
     UserLogic      = new UserLogic(UserDAL);
     BookDAL        = new BookDAL();
     BookLogic      = new BookLogic(BookDAL);
     BookModelDAL   = new BookModelDAL();
     BookModelLogic = new BookModelLogic(BookModelDAL);
 }
Example #24
0
        private void buttonListAllBooks_Click(object sender, EventArgs e)
        {
            labelSystemMessage.ForeColor = System.Drawing.Color.Black;
            labelSystemMessage.Text      = null;
            textBoxISBN.Text             = null;
            textBoxBookName.Text         = null;
            textBoxAuthor.Text           = null;

            BookLogic bookLogic = new BookLogic();

            dataGridViewListBooks.DataSource = bookLogic.GetAllBooksView();
        }
Example #25
0
        public virtual int GetCount(string id)
        {
            var logic = new BookLogic();

            var conditions = new Dictionary <string, string>()
            {
                { "id", id }
            };
            var result = logic.GetCount(conditions);

            return(result);
        }
Example #26
0
        private void buttonReturnBook_Click(object sender, EventArgs e)
        {
            try
            {
                labelSystemMessage.ForeColor = System.Drawing.Color.Black;
                labelSystemMessage.Text      = null;

                if (dataGridViewBooksBorrowed.DataSource != null && dataGridViewBooksBorrowed.SelectedRows.Count > 0)
                {
                    int bidColumnIndex        = (int)AppEnum.ViewBookBorrowedWithUserModel.BorrowId;
                    int returnDateColumnIndex = (int)AppEnum.ViewBookBorrowedWithUserModel.Return;

                    int    bid        = (int)dataGridViewBooksBorrowed.SelectedRows[0].Cells[bidColumnIndex].Value;
                    String returnDate = dataGridViewBooksBorrowed.SelectedRows[0].Cells[returnDateColumnIndex].Value.ToString();

                    BookLogic bookLogic       = new BookLogic();
                    int       resultOperation = bookLogic.ReturnBorrowBook(bid, returnDate);

                    if (resultOperation == 0)
                    {
                        labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                        labelSystemMessage.Text      = Constants.msgErrorBusinessToUser;
                    }
                    else
                    {
                        labelSystemMessage.ForeColor         = System.Drawing.Color.Black;
                        labelSystemMessage.Text              = Constants.msgOperationCompleted;
                        dataGridViewBooksBorrowed.DataSource = null;
                    }
                }
                else
                {
                    labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                    labelSystemMessage.Text      = Constants.msgSelectRecord;
                }
            }
            catch (BusinessLogicException ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                labelSystemMessage.Text      = Constants.msgErrorBusinessToUser + ex.Message;
            }
            catch (Exception ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                labelSystemMessage.Text      = Constants.msgErrorSystemToUser;
            }
        }
Example #27
0
        private void buttonBorrowBook_Click(object sender, EventArgs e)
        {
            labelSystemMessage.ForeColor = System.Drawing.Color.Black;
            labelSystemMessage.Text      = Constants.msgLabelDefault;

            try
            {
                if ((dataGridViewListBooks.DataSource != null && dataGridViewListBooks.SelectedRows.Count > 0) &&
                    (dataGridViewUser.DataSource != null && dataGridViewUser.SelectedRows.Count > 0))
                {
                    String isbn   = dataGridViewListBooks.SelectedRows[0].Cells[(int)AppEnum.ViewBookModel.Isbn].Value.ToString();
                    int    userId = (int)dataGridViewUser.SelectedRows[0].Cells[(int)AppEnum.TabUserModel.ID].Value;

                    BookLogic bookLogic       = new BookLogic();
                    int       resultOperation = bookLogic.InsertBorrowBook(userId, isbn);

                    if (resultOperation == 0)
                    {
                        labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                        labelSystemMessage.Text      = Constants.msgErrorBusinessToUser;
                    }
                    else
                    {
                        labelSystemMessage.ForeColor     = System.Drawing.Color.Black;
                        labelSystemMessage.Text          = Constants.msgOperationCompleted;
                        dataGridViewListBooks.DataSource = null;
                        dataGridViewUser.DataSource      = null;
                    }
                }
                else
                {
                    labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                    labelSystemMessage.Text      = Constants.msgSelectRecord;
                }
            }
            catch (BusinessLogicException ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                labelSystemMessage.Text      = Constants.msgErrorBusinessToUser + ex.Message;
            }
            catch (Exception ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                labelSystemMessage.Text      = Constants.msgErrorSystemToUser;
            }
        }
Example #28
0
        private void button_ShowAllBooks_Click(object sender, EventArgs e)
        {
            BookLogic bl = new BookLogic();

            //clear message box
            label_Message.Text = "";

            //clear view
            dataGridView_BookBrowsing.Refresh();

            //populate grid view with data
            dataGridView_BookBrowsing.DataSource = bl.GetBooks();
        }
Example #29
0
        public void GetBookListTest()
        {
            // Injecting the Fake File Reader
            BookLogic     logic          = new BookLogic(new FakeFileReader());
            BookViewModel actualResult   = logic.GetBookList();
            BookViewModel expectedResult = BookResult.ExpectedResult;

            Assert.IsNotNull(actualResult.Books);
            Assert.IsNotNull(expectedResult.Books);
            Assert.AreEqual(expectedResult.Books[0].Author, actualResult.Books[0].Author);
            Assert.AreEqual(expectedResult.Books[0].Name, actualResult.Books[0].Name);
            Assert.AreEqual(expectedResult.Books[0].ISBN, actualResult.Books[0].ISBN);
        }
Example #30
0
        private void ReportBookBorrowedForm_Load(object sender, EventArgs e)
        {
            labelSystemMessage.Text              = Constants.msgLabelDefault;
            labelSystemMessage.ForeColor         = System.Drawing.Color.Black;
            dataGridViewBorrowedBooks.DataSource = null;

            BookLogic bookLogic = new BookLogic();

            dataGridViewBorrowedBooks.DataSource = bookLogic.GetAllBorrowedBooksWithUser();
            dataGridViewBorrowedBooks.Columns[Constants.fieldBorrowId].Visible = false;
            dataGridViewBorrowedBooks.Columns[Constants.fieldLatefee].Visible  = false;
            dataGridViewBorrowedBooks.Columns[Constants.fieldUserId].Visible   = false;
        }