Пример #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the inventory_book_authors EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToinventory_book_authors(inventory_book_authors inventory_book_authors)
 {
     base.AddObject("inventory_book_authors", inventory_book_authors);
 }
Пример #2
0
Файл: Book.cs Проект: awpro/sbim
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Boolean is_updated = false;
            if (MessageBox.Show("Are you sure that you want to update?", "Update Book", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            Boolean ok = checkBook();
            if (!ok)
            {
                return;
            }

            inventory_book_authors authors = new inventory_book_authors();
            inventory_book_illustrators illustrators = new inventory_book_illustrators();
            inventory_book_photographers photographers = new inventory_book_photographers();

            var ind = this.dgvBook.SelectedRows[0].Index;
            int bookID = Convert.ToInt16(this.dgvBook.Rows[ind].Cells[0].Value);

            inventory_book book = inventory.inventory_book.First(i => i.id == bookID);

            var check_ref = inventory.inventory_book.Where(r => r.reference == this.txtReference.Text).SingleOrDefault();
            if (check_ref != null)
            {
                if (check_ref.reference != book.reference)
                {
                    MessageBox.Show("Reference is duplicated!", "Book Add");
                    return;
                }
            }

            book.title = this.txtTitle.Text;
            book.title_kh = this.txtTitleKH.Text;
            book.reference = this.txtReference.Text;
            book.public_price = Convert.ToDecimal(this.txtPublicPrice.Text);
            book.book_stock_alert = Convert.ToInt16(this.txtStockAlert.Text);
            book.collection_id = Convert.ToInt16(this.cboCollection.SelectedValue);
            book.original_publisher_id = Convert.ToInt16(this.cboPublisher.SelectedValue);

            try
            {
                inventory.SaveChanges();
                is_updated = true;
            }
            catch (EntitySqlException ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (is_updated)
            {
                this.dgvBook.DataSource = null;
                this.dgvBook.DataSource = inventory.inventory_book.ToList();
                MessageBox.Show("1 Book is updated!", "Book Update");
            }
        }
Пример #3
0
 /// <summary>
 /// Create a new inventory_book_authors object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 public static inventory_book_authors Createinventory_book_authors(global::System.Int32 id)
 {
     inventory_book_authors inventory_book_authors = new inventory_book_authors();
     inventory_book_authors.id = id;
     return inventory_book_authors;
 }
Пример #4
0
Файл: Book.cs Проект: awpro/sbim
        private void btnSave_Click(object sender, EventArgs e)
        {
            Boolean is_added = false;
            int bookID;

            Boolean ok = checkBook();
            if (!ok)
            {
                return;
            }

            var check_ref = inventory.inventory_book.Where(r => r.reference == this.txtReference.Text).SingleOrDefault();
            if (check_ref != null)
            {
                MessageBox.Show("Reference is duplicated!","Book Add");
                return;
            }

            inventory_book book = new inventory_book();
            book.title = this.txtTitle.Text;
            book.title_kh = this.txtTitleKH.Text;
            book.reference = this.txtReference.Text;
            book.public_price = Convert.ToDecimal(this.txtPublicPrice.Text);
            book.book_stock_alert = Convert.ToInt16(this.txtStockAlert.Text);
            book.collection_id = Convert.ToInt16(this.cboCollection.SelectedValue);
            book.original_publisher_id = Convert.ToInt16(this.cboPublisher.SelectedValue);

            try
            {
                inventory.inventory_book.AddObject(book);
                inventory.SaveChanges();
                bookID = book.id;
                book = null;

                if (bookID > 0)
                {
                    foreach (inventory_individual  illustrator in this.lstIllustrator.SelectedItems)
                    {
                        inventory_book_illustrators illustrators = new inventory_book_illustrators();
                        illustrators.book_id = bookID;
                        illustrators.individual_id = illustrator.id;
                        inventory.inventory_book_illustrators.AddObject(illustrators);
                        inventory.SaveChanges();
                    }

                    foreach (inventory_individual author in this.lstAuthor.SelectedItems)
                    {
                        inventory_book_authors authors = new inventory_book_authors();
                        authors.book_id = bookID;
                        authors.individual_id = author.id;
                        inventory.inventory_book_authors.AddObject(authors);
                        inventory.SaveChanges();
                    }

                    foreach (inventory_individual photographer in this.lstPhotographer.SelectedItems)
                    {
                        inventory_book_photographers photographers = new inventory_book_photographers();
                        photographers.book_id = bookID;
                        photographers.individual_id = photographer.id;
                        inventory.inventory_book_photographers.AddObject(photographers);
                        inventory.SaveChanges();
                    }
                    is_added = true;

                }
            }
            catch (EntitySqlException ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (is_added)
            {
                this.dgvBook.DataSource = null;
                this.dgvBook.DataSource = inventory.inventory_book.ToList();
                MessageBox.Show("1 Book is added!", "Book Add");
            }
        }