private void saveBookButton_Click(object sender, EventArgs e) { Book aBook = new Book(); BookManager aBookManager = new BookManager(); if (bookIDTextBox.Text != "" && bookNameTextBox.Text != "" && authorTextBox.Text != "" && quantityTextBox.Text != "") { int a; if (int.TryParse(quantityTextBox.Text, out a)) { aBook.BookID = bookIDTextBox.Text; aBook.BookName = bookNameTextBox.Text; aBook.Author = authorTextBox.Text; aBook.Quantity = Convert.ToInt32(quantityTextBox.Text); MessageBox.Show(aBookManager.SaveThisBook(aBook)); LoadBookListGridView(); bookIDTextBox.Clear(); bookNameTextBox.Clear(); authorTextBox.Clear(); quantityTextBox.Clear(); } else { MessageBox.Show("Please Insert correct type"); } } else { MessageBox.Show("Please fill up the fields"); } }
private void button10_Click(object sender, EventArgs e) { try { Book book = BookManager.Books.Single((x) => x.BookRegisterNumber == int.Parse(txtRegisterNumber.Text)); BookManager.Books.Remove(book); DataTable table = BookManager.TableMake(); foreach (var item in BookManager.Books) { table.Rows.Add(item.Num, item.BookRegisterNumber, item.BookState, item.BookName, item.BookAuthor, item.BookPublish, item.BookSortId, item.BookAuthorId, item.BookCharge, item.BookCopy, item.BookSeperate, item.BookISBN, item.BookLocation, item.BookImport, item.BookPublishDate, item.BookPage, item.BookSize, item.BookPrice, item.BookFullName); } dataGridView1.DataSource = null; dataGridView1.DataSource = table; MySqlConnection myConn = new MySqlConnection(myConnection); MySqlCommand cmd = new MySqlCommand("DELETE FROM bookmanagement.books WHERE BookRegisterNumber = " + book.BookRegisterNumber, myConn); myConn.Open(); cmd.ExecuteNonQuery(); myConn.Close(); datagrid_Select(); MessageBox.Show("도서를 삭제했습니다!!!!"); } catch (Exception) { MessageBox.Show("존재하지 않는 도서입니다!!!!"); } }
private void button3_Click(object sender, EventArgs e) { DataTable table = BookManager.TableMake(); dataGridView1.DataSource = null; dataGridView1.DataSource = table; BookManager.Books.Clear(); txtRegisterNumber.Text = ""; txtName.Text = ""; txtAuthor.Text = ""; txtPublish.Text = ""; txtSortId.Text = ""; txtAuthorId.Text = ""; txtCharge.Text = ""; txtCopy.Text = ""; txtSeperate.Text = ""; txtISBN.Text = ""; txtPublishDate.Text = ""; txtPage.Text = ""; txtSize.Text = ""; txtPrice.Text = ""; txtFullName.Text = ""; }
private void deleteBookButton_Click(object sender, EventArgs e) { BookManager aBookManager = new BookManager(); MessageBox.Show(aBookManager.DeleteThisBook(deleteBookIDTextBox.Text)); LoadBookListGridView(); }
private void updateBookQuantityButton_Click(object sender, EventArgs e) { BookManager aBookManager = new BookManager(); MessageBox.Show(aBookManager.UpdateThisBookQuantity(updateBookIDTextBox.Text, addQuantityTextBox.Text)); updateBookIDTextBox.Clear(); updateBookQuantityTextBox.Clear(); addQuantityTextBox.Clear(); LoadBookListGridView(); }
private void button8_Click(object sender, EventArgs e) { try { Book book = BookManager.Books.Single((x) => x.BookRegisterNumber == int.Parse(txtRegisterNumber.Text)); book.BookRegisterNumber = int.Parse(txtRegisterNumber.Text); book.BookState = cbState.Text; book.BookName = txtName.Text; book.BookAuthor = txtAuthor.Text; book.BookPublish = txtPublish.Text; book.BookSortId = int.Parse(txtSortId.Text); book.BookAuthorId = txtAuthorId.Text; book.BookCharge = txtCharge.Text; book.BookCopy = txtCopy.Text; book.BookSeperate = txtSeperate.Text; book.BookISBN = int.Parse(txtISBN.Text); book.BookLocation = cbLocation.Text; book.BookImport = cbImport.Text; book.BookPublishDate = txtPublishDate.Text; book.BookPage = txtPage.Text; book.BookSize = txtSize.Text; book.BookPrice = txtPrice.Text; book.BookFullName = txtFullName.Text; DataTable table = BookManager.TableMake(); foreach (var item in BookManager.Books) { table.Rows.Add(item.Num, item.BookRegisterNumber, item.BookState, item.BookName, item.BookAuthor, item.BookPublish, item.BookSortId, item.BookAuthorId, item.BookCharge, item.BookCopy, item.BookSeperate, item.BookISBN, item.BookLocation, item.BookImport, item.BookPublishDate, item.BookPage, item.BookSize, item.BookPrice, item.BookFullName); } dataGridView1.DataSource = null; dataGridView1.DataSource = table; MySqlConnection myConn = new MySqlConnection(myConnection); myConn.Open(); MySqlCommand cmd = new MySqlCommand("UPDATE bookmanagement.books SET BookState = '" + book.BookState + "', BookName = '" + book.BookName + "', BookAuthor = '" + book.BookAuthor + "', BookPublish = '" + book.BookPublish + "', BookSortId = " + book.BookSortId + ", BookAuthorId = '" + book.BookAuthorId + "', BookCharge = '" + book.BookCharge + "', BookCopy = '" + book.BookCopy + "', BookSeperate = '" + book.BookSeperate + "', BookISBN = " + book.BookISBN + ", BookLocation = '" + book.BookLocation + "', BookImport = '" + book.BookImport + "', BookPublishDate = '" + book.BookPublishDate + "', BookPage = '" + book.BookPage + "', BookSize = '" + book.BookSize + "', BookPrice = '" + book.BookPrice + "', FullName = '" + book.BookFullName + "' WHERE BookRegisterNumber = " + book.BookRegisterNumber, myConn); cmd.ExecuteNonQuery(); myConn.Close(); datagrid_Select(); MessageBox.Show("도서를 수정했습니다!!!!"); } catch (Exception) { MessageBox.Show("존재하지 않는 도서입니다!!!!"); } }
private void LoadBookListGridView() { BookManager aBookManager = new BookManager(); List <Book> bookList = new List <Book>(); bookList = aBookManager.LoadBookListGridView(); int serialNumber = 1; bookListGridView.Rows.Clear(); foreach (var book in bookList) { bookListGridView.Rows.Add(serialNumber, book.BookID, book.BookName, book.Author, book.Quantity); serialNumber++; } }
private void button1_Click(object sender, EventArgs e) { BookManager.Books.Clear(); // 중복 불러오기 방지 BookManager.Load(); DataTable table = BookManager.TableMake(); foreach (var item in BookManager.Books) { table.Rows.Add(item.Num, item.BookRegisterNumber, item.BookState, item.BookName, item.BookAuthor, item.BookPublish, item.BookSortId, item.BookAuthorId, item.BookCharge, item.BookCopy, item.BookSeperate, item.BookISBN, item.BookLocation, item.BookImport, item.BookPublishDate, item.BookPage, item.BookSize, item.BookPrice, item.BookFullName); } dataGridView1.DataSource = null; dataGridView1.DataSource = table; }
private void button9_Click(object sender, EventArgs e) { int isnum = 0; MySqlConnection myConn = new MySqlConnection(myConnection); MySqlCommand cm = new MySqlCommand("SELECT * FROM bookmanagement.books WHERE BookRegisterNumber = " + int.Parse(txtRegisterNumber.Text), myConn); myConn.Open(); cm.ExecuteNonQuery(); if (txtISBN.Text == "") { MessageBox.Show("ISBN을 입력해주세요!!!!", "필수항목 누락"); } else if (txtName.Text == "") { MessageBox.Show("도서명을 입력해주세요!!!!", "필수항목 누락"); } else if (txtAuthor.Text == "") { MessageBox.Show("저자를 입력해주세요!!!!", "필수항목 누락"); } else if (txtPublish.Text == "") { MessageBox.Show("출판사를 입력해주세요!!!!", "필수항목 누락"); } else if (txtSortId.Text == "") { MessageBox.Show("분류기호를 입력해주세요!!!!", "필수항목 누락"); } else if (txtAuthorId.Text == "") { MessageBox.Show("저자기호를 입력해주세요!!!!", "필수항목 누락"); } else if (txtRegisterNumber.Text == "") { MessageBox.Show("등록번호를 입력해주세요!!!!", "필수항목 누락"); } else if (!(int.TryParse(txtISBN.Text, out isnum))) { MessageBox.Show("ISBN는 숫자만 입력해주세요!!!!", "숫자 오류"); } else if (!(int.TryParse(txtSortId.Text, out isnum))) { MessageBox.Show("분류기호는 숫자만 입력해주세요!!!!", "숫자 오류"); } else if (!(int.TryParse(txtRegisterNumber.Text, out isnum))) { MessageBox.Show("등록번호는 숫자만 입력해주세요!!!!", "숫자 오류"); } else { Book book = new Book() { Num = variable++, BookRegisterNumber = int.Parse(txtRegisterNumber.Text), BookState = cbState.Text, BookName = txtName.Text, BookAuthor = txtAuthor.Text, BookPublish = txtPublish.Text, BookSortId = int.Parse(txtSortId.Text), BookAuthorId = txtAuthorId.Text, BookCharge = txtCharge.Text, BookCopy = txtCopy.Text, BookSeperate = txtSeperate.Text, BookISBN = int.Parse(txtISBN.Text), BookLocation = cbLocation.Text, BookImport = cbImport.Text, BookPublishDate = txtPublishDate.Text, BookPage = txtPage.Text, BookSize = txtSize.Text, BookPrice = txtPrice.Text, BookFullName = txtFullName.Text }; BookManager.Books.Add(book); DataTable table = BookManager.TableMake(); foreach (var item in BookManager.Books) { table.Rows.Add(item.Num, item.BookRegisterNumber, item.BookState, item.BookName, item.BookAuthor, item.BookPublish, item.BookSortId, item.BookAuthorId, item.BookCharge, item.BookCopy, item.BookSeperate, item.BookISBN, item.BookLocation, item.BookImport, item.BookPublishDate, item.BookPage, item.BookSize, item.BookPrice, item.BookFullName); } dataGridView1.DataSource = null; dataGridView1.DataSource = table; MySqlCommand cmd = new MySqlCommand("INSERT INTO bookmanagement.books VALUES(" + book.Num + ", " + book.BookRegisterNumber + ", '" + book.BookState + "', '" + book.BookName + "', '" + book.BookAuthor + "', '" + book.BookPublish + "', " + book.BookSortId + ", '" + book.BookAuthorId + "', '" + book.BookCharge + "', '" + book.BookCopy + "', '" + book.BookSeperate + "', " + book.BookISBN + ", '" + book.BookLocation + "', '" + book.BookImport + "', '" + book.BookPublishDate + "', '" + book.BookPage + "', '" + book.BookSize + "', '" + book.BookPrice + "', '" + book.BookFullName + "')", myConn); cmd.ExecuteNonQuery(); myConn.Close(); datagrid_Select(); MessageBox.Show("도서를 저장했습니다!!!!"); } }
private void button4_Click(object sender, EventArgs e) { BookManager.Save(); }
private void button1_Click(object sender, EventArgs e) { dataGridView1.DataSource = ""; string selected = ""; if (comboBox1.SelectedItem != null) { selected = comboBox1.SelectedItem.ToString(); } Console.WriteLine(selected); string tableName = "books"; string search = ""; string keyword = textBox1.Text; switch (selected) { case "등록번호": search = "BookRegisterNumber"; break; case "서명": search = "BookName"; break; case "총서명": search = "BookFullName"; break; case "저자": search = "BookAuthor"; break; default: break; } DataTable table = new DataTable(); /* * 순번 books * 도서상태 books * 등록번호 books * 도서명 books * 저자 books * 청구기호 books * 대출일자 ? - rent * 반납일자 ? - rent * 대출자 members * 예약자 members - 미사용 * 소장위치 books * 반입구분 books * 등록일 books * */ //book table.Columns.Add("순번", typeof(int)); table.Columns.Add("도서상태", typeof(string)); table.Columns.Add("등록번호", typeof(int)); table.Columns.Add("도서명", typeof(string)); table.Columns.Add("저자", typeof(string)); // table.Columns.Add("청구기호", typeof(string));//미사용 //rent table.Columns.Add("대출일자", typeof(string)); table.Columns.Add("반납일자", typeof(string)); table.Columns.Add("대출자", typeof(string)); // table.Columns.Add("예약자", typeof(string));//미사용 table.Columns.Add("소장위치", typeof(string)); // table.Columns.Add("반입구분", typeof(string));// 임시 해제 table.Columns.Add("등록일", typeof(string)); /* * 수정 중 */ foreach (var item in BookManager.Load(SearchQueryManager.makeSearchQuery(tableName, search, keyword))) { Rent r = null; Member m = null; if (RentManager.Load("select * from bookmanagement.rent where BookRegisterNumber=" + item.BookRegisterNumber + ";").Count > 0) { r = RentManager.Load("select * from bookmanagement.rent where BookRegisterNumber=" + item.BookRegisterNumber + ";")[0]; m = MemberManager.Load(SearchQueryManager.makeSearchQuery("members", "MemberId", r.MemberId.ToString()))[0]; } if (r != null) { table.Rows.Add(item.Num, item.BookState, item.BookRegisterNumber, item.BookName, item.BookAuthor, r.Rent_Date, r.Rent_Date_Last, m.MemberName, item.BookLocation, item.BookPublishDate); } else { table.Rows.Add(item.Num, item.BookState, item.BookRegisterNumber, item.BookName, item.BookAuthor, "-", "-", "-", item.BookLocation, item.BookPublishDate); } } /* * */ dataGridView1.DataSource = table; }