private void completeBook(BookName b) { switch(b) { case BookName.Dictionary: itemName = "Dictionary"; itemDescription = ""; weight = 10; value = 10; bookEffect = BookEffect.None; contents = ""; break; case BookName.Encylopedia: itemName = "Encylopedia"; itemDescription = ""; weight = 10; value = 10; bookEffect = BookEffect.None; contents = ""; break; case BookName.SomeOtherBook: itemName = "Some Other Book"; itemDescription = ""; weight = 10; value = 10; bookEffect = BookEffect.None; contents = ""; break; default: break; } }
public override int GetHashCode() { int hash = 1; if (UserName.Length != 0) { hash ^= UserName.GetHashCode(); } if (BookName.Length != 0) { hash ^= BookName.GetHashCode(); } if (BorrowTime.Length != 0) { hash ^= BorrowTime.GetHashCode(); } if (ReturnTime.Length != 0) { hash ^= ReturnTime.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private Book(Guid id, int?idInDb, BookName bookName, Author author, DateTimeOffset publishedDate, BookPagesValue pages) : base(id: id) { this.IdInDb = idInDb; this.BookName = bookName; this.Author = author; this.PublishedDate = publishedDate; this.Pages = pages; }
partial void OnBookNameChanging(string value) // Boilerplate { if (BookName == null || BookName.Equals(value)) { return; } HasChanges = true; }
public AddBook( BookId bookId, BookName bookName, YearOfPrint yearOfPrint) : base(bookId) { BookName = bookName; YearOfPrint = yearOfPrint; }
public static void Main(string[] args) { var repository = new Repository( new EventStoreAppender("tcp://localhost:1113", "Library")); var result = repository.InsertNew(NewBookFrom(BookIdFrom("2"), BookName.BookNameFrom("Lord of the rings 1"), YearOfPrintFrom(2010))).Result; Console.WriteLine(result.IsSuccess); }
public int CompareTo(Book other) { int compare = BookName?.CompareTo(other?.BookName) ?? -1; if (compare == 0) { return(Author?.CompareTo(other?.Author) ?? -1); } return(compare); }
public static Book Create(int?idInDb, BookName bookName, Author author, DateTimeOffset publishedDate, BookPagesValue pages) { return(new Book( id: Guid.NewGuid(), idInDb: idInDb, bookName: bookName, author: author, publishedDate: publishedDate, pages: pages)); }
// Constructor public Book(Bible bible, BookName bookId) { if(bible == null) throw new ArgumentNullException("bible"); if((Int32) bookId < 0 || (Int32) bookId > 65) throw new ArgumentOutOfRangeException("bookId"); _bible = bible; _book = bookId; _chapters = new ChapterCollection(); }
private void RightButton_Click(object sender, EventArgs e) { if (BookName.Text != "" && Writter.Text != "" && Page.Text != "" && PublishCompany.Text != "") { OnTimeEventFuntion(BookName.Text, Writter.Text, DateTimePicker.Value.ToString("yyyy-MM-dd"), PublishCompany.Text, Page.Text); BookName.Clear(); Writter.Clear(); PublishCompany.Clear(); Page.Clear(); MessageBox.Show("书籍加入成功"); } }
public override int GetHashCode() { unchecked { int dictHash = 17; foreach (KeyValuePair <string, string> kv in this.BookDictionary) { dictHash = dictHash * 23 + kv.Key.GetHashCode(); dictHash = dictHash * 23 + (kv.Value ?? "").GetHashCode(); } return(((BookName != null ? BookName.GetHashCode() : 0) * 397) ^ dictHash); } }
protected void editBtn_Click(object sender, EventArgs e) { //BookName.Enabled = true; BookName.Disabled = false; BookCategory.Enabled = true; BookDescription.Disabled = false; BookPrice.Enabled = true; saveBtn.Visible = true; BookCountLbl.Visible = true; BookCount.Visible = true; BookCount.Enabled = true; BookName.Focus(); }
public double PagePrice() { if (pages != 0 && price != 0) { if (BookName.Contains("Программирование")) { return((price / pages) * 2); } else { return(price / pages); } } else { Console.WriteLine("Pages or Price is 0"); return(0); } }
public int CompareTo(SheetId other) { if (Equals(other, null)) { return(1); } var x = ProcessId.CompareTo(other.ProcessId); if (x != 0) { return(x); } x = BookName.CompareTo(other.BookName); if (x != 0) { return(x); } return(SheetName.CompareTo(other.SheetName)); }
public int CompareTo(WindowId other) { if (Equals(other, null)) { return(1); } var x = ProcessId.CompareTo(other.ProcessId); if (x != 0) { return(x); } x = BookName.CompareTo(other.BookName); if (x != 0) { return(x); } return(WindowIndex.CompareTo(other.WindowIndex)); }
public bool Exercise_EqualsObject(BookName id1, BookName id2) { object book1 = CreateBookUnderTest(id: id1); object book2 = CreateBookUnderTest(id: id2); return book1.Equals(book2); }
public bool Exercise_GetHashCode(BookName id1, BookName id2) { var book1 = CreateBookUnderTest(id: id1); var book2 = CreateBookUnderTest(id: id2); return book1.GetHashCode() == book2.GetHashCode(); }
private static Book CreateBookUnderTest(IBible bible = null, BookName id = BookName.None) { return new Book(bible ?? new BibleStub(), id); }
public bool Equals(BookClass other) => other is BookClass && BookName.Equals(other.BookName) && AuthorName.Equals(other.AuthorName);
public bool Exercise_Equals(BookName id1, BookName id2) { var book1 = CreateBookUnderTest(id: id1); var book2 = CreateBookUnderTest(id: id2); return book1.Equals(book2); }
public Product GetProduct(BookName bookName) { return GetProductList().FirstOrDefault(p => p.BookName == bookName); }
public Book this[BookName bookId] { get { // Assertions var idx = (Int32) bookId; if(idx < 0 || idx > 65) throw new ArgumentNullException("bookId"); return _books[idx] ?? (_books[idx] = new Book(_bible, bookId)); } }
public Book(BookName bookName) { this.bookName = bookName; baseItemType = BaseItemType.Book; completeBook(bookName); }
public Book(ISBN isbn, BookName bookName, Quantity quantity) { this.Isbn = isbn; this.BookName = bookName; this.Quantity = quantity; }
public void NameIsOk_Should_BeOk(string name) { BookName bookName = new BookName(name); Assert.Equal(name, bookName.Name); }
} //Для сортировки public HomeViewModel(MainViewModel mainVM, int _userID) //Конструктор { ChoiceGenre = "Жанр"; Choice = "умолчанию"; this.mainVM = mainVM; AllBooks = Get_allBooks(); t_userID = _userID; Sort_books = new RelayCommand(o => { switch (Choice) { case "умолчанию": AllBooks = Get_allBooks(); break; case "названию (A->Я)": AllBooks = Sort_Books_ByName_asc(); break; case "названию (Я->А)": AllBooks = Sort_Books_ByName_desc(); break; case "жанру (A->Я)": AllBooks = Sort_Books_ByGenre_asc(); break; case "жанру (Я->А)": AllBooks = Sort_Books_ByGenre_desc(); break; case "автору (A->Я)": AllBooks = Sort_Books_ByAuthor_asc(); break; case "автору (Я->А)": AllBooks = Sort_Books_ByAuthor_desc(); break; } }); Search_book = new RelayCommand(o => { if (IsValid) { //=====================Все поля заполнены if ((BookName != "") && (AuthorFIO != "") && (ChoiceGenre != "Жанр")) { BookName = BookName.Trim(); string[] tempBName = BookName.Split(' '); AuthorFIO = AuthorFIO.Trim(); string[] tempAFIO = AuthorFIO.Split(' '); AllBooks = new ObservableCollection <Books>(db.GetDataList().Where(b => b.BookGenre.ToLower() == ChoiceGenre.ToLower() && SearchName(tempBName, b) && SearchFIO(tempAFIO, b)).ToList()); if (AllBooks.Count == 0) { MessageBox.Show("Нет ни одного результата по вашему запросу!", "Поиск"); AllBooks = Get_allBooks(); } } else { //=====================Только название и ФИО if ((BookName != "") && (AuthorFIO != "")) { BookName = BookName.Trim(); string[] tempBName = BookName.Split(' '); AuthorFIO = AuthorFIO.Trim(); string[] tempAFIO = AuthorFIO.Split(' '); AllBooks = new ObservableCollection <Books>(db.GetDataList().Where(b => SearchName(tempBName, b) && SearchFIO(tempAFIO, b)).ToList()); if (AllBooks.Count == 0) { MessageBox.Show("Нет ни одного результата по вашему запросу!", "Поиск"); AllBooks = Get_allBooks(); } } else { //=====================Только название и жанр if ((BookName != "") && (ChoiceGenre != "Жанр")) { BookName = BookName.Trim(); string[] tempBName = BookName.Split(' '); AllBooks = new ObservableCollection <Books>(db.GetDataList().Where(b => b.BookGenre.ToLower() == ChoiceGenre.ToLower() && SearchName(tempBName, b)).ToList()); if (AllBooks.Count == 0) { MessageBox.Show("Нет ни одного результата по вашему запросу!", "Поиск"); AllBooks = Get_allBooks(); } } else { //=====================Только название if (BookName != "") { BookName = BookName.Trim(); string[] tempBName = BookName.Split(' '); AllBooks = new ObservableCollection <Books>(db.GetDataList().Where(b => SearchName(tempBName, b)).ToList()); if (AllBooks.Count == 0) { MessageBox.Show("Нет ни одного результата по вашему запросу!", "Поиск"); AllBooks = Get_allBooks(); } } else { MessageBox.Show("Строка поиска по названию книги пуста!", "Поиск"); AllBooks = Get_allBooks(); } } } } } else { System.Windows.MessageBox.Show("Неккоректные данные!", "Поиск"); } }); ResetSearch = new RelayCommand(o => { AllBooks = Get_allBooks(); ChoiceGenre = "Жанр"; Choice = "умолчанию"; BookName = ""; AuthorFIO = ""; }); }
private void pictureBox2_Click(object sender, EventArgs e) { if (SerialNumber.Text == "" || PublishYear.Text == "" || BookName.Text == "") { MessageBox.Show("Please enter the required data."); } else { bool b = false; FileStream fs = new FileStream("Books.txt", FileMode.OpenOrCreate); StreamReader sr = new StreamReader(fs); string[] fields; string[] records; while (sr.Peek() != -1) { records = sr.ReadLine().Split('#'); for (int i = 0; i < records.Length - 1; i++) { fields = records[i].Split('@'); if (fields[1] == BookName.Text) { b = true; } } } sr.Close(); fs.Close(); if (b == false && AutherIDs.SelectedIndex != -1) { FileStream File = new FileStream("Books.txt", FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(File); // gets the string value of the combobox string AuthorId = AutherIDs.SelectedItem.ToString().Trim('\0'); //writes the book using '@' dilimter only if the auther id is valid sw.Write(SerialNumber.Text); sw.Write('@'); sw.Write(BookName.Text); sw.Write('@'); sw.Write(PublishYear.Text); sw.Write('@'); sw.Write(dic[AuthorId]); sw.Write('#'); //resets the text boxes SerialNumber.Clear(); BookName.Clear(); PublishYear.Clear(); AutherIDs.SelectedText = " "; // Confirms the addition to the user MessageBox.Show("Book added sucssefully."); sw.Close(); File.Close(); } else { MessageBox.Show("Book already exists."); } } }
////////////////////////////////////////////////////////////////////////// //Операции общего назначения private void EditField_TextChanged(object sender, TextChangedEventArgs e) { TextBox textBox = (TextBox)sender; if (Name.Equals(textBox)) { if (Name.Text.Length > 0) { NameWatermark.Visibility = Visibility.Hidden; } else { NameWatermark.Visibility = Visibility.Visible; } } else if (Surname.Equals(textBox)) { if (Surname.Text.Length > 0) { SurnameWatermark.Visibility = Visibility.Hidden; } else { SurnameWatermark.Visibility = Visibility.Visible; } } else if (Patronymic.Equals(textBox)) { if (Patronymic.Text.Length > 0) { PatronymicWatermark.Visibility = Visibility.Hidden; } else { PatronymicWatermark.Visibility = Visibility.Visible; } } else if (Password.Equals(textBox)) { if (Password.Text.Length > 0) { PasswordWatermark.Visibility = Visibility.Hidden; } else { PasswordWatermark.Visibility = Visibility.Visible; } } else if (AuthorSurname.Equals(textBox)) { if (AuthorSurname.Text.Length > 0) { AuthorSurnameWatermark.Visibility = Visibility.Hidden; } else { AuthorSurnameWatermark.Visibility = Visibility.Visible; } } else if (AuthorName.Equals(textBox)) { if (AuthorName.Text.Length > 0) { AuthorNameWatermark.Visibility = Visibility.Hidden; } else { AuthorNameWatermark.Visibility = Visibility.Visible; } } else if (AuthorPatronymic.Equals(textBox)) { if (AuthorPatronymic.Text.Length > 0) { AuthorPatronymicWatermark.Visibility = Visibility.Hidden; } else { AuthorPatronymicWatermark.Visibility = Visibility.Visible; } } else if (BookName.Equals(textBox)) { if (BookName.Text.Length > 0) { BookNameWatermark.Visibility = Visibility.Hidden; } else { BookNameWatermark.Visibility = Visibility.Visible; } } else if (Publisher.Equals(textBox)) { if (Publisher.Text.Length > 0) { PublisherWatermark.Visibility = Visibility.Hidden; } else { PublisherWatermark.Visibility = Visibility.Visible; } } else if (PublicationDate.Equals(textBox)) { if (PublicationDate.Text.Length > 0) { PublicationDateWatermark.Visibility = Visibility.Hidden; } else { PublicationDateWatermark.Visibility = Visibility.Visible; } } else if (PageCount.Equals(textBox)) { if (PageCount.Text.Length > 0) { PageCountWatermark.Visibility = Visibility.Hidden; } else { PageCountWatermark.Visibility = Visibility.Visible; } } else if (Location.Equals(textBox)) { if (Location.Text.Length > 0) { LocationWatermark.Visibility = Visibility.Hidden; } else { LocationWatermark.Visibility = Visibility.Visible; } } else if (Search.Equals(textBox)) { SearchUpdate(); } }