private void Confirm_Click(object sender, EventArgs e) { m = new LibraryMember(); using (TransactionScope ts = new TransactionScope()) { context = new SA45Team13bLibraryEntities(); m.CustomerName = textBox2.Text; var k = Int16.Parse(textBox3.Text); m.Age = Int16.Parse(textBox3.Text); m.Address = textBox4.Text; m.PostalCode = textBox5.Text; m.DocumentNo = textBox6.Text; m.DocumentType = comboBox1.Text; m.PhoneNumber = textBox8.Text; m.EmailAddress = textBox9.Text; m.AltPhoneNumber = textBox10.Text; context.LibraryMember.Add(m); context.SaveChanges(); ts.Complete(); MessageBox.Show("Submit success!"); this.Close(); } }
private void Confirm_Click(object sender, EventArgs e) { if (textBox2.Text == "" || textBox4.Text == "" || textBox6.Text == "" || comboBox1.Text == "" || textBox3.Text == "") { MessageBox.Show("Error!Please fill the blanks with (*)."); } else { context = new SA45Team13bLibraryEntities(); int i = Int32.Parse(textBox1.Text); LibraryMember lb = new LibraryMember(); lb = context.LibraryMembers.Where(x => x.CustomerID == i).First(); lb.CustomerName = textBox2.Text; lb.Age = Int16.Parse(textBox3.Text); lb.Address = textBox4.Text; lb.PostalCode = textBox5.Text; lb.DocumentNo = textBox6.Text; lb.DocumentType = comboBox1.Text; lb.PhoneNumber = textBox8.Text; lb.EmailAddress = textBox9.Text; lb.AltPhoneNumber = textBox10.Text; context.SaveChanges(); MessageBox.Show("Submit success!"); this.Close(); } }
private void Search_Click(object sender, System.EventArgs e) { SA45Team13bLibraryEntities nm = new SA45Team13bLibraryEntities(); var search = from x in nm.LibraryMembers where (x.CustomerID.ToString().Contains(SearchBox.Text) || x.CustomerName.ToString().Contains(SearchBox.Text)) select x; dataGridView1.DataSource = search.ToList(); }
private void Confirm_Click_1(object sender, EventArgs e) { m = new LibraryMember(); context = new SA45Team13bLibraryEntities(); if (CustomerNameBox.Text == "" || AddressBox.Text == "" || DocumentNoBox.Text == "" || DocumentTypeBox.Text == "" || AgeBox.Text == "") { MessageBox.Show("Error!Please fill the blanks with (*)."); } else if (System.Text.RegularExpressions.Regex.IsMatch(AgeBox.Text, "[^0-9]")) { MessageBox.Show("Please enter correct age."); } else { m.CustomerName = CustomerNameBox.Text; m.Age = Int16.Parse(AgeBox.Text); m.Address = AddressBox.Text; m.PostalCode = PostalCodeBox.Text; m.DocumentNo = DocumentNoBox.Text; m.DocumentType = DocumentTypeBox.Text; m.PhoneNumber = PhoneNumberBox.Text; m.EmailAddress = EmailAddressBox.Text; m.AltPhoneNumber = AltPhoneNumberBox.Text; context.LibraryMembers.Add(m); context.SaveChanges(); MessageBox.Show("Submit success!"); Refresh(); this.Close(); } }
void FilterBooks(String title, String author, String isbn, String publisher, String language, String genre) { // Get Entity Context SA45Team13bLibraryEntities context = new SA45Team13bLibraryEntities(); // Get Filtered Books FilteredBooks = context.BookLists.Where( book => book.BookTitle.Contains(title) && book.Author.Contains(author) && book.ISBN.Contains(isbn) && book.Publisher.Contains(publisher) && language == "All" ? true : (book.Language == language) ).ToList(); // Genre Check if (genre != "All") { FilteredBooks = FilteredBooks.Where(book => book.Genre == genre).ToList(); } // Available books Check if (AvailableBooksOnlyCheckBox.Checked) { FilteredBooks = FilteredBooks.Where(book => book.TotalStock != book.Loaned).ToList(); } // Get Number of Books BooksFound = (UInt32)FilteredBooks.Count; // Update Datagrid View with elements from first page BooksDataGridView.DataSource = FilteredBooks; }
private void TransReceiptForm_Load(object sender, EventArgs e) { SA45Team13bLibraryEntities ctx = new SA45Team13bLibraryEntities(); var maxTrans = ctx.BookIssueds.Max(x => x.TransactionNo); //pull data from max Transaction No. var qryReceipt1 = from x in ctx.BookIssueds where x.TransactionNo == maxTrans select new { x.TransactionNo, x.ISBN, x.BookTitle, x.DateBorrow, x.DateDue, DateActualReturn = x.DateActualReturn ?? DateTime.MinValue, }; var qryReceipt2 = from x in ctx.IssueTrans where x.TransactionNo == maxTrans select x.CustomerID; int qryReceipt2CId = qryReceipt2.First(); //retrieve CustomerID that made latest transaction var qryReceipt3 = from x in ctx.LibraryMembers where x.CustomerID == qryReceipt2CId select x.CustomerName; string qryReceipt3CName = qryReceipt3.First(); //retreive CustomerName of made latest transaction TransReceipt crTR = new TransReceipt(); crTR.SetDataSource(qryReceipt1); crTR.SetParameterValue("pMemberName", qryReceipt3CName); crystalReportViewer1.ReportSource = crTR; }
public ManageMembers() { InitializeComponent(); context = new SA45Team13bLibraryEntities(); var qry = from x in context.LibraryMembers select new { x.CustomerID, x.CustomerName, x.Age, x.Address, x.PostalCode, x.DocumentNo, x.DocumentType, x.PhoneNumber, x.EmailAddress, x.AltPhoneNumber }; dataGridView1.DataSource = qry.ToList(); }
private void AddNewBookForm_Load(object sender, EventArgs e) { SA45Team13bLibraryEntities context = new SA45Team13bLibraryEntities(); // ShelfComboBox ShelfComboBox.SelectedIndex = 0; ShelfComboBox.SelectedItem = ShelfComboBox.Items[0]; }
private void refresh() { dataGridView1.DataSource = null; SA45Team13bLibraryEntities lm = new SA45Team13bLibraryEntities(); var qry = from x in context.LibraryMembers select new { x.CustomerID, x.CustomerName, x.Age, x.Address, x.PostalCode, x.DocumentNo, x.DocumentType, x.PhoneNumber, x.EmailAddress, x.AltPhoneNumber }; dataGridView1.DataSource = qry.ToList(); }
private void DeleteBookToolStripButton_Click(object sender, EventArgs e) { SA45Team13bLibraryEntities context = new SA45Team13bLibraryEntities(); BookList bookToBeDeleted; int loaned; String selectedISBN; // Get the Selected Row, if any if (BooksDataGridView.SelectedRows.Count != 0) { // Get the selected Row (There's only one) loaned = Convert.ToInt32(BooksDataGridView.SelectedRows[0].Cells["LoanedColumn"].Value.ToString()); selectedISBN = BooksDataGridView.SelectedRows[0].Cells["ISBNColumn"].Value.ToString(); // Can't delete book which is still loaned out if (loaned == 0) { // Confirm Deletion, otherwise cancel if (MessageBox.Show("Are you sure you want to delete?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.No) { return; } // Delete the book bookToBeDeleted = context.BookLists.Where(book => book.ISBN == selectedISBN).First(); context.BookLists.Remove(bookToBeDeleted); context.SaveChanges(); // Refresh the display RefreshDisplay(); } else { MessageBox.Show("Please Return All Loaned Books First"); return; } } else { MessageBox.Show("Please Select a Book First"); return; } }
//Refresh private void refresh() { dataGridView1.DataSource = null; SA45Team13bLibraryEntities lm = new SA45Team13bLibraryEntities(); // Get Transactions which the CustomerID is involved in var query_getTransactionsrefresh = from x in lm.IssueTrans where x.CustomerID.ToString() == textBox1.Text select x.TransactionNo; // Get Books from Above Transactions Which are not returned var query_getBooksrefresh = from x in lm.BookIssueds where query_getTransactionsrefresh.ToList().Contains(x.TransactionNo) && x.DateActualReturn == null select new { x.ISBN, x.DateDue, x.BookTitle }; // Display Books in Data Grid View dataGridView1.DataSource = query_getBooksrefresh.ToList(); }
private void AddButton_Click(object sender, EventArgs e) { String errorMessage; // Get Entity Context SA45Team13bLibraryEntities context = new SA45Team13bLibraryEntities(); // Display error if values are invalid if (!ValidateValues(out errorMessage)) { MessageBox.Show(errorMessage, "Unable to add new Book", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // Continue to add book BookList book = new BookList(); book.BookTitle = TitleTextBox.Text; book.Author = AuthorTextBox.Text; book.Publisher = PublisherTextBox.Text; book.ISBN = ISBNTextBox.Text; book.Loaned = 0; book.TotalStock = (short)StockNumericUpDown.Value; book.Language = LanguageTextBox.Text; book.Genre = GenreTextBox.Text; book.BookCost = (float)Double.Parse(BookCostTextBox.Text); if (ShelfComboBox.SelectedValue != null) { book.Shelf = ShelfComboBox.SelectedValue.ToString(); } else { book.Shelf = "1"; } context.BookLists.Add(book); context.SaveChanges(); // Display message MessageBox.Show("Book Added Sucessfully"); DialogResult = DialogResult.OK; this.Close(); }
private void UpdateDropDowns() { // Get Entity Context SA45Team13bLibraryEntities context = new SA45Team13bLibraryEntities(); // Fill LanguageComboBox and select all LanguageComboBox.Items.Clear(); LanguageComboBox.Items.Add("All"); LanguageComboBox.Items.AddRange(context.BookLists .Select(book => book.Language) .Distinct().ToArray()); // Fill GenreComboBox GenreComboBox.Items.Clear(); GenreComboBox.Items.Add("All"); GenreComboBox.Items.AddRange(context.BookLists .Select(book => book.Genre) .Distinct().ToArray()); }
public ModifyBookForm(String ISBN, String Title) { InitializeComponent(); context = new SA45Team13bLibraryEntities(); SelectedBook = context.BookLists.Single( book => book.ISBN == ISBN && book.BookTitle == Title ); TitleTextBox.Text = SelectedBook.BookTitle; AuthorTextBox.Text = SelectedBook.Author; PublisherTextBox.Text = SelectedBook.Publisher; ISBNTextBox.Text = SelectedBook.ISBN; LanguageTextBox.Text = SelectedBook.Language; GenreTextBox.Text = SelectedBook.Genre; StockNumericUpDown.Value = SelectedBook.TotalStock; StockNumericUpDown.Minimum = SelectedBook.Loaned; BookCostTextBox.Text = SelectedBook.BookCost.ToString(); ShelfComboBox.SelectedIndex = Int32.Parse(SelectedBook.Shelf) - 1; }
private void ManageBooks_Load(object sender, EventArgs e) { SA45Team13bLibraryEntities context = new SA45Team13bLibraryEntities(); // Disable Column Generation BooksDataGridView.AutoGenerateColumns = false; // Update DropDowns UpdateDropDowns(); // Set Genre boxes LanguageComboBox.SelectedIndex = 0; GenreComboBox.SelectedIndex = 0; // Set the Label BooksFound = 0; // Display all the books FilterBooks(TitleTextBox.Text, AuthorTextBox.Text, ISBNTextBox.Text, PublisherTextBox.Text, LanguageComboBox.SelectedItem.ToString(), GenreComboBox.SelectedItem.ToString()); }
private void BorrowBooksRevised_Load(object sender, EventArgs e) { context = new SA45Team13bLibraryEntities(); bL = new List <BookList>(); }
public ReturnBooks() { InitializeComponent(); context = new SA45Team13bLibraryEntities(); }
private void BorrowBooks_SearchForCustomer_Load(object sender, EventArgs e) { context = new SA45Team13bLibraryEntities(); dataGridView1.DataSource = context.LibraryMembers.ToList(); }