示例#1
0
        private void btnDeliver_Click(object sender, EventArgs e)
        {
            Store current_store = _sorted_stores_list[_current_store];

            Logger.Log(String.Format("Delivery started, next store {0}", current_store.storeName));
            double       total_payed   = current_store.GetTotalProductsPrice();
            DialogResult dialog_result = MessageBox.Show("Your order has been delivered.\nYou have payed: $" +
                                                         total_payed.ToString() + ".\nDo you want to order more products?", "Delivering to " +
                                                         current_store.storeName, MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            Logger.Log(String.Format("Delivery successful, for store {0}", current_store.storeName));
            _total_earning += total_payed;

            if (dialog_result == DialogResult.Yes)
            {
                Logger.Log(String.Format("Store {0} is ready for creating  new order", current_store.storeName));
                OrderProducts order_products = new OrderProducts();
                order_products.SetCurrentStore(current_store);
                order_products.ShowDialog();
            }
            else
            {
                Logger.Log(String.Format("Store {0} will not create a new order", current_store.storeName));
                current_store.products = new List <StoreProduct>();
                _qrAdapter.CreateQR(current_store);
            }

            _current_store++;
            if (_current_store == _sorted_stores_list.Count)
            {
                Form fstores = new fStores();
                fstores.Show();
                Logger.Log(String.Format("You have finished delivering today's products. Hooray!"));
                this.Close();
            }
            else
            {
                UpdateUI();
            }
        }
示例#2
0
        private void btnOrder_Click(object sender, EventArgs e)
        {
            List <StoreProduct> products = new List <StoreProduct>();

            foreach (DataGridViewRow row in dgvProducts.Rows)
            {
                if (Convert.ToInt32(row.Cells["Quantity"].Value) > 0)
                {
                    int id       = Convert.ToInt32(row.Cells["Id"].Value);
                    int quantity = Convert.ToInt32(row.Cells["Quantity"].Value);

                    StoreProduct prod = new StoreProduct(ProductList.GetProductById(id), quantity);
                    products.Add(prod);

                    Logger.Log(String.Format("Store requested {0} of product {1}", quantity, prod.name));
                }
            }

            current_store.products = products;
            qrAdapter.CreateQR(current_store);
            this.Close();
        }