コード例 #1
0
        // Send payment to database (amount -1)
        private void buttonPay_Click(object sender, EventArgs e)
        {
            SomerenLogic.Stock_Service stockService = new SomerenLogic.Stock_Service();


            string studentName = cmb_Student.SelectedItem.ToString();
            string drinkName   = cmb_Drink.SelectedItem.ToString();

            testLabel.Text = studentName + " Has purchased " + drinkName;
            stockService.SellItem(drinkName);
        }
コード例 #2
0
        // Send payment to database (amount -1)
        private void buttonPay_Click(object sender, EventArgs e)
        {
            SomerenLogic.Stock_Service   stockService = new SomerenLogic.Stock_Service();
            SomerenLogic.Student_Service studService  = new SomerenLogic.Student_Service();
            List <Student> studentList = studService.GetStudents();

            // Get the name from the selected items
            string studentName = cmb_Student.SelectedItem.ToString();
            string drinkName   = cmb_Drink.SelectedItem.ToString();

            // Give a message that the payment has succeeded
            testLabel.Text = studentName + " Has purchased " + drinkName;
            stockService.SellItem(drinkName);

            // Match the right studentnumber with the right name, then add a purchase to that student.
            foreach (Student s in studentList)
            {
                string fullName = s.FirstName + " " + s.LastName;
                if (fullName == studentName)
                {
                    studService.AddPurchase(s.Number);
                }
            }
        }