Пример #1
0
 public EditBook(DAL.Model.Book book, Form parent)
 {
     InitializeComponent();
     _listBook           = parent as ListBook;
     idTxt.Text          = book.Id.ToString();
     nameTxt.Text        = book.Name;
     descriptionTxt.Text = book.Description;
     priceTxt.Text       = Math.Round(book.Price, 2).ToString();
 }
Пример #2
0
        private void bookCbo_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selectValue;

            if (int.TryParse(bookCbo.SelectedValue.ToString(), out selectValue))
            {
                if (selectValue >= 1)
                {
                    DAL.Model.Book b = BookServices.GetBookById(selectValue);
                    books.Add(b);
                    itemDgv.Rows.Add(b.Id.ToString(), b.Name, b.Price.ToString());
                }
            }
        }
Пример #3
0
        private void updateBtn_Click(object sender, EventArgs e)
        {
            DAL.Model.Book book = new DAL.Model.Book();
            book.Id          = int.Parse(idTxt.Text);
            book.Name        = nameTxt.Text;
            book.Description = descriptionTxt.Text;
            book.Price       = Math.Round(double.Parse(priceTxt.Text));

            try
            {
                Services.BookServices.UpdateBook(book);
                _listBook.BookListDgv.DataSource = Services.BookServices.ListBook();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #4
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            saveBtn.Enabled = false;
            DAL.Model.Book book = new DAL.Model.Book();
            book.Name        = nameTxt.Text;
            book.Description = descriptionTxt.Text;
            book.Price       = double.Parse(priceTxt.Text);

            try
            {
                Services.BookServices.AddBook(book);
                nameTxt.Text        = string.Empty;
                descriptionTxt.Text = string.Empty;
                priceTxt.Text       = string.Empty;
                saveBtn.Enabled     = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                saveBtn.Enabled = true;
            }
        }