From 7b52c262cc735eb00846ca4ea393252404e9b081 Mon Sep 17 00:00:00 2001 From: kougyokugentou <41278462+kougyokugentou@users.noreply.github.com> Date: Wed, 20 Jan 2021 16:11:26 -0800 Subject: [PATCH] Datagrid view of admin form, populate with all children --- frmAdminForm.Designer.cs | 37 +++++++++++++++++++++++++++++++++++++ frmAdminForm.cs | 12 ++++++++++++ frmAdminForm.resx | 9 +++++++++ 3 files changed, 58 insertions(+) diff --git a/frmAdminForm.Designer.cs b/frmAdminForm.Designer.cs index deb4b35..1bbc5d0 100644 --- a/frmAdminForm.Designer.cs +++ b/frmAdminForm.Designer.cs @@ -34,6 +34,9 @@ namespace GreatHomeChildcare this.sqLiteCommand1 = new System.Data.SQLite.SQLiteCommand(); this.btnAdd = new System.Windows.Forms.Button(); this.dgvChildren = new System.Windows.Forms.DataGridView(); + this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Photo = new System.Windows.Forms.DataGridViewImageColumn(); + this.DisplayName = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dgvChildren)).BeginInit(); this.SuspendLayout(); // @@ -73,6 +76,10 @@ namespace GreatHomeChildcare this.dgvChildren.AllowUserToAddRows = false; this.dgvChildren.AllowUserToDeleteRows = false; this.dgvChildren.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvChildren.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.id, + this.Photo, + this.DisplayName}); this.dgvChildren.Location = new System.Drawing.Point(217, 36); this.dgvChildren.MultiSelect = false; this.dgvChildren.Name = "dgvChildren"; @@ -82,6 +89,33 @@ namespace GreatHomeChildcare this.dgvChildren.Size = new System.Drawing.Size(571, 392); this.dgvChildren.TabIndex = 4; // + // id + // + this.id.HeaderText = "id"; + this.id.MinimumWidth = 6; + this.id.Name = "id"; + this.id.ReadOnly = true; + this.id.Visible = false; + this.id.Width = 125; + // + // Photo + // + this.Photo.HeaderText = "Photo"; + this.Photo.MinimumWidth = 6; + this.Photo.Name = "Photo"; + this.Photo.ReadOnly = true; + this.Photo.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.Photo.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.Photo.Width = 125; + // + // DisplayName + // + this.DisplayName.HeaderText = "DisplayName"; + this.DisplayName.MinimumWidth = 6; + this.DisplayName.Name = "DisplayName"; + this.DisplayName.ReadOnly = true; + this.DisplayName.Width = 125; + // // frmAdminForm // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); @@ -106,5 +140,8 @@ namespace GreatHomeChildcare private System.Data.SQLite.SQLiteCommand sqLiteCommand1; private System.Windows.Forms.Button btnAdd; private System.Windows.Forms.DataGridView dgvChildren; + private System.Windows.Forms.DataGridViewTextBoxColumn id; + private System.Windows.Forms.DataGridViewImageColumn Photo; + private System.Windows.Forms.DataGridViewTextBoxColumn DisplayName; } } \ No newline at end of file diff --git a/frmAdminForm.cs b/frmAdminForm.cs index bdd7428..07c830e 100644 --- a/frmAdminForm.cs +++ b/frmAdminForm.cs @@ -7,11 +7,15 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using GreatHomeChildcare.Models; namespace GreatHomeChildcare { public partial class frmAdminForm : Form { + //globals for cheap access. + SqliteDataAccess SqliteDataAccess = new SqliteDataAccess(); + public frmAdminForm() { InitializeComponent(); @@ -19,7 +23,15 @@ namespace GreatHomeChildcare private void frmAdminForm_Load(object sender, EventArgs e) { + List children = new List(); + children = SqliteDataAccess.GetAllChildren(); + foreach(Child c in children) + { + Image photo = (c.photo != null) ? ImageWrangler.ByteArrayToImage(c.photo) : Properties.Resources.child; + + dgvChildren.Rows.Add(c.id, photo, c.DisplayName); + } } } } diff --git a/frmAdminForm.resx b/frmAdminForm.resx index ff35c0b..5b993e1 100644 --- a/frmAdminForm.resx +++ b/frmAdminForm.resx @@ -120,4 +120,13 @@ 17, 17 + + True + + + True + + + True + \ No newline at end of file