Exemplo n.º 1
0
        private void ButtonAddPublisher_Click(object sender, EventArgs e)
        {
            if (!IsReadyForAdd())
            {
                return;
            }
            string    publisherName = textBoxPublisherName.Text.Trim();
            string    address       = textBoxAddress.Text.Trim();
            string    phone         = textBoxPhone.Text.Trim();
            string    fax           = textBoxFax.Text.Trim();
            string    email         = textBoxEmail.Text.Trim();
            Publisher publisher     = new Publisher()
            {
                PublisherName = publisherName,
                Address       = address,
                Phone         = phone,
                Fax           = fax,
                Email         = email
            };
            int publisherID = PublisherDAO.AddNewPublisher(publisher);

            MessageBox.Show("Publisher Added Successful!");
            if (containerForm is AddBookForm addBookForm)
            {
                addBookForm.UpdateComboBoxPublishers(publisherID);
                addBookForm.ClearAddNewPanel();
            }
            else if (containerForm is EditBookForm editBookForm)
            {
                editBookForm.UpdateComboBoxPublishers(publisherID);
                editBookForm.ClearAddNewPanel();
            }
        }
Exemplo n.º 2
0
 public AddBookForm(Employee e, FrmMenu menuForm)
 {
     this.EMPLOYEE = e;
     this.menuForm = menuForm;
     InitializeComponent();
     publishers = PublisherDAO.SelectAllPublishers();
     categories = CategoryDAO.SelectAllCategories();
 }
Exemplo n.º 3
0
 public EditBookForm(int bookID, FrmMenu frmMenu, Employee e)
 {
     InitializeComponent();
     this.bookID  = bookID;
     this.frmMenu = frmMenu;
     EMPLOYEE     = e;
     authors      = AuthorDAO.SelectAllAuthors();
     publishers   = PublisherDAO.SelectAllPublishers();
     categories   = CategoryDAO.SelectAllCategories();
 }
Exemplo n.º 4
0
 public void UpdateComboBoxPublishers(int publisherID)
 {
     comboBoxPublishers.Items.Clear();
     publishers = PublisherDAO.SelectAllPublishers();
     for (int index = 0; index < publishers.Count; index++)
     {
         Publisher publisher = publishers[index];
         comboBoxPublishers.Items.Add(publisher.PublisherName);
         if (publisher.PublisherID == publisherID)
         {
             comboBoxPublishers.SelectedIndex = index;
         }
     }
 }
Exemplo n.º 5
0
        private void TextBoxPublisherName_TextChanged(object sender, EventArgs e)
        {
            string publisherName = textBoxPublisherName.Text.Trim();

            if (publisherName.Length == 0)
            {
                labelPublisherNameMessage.ForeColor = Color.Red;
                labelPublisherNameMessage.Text      = "Publisher Name is required";
                return;
            }
            List <Publisher> publishers = PublisherDAO.SelectAllPublishers();

            foreach (Publisher publisher in publishers)
            {
                if (publisher.PublisherName.Equals(publisherName))
                {
                    labelPublisherNameMessage.ForeColor = Color.Red;
                    labelPublisherNameMessage.Text      = "Publisher Name already existed";
                    return;
                }
            }
            labelPublisherNameMessage.ForeColor = Color.Green;
            labelPublisherNameMessage.Text      = "Publisher Name is OK";
        }
Exemplo n.º 6
0
 public SearchBookPanel(Form containerForm)
 {
     this.containerForm = containerForm;
     authors            = AuthorDAO.SelectAllAuthors();
     publishers         = PublisherDAO.SelectAllPublishers();
     categories         = CategoryDAO.SelectAllCategories();
     Size     = new Size(1205, 265);
     groupBox = new GroupBox()
     {
         Text     = "Search Book",
         Location = new Point(12, 12),
         Size     = new Size(1190, 250)
     };
     labelTitle = new Label()
     {
         Text     = "Title",
         AutoSize = true,
         Location = new Point(6, 23),
         Size     = new Size(27, 13)
     };
     textBoxTitle = new TextBox()
     {
         Location = new Point(69, 19),
         Size     = new Size(175, 20)
     };
     labelAuthor = new Label()
     {
         Text     = "Author",
         AutoSize = true,
         Location = new Point(6, 49),
         Size     = new Size(38, 13)
     };
     comboBoxAuthors = new ComboBox()
     {
         Location = new Point(69, 46),
         Size     = new Size(175, 21)
     };
     labelPublisher = new Label()
     {
         Text     = "Publisher",
         AutoSize = true,
         Location = new Point(6, 76),
         Size     = new Size(30, 13)
     };
     comboBoxPublishers = new ComboBox()
     {
         Location = new Point(69, 73),
         Size     = new Size(175, 21)
     };
     labelCategories = new Label()
     {
         Text     = "Categories",
         AutoSize = true,
         Location = new Point(6, 103),
         Size     = new Size(57, 13)
     };
     checkedListBoxCategories = new CheckedListBox()
     {
         ScrollAlwaysVisible = true,
         Location            = new Point(69, 103),
         Size = new Size(175, 94)
     };
     labelPublicationDate = new Label()
     {
         Text     = "Publication Date",
         AutoSize = true,
         Location = new Point(6, 204),
         Size     = new Size(85, 13)
     };
     comboBoxPublicationDate = new ComboBox()
     {
         Location = new Point(9, 221),
         Size     = new Size(82, 21)
     };
     labelMonth = new Label()
     {
         Text     = "Month",
         AutoSize = true,
         Location = new Point(97, 204),
         Size     = new Size(37, 13)
     };
     comboBoxMonth = new ComboBox()
     {
         Location = new Point(97, 221),
         Size     = new Size(72, 21)
     };
     labelYear = new Label()
     {
         Text     = "Year",
         AutoSize = true,
         Location = new Point(172, 204),
         Size     = new Size(29, 13)
     };
     numericUpDownYear = new NumericUpDown()
     {
         Location = new Point(175, 222),
         Size     = new Size(69, 20)
     };
     labelSearchResult = new Label()
     {
         Text     = "Search Result",
         AutoSize = true,
         Location = new Point(250, 16),
         Size     = new Size(74, 13)
     };
     dataGridViewSearchResult = new DataGridView()
     {
         AllowUserToAddRows    = false,
         AllowUserToDeleteRows = false,
         AutoSizeColumnsMode   = DataGridViewAutoSizeColumnsMode.AllCells,
         Location = new Point(253, 32),
         Size     = new Size(600, 210)
     };
     AddControls();
     AddItemsToComboBoxAuthors();
     AddItemsToComboBoxPublishers();
     AddItemsToCheckedListBoxCategories();
     AddItemsToComboBoxPublicationDate();
     AddItemsToComboBoxMonth();
     AddItemsToNumericUpDownYear();
     AddEventsToControls();
     UpdateDataGridViewSearchResult();
 }