Corrected errors in code that cause application to crash during initial testing.

Added code to allow for resetting security for a database.
Added class to Reset Security.
This commit is contained in:
Rich
2013-11-25 04:42:53 +00:00
parent d7da2e454d
commit 2d612fcd91
4 changed files with 121 additions and 13 deletions

View File

@@ -696,6 +696,7 @@ namespace VEPROMS
private SessionInfo MySessionInfo;
private System.Threading.Timer MyActivityTimer;
private DevComponents.DotNetBar.ButtonItem btnManageSecurity;
private DevComponents.DotNetBar.ButtonItem btnResetSecurity;
private TabItemsToClose _MyCloseTabList = new TabItemsToClose();
public TabItemsToClose MyCloseTabList
{
@@ -719,6 +720,13 @@ namespace VEPROMS
btnManageSecurity = new ButtonItem("btnManageSecurity", "Manage Security");
btnAdmin.SubItems.Add(btnManageSecurity);
btnManageSecurity.Click += new EventHandler(btnManageSecurity_Click);
//added by jcb
//menu item to reset security
//requires password to implement
btnResetSecurity = new ButtonItem("btnResetSecurity", "Reset Security");
btnAdmin.SubItems.Add(btnResetSecurity);
btnResetSecurity.Click += new EventHandler(btnResetSecurity_Click);
//end added by jcb
UserInfo ui = null;
try
{
@@ -740,6 +748,7 @@ namespace VEPROMS
bool isVisible = ui.IsAdministrator();
btnManageSecurity.Visible = isVisible;
btnUpdateFormats.Visible = isVisible;
btnResetSecurity.Visible = isVisible;
tmrCloseTabItems = new Timer();
tmrCloseTabItems.Interval = 100;
tmrCloseTabItems.Tick += new EventHandler(tmrCloseTabItems_Tick);
@@ -913,6 +922,69 @@ namespace VEPROMS
dlgManageSecurity dlg = new dlgManageSecurity();
dlg.ShowDialog(this);
}
void btnResetSecurity_Click(object sender, EventArgs e)
{
string password = string.Empty;
if (ShowInputDialog(ref password) == DialogResult.OK)
{
if(password == "V3Pr0m5")
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("***** WARNING *****");
sb.AppendLine();
sb.AppendLine("This action will delete all Groups, Users and Memberships from the database.");
sb.AppendLine("This action is NOT reversible.");
sb.AppendLine("Following this action the application will terminate.");
sb.AppendLine();
sb.AppendLine("Are you sure you want to continue?");
if (MessageBox.Show(sb.ToString(), "Confirm Security Reset", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop) == DialogResult.Yes)
{
ResetSecurity.Execute();
Application.Exit();
}
}
else
MessageBox.Show("You have entered an incorrect password.");
}
}
private static DialogResult ShowInputDialog(ref string input)
{
System.Drawing.Size size = new System.Drawing.Size(200, 70);
Form inputBox = new Form();
inputBox.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
inputBox.ClientSize = size;
inputBox.Text = "Enter Password";
inputBox.StartPosition = FormStartPosition.CenterScreen;
System.Windows.Forms.TextBox textBox = new TextBox();
textBox.Size = new System.Drawing.Size(size.Width - 10, 23);
textBox.Location = new System.Drawing.Point(5, 5);
textBox.PasswordChar = '*';
textBox.Text = input;
inputBox.Controls.Add(textBox);
Button okButton = new Button();
okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
okButton.Name = "okButton";
okButton.Size = new System.Drawing.Size(75, 23);
okButton.Text = "&OK";
okButton.Location = new System.Drawing.Point(size.Width - 80 - 80, 39);
inputBox.Controls.Add(okButton);
Button cancelButton = new Button();
cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
cancelButton.Name = "cancelButton";
cancelButton.Size = new System.Drawing.Size(75, 23);
cancelButton.Text = "&Cancel";
cancelButton.Location = new System.Drawing.Point(size.Width - 80, 39);
inputBox.Controls.Add(cancelButton);
DialogResult result = inputBox.ShowDialog();
input = textBox.Text;
return result;
}
void tc_StatusChanged(object sender, DisplayTabControlStatusEventArgs args)
{