Hook up employee view to datasource.

This commit is contained in:
kougyoku 2019-10-15 13:04:57 -07:00
parent 93a6e6a691
commit fa950f79b0
3 changed files with 78 additions and 0 deletions

View File

@ -41,6 +41,8 @@
this.exitAltF4ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tbEmployeeName = new System.Windows.Forms.TextBox();
this.dgvEmployeeView = new System.Windows.Forms.DataGridView();
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvEmployeeView)).BeginInit();
this.SuspendLayout();
@ -165,6 +167,9 @@
//
this.dgvEmployeeView.AllowUserToAddRows = false;
this.dgvEmployeeView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvEmployeeView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.dataGridViewTextBoxColumn1,
this.dataGridViewTextBoxColumn2});
this.dgvEmployeeView.Location = new System.Drawing.Point(22, 181);
this.dgvEmployeeView.Name = "dgvEmployeeView";
this.dgvEmployeeView.RowHeadersWidth = 62;
@ -172,6 +177,19 @@
this.dgvEmployeeView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.dgvEmployeeView.Size = new System.Drawing.Size(843, 352);
this.dgvEmployeeView.TabIndex = 7;
this.dgvEmployeeView.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvEmployeeView_CellClick);
//
// dataGridViewTextBoxColumn1
//
this.dataGridViewTextBoxColumn1.MinimumWidth = 8;
this.dataGridViewTextBoxColumn1.Name = "CustomerID";
this.dataGridViewTextBoxColumn1.Width = 150;
//
// dataGridViewTextBoxColumn2
//
this.dataGridViewTextBoxColumn2.MinimumWidth = 8;
this.dataGridViewTextBoxColumn2.Name = "CustomerName";
this.dataGridViewTextBoxColumn2.Width = 150;
//
// frmEmployeeView
//
@ -216,6 +234,8 @@
private System.Windows.Forms.ToolStripMenuItem generateReportToolStripMenuItem;
private System.Windows.Forms.TextBox tbEmployeeName;
private System.Windows.Forms.DataGridView dgvEmployeeView;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
}
}

View File

@ -37,6 +37,7 @@ namespace QueueSys
frmCustomerView frm = new frmCustomerView();
OnSendMessage += frm.MessageReceived;
frm.Show();
RefreshEmployeeView();
}
/* Enable options menu. */
@ -78,6 +79,60 @@ namespace QueueSys
private void RefreshEmployeeView()
{
// Build the row.
SqliteDataAccess sdaEvView = new SqliteDataAccess();
List<EmployeeView> evList = new List<EmployeeView>();
evList = sdaEvView.LoadEmployeeView();
foreach (EmployeeView item in evList)
{
string[] row = new string[] { item.id.ToString(), item.customer_name };
dgvEmployeeView.Rows.Add(row);
}
DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
cmb.HeaderText = "Status";
cmb.MaxDropDownItems = 3;
//Allows for dynamic adding/removing status items per
//the status lookup table in the sqlite db.
List<StatusModel> s = new List<StatusModel>();
s = sdaEvView.LoadStatusStrings();
foreach (StatusModel item in s)
{
cmb.Items.Add(item.status);
}
dgvEmployeeView.Columns.Add(cmb);
//Change the status of the combobox based on the query from the db.
List<StatusModel> cxStatus = new List<StatusModel>();
//Select the id column from the current row.
foreach(DataGridViewRow row in dgvEmployeeView.Rows)
{
cxStatus = sdaEvView.GetCxStatus(Int32.Parse(dgvEmployeeView.CurrentRow.Cells[0].Value.ToString()));
row.Cells[2].Value = cxStatus[0].status;
}
// Add the delete button.
DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
btn.HeaderText = "Delete";
btn.Text = "Delete";
btn.Name = "btn";
btn.UseColumnTextForButtonValue = true;
dgvEmployeeView.Columns.Add(btn);
}
private void dgvEmployeeView_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 3)
{
MessageBox.Show("Row"+e.RowIndex);
}
}
}

View File

@ -120,4 +120,7 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>49</value>
</metadata>
</root>