//This function is supposed to check if any of the textboxes is null or "" private void CheckTBox() { err.Clear(); var errorcount = new List <Control>(); foreach (Control tb in Controls) { if (tb.GetType() == typeof(MetroFramework.Controls.MetroTextBox)) { if (tb.Text == "") { err.SetError(tb, "Required!"); errorcount.Add(tb); } } } if (errorcount.Count > 0) { throw new Exception("Field(s) cannot be empty!"); } }
private void ChangePass() { current_user = userbal.GetByUsername(UserSettings.Username); err.Clear(); if (current_user.Password == mtxtOldPass.Text) { if (mtxtNewPass.Text != "" && mtxtConPass.Text != "") { if (mtxtNewPass.Text == mtxtConPass.Text) { current_user.Password = mtxtConPass.Text; if (MessageHelpers.ShowQuestion("Are you sure want to change your password?") == DialogResult.Yes) { if (userbal.Update(current_user)) { MessageHelpers.ShowInfo("Password successfully changed."); this.Close(); } else { throw new Exception("Error occured!"); } } } else { err.SetError(mtxtConPass, "Passwords entered does not match!"); } } else { if (mtxtNewPass.Text == "") { err.SetError(mtxtNewPass, "Required"); } else if (mtxtNewPass.Text == "") { err.SetError(mtxtConPass, "Required"); } else { err.SetError(mtxtNewPass, "Required"); err.SetError(mtxtConPass, "Required"); } } } else { err.SetError(mtxtOldPass, "Please enter your old password!"); } err.CheckAndShowSummaryErrorMessage(); }