Ejemplo n.º 1
0
 private void changeP_Click(object sender, EventArgs e)
 {
     if (userName.Text == "")
     {
         MessageBox.Show("Please do enter user name it is mandatory!");
     }
     else if (pwd.Text == "")
     {
         MessageBox.Show("Password Mandatory!");
     }
     else if (newPwd.Text != pwd.Text)
     {
         MessageBox.Show("Re enter password carefully!");
     }
     else
     {
         try
         {
             con1.Open();
             string       cmdstr = "update user set password ='******' where name='" + userName.Text + "';";
             MySqlCommand cmd    = new MySqlCommand(cmdstr, con1);
             cmd.ExecuteNonQuery();
             MessageBox.Show("Password changed successfully!!", "Change Password");
             Welcome newform = new Welcome();
             newform.Show();
             this.Close();
         }
         catch (Exception test)
         {
             MessageBox.Show("Unable to change the password due to error! " + test.Message);
         }
     }
 }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Welcome newformm = new Welcome();

            newformm.Show();
            this.Close();
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (user.Text == "" || password.Text == "")
                {
                    MessageBox.Show("Please enter all mandatory fields");
                }
                else
                {
                    con1.Open();
                    string          command = "select password from user where name='" + user.Text + "';";
                    MySqlCommand    cmd     = new MySqlCommand(command, con1);
                    MySqlDataReader dr      = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        string pd = dr.GetString(0);
                        if (pd == password.Text)
                        {
                            //correct password
                            {
                                Program.userName = user.Text;

                                //logout.Enabled = true;
                                this.Hide();

                                Welcome form1 = new Welcome();
                                form1.Closed += (s, args) => this.Close();

                                form1.Show();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Incorrect  password ! try again!!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Incorrect user name !", "Attention required");
                    }
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
            con1.Close();
        }
Ejemplo n.º 4
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();
        }