Пример #1
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            ep.Clear();

            if (txtBookName.Text.Trim().Length == 0)
            {
                ep.SetError(txtBookName, "Book Name boş bırakılamaz!");
                txtBookName.Focus();
                return;
            }
            if (txtTitle.Text.Trim().Length == 0)
            {
                ep.SetError(txtTitle, "Title boş bırakılamaz!");
                txtTitle.Focus();
                return;
            }
            if (txtAuthor.Text.Trim().Length == 0)
            {
                ep.SetError(txtAuthor, "Author boş bırakılamaz!");
                txtAuthor.Focus();
                return;
            }
            if (txtEdition.Text.Trim().Length == 0)
            {
                ep.SetError(txtEdition, "Edition boş bırakılamaz!");
                txtEdition.Focus();
                return;
            }
            if (txtNoOfCopies.Text.Trim().Length == 0)
            {
                ep.SetError(txtNoOfCopies, "Edition boş bırakılamaz!");
                txtNoOfCopies.Focus();
                return;
            }
            if (txtPrice.Text.Trim().Length == 0)
            {
                ep.SetError(txtPrice, "Price boş bırakılamaz!");
                txtPrice.Focus();
                return;
            }

            if (!BooksHelper.HaveBook(txtBookName.Text, txtAuthor.Text, txtAuthor.Text))
            {
                Books b = new Books();
                b.BookCategoryID = BookCategoriesHelper.GetByName(cmbCategory.SelectedItem.ToString());
                b.StaffID        = _staffID;
                b.DepartmentID   = DepartmentsHelper.GetByName(cmbDepartment.SelectedItem.ToString());
                b.BookName       = txtBookName.Text;
                b.Author         = txtAuthor.Text;
                b.Title          = txtTitle.Text;
                b.Edition        = txtEdition.Text;
                b.NoOfCopies     = Convert.ToInt32(txtNoOfCopies.Text);
                b.DateOfRegister = dtpRegDate.Value;
                b.Price          = Convert.ToInt32(txtPrice.Text);
                BooksHelper.Add(b);

                MessageBox.Show("Kitap Ekleme Başarılı", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information);

                cmbDepartment.SelectedIndex = 0;
                cmbCategory.SelectedIndex   = 0;
                txtBookName.Text            = string.Empty;
                txtTitle.Text      = string.Empty;
                txtAuthor.Text     = string.Empty;
                txtEdition.Text    = string.Empty;
                txtNoOfCopies.Text = string.Empty;
                dtpRegDate.Value   = DateTime.Now;
                txtPrice.Text      = string.Empty;

                FillGrid();
            }
            else
            {
                MessageBox.Show("Eklemk istediğiniz kitap sistemde zaten mevcut!", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }