private void searchTextBox_Leave(object sender, EventArgs e) { try { resultDataGridView.Rows.Clear(); LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); resultDataGridView.ColumnCount = 5; resultDataGridView.Columns[0].Name = "Book Number"; resultDataGridView.Columns[1].Name = "Book Name"; resultDataGridView.Columns[2].Name = "Author"; resultDataGridView.Columns[3].Name = "Publication"; resultDataGridView.Columns[4].Name = "Quantity"; if (searchTextBox.Text != "") { foreach (Book book in libraryBL.SearchBooks(searchTextBox.Text)) { if (book.Quantity > 0) { resultDataGridView.Rows.Add(book.Book_Number, book.Book_Name, book.Author, book.Publication, book.Quantity); } else { resultDataGridView.Rows.Add(book.Book_Number, book.Book_Name, book.Author, book.Publication, book.Quantity); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void IssuedForm_Load(object sender, EventArgs e) { try { LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); resultDataGridView.ColumnCount = 5; resultDataGridView.Columns[0].Name = "Book Number"; resultDataGridView.Columns[1].Name = "Book Name"; resultDataGridView.Columns[2].Name = "Book Author"; resultDataGridView.Columns[3].Name = "Issue date"; resultDataGridView.Columns[4].Name = "Return Date"; foreach (BookIssue data in libraryBL.GetDataByID(int.Parse(studentID))) { Book book = libraryBL.GetBookByID(data.Book_Number); resultDataGridView.Rows.Add(data.Book_Number, book.Book_Name, book.Author, data.Issued_Date, data.Return_Date); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void bookNumberTextBox_Leave(object sender, EventArgs e) { try { LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); int bookNumber; if (!int.TryParse(bookNumberTextBox.Text, out bookNumber)) { throw new Exception("Book number should be numeric only"); } Book book = libraryBL.GetBookByID(bookNumber); if (book != null) { bookTitleTextBox.Text = book.Book_Name.Trim(); categoryComboBox.SelectedItem = libraryBL.GetCategory(book.Category_ID).Trim(); publicationTextBox.Text = book.Publication.Trim(); authorTextBox.Text = book.Author.Trim(); quantityTextBox.Text = book.Quantity.ToString(); bookNumberTextBox.Enabled = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button2_Click(object sender, EventArgs e) { try { LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); if (bookNumberTextBox.Enabled == false) { if (libraryBL.DeleteBook(int.Parse(bookNumberTextBox.Text))) { MessageBox.Show("Data Deleted"); bookNumberTextBox.Clear(); bookTitleTextBox.Clear(); authorTextBox.Clear(); publicationTextBox.Clear(); quantityTextBox.Clear();; categoryComboBox.SelectedIndex = 0; bookNumberTextBox.Enabled = true; SetData(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { string loginID = loginIDTextBox.Text; string password = passwordTextBox.Text; LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); if (libraryBL.LoginAuth(loginID, password)) { Home home = new Home(); if (loginID.Equals("Admin123") && password.Equals("Admin123")) { home.SetData("Admin", loginID); } else { home.SetData("Student", loginID); } home.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); if (resultDataGridView.SelectedRows.Count > 0) { foreach (DataGridViewRow row in resultDataGridView.SelectedRows) { DialogResult dialogResult = MessageBox.Show("Confirm the Task Performed", "Checking", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { int studentID = int.Parse(row.Cells[2].Value.ToString()); int bookNumber = int.Parse(row.Cells[0].Value.ToString()); if (libraryBL.DeleteBookIssues(studentID, bookNumber)) { MessageBox.Show("Book Returned"); SetData(); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void SetData() { LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); int studentID; if (!int.TryParse(studentNumberTextBox.Text, out studentID)) { throw new Exception("Please Enter numeric value only"); } resultDataGridView.Rows.Clear(); resultDataGridView.ColumnCount = 6; resultDataGridView.Columns[0].Name = "Book Number"; resultDataGridView.Columns[1].Name = "Book Name"; resultDataGridView.Columns[2].Name = "Student Number"; resultDataGridView.Columns[3].Name = "Date of Issue"; resultDataGridView.Columns[4].Name = "Date of Return"; resultDataGridView.Columns[5].Name = "Late fees"; foreach (BookIssue book in libraryBL.GetDataByID(studentID)) { Book data = libraryBL.GetBookByID(book.Book_Number); int numberOfDays = (int)(DateTime.Today - book.Return_Date).TotalDays; if (numberOfDays > 0) { resultDataGridView.Rows.Add(book.Book_Number, data.Book_Name, book.Student_Number, book.Issued_Date, book.Return_Date, 10 * numberOfDays); } else { resultDataGridView.Rows.Add(book.Book_Number, data.Book_Name, book.Student_Number, book.Issued_Date, book.Return_Date, 0); } } }
private void button1_Click(object sender, EventArgs e) { try { LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); if (resultDataGridView.SelectedRows.Count > 0) { int studentNumber; if (!int.TryParse(studentNumberTextBox.Text, out studentNumber)) { throw new Exception("Student Number should be numeric only"); } if (libraryBL.ValidateID(studentNumber)) { foreach (DataGridViewRow row in resultDataGridView.SelectedRows) { BookIssue bookIssue = new BookIssue(); bookIssue.Book_Number = int.Parse(row.Cells[0].Value.ToString()); bookIssue.Student_Number = studentNumber; MessageBox.Show(row.Cells[0].Value.ToString()); bookIssue.Issued_Date = issueDateTimePicker.Value; bookIssue.Return_Date = returnDateTimePicker.Value; int quantity = int.Parse(row.Cells[4].Value.ToString()); //MessageBox.Show("Hello"); if (quantity > 0) { if (libraryBL.NewBookIssue(bookIssue)) { MessageBox.Show("Book Issued"); searchTextBox.Clear(); studentNumberTextBox.Clear(); } } else { throw new Exception("Cannot issue book because it is not available right now "); } } } else { throw new Exception("Invalid Student Number"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void SetData() { LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); resultDataGridView.Rows.Clear(); resultDataGridView.ColumnCount = 5; resultDataGridView.Columns[0].Name = "Book Number"; resultDataGridView.Columns[1].Name = "Book Name"; resultDataGridView.Columns[2].Name = "Author"; resultDataGridView.Columns[3].Name = "Publication"; resultDataGridView.Columns[4].Name = "Quantity"; foreach (Book book in libraryBL.GetAllBooks()) { resultDataGridView.Rows.Add(book.Book_Number, book.Book_Name, book.Author, book.Publication, book.Quantity); } }
private void AddBook_Load_1(object sender, EventArgs e) { try { LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); categoryComboBox.Items.Add("----Select Category-----"); foreach (BookCategory category in libraryBL.GetAllCategory()) { categoryComboBox.Items.Add(category.Category_Name.Trim()); } SetData(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ViewAllBook_Load(object sender, EventArgs e) { try { LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); resultDataGridView.ColumnCount = 5; resultDataGridView.Columns[0].Name = "Book Number"; resultDataGridView.Columns[1].Name = "Book Name"; resultDataGridView.Columns[2].Name = "Author"; resultDataGridView.Columns[3].Name = "Publication"; resultDataGridView.Columns[4].Name = "Quantity"; foreach (Book book in libraryBL.GetAllBooks()) { resultDataGridView.Rows.Add(book.Book_Number, book.Book_Name, book.Author, book.Publication, book.Quantity); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); int bookNumber; if (!int.TryParse(bookNumberTextBox.Text, out bookNumber)) { throw new Exception("Book number should be numeric only"); } string name = bookTitleTextBox.Text; int category = categoryComboBox.SelectedIndex; string publication = publicationTextBox.Text; string author = authorTextBox.Text; int quantity; if (!int.TryParse(quantityTextBox.Text, out quantity)) { throw new Exception("Quantity should be numeric"); } NewBook newBook = new NewBook(); newBook.BookNumber = bookNumber; newBook.BookName = name; newBook.CategoryID = category; newBook.Publication = publication; newBook.Author = author; newBook.Quantity = quantity; newBook.checkStock += OnSetup; if (newBook.Quantity > 100) { newBook.OnStockCheck(EventArgs.Empty); } if (bookNumberTextBox.Enabled == false) { if (libraryBL.UpdateBook(newBook)) { MessageBox.Show("Data Updated"); bookNumberTextBox.Clear(); bookTitleTextBox.Clear(); authorTextBox.Clear(); publicationTextBox.Clear(); quantityTextBox.Clear();; categoryComboBox.SelectedIndex = 0; } } else if (libraryBL.AddNewBook(newBook)) { MessageBox.Show("Data Inserted"); bookNumberTextBox.Clear(); bookTitleTextBox.Clear(); authorTextBox.Clear(); publicationTextBox.Clear(); quantityTextBox.Clear();; categoryComboBox.SelectedIndex = 0; } SetData(); bookNumberTextBox.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { AddRegistration reg = new AddRegistration(); LibraryBusinessLogic libraryBL = new LibraryBusinessLogic(); string name = nameTextBox.Text; int number = 0; if (!int.TryParse(universityNumberTextBox.Text, out number)) { throw new Exception("University Number should be numeric only"); } string emailID = emailIDTextBox.Text; string gender = ""; string password; if (maleRadioButton.Checked == true) { gender = "Male"; } if (femaleradioButton.Checked == true) { gender = "female"; } if (!passwordTextBox.Text.Equals(reEnterPasswordTextBox.Text)) { throw new Exception("Both Password don't match"); } password = passwordTextBox.Text; string address = addressTextBox.Text; int contact = 0; if (!int.TryParse(contactNumberTextBox.Text, out contact)) { throw new Exception("Contact Number should be numeric only"); } reg.StudentNumber = number; reg.StudentName = name; reg.EmailID = emailID; reg.Gender = gender; reg.Address = address; reg.ContactNumber = contact; reg.Password = password; if (libraryBL.RegistrationAdd(reg)) { Home home = new Home(); home.SetData("Student", number.ToString()); home.Show(); this.Dispose(); ClearData(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }