/// <summary> /// Initialize the User Control. /// </summary> /// <param name="form"></param> public UCAuthor(Form form) { InitializeComponent(); this.form = form as LibraryForm; this.txtFirstNamePlaceholder = txtFirstName.Text; this.txtLastNamePlaceholder = txtLastName.Text; }
/// <summary> /// Initialize the User Control /// </summary> public UCMember(Form form) { InitializeComponent(); this.form = form as LibraryForm; this.txtFirstNamePlaceholder = txtFirstName.Text; this.txtLastNamePlaceholder = txtLastName.Text; this.txtPersonalIDPlaceholder = txtPersonalID.Text; this.txtUsernamePlaceholder = txtUsername.Text; }
/// <summary> /// Initialize the User Control /// </summary> public UCViewMember(Form form) { InitializeComponent(); this.form = form as LibraryForm; // Subscribes the information fields update methods to run whenever other services are updated in database. this.form.loanService.Updated += LoanService_Updated; this.form.memberService.Updated += MemberService_Updated; }
/// <summary> /// Initialize the User Control /// </summary> public UCMembers(Form form) { InitializeComponent(); this.form = form as LibraryForm; this.txtSearchPlaceholder = txtSearch.Text; UIExtension.CreateListViewAlphabeticGroups(lvMembers); // Subscribes the information fields update methods to run whenever other services are updated in database. this.form.memberService.Updated += MemberService_Updated; }
/// <summary> /// Initialize the User Control. /// </summary> public UCBook(Form form) { InitializeComponent(); this.form = form as LibraryForm; this.txtFilterPlaceholder = txtFilter.Text; UIExtension.CreateListViewAlphabeticGroups(lvSelectAuthor); // Subscribes the information fields update methods to run whenever other services are updated in database. this.form.authorService.Updated += AuthorService_Updated; this.form.bookCopyService.Updated += BookCopyService_Updated; }
public ControllerLibrary(MainModel model, LibraryForm libraryForm, EditForm edit, Authorization authorizationForm, AddForm addForm) { this.model = model ?? throw new ArgumentNullException(nameof(model)); this.libraryForm = libraryForm ?? throw new ArgumentNullException(nameof(libraryForm)); this.edit = edit ?? throw new ArgumentNullException(nameof(edit)); this.authorizationForm = authorizationForm ?? throw new ArgumentNullException(nameof(authorizationForm)); this.addForm = addForm ?? throw new ArgumentNullException(nameof(addForm)); this.libraryForm.setController(this); this.edit.setController(this); this.authorizationForm.setController(this); this.addForm.setController(this); }
public void DeleteTest() { MainModel mainModel = new MainModel(); var target = new LibraryForm(); ControllerLibrary controllerLibrary = new ControllerLibrary(mainModel, target, new EditForm(), new Authorization(), new AddForm()); target.setController(controllerLibrary); List <Book> expected = new List <Book>(); expected.Add(new Book(9999, "Scott Fitzgerald", 1925, "The Great Gatsby", 77)); expected.Add(new Book(8888, "Scott Fitzgerald", 2001, "The Great Gatsby", 78)); expected.Add(new Book(7777, "Scott Fitzgerald", 2021, "The Great Gatsby", 79)); expected.Add(new Book(9999, "Scott Fitzgerald", 1925, "The Great Gatsby", 80)); expected.Add(new Book(8888, "Scott Fitzgerald", 2001, "The Great Gatsby", 81)); expected.Add(new Book(7777, "Scott Fitzgerald", 2021, "The Great Gatsby", 82)); expected.Add(new Book(9999, "Scott Fitzgerald", 1925, "The Great Gatsby", 83)); expected.Add(new Book(8888, "Scott Fitzgerald", 2001, "The Great Gatsby", 84)); expected.Add(new Book(7777, "Scott Fitzgerald", 2021, "The Great Gatsby", 85)); expected.Add(new Book(9999, "Scott Fitzgerald", 1925, "The Great Gatsby", 86)); expected.Add(new Book(8888, "Scott Fitzgerald", 2001, "The Great Gatsby", 87)); expected.Add(new Book(7777, "Scott Fitzgerald", 2021, "The Great Gatsby", 88)); object sender = target; RoutedEventArgs e = null; target.InitializeComponent(); controllerLibrary.LoadAll(); // пошук target.dataGridView1.ClearSelection(); for (int i = target.dataGridView1.RowCount - 1; i >= 0; i--) { target.dataGridView1.Rows[i].Selected = true; if (!target.dataGridView1.SelectedRows[0].Cells["Column3"].Value.ToString().Equals("Scott Fitzgerald")) { target.Button5_Click(sender, e); } } List <Book> actual; actual = mainModel.getAll(); Assert.AreEqual(expected.Count, actual.Count, 0, "actual and expected sizes of arrays are not equal"); for (int i = 0; i < expected.Count; i++) { Assert.AreEqual(expected[i].Id, actual[i].Id); Assert.AreEqual(expected[i].Name, actual[i].Name); Assert.AreEqual(expected[i].Author, actual[i].Author); Assert.AreEqual(expected[i].YearOfBook, actual[i].YearOfBook); Assert.AreEqual(expected[i].Location, actual[i].Location); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //LibraryForm libraryForm = new LibraryForm(); MainModel mainModel = new MainModel(); EditForm editForm = new EditForm(); Authorization authorization = new Authorization(); LibraryForm libraryForm = new LibraryForm(mainModel); AddForm addForm = new AddForm(); ControllerLibrary controllerLibrary = new ControllerLibrary(mainModel, libraryForm, editForm, authorization, addForm); Application.Run(authorization); }
/// <summary> /// Initialize the User Control. /// </summary> public UCLoansSearch(Form form = null) { InitializeComponent(); this.form = form as LibraryForm; this.txtSearchPlaceholder = txtSearch.Text; UIExtension.CreateListViewAlphabeticGroups(lvNewLoan); UIExtension.CreateListViewAlphabeticGroups(lvReturnLoan); // Subscribes the information fields update methods to run whenever other services are updated in database. this.form.authorService.Updated += AuthorService_Updated; this.form.bookService.Updated += BookService_Updated; this.form.bookCopyService.Updated += BookCopyService_Updated; this.form.loanService.Updated += LoanService_Updated; this.form.memberService.Updated += MemberService_Updated; }
public void FilterByAuthorTest() { MainModel mainModel = new MainModel(); var target = new LibraryForm(); ControllerLibrary controllerLibrary = new ControllerLibrary(mainModel, target, new EditForm(), new Authorization(), new AddForm()); target.setController(controllerLibrary); List <Book> expected = new List <Book>(); expected.Add(new Book(9999, "Scott Fitzgerald", 1925, "The Great Gatsby", 77)); expected.Add(new Book(8888, "Scott Fitzgerald", 2001, "The Great Gatsby", 78)); expected.Add(new Book(7777, "Scott Fitzgerald", 2021, "The Great Gatsby", 79)); expected.Add(new Book(9999, "Scott Fitzgerald", 1925, "The Great Gatsby", 80)); expected.Add(new Book(8888, "Scott Fitzgerald", 2001, "The Great Gatsby", 81)); expected.Add(new Book(7777, "Scott Fitzgerald", 2021, "The Great Gatsby", 82)); expected.Add(new Book(9999, "Scott Fitzgerald", 1925, "The Great Gatsby", 83)); expected.Add(new Book(8888, "Scott Fitzgerald", 2001, "The Great Gatsby", 84)); expected.Add(new Book(7777, "Scott Fitzgerald", 2021, "The Great Gatsby", 85)); expected.Add(new Book(9999, "Scott Fitzgerald", 1925, "The Great Gatsby", 86)); expected.Add(new Book(8888, "Scott Fitzgerald", 2001, "The Great Gatsby", 87)); expected.Add(new Book(7777, "Scott Fitzgerald", 2021, "The Great Gatsby", 88)); object sender = target; RoutedEventArgs e = null; target.InitializeComponent(); target.textBox1.Text = "The Great Gatsby"; target.textBox2.Text = "Scott Fitzgerald"; // пошук target.Button2_Click(sender, e); List <Book> actual; actual = mainModel.getFiltered(); Assert.AreEqual(expected.Count, actual.Count); for (int i = 0; i < expected.Count; i++) { Assert.AreEqual(expected[i].Id, actual[i].Id); Assert.AreEqual(expected[i].Name, actual[i].Name); Assert.AreEqual(expected[i].Author, actual[i].Author); Assert.AreEqual(expected[i].YearOfBook, actual[i].YearOfBook); Assert.AreEqual(expected[i].Location, actual[i].Location); } }
/// <summary> /// Initialize the User Control /// </summary> public UCHome(Form form) { InitializeComponent(); this.form = form as LibraryForm; }
/// <summary> /// Initialize the User Control /// </summary> public UCReturnBook(Form form) { InitializeComponent(); this.form = form as LibraryForm; this.btnReturnLoanBackColor = btnReturnLoan.BackColor; }