コード例 #1
0
        private void drinkUpdateBtn_Click(object sender, EventArgs e)
        {
            if (boxId.Text == "" || drinkNameBox.Text == "" || drinkPriceBox.Text == "" || drinkAmountBox.Text == "")
            {
                // show a message if a user did not enter a value
                MessageBox.Show("Please enter a value for all fields before clicking on Update", "",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                // reading data from the textboxes
                int     id     = int.Parse(boxId.Text);
                string  name   = drinkNameBox.Text;
                decimal price  = decimal.Parse(drinkPriceBox.Text);
                int     amount = int.Parse(drinkAmountBox.Text);

                // passing data to the UI layer
                SomerenUI.uppdateBarServiceUI(id, name, price, amount);

                // show a messagebox after clicking on update button
                MessageBox.Show("You have successfully updated a drink!!\n" +
                                "Enter Refresh the list to see the changes", "",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            // clearing data from textboxes
            drinkAmountBox.Clear();
            drinkNameBox.Clear();
            drinkPriceBox.Clear();
            boxId.Clear();
        }