コード例 #1
0
        private void AddRestaurantButton_Click(object sender, EventArgs e)
        {
            EditRestaurantForm createForm = new EditRestaurantForm();

            createForm.ShowDialog();

            if (createForm.Success)
            {
                var newRestaurant = restaurantsDataSet.restaurants.NewrestaurantsRow();
                newRestaurant.name    = createForm.RestaurantName;
                newRestaurant.address = createForm.RestaurantAddress;

                restaurantsDataSet.restaurants.Rows.Add(newRestaurant);
                restaurantsTableAdapter.Update(restaurantsDataSet.restaurants);
            }
        }
コード例 #2
0
        private void EditRestaurantButton_Click(object sender, EventArgs e)
        {
            var selectedRow = restaurantsDataGridView.SelectedRows[0];

            EditRestaurantForm editForm = new EditRestaurantForm
            {
                RestaurantName    = (string)selectedRow.Cells["name"].Value,
                RestaurantAddress = (string)selectedRow.Cells["address"].Value
            };

            editForm.ShowDialog();

            if (editForm.Success)
            {
                var restaurantRow = restaurantsDataSet.restaurants.FindByid((decimal)selectedRow.Cells["id"].Value);
                restaurantRow.name    = editForm.RestaurantName;
                restaurantRow.address = editForm.RestaurantAddress;

                restaurantsTableAdapter.Update(restaurantsDataSet.restaurants);
            }
        }