Пример #1
0
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            String        MenuList = null;
            String        qurey    = "select Count(MenuId) from Menu";
            SqlDataReader read     = DataAccess.GetData(qurey);

            read.Read();
            Item i = new Item(menuItemsTextBox.Text, read.GetInt32(0));

            i.CategoryId = categoryNameComboBox.Text;
            ItemService Is = new ItemService();

            Is.AddMenuItem(i);
            MessageBox.Show(menuItemsTextBox.Text);
            String        query1 = "select MENUNAME from MENU where CATEGORYID = '" + categoryNameComboBox.Text + "'";
            SqlDataReader reader = DataAccess.GetData(query1);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    if (MenuList != null)
                    {
                        MenuList = MenuList + "," + reader.GetString(0);
                    }
                    else
                    {
                        MenuList = reader.GetString(0);
                    }
                }
            }
            String query2 = "update CATEGORY set MENULIST ='" + MenuList + "' where CATEGORYID='" + categoryNameComboBox.Text + "' ";

            DataAccess.ExecuteQuery(query2);
            MessageBox.Show("Menu Successfully Added", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
            LoadData();
        }