Esempio n. 1
0
        private void btEndWorkout_Click(object sender, EventArgs e)
        {
            double      potentORM = CalcLib.OrmCalc((double)numMainCount3.Value, (int)numMainWeight3.Value);
            XmlDocument xmlDoc    = new XmlDocument();

            xmlDoc.Load(name + ".xml");
            XmlElement root = xmlDoc.DocumentElement;

            if (root.SelectSingleNode($"Week{exercise}").InnerText == "3")
            {
                root.SelectSingleNode($"Week{exercise}").InnerText = "1";
                cycle++;
                root.SelectSingleNode($"Cycle{exercise}").InnerText = "1";
            }
            else
            {
                week++;
                root.SelectSingleNode($"Week{exercise}").InnerText = week.ToString();
            }
            if (potentORM > Convert.ToDouble(root.SelectSingleNode($"ORM{exercise}").InnerText))
            {
                root.SelectSingleNode($"ORM{exercise}").InnerText = potentORM.ToString();
                MessageBox.Show($"New {exercise} 1RM ! {potentORM} kg!");
            }
            this.Close();
        }
        private void btProceed_Click(object sender, EventArgs e)
        {
            try {
                name = tBoxName.Text;
                double benchPressValue = double.Parse(tBoxInitBenchPress.Text);
                double squatValue      = double.Parse(tBoxInitSquat.Text);
                double deadliftValue   = double.Parse(tBoxInitDeadlift.Text);
                double ohpValue        = double.Parse(tBoxInitOHP.Text);

                benchPressInit = CalcLib.OrmCalc(benchPressValue, Convert.ToInt32(numInitBenchPress.Value));
                ohpInit        = CalcLib.OrmCalc(ohpValue, Convert.ToInt32(numInitBenchPress.Value));
                squatInit      = CalcLib.OrmCalc(squatValue, Convert.ToInt32(numInitBenchPress.Value));
                deadliftInit   = CalcLib.OrmCalc(deadliftValue, Convert.ToInt32(numInitBenchPress.Value));
                try {
                    FileLib.SaveIntoFile(name, benchPressInit, squatInit, deadliftInit, ohpInit);
                }
                catch { }

                this.Hide();
                MainForm mainForm = new MainForm(name);
                mainForm.Closed += (s, args) => this.Close();
                mainForm.ShowDialog();
            }
            catch (FormatException) {
                MessageBox.Show("Enter valid data", "Error");
            }
        }