Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
        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;
                    }
                }
            });
        }