Example #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>();
        }
Example #2
0
        private void addBooksButton_Click(object sender, EventArgs e)
        {
            book book;

            if (payTermsDropDown.Text == "")
            {
                MessageBox.Show("Select Pay Term.", "Error", MessageBoxButtons.OK);
                return;
            }
            else
            {
                try
                {
                    _sales = new sales
                    {
                        stor_id  = _bookOverview._storeName.stor_id,
                        ord_num  = orderNum,
                        ord_date = date,
                        payterms = payTermsDropDown.Text,
                        qty      = new short(),
                        title_id = ""
                    };

                    _bookList = new BookList(this, _sales)
                    {
                        Enabled = true
                    };

                    _bookList.ShowDialog();

                    if (_sales.qty == 0)
                    {
                        return;
                    }

                    //existing books in order wont show. This was kept for a backup

                    /*foreach(sales sale in transaction)
                     * //{
                     * //    if(sale.title_id == _sales.title_id)
                     * //    {
                     * //        MessageBox.Show("Book is already in order.", "Error", MessageBoxButtons.OK);
                     * //        return;
                     * //    }
                     * //}
                     */

                    //try catch for when cancel in booklist form is pressed
                    try
                    {
                        book = placeOrderService.findBook(_sales.title_id);
                    }
                    catch
                    {
                        return;
                    }

                    ListViewItem lvi = new ListViewItem(_sales.title_id);
                    lvi.SubItems.Add(book.title);
                    lvi.SubItems.Add(_sales.qty.ToString());
                    bookOrderListViewPOF.Items.Add(lvi);

                    if (bookOrderListViewPOF.Items.Count != 0)
                    {
                        removeBookButton.Enabled  = true;
                        submitOrderButton.Enabled = true;
                        payTermsDropDown.Enabled  = false; //if list count is not zero, payterms is disabled
                    }

                    transaction.Add(_sales);

                    bookOrderColumnHead();
                }
                catch
                {
                    MessageBox.Show("Could not add book to order.", "Error", MessageBoxButtons.OK);
                    return;
                }
            }
        }