// Book Create Event//
        private void BtnSave_Click(object sender, EventArgs e)
        {
            //Book Update Event//
            CmbCombobox select = CmbGenre.SelectedItem as CmbCombobox;

            if (_isUpdate)
            {
                _book.Name    = TxtBookName.Text;
                _book.Price   = Convert.ToDecimal(TxtPrice.Text);
                _book.Count   = Convert.ToInt32(TxtCount.Text);
                _book.GenreId = select.Id;
                _bookDal.Update(_book);
                AddBook?.Invoke(_book, new EventArgs());
                MessageBox.Show("Melumat Deisildi");
            }
            else
            {
                if (!this.CheckInput() || CmbGenre.SelectedItem == null)
                {
                    MessageBox.Show("Xanalari doldurun");
                    return;
                }
                Book book = new Book
                {
                    Name    = TxtBookName.Text,
                    Price   = Convert.ToDecimal(TxtPrice.Text),
                    Count   = Convert.ToInt32(TxtCount.Text),
                    GenreId = select.Id
                };
                _bookDal.Create(book);
                MessageBox.Show("Melumat elave edildi");
                AddBook?.Invoke(book, new EventArgs());
            }
            this.Close();
        }
Exemplo n.º 2
0
 internal bool Create(Book book)
 {
     status = _bookDal.Create(book);
     return(status);
 }