private void ConfirmLoad_Button_Click(object sender, EventArgs e) { if (Profiles_ListBox.SelectedItems.Count != 0) { Profile profile = new Profile(Profiles_ListBox.SelectedItems[0].Text); profile.LoadProfileFromJson(); BeFit_Form form = new BeFit_Form(profile); form.Show(); this.Close(); } else { new GiveUserInfo_Form(true, "Zaznacz profil który ma być załadowany"); } }
private void AddProfile_Button_Click(object sender, EventArgs e) { bool IsNameValid = true; string[] files = GetProfilesNames(); string pom; string name = ProfileName_TextBox.Text; if (name.Length < 3) { new GiveUserInfo_Form(true, "Nazwa powinna składać się przynajmniej z 3 znaków"); } else if (Convert.ToInt32(Percent_Label.Text) != 0) { new GiveUserInfo_Form(true, "Wprowadź prawidłowy procentowy rozkład makroskładników"); } else { foreach (string s in files) // sprawdza czy nie ma takiej nazwy profilu { pom = Path.GetFileNameWithoutExtension(s); if (name == pom) { IsNameValid = false; new GiveUserInfo_Form(true, "Wprowadzona nazwa profilu już istnieje"); break; } } if (IsNameValid == true) { double[] tab = CalculateDemandInGrams.CaltulateIngredients(Convert.ToDouble(CaloricDemand_Textbox.Text), Convert.ToDouble(FatDemand_Textbox.Text), Convert.ToDouble(CarboDemand_Textbox.Text), Convert.ToDouble(ProteinDemand_Textbox.Text)); Day_Meals DayMeal = new Day_Meals(Convert.ToDouble(CaloricDemand_Textbox.Text), tab[0], tab[1], tab[2]); Profile profile = new Profile(name); profile.List_Of_meals.Add(DayMeal); BeFit_Form form = new BeFit_Form(profile); form.Show(); this.Close(); } } }