示例#1
0
        public PlaceOrderForm(Book_Overview frm1, store store)
        {
            InitializeComponent();

            ActiveControl = payTermsDropDown;

            string apiRoot = configFile.getSetting("apiRoot");

            BookRepoREST      bookRepo      = new BookRepoREST(apiRoot);
            StoreRepoREST     storeRepo     = new StoreRepoREST(apiRoot);
            SalesRepoREST     salesRepo     = new SalesRepoREST(apiRoot);
            BookOrderRepoREST bookOrderRepo = new BookOrderRepoREST(apiRoot);

            placeOrderService = new pubsService(bookRepo, storeRepo, salesRepo, bookOrderRepo);

            //creates new order number
            orderNum = RandomString(8);

            _store        = store;
            _bookOverview = frm1;
            _bookList     = new BookList(this, _sales);
            _bookQtyEdit  = new BookQuantityForm(this, _sales);

            transaction = new List <sales>();
        }
示例#2
0
        private void editBookQuantityButton_Click(object sender, EventArgs e)
        {
            book book;

            try
            {
                string selectedSaleId = bookOrderListViewPOF.SelectedItems[0].Text;

                foreach (sales sale in transaction)
                {
                    if (selectedSaleId == sale.title_id)
                    {
                        _bookQtyEdit         = new BookQuantityForm(this, sale);
                        _bookQtyEdit.Enabled = true;
                        _bookQtyEdit.ShowDialog();
                    }
                }

                try
                {
                    book = placeOrderService.findBook(selectedSaleId);

                    //removes original list view item
                    bookOrderListViewPOF.Items.RemoveAt(bookOrderListViewPOF.SelectedIndices[0]);

                    //allows modification of tranaction
                    editedTransaction = transaction;

                    foreach (sales sale in editedTransaction)
                    {
                        if (selectedSaleId == sale.title_id)
                        {
                            ListViewItem lvi = new ListViewItem(sale.title_id);
                            lvi.SubItems.Add(book.title);
                            lvi.SubItems.Add(sale.qty.ToString());
                            bookOrderListViewPOF.Items.Add(lvi);
                        }
                    }


                    editBookQuantityButton.Enabled = false;

                    if (bookOrderListViewPOF.Items.Count == 0)
                    {
                        submitOrderButton.Enabled = false;
                        removeBookButton.Enabled  = false;
                        payTermsDropDown.Enabled  = true;
                        ActiveControl             = submitOrderButton;
                    }
                }
                catch
                {
                    return;
                }

                bookOrderColumnHead();
            }
            catch
            {
                return;
            }
        }