Ejemplo n.º 1
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult dialogResult = MessageBox.Show("MAKE SURE YOUR PASSWORD IS EASY TO REMEMBER", "UPDATE PASSWORD?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (dialogResult == DialogResult.Yes)
         {
             if (tbPassword.Text == "" || tbRepeat.Text == "")
             {
                 MessageBox.Show("PLEASE INPUT PASSWORD AND/OR REPEAT THE PASSWORD", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 tbPassword.Clear();
                 tbRepeat.Clear();
             }
             else
             {
                 if (tbPassword.Text == tbRepeat.Text)
                 {
                     Admin A = new Admin();
                     A.UpdatePassword(tbRepeat.Text, lblUsername.Text);
                     MessageBox.Show("PASSWORD UPDATED", "UPDATED", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     tbPassword.Clear();
                     tbRepeat.Clear();
                 }
                 else
                 {
                     tbPassword.Clear();
                     tbRepeat.Clear();
                     MessageBox.Show("PASSWORD MISSMATCH", "FAILED TO UPDATE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     tbPassword.Focus();
                 }
             }
         }
     }
     catch (SqlException)
     {
         MessageBox.Show("MICROSOFT SQL SERVER DATABASE ERROR!", "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (InvalidOperationException)
     {
         MessageBox.Show("INVALID OPERATION!", "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }