예제 #1
0
        private void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            if (textPassword.Text != "" && textRPassword.Text != "" && backup.Text != "" && Currentpass.Text != "")
            {
                SqlConnection  conn1 = new SqlConnection("Data Source=DESKTOP-CU4B5J7;Initial Catalog=projectsmartassistant;Integrated Security=True");
                SqlDataAdapter sda1  = new SqlDataAdapter("Select Password From Signup where Username='******'", conn1);

                DataTable dt1 = new DataTable();
                conn1.Open();
                sda1.Fill(dt1);
                string p = dt1.Rows[0][0].ToString();
                if (Currentpass.Text == p)
                {
                    if (textPassword.Text.Length >= 8)
                    {
                        if (textPassword.Text == textRPassword.Text)
                        {
                            if (backup.Text.Length == 6)
                            {
                                Isintnum(backup.Text);
                                if (r == 1)
                                {
                                    try
                                    {
                                        con.Open();

                                        string     Query = "update Signup set Password= '******', Backuppin= '" + int.Parse(backup.Text.ToString()) + "'where Username= '******'";
                                        SqlCommand cmd   = new SqlCommand(Query, con);

                                        cmd.ExecuteNonQuery();

                                        MessageBox.Show("Successfully updated!!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                        Form8 f8 = new Form8();
                                        f8.Show();
                                        f8.back(f, aa);
                                        this.Hide();



                                        //btnNewRecord_Click(sender, e);
                                        //ShowInfo();

                                        con.Close();
                                    }
                                    catch (Exception exp)
                                    {
                                        MessageBox.Show(exp.Message);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Backup pin will be only number", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Backup pin must contain 6 number", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Password & Re Password dont match", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Password must containt at least 8 caracter", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Your current password is wrong\nPlease enter right password", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Please fill up all informations", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }