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          = 1000;
                    msg.Top           = 500;

                    msg.ShowDialog();

                    listBox1.Items.Add(res + ") " + nameBox.Text);
                    nameBox.Text = ""; cal.Text = "";
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                con1.Close();
            }
        }
Пример #2
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          = 1000;
                msg.Top           = 500;

                msg.ShowDialog();

                AddDiet.Enabled = false;
                condatabase.Close();
                GoalDiet();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
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          = 1000;
            msg.Top           = 500;

            msg.ShowDialog();
        }
Пример #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          = 1000;
                    msg.Top           = 500;
                    msg.ShowDialog();
                    //this.Close();
                    //myparent.openChildForm(new HomePage(myparent));
                }
                condatabase.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


            // string Query1 = "insert into user(;";
        }
Пример #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");
                msg.StartPosition = FormStartPosition.Manual;

                msg.Left = 1000;
                msg.Top  = 500;

                msg.ShowDialog();



                username         = userName.Text;
                password         = pwd.Text;
                Program.userName = username;
                this.Close();
                myparent.openChildForm(new UserPage(myparent));
                myparent.toggleNav();
            }
        }
        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
            {
                try
                {
                    con1.Open();
                    string          myq = "select * from user where name='" + userName.Text + "'";
                    MySqlCommand    cmd = new MySqlCommand(myq, con1);
                    MySqlDataReader dr  = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        msgBox msg = new msgBox("Username already exists, So please try again!!");
                        msg.StartPosition = FormStartPosition.Manual;

                        msg.Left = 1000;
                        msg.Top  = 500;

                        msg.ShowDialog();
                        // return;
                    }
                    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");
                        msg.StartPosition = FormStartPosition.Manual;

                        msg.Left = 1000;
                        msg.Top  = 500;

                        msg.ShowDialog();



                        username         = userName.Text;
                        password         = pwd.Text;
                        Program.userName = username;
                        this.Close();
                        myparent.openChildForm(new UserPage(myparent));
                        myparent.toggleNav();
                        {
                            PopupNotifier popup = new PopupNotifier();
                            popup.Image       = (Bitmap)Properties.Resources.ResourceManager.GetObject("icon");
                            popup.TitleText   = "Set up Profile";
                            popup.ContentText = "Please fill in profile details... Only after successful saving of profile, your account is usable ";
                            popup.Popup();
                        }
                    }
                }catch (Exception er)
                {
                }
            }
        }
Пример #7
0
        private void dietsubmit_Click_1(object sender, EventArgs e)
        {
            int     id = 0;
            decimal carbo = 0, protein = 0, vitamin = 0, fat = 0, calories = 0;

            con1.Open();
            string junk;

            string          Query = "select max(LogNo)+1 as Log from dietchart;";
            MySqlCommand    cmd   = new MySqlCommand(Query, con1);
            MySqlDataReader myReader;

            try
            {
                //condatabase.Open();
                myReader = cmd.ExecuteReader();
                while (myReader.Read())
                {
                    logno1 = myReader.GetInt32("Log");
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }

            con1.Close();
            con1.Open();
            //To get activity id from master table using activity name
            Query = "select * from dietmaster where dietname='" + diet.Text + "' ;";
            cmd   = new MySqlCommand(Query, con1);
            try
            {
                //
                //
                myReader = cmd.ExecuteReader();
                while (myReader.Read())
                {
                    id = myReader.GetInt32("DietID");
                }
                // con1.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            con1.Close();



            con1.Open();
            Query = "select * from dietmaster where dietname='" + diet.Text + "';";



            try
            {
                //condatabase.Open();
                cmd      = new MySqlCommand(Query, con1);
                myReader = cmd.ExecuteReader();
                while (myReader.Read())
                {
                    carbo    = myReader.GetDecimal("Carbo");
                    protein  = myReader.GetDecimal("Protein");
                    vitamin  = myReader.GetDecimal("Vitamin");
                    fat      = myReader.GetDecimal("Fat");
                    junk     = myReader.GetString("isJunk");
                    calories = myReader.GetDecimal("CaloriesperS");
                }



                // MessageBox.Show("Result is" + temp +" "+x +" "+CaloriesBurnt);
                //condatabase.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            con1.Close();
            con1.Open();
            string serve = serving_no.Value.ToString();
            int    x     = Convert.ToInt32(serve);

            decimal c = x * carbo;
            decimal p = x * protein;
            decimal v = x * vitamin;
            decimal f = x * fat;
            // int j = x * junk;
            decimal ca = x * calories;

            carbo_in.Text   = c.ToString();
            protein_in.Text = p.ToString();
            vitamin_in.Text = v.ToString();
            fat_in.Text     = f.ToString();
            //junks.Text = j.ToString();
            cal_in.Text = ca.ToString();

            Query = "insert into dietchart(LogNo,dietDate, noOfServings,Userid,DietID,carbo,Protein,Vitamin,Fat,CaloriesIntake,Remark) values("
                    + logno1 + ",CURDATE()," + x + "," + uid + "," + id + "," + c + "," + p + "," + v + "," + f + "," + ca + ",'" + remarks.Text + "');";

            try
            {
                cmd = new MySqlCommand(Query, con1);
                cmd.ExecuteNonQuery();
                con1.Close();
                //dietintake();
                //MessageBox.Show("Saved Successfully");

                msgBox msg = new msgBox("Saved Sucessfully!!!");
                msg.StartPosition = FormStartPosition.Manual;
                msg.Left          = 300;
                msg.Top           = 200;
                msg.ShowDialog();

                AlreadyTaken();


                //condatabase.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            con1.Close();
        }
Пример #8
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          = 1000;
                msg.Top           = 500;

                msg.ShowDialog();

                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();
        }
Пример #9
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:"); return;
            }
            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!!Set your Goal and rock!!!!");
                msg.StartPosition = FormStartPosition.Manual;
                msg.Left          = 1000;
                msg.Top           = 500;

                msg.ShowDialog();
                this.Close();
                myparent.openChildForm(new HomePage(myparent, "Set your Goal and track your fitness"));
            }
            catch (MySqlException error)
            {
                MessageBox.Show(error.Message);
            }
            catch (SystemException er)
            {
                MessageBox.Show(er.Message);
            }
            con1.Close();
        }
Пример #10
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          = 1000;
                msg.Top           = 500;

                msg.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                condatabase.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          = 1000;
                    msg.Top           = 500;
                    msg.ShowDialog();


                    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;
            }
        }
Пример #12
0
        private void UpdatePWD_Click(object sender, EventArgs e)
        {
            string pass = string.Empty;

            condatabase.Open();
            string          Query    = "select * from user where Userid=" + uid + ";";
            MySqlCommand    cmd      = new MySqlCommand(Query, condatabase);
            MySqlDataReader myReader = cmd.ExecuteReader();

            while (myReader.Read())
            {
                pass = myReader.GetString("Password");
            }
            condatabase.Close();
            if (CurrentPWD.Text == "")
            {
                MessageBox.Show("Please fill all dateils");
            }
            else if (NewPWD.Text == "")
            {
                MessageBox.Show("please fill all details");
            }
            else if (ConfirmPWD.Text == "")
            {
                MessageBox.Show("Please fill all details");
            }
            else if (!ValidatePassword(NewPWD.Text))
            {
                MessageBox.Show("Check the criteria for password; Minimum 1 special character, number and Uppercase alphabet", "Password Validatation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                // NewPWD.ForeColor = Color.Red;
            }
            else if (NewPWD.Text != ConfirmPWD.Text)
            {
                MessageBox.Show("Re enter the password carefully");
                // ConfirmPWD.ForeColor = Color.Red;
            }
            else if (pass != CurrentPWD.Text)
            {
                MessageBox.Show("Enter your current password correclty");
                //CurrentPWD.ForeColor = Color.Red;
            }
            else
            {
                condatabase.Open();
                Query = "update user set Password='******' where Userid=" + uid + ";";
                cmd   = new MySqlCommand(Query, condatabase);
                try
                {
                    cmd.ExecuteNonQuery();
                    msgBox msg = new msgBox("Password Updated Successfully");
                    msg.StartPosition = FormStartPosition.Manual;

                    msg.Left = 1000;
                    msg.Top  = 500;

                    msg.ShowDialog();
                }
                catch (Exception ex)
                { }
            }
            condatabase.Close();
        }