private void BeFit_FormClosed(object sender, FormClosedEventArgs e) { if (IsChangedProfile) { GiveUserInfo_Form form = new GiveUserInfo_Form("Czy chcesz zapisać profil przed wyjściem?"); if (form.DialogResult == DialogResult.OK) { InvokeOnClick(SaveProfile_Button, EventArgs.Empty); } } Application.Exit(); }
private void RemoveProductFromDB(object sender, EventArgs e) { Product product = ((sender as MetroButton).Parent as SearchedProducts_Control).Product; GiveUserInfo_Form form = new GiveUserInfo_Form("Czy chcesz trwale usunąć element '" + product.Name + "' z bazy?"); if (form.DialogResult == DialogResult.OK) { using (var db = new DB_Model()) { db.Entry(product).State = EntityState.Deleted; db.SaveChanges(); } splitContainer1.Panel2.Controls.Clear(); } }
private void RemoveControlMeal(object sender, EventArgs e) { GiveUserInfo_Form form = new GiveUserInfo_Form("Czy chcesz usunąć '" + (((sender as MetroButton).Parent as ProductInMeal_Control).Product.Product.Name) + "'?"); if (form.DialogResult == DialogResult.OK) { // index -> znalezienie dzisiejszego daymeala // int index = ActiveProfile.List_Of_meals.FindIndex(x => x.Date.Date == DateTime.Today); int index = List_Indexator.ReturnTodaysMealIndex(ActiveProfile.List_Of_meals); //index2 - > znalezienie meala po nazwie w dzisiejszym daymealu int index2 = ActiveProfile.List_Of_meals[index].Meals.FindIndex(x => x.MealName == ((sender as MetroButton).Parent.Parent.Parent.Parent as MealPanel_Control).Title_Label.Text); //index3 -> znalezienie produktu ktory ma byc usuniety int index3 = ActiveProfile.List_Of_meals[index].Meals[index2].Products.FindIndex(x => x == ((sender as MetroButton).Parent as ProductInMeal_Control).Product); // finito ActiveProfile.List_Of_meals[index].Meals[index2].Products.RemoveAt(index3); //refreszo RefreshControlsMeal(); SummarizeToday(); IsChangedProfile = true; } }