Example #1
0
 private void AddDiet_Click(object sender, EventArgs e)
 {
     try
     {
         string goal  = DietGoal.Text;
         double gl    = Convert.ToDouble(goal);
         string Query = " update user set GoalCalorieIntake=" + gl + " where Userid=" + uid + ";";
         condatabase.Open();
         MySqlCommand cmd = new MySqlCommand(Query, condatabase);
         cmd.ExecuteNonQuery();
         //MessageBox.Show("Added successfully");
         msgBox msg = new msgBox("Editted Successfully!!!");
         msg.StartPosition = FormStartPosition.Manual;
         msg.Left          = 300;
         msg.Top           = 200;
         msg.Show();
         AddDiet.Enabled = false;
         condatabase.Close();
         GoalDiet();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            int k;

            string[] t = new string[50];
            string[] s = new string[50];
            for (k = 1; k < i; k++)
            {
                t[k] = ((TextBox)this.Controls["txt" + k.ToString()]).Text;
                s[k] = ((Label)this.Controls["lbl" + k.ToString()]).Text;
            }
            for (int j = 1; j < k; j++)
            {
                condatabase.Open();
                string       Query = "update  mustdo set Actduration=" + t[j] + " where ActivityID in (select ActivityID from activitymaster where ActivityName='" + s[j] + "' and userid=" + uid + ");";
                MySqlCommand cmd   = new MySqlCommand(Query, condatabase);
                cmd.ExecuteNonQuery();
                condatabase.Close();
            }
            msgBox msg = new msgBox("Updated Successfully");

            msg.StartPosition = FormStartPosition.Manual;
            msg.Left          = 300;
            msg.Top           = 200;
            msg.Show();
        }
 private void SAVE_Click(object sender, EventArgs e)
 {
     if (nameBox.Text == "" || cal.Text == "")
     {
         MessageBox.Show("Please fill all values");
     }
     else
     {
         try
         {
             findAID();
             con1.Open();
             string       cmdquery = "insert into activitymaster values(" + res + ",'" + nameBox.Text + "','" + cal.Text + "');";
             MySqlCommand cmd      = new MySqlCommand(cmdquery, con1);
             cmd.ExecuteNonQuery();
             //MessageBox.Show("Successfully SAVED");
             msgBox msg = new msgBox("Saved Successfully!!!");
             msg.StartPosition = FormStartPosition.Manual;
             msg.Left          = 300;
             msg.Top           = 200;
             msg.Show();
             listBox1.Items.Add(res + ") " + nameBox.Text);
             nameBox.Text = ""; cal.Text = "";
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         con1.Close();
     }
 }
Example #4
0
        private void addact_Click(object sender, EventArgs e)
        {
            condatabase.Open();
            string          sName = actname.Text;
            string          Query = "select * from ft.activitymaster where ActivityName='" + sName + "';";
            MySqlCommand    cmddb = new MySqlCommand(Query, condatabase);
            MySqlDataReader myReader;

            try
            {
                int id = 0;
                myReader = cmddb.ExecuteReader();
                while (myReader.Read())
                {
                    id = myReader.GetInt32("ActivityID");
                    condatabase.Close();
                    goalselected(id);
                    break;
                }
                condatabase.Open();
                if (id != 0)
                {
                    string       Query3 = "insert into ft.mustdo values(" + uid + "," + id + "," + actdur.Text + ")";
                    MySqlCommand cmd    = new MySqlCommand(Query3, condatabase);
                    cmd.ExecuteNonQuery();
                    //MessageBox.Show("Saved Successfully");
                    msgBox msg = new msgBox("Saved Successfully!!!");
                    msg.StartPosition = FormStartPosition.Manual;
                    msg.Left          = 300;
                    msg.Top           = 200;
                    msg.Show();
                }
                condatabase.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


            // string Query1 = "insert into user(;";
        }
Example #5
0
        private void CreateAccnt_Click1(object sender, EventArgs e)
        {
            Console.WriteLine(ValidatePassword(pwd.Text).ToString());
            if (userName.Text == "")
            {
                MessageBox.Show("Please do enter user name it is mandatory!", "Validation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            }
            else if (pwd.Text == "")
            {
                MessageBox.Show("Password Mandatory!", "Password Validation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            }
            else if (pwd.Text.Length < 6)
            {
                MessageBox.Show("Minimum 6 characters required", "Password Validation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            }
            else if (!ValidatePassword(pwd.Text))
            {
                MessageBox.Show("Check the criteria for password; Minimum 1 special character, number and Uppercase alphabet", "Password Validatation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (newPwd.Text != pwd.Text)
            {
                MessageBox.Show("Re enter password carefully!");
            }
            else
            {
                //MessageBox.Show("Please enter all essential details now in Profile section  and set ur goals to get started!!","Fill up details now or later",MessageBoxButtons.OK,MessageBoxIcon.Information);
                msgBox msg = new msgBox("Account Created Suceessfully. Enter profile details... \n Click Okay to proceed further!!!");
                msg.StartPosition = FormStartPosition.Manual;
                msg.Left          = 300;
                msg.Top           = 200;
                msg.Show();


                username         = userName.Text;
                password         = pwd.Text;
                Program.userName = username;
                this.Close();
                myparent.openChildForm(new UserPage(myparent));
                myparent.toggleNav();
            }
        }
Example #6
0
        private void Updatenew_Click(object sender, EventArgs e)
        {
            dob = agebox.Value.ToString("yyyy-MM-dd");

            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 = "update user set dob='" + dob + "',gender='" + gender + "',weight=" + weight + ",height=" + height + ",category='" + category.SelectedItem + "',phoneNo='" + phone.Text + "',email='" + email.Text + "' where name='" + name.Text + "' and userid=" + cur;
            MySqlCommand cmd   = new MySqlCommand(Query, con1);


            try
            {
                con1.Open();
                cmd.ExecuteNonQuery();
                //MessageBox.Show("Updated Successfully");
                msgBox msg = new msgBox("Updated Successfully!!!");
                msg.StartPosition = FormStartPosition.Manual;
                msg.Left          = 300;
                msg.Top           = 200;
                msg.Show();
                con1.Close();
                this.Close();
                myparent.openChildForm(new HomePage(myparent));
                //  this.Close();
            }
            catch (MySqlException error)
            {
                MessageBox.Show(error.Message);
            }
            catch (SystemException er)
            {
                MessageBox.Show(er.Message);
            }
            con1.Close();
        }
Example #7
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 + "','" + CreateAcnt.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);

                msgBox msg = new msgBox("Profile Created Successfully!!\nSet your Goal and rock!!!!");
                msg.StartPosition = FormStartPosition.Manual;
                msg.Left          = 300;
                msg.Top           = 200;
                msg.Show();
                this.Close();
                myparent.openChildForm(new Goals(myparent));
            }
            catch (MySqlException error)
            {
                MessageBox.Show(error.Message);
            }
            catch (SystemException er)
            {
                MessageBox.Show(er.Message);
            }
            con1.Close();
        }
        private void Save_Click_1(object sender, EventArgs e)
        {
            if (DietName.Text == "" && carbo.Text == "" && prot.Text == "" && vit.Text == "" && fat.Text == "" && cal.Text == "" && other.Text == "")
            {
                MessageBox.Show("Please fill all the details ");
            }

            // string calories = cal.ToString();
            // string car = carbo.ToString();
            // string pro = prot.ToString();
            // string vitamin = vit.ToString();
            // string fats = fat.ToString();
            // string others = other.ToString();
            //string others = textBox7.ToString();
            else
            {
                try
                {
                    FindDID();
                    string JUNK = string.Empty;
                    if (Yes.Checked && No.Checked)
                    {
                        MessageBox.Show("Select whether the food is junk or not! Enter one value please!");
                    }
                    if (Yes.Checked)
                    {
                        JUNK = "Yes";
                    }
                    else if (No.Checked)
                    {
                        JUNK = "No";
                    }
                    else
                    {
                        MessageBox.Show("Select yes or no");
                    }
                    con1.Open();
                    string       Query = "insert into DietMaster values (" + res + ",' " + DietName.Text + " ',' " + carbo.Text + " ', ' " + prot.Text + " ',' " + vit.Text + " ',' " + fat.Text + " ', ' " + cal.Text + " ',' " + other.Text + " ',' " + JUNK + " ');";
                    MySqlCommand cmd   = new MySqlCommand(Query, con1);
                    cmd.ExecuteNonQuery();
                    //MessageBox.Show("Details saved successfully");
                    msgBox msg = new msgBox("Saved Successfully!!!");
                    msg.StartPosition = FormStartPosition.Manual;
                    msg.Left          = 300;
                    msg.Top           = 200;
                    msg.Show();


                    listBox1.Items.Add(res + " . " + DietName.Text);
                    Resettingvalues();
                }
                catch (MySqlException er)
                {
                    MessageBox.Show(er.Message);
                }
                catch (SystemException err)
                {
                    MessageBox.Show(err.Message);
                }
                con1.Close();
            }
            void Resettingvalues()
            {
                DietName.Text = "";
                carbo.Text    = "";
                prot.Text     = "";
                vit.Text      = "";
                fat.Text      = "";
                cal.Text      = "";
                other.Text    = "";
                Yes.Checked   = false;
                No.Checked    = false;
            }
        }
Example #9
0
        private void actsub_Click(object sender, EventArgs e)
        {
            int    id = 0;
            float  CaloriesBurnt = 0;
            string intensity = " ", ActName = "";

            //To insert the logno into the activitychart table
            condatabase.Open();
            string          Query = "select max(LogNo)+1 as Log from activitychart;";
            MySqlCommand    cmd   = new MySqlCommand(Query, condatabase);
            MySqlDataReader myReader;

            try
            {
                //condatabase.Open();
                myReader = cmd.ExecuteReader();
                while (myReader.Read())
                {
                    logno1 = myReader.GetInt32("Log");
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
            condatabase.Close();
            condatabase.Open();
            //To get activity id from master table using activity name
            Query = "select * from activitymaster where activityname='" + actiname.Text + "' ;";
            cmd   = new MySqlCommand(Query, condatabase);
            try
            {
                //
                //
                myReader = cmd.ExecuteReader();
                while (myReader.Read())
                {
                    id            = myReader.GetInt32("ActivityID");
                    CaloriesBurnt = myReader.GetFloat("CaloriesPerMin");
                    ActName       = myReader.GetString("ActivityName");
                }
                // condatabase.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            condatabase.Close();
            //To get type of activity(high or low)
            if (workhigh.Checked && worklow.Checked)
            {
                MessageBox.Show("Select Anyone type");
            }
            else if (workhigh.Checked)
            {
                intensity = workhigh.Text;
            }
            else if (worklow.Checked)
            {
                intensity = worklow.Text;
            }
            else
            {
                MessageBox.Show("Please Enter the Workout Intensity");
            }
            //To calculate the Calories burnt
            string duration = "";

            duration = actdur1.Text;
            int x = Convert.ToInt32(duration);


            float temp = x * CaloriesBurnt;

            condatabase.Open();
            Query = "insert into activitychart(LogNo,Adate,AID,Duration,Type,CaloriesBurnt,UserID,Remark) values(" + logno1 + ",CURDATE()," + id + "," + x + ",'" + intensity + "'," + temp + "," + uid + ",'" + actrem1.Text + "');";
            try
            {
                // condatabase.Open();
                cmd = new MySqlCommand(Query, condatabase);
                cmd.ExecuteNonQuery();
                condatabase.Close();
                ActDone();
                Console.WriteLine(logno1);
                //MessageBox.Show("Saved Successfully");
                msgBox msg = new msgBox("Saved Successfully!!!");
                msg.StartPosition = FormStartPosition.Manual;
                msg.Left          = 300;
                msg.Top           = 200;
                msg.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                condatabase.Close();
            }
        }