Пример #1
0
        public AddBookForm(catalogBooksEntities dbCatalog, ShowForm parent = null)
        {
            InitializeComponent();
            this.dbCatalog = dbCatalog;
            this.parent    = parent;
            List <Genre> listGenre = // get genre from db
                                     (from genre in dbCatalog.Genre
                                      select genre).ToList();

            cmbGenre.DataSource    = listGenre;
            cmbGenre.DisplayMember = "name";
            if (listGenre.Count > 0)
            {
                cmbGenre.SelectedItem = listGenre[0]; // set first record in combobox
            }
            List <Publishing> listPublishing =        // get Publishing from db
                                               (from publishing in dbCatalog.Publishing
                                                select publishing).ToList();

            cmbPublishing.DataSource    = listPublishing;
            cmbPublishing.DisplayMember = "name";
            if (listPublishing.Count > 0)
            {
                cmbPublishing.SelectedItem = listPublishing[0]; // set first record in combobox
            }
        }
Пример #2
0
        private void showBooksToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool     show     = true;
            ShowForm showForm = new ShowForm();

            foreach (Form item in this.MdiChildren)
            {
                if (item is ShowForm)
                {
                    show = false;
                    item.Focus();
                }
            }
            if (show)
            {
                showForm.MdiParent = this;
                showForm.Show();
            }
        }