Exemplo n.º 1
0
        private void Save_Click(object sender, System.EventArgs e)
        {
            dob = agebox.Value.ToString("yyyy-MM-dd");
            findUID();

            string gender = string.Empty;

            if (male.Checked && female.Checked)
            {
                MessageBox.Show("Select one gender");
            }
            if (male.Checked)
            {
                gender = "Male";
            }
            else if (female.Checked)
            {
                gender = "Female";
            }
            else
            {
                MessageBox.Show("Please select a gender:");
            }
            if (!email_Text())
            {
                return;
            }
            if (!phone_Text())
            {
                return;
            }

            string height = ht.Value.ToString();
            string weight = wt.Value.ToString();

            string       Query = "insert into user (userid,name,password,dob,gender,phoneNo,email,height,weight,category,GoalCalorieIntake) values (" + res + ",'" + name.Text + "','" + NewUser.password + "','" + dob + "','" + gender + "','" + phone.Text + "','" + email.Text + "'," + height + "," + weight + ",'" + category.SelectedItem.ToString() + "',0);";
            MySqlCommand cmd   = new MySqlCommand(Query, con1);


            try
            {
                con1.Open();
                cmd.ExecuteNonQuery();
                MessageBox.Show("Saved Successfully! Now you re ready to rock!! Please go set the goals ! You can check if our advised goals are sufficient ", "Getting Ready", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Welcome newPage = new Welcome();
                newPage.Show();
                this.Close();

                con1.Close();
                //  this.Close();
            }
            catch (MySqlException error)
            {
                MessageBox.Show(error.Message);
            }
            catch (SystemException er)
            {
                MessageBox.Show(er.Message);
            }
            con1.Close();
        }