public MainForm() { InitializeComponent(); Connector = new DigestRestConnector(deviceIP.Text, "adminuser", "adminpass", false); BookClient = new BookClient(Connector); deviceIP.Validated += new EventHandler(deviceIP_Validated); BooksChanged += new EventHandler(MainForm_BooksChanged); ServiceError += new ErrorEventHandler(MainForm_ServiceError); BeginGetBooks(); }
private void add_Click(object sender, EventArgs e) { EditForm f = new EditForm(); f.Text = "Add New Book"; if (f.ShowDialog() == DialogResult.OK) { BookClient.AddNewBook(f.Title, f.Author, f.Pages); BeginGetBooks(); } f.Dispose(); }
private void delete_Click(object sender, EventArgs e) { if (bookList.SelectedItems.Count == 0) { return; } Book existing = bookList.SelectedItems[0].Tag as Book; if (MessageBox.Show(string.Format("Delete book '{0}'?", existing.Title), "Confirm Delete", MessageBoxButtons.YesNo) == DialogResult.Yes) { BookClient.DeleteBook(existing.ID); BeginGetBooks(); } }
private void modify_Click(object sender, EventArgs e) { if (bookList.SelectedItems.Count == 0) { return; } Book existing = bookList.SelectedItems[0].Tag as Book; EditForm f = new EditForm(existing); f.Text = "Update Book"; if (f.ShowDialog() == DialogResult.OK) { BookClient.UpdateBook(existing.ID, f.Title, f.Author, f.Pages); BeginGetBooks(); } f.Dispose(); }
private void BeginGetBooks() { status.Text = "Getting book list..."; status.Visible = true; ThreadPool.QueueUserWorkItem(delegate { try { Books = BookClient.GetAllBooks(); } catch (Exception ex) { if (ServiceError != null) { ServiceError(this, ex); } else { throw; } } }); }