Exemple #1
0
        private void Urun_Guncelle_Click(object sender, EventArgs e)
        {
            Guncelle guncelle = new Guncelle();

            guncelle.StartPosition = FormStartPosition.CenterScreen;
            guncelle.Show();
            this.Hide();
        }
        private void Update_Product_Click(object sender, EventArgs e)
        {
            if (DropDown.SelectedItem != null)
            {
                connection.Open();

                foreach (var item in deletedDrinkTypes)
                {
                    commandUpdate = new SqlCommand("Delete dbo.Menu_Drink where Id_Drink = @deletedID and Id_Type = @deletedType ", connection);
                    commandUpdate.Parameters.AddWithValue("@deletedID", item.productID);
                    commandUpdate.Parameters.AddWithValue("@deletedType", item.typeID);
                    commandUpdate.ExecuteNonQuery();
                }
                foreach (var item in deletedFoodTypes)
                {
                    commandUpdate = new SqlCommand("Delete dbo.Menu_Food where Id_Food = @deletedID and Id_Type = @deletedType ", connection);
                    commandUpdate.Parameters.AddWithValue("@deletedID", item.productID);
                    commandUpdate.Parameters.AddWithValue("@deletedType", item.typeID);
                    commandUpdate.ExecuteNonQuery();
                }
                foreach (var item in addedFoodTypes)
                {
                    commandUpdate = new SqlCommand("insert into dbo.Menu_Food values(@insertID,@insertType) ", connection);
                    commandUpdate.Parameters.AddWithValue("@insertID", item.productID);
                    commandUpdate.Parameters.AddWithValue("@insertType", item.typeID);
                    commandUpdate.ExecuteNonQuery();
                }
                foreach (var item in addedDrinkTypes)
                {
                    commandUpdate = new SqlCommand("insert into dbo.Menu_Drink values(@insertID,@insertType) ", connection);
                    commandUpdate.Parameters.AddWithValue("@insertID", item.productID);
                    commandUpdate.Parameters.AddWithValue("@insertType", item.typeID);
                    commandUpdate.ExecuteNonQuery();
                }

                UpdateInformation();

                MessageBox.Show("Güncellendi");

                connection.Close();
                ResetAllData();

                Guncelle newForm1 = new Guncelle();
                newForm1.Show();
                this.Dispose(false);
            }
            else
            {
                MessageBox.Show("Onur, yapma böyle şeyler!!!");
            }
        }