コード例 #1
0
ファイル: Form1.cs プロジェクト: OlegKret/WCF-with-image
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Books books = new Books();
                books.AuthorId        = Int32.Parse(txtAuthorId.Text);
                books.PublisherId     = Int32.Parse(txtPublisherId.Text);
                books.Title           = txtTitle.Text;
                books.ISBN            = txtISBN.Text;
                books.Genre           = txtGenre.Text;
                books.Type            = txtType.Text;
                books.PublicationYear = txtPubYear.Text;
                books.Price           = Int32.Parse(txtPrice.Text);

                books.Condition = txtCondition.Text;

                BookLotEntities lotEntities = new BookLotEntities();
                lotEntities.Books.Add(books);
                lotEntities.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Empty format");
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: OlegKret/WCF-with-image
        private void updateOrders_Click(object sender, EventArgs e)
        {
            using (var context = new BookLotEntities())
            {
                int    orderId = Int32.Parse(txt_OrderId.Text);
                Orders orders  = context.Orders.Find(orderId);
                if (orders != null)
                {
                    try
                    {
                        orders.OrderId   = Int32.Parse(txt_OrderId.Text);
                        orders.CustId    = Int32.Parse(txtCustId.Text);
                        orders.Subtotal  = Int32.Parse(txtSubtotal.Text);
                        orders.Shipping  = txtShipping.Text;
                        orders.OrderDate = DateTime.Now;
                        orders.Total     = orders.Subtotal / 100 * 120;
                        txtTotal.Text    = (orders.Subtotal / 100 * 120).ToString();

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

                    {
                        MessageBox.Show("Just format is bad :)");
                    }
                }
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: OlegKret/WCF-with-image
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //using (var repo = new BooksRepo())
            //{
            //    int bookId = Int32.Parse(txtBooksId.Text);
            //    var booksToUpdate = repo.GetOne(bookId);
            //    if (booksToUpdate != null)
            //    {
            //        booksToUpdate.BookId = Int32.Parse(txtBooksId.Text);
            //        booksToUpdate.AuthorId = Int32.Parse(txtAuthorId.Text);
            //        booksToUpdate.PublisherId = Int32.Parse(txtAuthorId.Text);
            //        booksToUpdate.Title = txtTitle.Text;
            //        booksToUpdate.ISBN = txtISBN.Text;
            //        booksToUpdate.Genre = txtGenre.Text;
            //        booksToUpdate.Type = txtType.Text;
            //        booksToUpdate.PublicationYear = txtPubYear.Text;
            //        booksToUpdate.Price = Int32.Parse(txtPrice.Text);

            //        booksToUpdate.Condition = txtCondition.Text;
            //        repo.Save(booksToUpdate);
            //    }
            //}
            using (var context = new BookLotEntities())
            {
                try
                {
                    int   bookId        = Int32.Parse(txtBooksId.Text);
                    Books booksToUpdate = context.Books.Find(bookId);
                    if (booksToUpdate != null)
                    {
                        booksToUpdate.BookId          = Int32.Parse(txtBooksId.Text);
                        booksToUpdate.AuthorId        = Int32.Parse(txtAuthorId.Text);
                        booksToUpdate.PublisherId     = Int32.Parse(txtAuthorId.Text);
                        booksToUpdate.Title           = txtTitle.Text;
                        booksToUpdate.ISBN            = txtISBN.Text;
                        booksToUpdate.Genre           = txtGenre.Text;
                        booksToUpdate.Type            = txtType.Text;
                        booksToUpdate.PublicationYear = txtPubYear.Text;
                        booksToUpdate.Price           = Int32.Parse(txtPrice.Text);

                        booksToUpdate.Condition = txtCondition.Text;
                        context.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Empty format, try again");
                }
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: OlegKret/WCF-with-image
        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();
            }
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: OlegKret/WCF-with-image
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int orderItem = Int32.Parse(txtOrderId.Text);

            using (var context = new BookLotEntities())
            {
                OrderItems ordersToDelete = new OrderItems()
                {
                    OrderId = orderItem
                };
                context.Entry(ordersToDelete).State = EntityState.Deleted;
                context.SaveChanges();
            }
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: OlegKret/WCF-with-image
        private void btnRemove_Click(object sender, EventArgs e)
        {
            int bookId = Int32.Parse(txtBooksId.Text);

            using (var context = new BookLotEntities())
            {
                Books booksToDelete = new Books()
                {
                    BookId = bookId
                };
                context.Entry(booksToDelete).State = EntityState.Deleted;
                context.SaveChanges();
            }
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: OlegKret/WCF-with-image
        private void btnSaveOrders_Click(object sender, EventArgs e)
        {
            Orders orders = new Orders();

            orders.OrderId   = Int32.Parse(txt_OrderId.Text);
            orders.CustId    = Int32.Parse(txtCustId.Text);
            orders.Subtotal  = Decimal.Parse(txtSubtotal.Text);
            orders.Shipping  = txtShipping.Text;
            orders.OrderDate = DateTime.Now;
            orders.Total     = orders.Subtotal / 100 * 120;
            txtTotal.Text    = (orders.Subtotal / 100 * 120).ToString();
            BookLotEntities lotEntities = new BookLotEntities();

            lotEntities.Orders.Add(orders);
            lotEntities.SaveChanges();
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: OlegKret/WCF-with-image
        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");
            }
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: OlegKret/WCF-with-image
        private void btn_Save_Click(object sender, EventArgs e)
        {
            OrderItems orderItem = new OrderItems();
            Books      books     = new Books();

            orderItem.OrderId  = Int32.Parse(txtOrderId.Text);
            orderItem.BookId   = Int32.Parse(txtBookId.Text);
            orderItem.Quantity = Int32.Parse(txtQuantity.Text);
            orderItem.Price    = Decimal.Parse(txt_Price.Text);

            //orderItem.Price = books.Price;
            //txtTotal.Text = (orders.Subtotal / 100 * 120).ToString();

            BookLotEntities lotEntities = new BookLotEntities();

            lotEntities.OrderItems.Add(orderItem);
            lotEntities.SaveChanges();
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: OlegKret/WCF-with-image
 private void btnDeleteOrders_Click(object sender, EventArgs e)
 {
     try
     {
         int orderItem = Int32.Parse(txt_OrderId.Text);
         using (var context = new BookLotEntities())
         {
             Orders ordersToDelete = new Orders()
             {
                 OrderId = orderItem
             };
             context.Entry(ordersToDelete).State = EntityState.Deleted;
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Bad Format");
     }
 }
コード例 #11
0
ファイル: Form1.cs プロジェクト: OlegKret/WCF-with-image
        private void btn_Update_Click(object sender, EventArgs e)
        {
            using (var context = new BookLotEntities())
            {
                int        orderId        = Int32.Parse(txtOrderId.Text);
                OrderItems ordersToUpdate = context.OrderItems.Find(orderId);
                if (ordersToUpdate != null)
                {
                    ordersToUpdate.OrderId  = Int32.Parse(txtOrderId.Text);
                    ordersToUpdate.BookId   = Int32.Parse(txtBookId.Text);
                    ordersToUpdate.Quantity = Int32.Parse(txtQuantity.Text);
                    decimal result;

                    ordersToUpdate.Price = Decimal.Parse(txt_Price.Text);


                    context.SaveChanges();
                }
            }
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: OlegKret/WCF-with-image
        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 :)");
                    }
                }
            }
        }