Move FirstTimeRun to the shown event. Ref: Microsoft

This commit is contained in:
kougyokugentou 2021-02-02 21:12:18 -08:00
parent c86b9fdf0d
commit fb7b68e773
2 changed files with 14 additions and 3 deletions

View File

@ -245,7 +245,7 @@ namespace GreatHomeChildcare
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "frmPinEntry";
this.Text = "Great Home Childcare";
this.Load += new System.EventHandler(this.frmPinEntry_Load);
this.Shown += new System.EventHandler(this.frmPinEntry_Shown);
this.tableLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -2,6 +2,8 @@
using System.Windows.Forms;
using GreatHomeChildcare.Models;
//Refs
// https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form.shown?redirectedfrom=MSDN&view=net-5.0
namespace GreatHomeChildcare
{
public partial class frmPinEntry : Form
@ -121,15 +123,20 @@ namespace GreatHomeChildcare
/* Checks to see if this is the first-ever time the application has
* run by querying number of rows in Guardian table.
* If number of rows <= 0, we must setup an admin user in the guardian table.
* The Shown event is only raised the first time a form is displayed; subsequently
* minimizing, maximizing, restoring, hiding, showing, or invalidating and repainting
* will not raise this event. Ref: Microsoft
*/
private void frmPinEntry_Load(object sender, EventArgs e)
private void frmPinEntry_Shown(object sender, EventArgs e)
{
Hide();
int num_admins = 0;
DialogResult dr;
num_admins = SqliteDataAccess.GetNumAdmins();
if(num_admins <= 0)
if (num_admins <= 0)
{
dr = MessageBox.Show("Program not setup yet. Setup now?", "Great Home Childcare", MessageBoxButtons.YesNo, MessageBoxIcon.None);
@ -147,6 +154,10 @@ namespace GreatHomeChildcare
Close();
}
}
else
{
Show();
}
}
}
}