Datagrid view of admin form, populate with all children

This commit is contained in:
kougyokugentou 2021-01-20 16:11:26 -08:00
parent 972898ccfa
commit 7b52c262cc
3 changed files with 58 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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<Child> children = new List<Child>();
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);
}
}
}
}

View File

@ -120,4 +120,13 @@
<metadata name="sqLiteCommand1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Photo.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DisplayName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>