From 3435e6161af4faf578f91004c31816897306b92c Mon Sep 17 00:00:00 2001 From: kougyokugentou <41278462+kougyokugentou@users.noreply.github.com> Date: Wed, 13 Jan 2021 20:12:39 -0800 Subject: [PATCH] Implement formload and admin button --- frmMainForm.Designer.cs | 17 +++++++++++++++++ frmMainForm.cs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/frmMainForm.Designer.cs b/frmMainForm.Designer.cs index 9c4fd5f..79723ee 100644 --- a/frmMainForm.Designer.cs +++ b/frmMainForm.Designer.cs @@ -29,13 +29,28 @@ namespace GreatHomeChildcare /// private void InitializeComponent() { + this.btnAdmin = new System.Windows.Forms.Button(); this.SuspendLayout(); // + // btnAdmin + // + this.btnAdmin.Enabled = false; + this.btnAdmin.Location = new System.Drawing.Point(675, 12); + this.btnAdmin.Name = "btnAdmin"; + this.btnAdmin.Size = new System.Drawing.Size(113, 41); + this.btnAdmin.TabIndex = 0; + this.btnAdmin.TabStop = false; + this.btnAdmin.Text = ">>ADMIN<<"; + this.btnAdmin.UseVisualStyleBackColor = true; + this.btnAdmin.Visible = false; + this.btnAdmin.Click += new System.EventHandler(this.btnAdmin_Click); + // // frmMainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.btnAdmin); this.Name = "frmMainForm"; this.Text = "Main Screen"; this.Load += new System.EventHandler(this.frmMainForm_Load); @@ -44,5 +59,7 @@ namespace GreatHomeChildcare } #endregion + + private System.Windows.Forms.Button btnAdmin; } } \ No newline at end of file diff --git a/frmMainForm.cs b/frmMainForm.cs index ef9996b..09c6222 100644 --- a/frmMainForm.cs +++ b/frmMainForm.cs @@ -7,11 +7,16 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using GreatHomeChildcare.Models; namespace GreatHomeChildcare { public partial class frmMainForm : Form { + //globals for cheap access. + SqliteDataAccess SqliteDataAccess = new SqliteDataAccess(); + Guardian guardian = new Guardian(); + public frmMainForm() { InitializeComponent(); @@ -21,7 +26,35 @@ namespace GreatHomeChildcare //TODO: Add admin button if guardian isAdmin = 1 private void frmMainForm_Load(object sender, EventArgs e) { + int guardian_pin = Int32.Parse(frmPinEntry.strPin); + guardian = SqliteDataAccess.GetGuardianByPin(guardian_pin); + List children = SqliteDataAccess.GetChildrenByGuardian(guardian); + //TODO: remove once valid login check is implemented + if (guardian == null) + return; + + //If the guardian is an admin user, enable the button for crud operations. + if (guardian.isAdmin == 1) + { + btnAdmin.Visible = true; + btnAdmin.Enabled = true; + } + + //For each child, present a new button to sign the student in/out. + foreach (Child c in children) + { + //Button b = new Button(); + } + + //TODO: remove once I figure out how to add new button, perhaps to a table layout panel. + Console.WriteLine("test"); + } + + //TODO: implement via another form. + private void btnAdmin_Click(object sender, EventArgs e) + { + MessageBox.Show("The admin button was clicked."); } } }