private void btn_Order_Click(object sender, EventArgs e)
        {
            //set to default
            combo_Students.Text = "Choose student";
            combo_Products.Text = "Choose product";
            //get studentid
            string studentInput    = combo_Students.SelectedItem.ToString();
            string selectedStudent = studentInput.Substring(0, 2);

            selectedStudent = selectedStudent.Replace(" ", String.Empty);
            int selectedStudentID = int.Parse(selectedStudent);
            //get productid
            string productInput    = combo_Products.SelectedItem.ToString();
            string selectedProduct = productInput.Substring(0, 2);

            selectedProduct = selectedProduct.Replace(" ", String.Empty);
            int selectedProductID = int.Parse(selectedProduct);

            //send to db
            try
            {
                Order_DAO order_db = new Order_DAO();
                order_db.Db_Send_Order(selectedProductID, selectedStudentID);
                MessageBox.Show("Successfully placed order.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString(), "Error while placing order", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        public bool PlaceOrder(int reservationID, int currentemployeeID)
        {
            Order_DAO dao = Order_DAO.GetOrderDAO();

            try
            {
                dao.PlaceOrder(1, reservationID, 1, currentemployeeID);
            } catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
예제 #3
0
        public void Checkout(String s, String d)
        {
            MessageBox.Show($"{s} /n {d}", "Checkout Data", MessageBoxButtons.OK);

            SomerenLogic.Drink_Service drink_Service = new SomerenLogic.Drink_Service();
            List <Drinks> drinkList = drink_Service.GetDrinks();

            String[] student = s.Split(' ');
            String[] drink   = d.Split(' ');


            Order o = new Order
            {
                DrinkID   = int.Parse(student[0]),
                StudentID = int.Parse(student[0]),
                Total     = drinkList[drinkList.FindIndex(item => item.Drinkid == int.Parse(drink[0]))].Price,
            };

            Order_DAO order_DB = new Order_DAO();

            order_DB.RecordOrder(o);
        }