Example #1
0
        private void BtnOrder_Click(object sender, RoutedEventArgs e)
        {
            OrderRequest or   = new OrderRequest();
            int          num  = or.GenerateNum();
            bool         flag = false;

            foreach (MedicalSupply item in cartList)
            {
                or = new OrderRequest(num, item.SupplyId, Login.userId);
                or.SetDrone(drone.DroneID);
                or.SetGeoLocaton(currentLoc);
                flag = or.InsertOrderRequests(or);

                if (!flag)
                {
                    notifier.error("Error Placing Order");
                }
            }

            if (flag)
            {
                notifier.success("Order Placed Succesfully");
                cartList.Clear();
                txtCart.Clear();
                lblTotal.Content = "";
            }

            MainWindow main = new MainWindow();

            Content = main;
        }
        public static List <OrderRequest> ReadOrderRequests()
        {
            List <OrderRequest> orderRequestList = new List <OrderRequest>();

            try
            {
                conn.Open();
                if (conn.State == ConnectionState.Open)
                {
                    OleDbCommand    cmd    = new OleDbCommand("Select * From OrderRequests Where OrderStatus = 0", conn);
                    OleDbDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        OrderRequest order = new OrderRequest(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetInt32(3));
                        order.SetDrone(reader.GetInt32(4));
                        order.SetGeoLocaton(new GeoCoordinate(double.Parse(reader.GetString(5)), double.Parse(reader.GetString(6))));
                        orderRequestList.Add(order);
                    }
                }
                else
                {
                    throw new CustomException("Database connection error");
                }
            }

            catch (CustomException ce)
            {
                notifier.error(ce.Message);
            }
            finally
            {
                conn.Close();
            }

            return(orderRequestList);
        }