private void signin() { LibraryDB lb = new LibraryDB("SQL Server", "sa", "sa"); var state = lb.Login(boxID.Text, boxpassword.Text); switch (state) { case LibraryDB.LoginStatus.Wrong: MessageBox.Show("Wrong password. Try again or click Forgot password to reset it."); break; case LibraryDB.LoginStatus.NotExist: MessageBox.Show("Couldn't find your account ID."); break; case LibraryDB.LoginStatus.Success: this.Hide(); interfaceMain main_i = new interfaceMain(lb); main_i.Show(); break; } }
private void btnIssue_Click(object sender, EventArgs e) { //If the student ID is empty or mask is not complete, show the error if (txtStudentID.Text == "" || !txtStudentID.MaskCompleted) { MessageBox.Show("Pleas enter a valid student ID", "Invalid Student ID", MessageBoxButtons.OK, MessageBoxIcon.Error); } else //The data is good, enter it into the borrower table { //LibraryDB object to insert the new borrow book row LibraryDB borrowBook = new LibraryDB(); borrowBook.insertNewBorrow(Int32.Parse(txtStudentID.Text), Int32.Parse(txtISBN.Text), dtpIssueDate.Text, dtpReturnDate.Text, Int32.Parse(txtIssuedBy.Text)); //Tells the user they successfully issued the book MessageBox.Show("Book has successfully been issued.", "Successful Issue", MessageBoxButtons.OK, MessageBoxIcon.Information); //Goes through all the open forms and finds dashboard to show it again for (int i = 0; i < Application.OpenForms.Count; i++) { //Open the dashboard form if (Application.OpenForms[i].Name == "frmDashboard") { Application.OpenForms[i].Show(); } //Close the Issue book form if (Application.OpenForms[i].Name == "frmIssueReturn") { Application.OpenForms[i].Close(); } } //Close this.Close(); } }
public cardManagement(LibraryDB lb) { InitializeComponent(); ldb = lb; refreshlistview(); }
public bookSearch(LibraryDB lb) { InitializeComponent(); ldb = lb; }
public bookBorrow(LibraryDB lb) { InitializeComponent(); ldb = lb; }
public void RefreshForm() { //Create a list of books to store in stock books List <Book> issueReturnBooks = new List <Book>(); //Database object to use the method to get in stock books LibraryDB issueBook = new LibraryDB(); //If the user wants to a book, show all the books that are in stock if (issueReturn == "Issue") { //Get the in stock books and put them in the list issueReturnBooks = issueBook.getInStockOutStockBooks("False"); //Shows all the books in the datagrid view dgvIssueReturn.DataSource = issueReturnBooks; //Change the form text this.Text = "Issue a Book"; //Change button text btnIssueReturn.Text = "Issue a Book"; } else { //Get the in stock books and put them in the list issueReturnBooks = issueBook.getInStockOutStockBooks("True"); //Shows all the books in the datagrid view dgvIssueReturn.DataSource = issueReturnBooks; //Change the form text this.Text = "Return a Book"; //Change button text btnIssueReturn.Text = "Return a Book"; } //Remove the out of stock column dgvIssueReturn.Columns.RemoveAt(8); //Column headers dgvIssueReturn.Columns[0].HeaderText = "ISBN"; dgvIssueReturn.Columns[1].HeaderText = "Book\nTitle"; dgvIssueReturn.Columns[2].HeaderText = "Language"; dgvIssueReturn.Columns[3].HeaderText = "Binding\nName"; dgvIssueReturn.Columns[4].HeaderText = "Original\nStock"; dgvIssueReturn.Columns[5].HeaderText = "Current\nStock"; dgvIssueReturn.Columns[6].HeaderText = "Category"; dgvIssueReturn.Columns[7].HeaderText = "Publication\nYear"; dgvIssueReturn.Columns[8].HeaderText = "Shelf"; dgvIssueReturn.Columns[9].HeaderText = "Floor"; //Dynamically size the data grid view each time the user searches int width = 0; foreach (DataGridViewColumn col in dgvIssueReturn.Columns) { width += col.Width; } width += dgvIssueReturn.RowHeadersWidth; dgvIssueReturn.ClientSize = new Size(width - 10, dgvIssueReturn.Height); dgvIssueReturn.BackgroundColor = System.Drawing.SystemColors.Control; btnIssueReturn.Enabled = false; }
public bookReturn(LibraryDB lb) { InitializeComponent( ); ldb = lb; }
private void btnSubmit_Click(object sender, EventArgs e) { //Create variables and initialize them int isbn = 0; String title = ""; String language = ""; String bindingName = ""; int numCopies = 0; String category = ""; String pubYear = ""; int shelfNo = 0; int floorNo = 0; //If the user is not editing (adding a new student, then collect their information) if (editOrAdd != "Edit") { //If input is correct, add the user if (checkInput()) { //Collect all information from form isbn = Int32.Parse(txtISBN.Text); title = txtTitle.Text; language = cmbLang.Text; bindingName = cmbBinding.Text; numCopies = (int)nudCopies.Value; category = cmbCategory.Text; pubYear = dtpPubYear.Text; shelfNo = Int32.Parse(cmbShelfNo.Text); floorNo = Int32.Parse(cmbFloorNo.Text); //Insert all that information into a book object Book newBook = new Book(isbn, title, language, bindingName, numCopies, numCopies, category, pubYear, "False", shelfNo, floorNo); //Insert the book into the databse LibraryDB enterNewBook = new LibraryDB(); enterNewBook.insertEditBook(newBook, "Add"); DialogResult dialogResult = MessageBox.Show("Book has been successfully added!\nWould you like to add another?", "Book Added", MessageBoxButtons.YesNo, MessageBoxIcon.Information); //if they choose yes, refresh the form if (dialogResult == DialogResult.Yes) { RefreshForm(); } else if (dialogResult == DialogResult.No) //If they choose no, exit the form { OpenDash(); this.Close(); } } } else //If user is editing information, use an UPDATE statement, not an INSERT statement { //Collect all information from form isbn = Int32.Parse(txtISBN.Text); title = txtTitle.Text; language = cmbLang.Text; bindingName = cmbBinding.Text; numCopies = (int)nudCopies.Value; category = cmbCategory.Text; pubYear = dtpPubYear.Text; shelfNo = Int32.Parse(cmbShelfNo.Text); floorNo = Int32.Parse(cmbFloorNo.Text); //Insert all that information into a book object Book newBook = new Book(isbn, title, language, bindingName, numCopies, 0, category, pubYear, "", shelfNo, floorNo); //Insert the book into the databse LibraryDB editBook = new LibraryDB(); editBook.insertEditBook(newBook, "Edit"); DialogResult dialogResult = MessageBox.Show("Book information has successfully been updated!", "Book Updated", MessageBoxButtons.OK, MessageBoxIcon.Information); OpenDash(); this.Close(); } }
/// <summary> /// Button to submit information about a new student, or an existing student. Checks for input validity, and checks whether the user is editing or not /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { //Create variables and initialize them int id = 0; String name = ""; String gender = ""; String dob = ""; String dept = ""; string contactNum = ""; //If the user is not editing (adding a new student, then collect their information) if (editOrAdd != "Edit") { //If input is correct, add the user if (checkInput()) { //Collect all information from form id = Int32.Parse(txtID.Text); name = txtName.Text; gender = cmbGender.Text; dob = dtpDOB.Text; dept = cmbDepartments.Text; contactNum = txtContactNum.Text; //Insert all that information into a student object Student newStudent = new Student(id, name, gender, dob, dept, contactNum); //Insert the student into the databse LibraryDB enterNewStudent = new LibraryDB(); enterNewStudent.insertEditStudent(newStudent, "Add"); DialogResult dialogResult = MessageBox.Show("Student has been successfully added!\nWould you like to add another?", "Student Added", MessageBoxButtons.YesNo, MessageBoxIcon.Information); //if they choose yes, refresh the form if (dialogResult == DialogResult.Yes) { RefreshForm(); } else if (dialogResult == DialogResult.No) //If they choose no, exit the form { OpenDash(); this.Close(); } } } else //If user is editing information, use an UPDATE statement, not an INSERT statement { //Collect all information from form id = Int32.Parse(txtID.Text); name = txtName.Text; gender = cmbGender.Text; dob = dtpDOB.Text; dept = cmbDepartments.Text; contactNum = txtContactNum.Text; //Insert all that information into a student object Student newInfo = new Student(id, name, gender, dob, dept, contactNum); //Insert the student into the databse LibraryDB editStudent = new LibraryDB(); editStudent.insertEditStudent(newInfo, "Edit"); DialogResult dialogResult = MessageBox.Show("Students information has successfully been updated!", "Student Updated", MessageBoxButtons.OK, MessageBoxIcon.Information); OpenDash(); this.Close(); } }
public bookStorage(LibraryDB lb) { InitializeComponent(); ldb = lb; }
private void btnSearchStudent_Click(object sender, EventArgs e) { //Create a list of students to store result(s) in List <Student> studentSearchResult = new List <Student>(); //Date of birth is empty String DOB = ""; //Initially set id to 0 (nothing entered in textbox) int id = 0; //If ID text box has something in it, replace 0 with the ID input by user if (txtID.Text != "") { if (txtID.MaskCompleted) { id = Int32.Parse(txtID.Text); } else { MessageBox.Show("Please enter a valid Student ID", "Invalid Student ID", MessageBoxButtons.OK, MessageBoxIcon.Information); } } //If the date time picker is not empty, put the value in the variable if (dtpDOB.Text != " ") { DOB = dtpDOB.Text; } //All of user input into variables String name = txtName.Text; String gender = cmbGender.Text; String dept = cmbDepartment.Text; //Create a new student with properties set Student searchStudent = new Student(id, name, gender, DOB, dept, ""); //Create a connection to the database and search for the student LibraryDB student = new LibraryDB(); //Search for the student studentSearchResult = student.StudentSearch(searchStudent); //Load the student data into the data grid view dgvStudent.DataSource = studentSearchResult; //Displays number of returned records to the user if (studentSearchResult.Count == 1) { lblNumRecords.Text = studentSearchResult.Count + " Student matches your filter."; } else { lblNumRecords.Text = studentSearchResult.Count + " Students match your filter."; } //Column headers dgvStudent.Columns[0].HeaderText = "Student ID"; dgvStudent.Columns[1].HeaderText = "Student Name"; dgvStudent.Columns[2].HeaderText = "Gender"; dgvStudent.Columns[3].HeaderText = "Date of Birth"; dgvStudent.Columns[4].HeaderText = "Department"; dgvStudent.Columns[5].HeaderText = "Contact Number"; //Dynamically size the data grid view each time the user searches int width = 0; foreach (DataGridViewColumn col in dgvStudent.Columns) { width += col.Width; } width += dgvStudent.RowHeadersWidth; dgvStudent.ClientSize = new Size(width + 2, dgvStudent.Height); dgvStudent.BackgroundColor = System.Drawing.SystemColors.Control; }
//When the user wants to search for a book private void btnSearchBook_Click(object sender, EventArgs e) { //Create a list of books to store result(s) in List <Book> bookSearchResult = new List <Book>(); //pyb year and out of stock are empty String pubYear = ""; String outOfStock = ""; //Initially set id to 0 (nothing entered in textbox) int ISBN = 0; //If ISBN text box has something in it, replace 0 with the ID input by user if (txtISBN.Text != "") { if (txtISBN.MaskCompleted) { ISBN = Int32.Parse(txtID.Text); } else { MessageBox.Show("Please enter a valid ISBN Code", "Invalid ISBN Code", MessageBoxButtons.OK, MessageBoxIcon.Information); } } //If the date time picker isn't empty, put the value into the variable if (dtpPubYear.Text != " ") { pubYear = dtpPubYear.Text; } //All of user input into variables String title = txtTitle.Text; String lang = cmbLang.Text; String category = cmbCategory.Text; //Sets the variable to true/false (as string for the SQL statement) based on whether the user wants to see items out of stock or in stock if (cmbOutOfStock.Text == "Yes") { outOfStock = "True"; } else if (cmbOutOfStock.Text == "No") { outOfStock = "False"; } //If there are no students to edit, disable the edit link if (bookSearchResult.Count == 0) { lblEditBook.Enabled = false; } //Create a new book with properties set Book searchBook = new Book(ISBN, title, lang, "", 0, 0, category, pubYear, outOfStock, 0, 0); //Create a connection to the database and search for the student LibraryDB book = new LibraryDB(); //Search for the student bookSearchResult = book.BookSearch(searchBook); //Load the student data into the data grid view dgvBooks.DataSource = bookSearchResult; //Displays number of returned records to the user if (bookSearchResult.Count == 1) { lblNumBooks.Text = bookSearchResult.Count + " Book matches your filter."; } else { lblNumBooks.Text = bookSearchResult.Count + " Books match your filter."; } //Remove the out of stock column dgvBooks.Columns.RemoveAt(8); //Column headers dgvBooks.Columns[0].HeaderText = "ISBN"; dgvBooks.Columns[1].HeaderText = "Book\nTitle"; dgvBooks.Columns[2].HeaderText = "Language"; dgvBooks.Columns[3].HeaderText = "Binding\nName"; dgvBooks.Columns[4].HeaderText = "Original\nStock"; dgvBooks.Columns[5].HeaderText = "Current\nStock"; dgvBooks.Columns[6].HeaderText = "Category"; dgvBooks.Columns[7].HeaderText = "Publication\nYear"; dgvBooks.Columns[8].HeaderText = "Shelf"; dgvBooks.Columns[9].HeaderText = "Floor"; //Dynamically size the data grid view each time the user searches int width = 0; foreach (DataGridViewColumn col in dgvBooks.Columns) { width += col.Width; } width += dgvBooks.RowHeadersWidth; dgvBooks.ClientSize = new Size(width + 2, dgvBooks.Height); dgvBooks.BackgroundColor = System.Drawing.SystemColors.Control; }
public interfaceMain(LibraryDB lb) { InitializeComponent(); ldb = lb; }