Exemple #1
0
        private void btnRemoveAction_Click(object sender, EventArgs e)
        {
            int salesItem = Int32.Parse(txtSalesBookId.Text);

            using (var context = new BookLotEntities())
            {
                SalesBook booksToDelete = new SalesBook()
                {
                    SalesBookId = salesItem
                };
                context.Entry(booksToDelete).State = EntityState.Deleted;
                context.SaveChanges();
            }
        }
Exemple #2
0
        private void btnSaveAction_Click(object sender, EventArgs e)
        {
            try
            {
                SalesBook sales = new SalesBook();
                sales.SalesBookId = Int32.Parse(txtSalesBookId.Text);
                sales.TitleAction = txtTitleAction.Text;
                sales.BookId      = Int32.Parse(txt_BookId.Text);

                BookLotEntities lotEntities = new BookLotEntities();
                lotEntities.SalesBook.Add(sales);
                lotEntities.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Bad Format");
            }
        }
Exemple #3
0
        private void btnUpdateAction_Click(object sender, EventArgs e)
        {
            using (var context = new BookLotEntities())
            {
                int       salesBookId = Int32.Parse(txtSalesBookId.Text);
                SalesBook sales       = context.SalesBook.Find(salesBookId);
                if (sales != null)
                {
                    try
                    {
                        sales.SalesBookId = Int32.Parse(txtSalesBookId.Text);
                        sales.TitleAction = txtTitleAction.Text;
                        sales.BookId      = Int32.Parse(txt_BookId.Text);

                        context.SaveChanges();
                    }
                    catch (Exception ex)

                    {
                        MessageBox.Show("Just format is bad :)");
                    }
                }
            }
        }