private void btnAdd_Click(object sender, RoutedEventArgs e) { TextBox[] txbArray = { txbId, txbFirstName, txbLastName, txbNationalCode }; bool a = MyFunctions.isTextBoxEmpty(txbArray); if (!a) { return; } bool b = MyFunctions.isTextBoxInt("Please Enter only integeral valuse in ID & National Code.", txbId, txbNationalCode); if (!b) { return; } bool c = MyFunctions.checkTextBoxLenght(4, txbId); if (!c) { return; } bool d = MyFunctions.checkDatePickerValidation(dpRegistrationDate); if (!d) { return; } bool f = MyFunctions.checkTextBoxLenght(10, txbNationalCode); if (!f) { return; } if (!MemberList.ContainsKey(txbId.Text)) { Member temp = new Member(); temp.FirstName = txbFirstName.Text; temp.LastName = txbLastName.Text; temp.NationalCode = txbNationalCode.Text; temp.Id = txbId.Text; temp.RegisteryDate = (DateTime)dpRegistrationDate.SelectedDate; MemberList.Add(txbId.Text, temp); MessageBox.Show("Member successfully added."); } else { MessageBox.Show("This ID is already used."); txbId.Clear(); txbId.Focus(); return; } txbFirstName.Clear(); txbId.Clear(); txbLastName.Clear(); dpRegistrationDate.Text = ""; txbNationalCode.Clear(); }
private void btnLoan_Click(object sender, RoutedEventArgs e) { bool a = MyFunctions.isTextBoxEmpty(txbBookId); if (!a) { return; } bool b = MyFunctions.checkTextBoxLenght(4, txbBookId); if (!b) { return; } bool c = MyFunctions.isTextBoxInt("Please enter only integeral values in BookID text box.", txbBookId); if (!c) { return; } if (BookList.ContainsKey(txbBookId.Text)) { tempBook = BookList[txbBookId.Text]; if (tempMember.Loaned.Count < 3) { if (tempBook.TotalNumber != 0) { tempMember.Loaned.Add(txbBookId.Text); tempBook.TotalNumber--; MessageBox.Show(tempMember.FirstName + " borrowed " + tempBook.Name + "."); txbMemberId.IsEnabled = true; txbBookId.IsEnabled = false; btnLoan.IsEnabled = false; btnSearchMember.IsEnabled = true; txbBookId.Clear(); txbMemberId.Clear(); } else { MessageBox.Show("This book is not available in the library."); } } else { MessageBox.Show(MemberList[txbMemberId.Text].FirstName + " can't borrow book any more."); } } else { MessageBox.Show("Book not found."); txbBookId.Focus(); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { TextBox[] txbArray = { txbName, txbId, txbWriterName, txbPublisher, txbPublicationYear, txbTotalNumber }; bool a = MyFunctions.isTextBoxEmpty(txbArray); if (!a) { return; } bool b = MyFunctions.isTextBoxInt("Please Enter only integeral valuse in Id ,publication year and number", txbId, txbPublicationYear, txbTotalNumber); if (!b) { return; } bool c = MyFunctions.checkTextBoxLenght(4, txbId, txbPublicationYear); if (!c) { return; } bool d = MyFunctions.checkDatePickerValidation(dpRegistrationDate); if (!d) { return; } if (!BookList.ContainsKey(txbId.Text)) { Book temp = new Book(); temp.Name = txbName.Text; temp.Id = txbId.Text; temp.Writer = txbWriterName.Text; temp.Publisher = txbPublisher.Text; temp.PublicationYear = Convert.ToInt32(txbPublicationYear.Text); temp.TotalNumber = Convert.ToInt32(txbTotalNumber.Text); temp.Registration = (DateTime)dpRegistrationDate.SelectedDate; BookList.Add(txbId.Text, temp); MessageBox.Show("Book successfully added."); } else { MessageBox.Show("This id is already used."); txbId.Clear(); txbId.Focus(); return; } txbName.Clear(); txbId.Clear(); txbWriterName.Clear(); txbPublisher.Clear(); txbPublicationYear.Clear(); txbTotalNumber.Clear(); dpRegistrationDate.Text = ""; }
private void btnEdit_Click(object sender, RoutedEventArgs e) { TextBox[] txbArray = { txbName, txbWriterName, txbPublisher, txbPublicationYear, txbTotalNumber }; bool a = MyFunctions.isTextBoxEmpty(txbArray); if (!a) { return; } bool b = MyFunctions.isTextBoxInt("Please Enter only integeral valuse in publication year and number", txbPublicationYear, txbTotalNumber); if (!b) { return; } bool c = MyFunctions.checkTextBoxLenght(4, txbPublicationYear); if (!c) { return; } bool d = MyFunctions.checkDatePickerValidation(dpRegistrationDate); if (!d) { return; } Book temp = new Book(); temp.Name = txbName.Text; temp.Id = txbId.Text; temp.Writer = txbWriterName.Text; temp.Publisher = txbPublisher.Text; temp.PublicationYear = Convert.ToInt32(txbPublicationYear.Text); temp.TotalNumber = Convert.ToInt32(txbTotalNumber.Text); temp.Registration = (DateTime)dpRegistrationDate.SelectedDate; BookList[temp.Id] = temp; MessageBox.Show("Book successfully Edied."); txbName.Clear(); txbId.Clear(); txbWriterName.Clear(); txbPublisher.Clear(); txbPublicationYear.Clear(); txbTotalNumber.Clear(); dpRegistrationDate.Text = ""; btnOk.IsEnabled = true; btnEdit.IsEnabled = false; txbId.IsEnabled = true; txbName.IsEnabled = false; txbWriterName.IsEnabled = false; txbPublisher.IsEnabled = false; txbPublicationYear.IsEnabled = false; txbTotalNumber.IsEnabled = false; dpRegistrationDate.IsEnabled = false; }
private void btnEdit_Click(object sender, RoutedEventArgs e) { TextBox[] txbArray = { txbFirstName, txbLastName, txbNationalCode }; bool a = MyFunctions.isTextBoxEmpty(txbArray); if (!a) { return; } bool b = MyFunctions.checkDatePickerValidation(dpRegistrationDate); if (!b) { return; } bool c = MyFunctions.checkTextBoxLenght(10, txbNationalCode); if (!c) { return; } bool d = MyFunctions.isTextBoxInt("Enter only integeral values in National Code.", txbNationalCode); if (!d) { return; } Member temp = new Member(); temp.FirstName = txbFirstName.Text; temp.LastName = txbLastName.Text; temp.NationalCode = txbNationalCode.Text; temp.Id = txbId.Text; temp.RegisteryDate = (DateTime)dpRegistrationDate.SelectedDate; MemberList[txbId.Text] = temp; MessageBox.Show("Member successfully edited."); txbFirstName.Clear(); txbId.Clear(); txbLastName.Clear(); txbNationalCode.Clear(); dpRegistrationDate.Text = ""; btnOk.IsEnabled = true; btnEdit.IsEnabled = false; txbId.IsEnabled = true; txbLastName.IsEnabled = false; txbFirstName.IsEnabled = false; txbNationalCode.IsEnabled = false; dpRegistrationDate.IsEnabled = false; }
private void btnSearch_Click(object sender, RoutedEventArgs e) { bool a = MyFunctions.isTextBoxEmpty(txbId); if (!a) { return; } bool b = MyFunctions.checkTextBoxLenght(4, txbId); if (!b) { return; } bool c = MyFunctions.isTextBoxInt("Id must be an integeral value.", txbId); if (!c) { return; } lblName.Content = ""; lblWriterName.Content = ""; lblPublisher.Content = ""; lblPublicationYear.Content = ""; lblTotalNumber.Content = ""; if (BookList.ContainsKey(txbId.Text)) { Book temp = BookList[txbId.Text]; lblName.Content = "Name: " + temp.Name; lblWriterName.Content = "Writer Name: " + temp.Writer; lblPublisher.Content = "Publisher: " + temp.Publisher; lblPublicationYear.Content = "Publication Year: " + temp.PublicationYear.ToString(); lblTotalNumber.Content = "Total Number: " + temp.TotalNumber.ToString(); lblRegistrationDate.Content = "Registration Date: " + temp.Registration.ToString(); btnSearch.IsEnabled = false; btnRemove.IsEnabled = true; txbId.IsEnabled = false; } else { MessageBox.Show("Book not found."); } }
private void btnSearchMember_Click(object sender, RoutedEventArgs e) { bool a = MyFunctions.isTextBoxEmpty(txbMemberId); if (!a) { return; } bool b = MyFunctions.checkTextBoxLenght(4, txbMemberId); if (!b) { return; } bool c = MyFunctions.isTextBoxInt("Please enteronly integeral values in MemberID textbox.", txbMemberId); if (!c) { return; } if (MemberList.ContainsKey(txbMemberId.Text)) { tempMember = MemberList[txbMemberId.Text]; txbMemberId.IsEnabled = false; btnSearchMember.IsEnabled = false; btnReturn.IsEnabled = true; List <string> tempLoaned = new List <string>(); tempLoaned = tempMember.Loaned; for (int i = 0; i < tempLoaned.Count; i++) { LiboBooks.Items.Add(tempLoaned[i] + "(" + BookList[tempLoaned[i]].Name + ")"); } } else { MessageBox.Show("Member not found"); txbMemberId.Focus(); } }
private void btnSearch_Click(object sender, RoutedEventArgs e) { lblFirstName.Content = ""; lblLastName.Content = ""; lblNationalCode.Content = ""; lblRegistrationDate.Content = ""; lblLiability.Content = ""; bool a = MyFunctions.isTextBoxEmpty(txbId); if (!a) { return; } bool b = MyFunctions.checkTextBoxLenght(4, txbId); if (!b) { return; } bool c = MyFunctions.isTextBoxInt("Id must be an integeral value.", txbId); if (!c) { return; } lblFirstName.Content = ""; lblLastName.Content = ""; lblNationalCode.Content = ""; if (MemberList.ContainsKey(txbId.Text)) { Member temp = MemberList[txbId.Text]; lblFirstName.Content = "First Name: " + temp.FirstName; lblLastName.Content = "Last Name: " + temp.LastName; lblNationalCode.Content = "National Cide: " + temp.NationalCode; lblRegistrationDate.Content = "Registration Date: " + temp.RegisteryDate.ToString(); lblLiability.Content = "Liability : " + temp.Liability.ToString(); } else { MessageBox.Show("Member not found."); } }
private void btnOk_Click(object sender, RoutedEventArgs e) { bool a = MyFunctions.isTextBoxEmpty(txbId); if (!a) { return; } bool b = MyFunctions.checkTextBoxLenght(4, txbId); if (!b) { return; } bool c = MyFunctions.isTextBoxInt("Id must be an integeral value.", txbId); if (!c) { return; } if (BookList.ContainsKey(txbId.Text)) { Book temp = BookList[txbId.Text]; txbName.Text = temp.Name; txbWriterName.Text = temp.Writer; txbPublisher.Text = temp.Publisher; txbPublicationYear.Text = temp.PublicationYear.ToString(); txbTotalNumber.Text = temp.TotalNumber.ToString(); dpRegistrationDate.Text = temp.Registration.ToString(); btnOk.IsEnabled = false; btnEdit.IsEnabled = true; txbId.IsEnabled = false; txbName.IsEnabled = true; txbWriterName.IsEnabled = true; txbPublisher.IsEnabled = true; txbPublicationYear.IsEnabled = true; txbTotalNumber.IsEnabled = true; dpRegistrationDate.IsEnabled = true; } else { MessageBox.Show("Book not found."); } }
private void btnOk_Click(object sender, RoutedEventArgs e) { bool a = MyFunctions.isTextBoxEmpty(txbId); if (!a) { return; } bool b = MyFunctions.checkTextBoxLenght(4, txbId); if (!b) { return; } bool c = MyFunctions.isTextBoxInt("Id must be an integeral value.", txbId); if (!c) { return; } if (MemberList.ContainsKey(txbId.Text)) { Member temp = MemberList[txbId.Text]; txbFirstName.Text = temp.FirstName; txbLastName.Text = temp.LastName; txbNationalCode.Text = temp.NationalCode; dpRegistrationDate.Text = temp.RegisteryDate.ToString(); btnOk.IsEnabled = false; btnEdit.IsEnabled = true; txbId.IsEnabled = false; txbFirstName.IsEnabled = true; txbLastName.IsEnabled = true; txbNationalCode.IsEnabled = true; dpRegistrationDate.IsEnabled = true; } else { MessageBox.Show("Member not found!"); } }
private void btnSearchMember_Click(object sender, RoutedEventArgs e) { bool a = MyFunctions.isTextBoxEmpty(txbMemberId); if (!a) { return; } bool b = MyFunctions.checkTextBoxLenght(4, txbMemberId); if (!b) { return; } bool c = MyFunctions.isTextBoxInt("Please enteronly integeral values in MemberID textbox.", txbMemberId); if (!c) { return; } if (MemberList.ContainsKey(txbMemberId.Text)) { tempMember = MemberList[txbMemberId.Text]; txbMemberId.IsEnabled = false; txbBookId.IsEnabled = true; btnSearchMember.IsEnabled = false; btnLoan.IsEnabled = true; } else { MessageBox.Show("Member not found"); txbMemberId.Focus(); } }