public frmLogin()
 {
     InitializeComponent();
     DatabaseCheck();
     //Add txtBox Enter handlers
     txtUserName.Enter += txtFocus;
     txtUserName.Click += txtFocus;
     txtPassword.Enter += txtFocus;
     txtPassword.Click += txtFocus;
     this.Height = 220;
     this.Update();
     foreach(Control txtControl in gNewUser.Controls)
     {
         if(txtControl is TextBox)
         {
             txtControl.Enter += txtFocus;
             txtControl.Click += txtFocus;
         }
     }
     if (System.IO.File.Exists(CurrentPath + "\\currentload.db") == true && FileInUse(CurrentPath + "\\currentload.db") == false)
     {
         Console.WriteLine("Improper previous close detected.");
         System.IO.File.Delete(CurrentPath + "\\currentload.db");
     }
     theLoginFrm = this;
 }
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     frmLogin loginFrm = new frmLogin();
     loginFrm.Show();
     Application.Run();
 }
 private void frmClose(object sender, FormClosingEventArgs e)
 {
     if(isLogOut == true && isExit == false)
     {
         isExit = true;
         this.Close();
         frmLogin loginFrm = new frmLogin();
         loginFrm.Show();
     }
     if(isLogOut == false && isExit == false)
     {
         MessageBox.Show("Please log out.", "Warning");
         e.Cancel = true;
         btnLogout.Focus();
     }
 }
 private void btnLogout_Click(object sender, EventArgs e)
 {
     Console.WriteLine("Encrypting all tenants.");
     String[] fileList;
     fileList = Directory.GetFiles(CurrentPath + Database + currentLoad, "*.db");
     //Encrypt all user tenants
     foreach (string fileName in fileList)
     {
         string tenantName;
         tenantName = Path.GetFileNameWithoutExtension(fileName);
         share.EncryptFile(fileName, CurrentPath + Database + currentUser.Name + "\\" + tenantName + ".db", userPassword);
     }
     System.IO.File.Delete(CurrentPath + "\\currentload.db");
     isLogOut = true;
     frmMain Main = this;
     Main.Hide();
     frmLogin mainLogin = new frmLogin();
     mainLogin.Show();
 }
 private void properExit()
 {
     isClosed = true;
     this.Hide();
     frmLogin loginFrm = new frmLogin();
     loginFrm.Show();
 }
 private void frmClose(object sender, FormClosingEventArgs e)
 {
     if(isClosed == false)
     {
         isClosed = true;
         MessageBox.Show("You have been signed out.", "Warning");
         this.Hide();
         frmLogin loginFrm = new frmLogin();
         loginFrm.Show();
     }
 }