Add: Refresh employee view after clicking the add button.
Change: Clear the employee datagrid view after adding a new cutsomer. Update/Bugfix: Incorrectly updating the combobox selection when populating the datagrid view. Fixed. Add: Delete button functionality. Add: Event hooking status combobox into a selection change commited event to automatically update db/customer view when status changes.
This commit is contained in:
parent
fa950f79b0
commit
559871d853
@ -75,10 +75,15 @@ namespace QueueSys
|
||||
tbEmployeeName.Text = "";
|
||||
|
||||
MessageBox.Show("Customer has been added!", "Queue System", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
RefreshEmployeeView();
|
||||
}
|
||||
|
||||
private void RefreshEmployeeView()
|
||||
{
|
||||
dgvEmployeeView.Rows.Clear();
|
||||
dgvEmployeeView.Refresh();
|
||||
|
||||
// Build the row.
|
||||
SqliteDataAccess sdaEvView = new SqliteDataAccess();
|
||||
List<EmployeeView> evList = new List<EmployeeView>();
|
||||
@ -113,7 +118,7 @@ namespace QueueSys
|
||||
//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()));
|
||||
cxStatus = sdaEvView.GetCxStatus(Int32.Parse(dgvEmployeeView.Rows[row.Index].Cells[0].Value.ToString()));
|
||||
row.Cells[2].Value = cxStatus[0].status;
|
||||
}
|
||||
|
||||
@ -127,13 +132,83 @@ namespace QueueSys
|
||||
dgvEmployeeView.Columns.Add(btn);
|
||||
}
|
||||
|
||||
|
||||
private void dgvEmployeeView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
//The delete button was clicked.
|
||||
if (e.ColumnIndex == 3)
|
||||
{
|
||||
MessageBox.Show("Row"+e.RowIndex);
|
||||
//Sanity check, per option.
|
||||
if (Properties.Settings.Default.ConfirmDelete)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("Are you sure you want to delete this customer?", "Queue System", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
|
||||
|
||||
if (result == DialogResult.No)
|
||||
{
|
||||
MessageBox.Show("Customer was not deleted.", "Queue System", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SqliteDataAccess sdaEvView = new SqliteDataAccess();
|
||||
|
||||
EmployeeView evCustomer = new EmployeeView();
|
||||
evCustomer.id = Int32.Parse(dgvEmployeeView.CurrentRow.Cells[0].Value.ToString());
|
||||
|
||||
sdaEvView.ArchiveCustomer(evCustomer);
|
||||
RefreshEmployeeView();
|
||||
|
||||
//Invoke the delegate to update customer view with updated data.
|
||||
OnSendMessage?.Invoke(this, e);
|
||||
|
||||
MessageBox.Show("Customer has been removed from the queue", "Queue System", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// This event hooks the status combobox into the change commit event
|
||||
private void dgvEmployeeView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
|
||||
{
|
||||
if (dgvEmployeeView.CurrentCell.ColumnIndex == 2)
|
||||
{
|
||||
ComboBox combo = e.Control as ComboBox;
|
||||
|
||||
if(combo != null)
|
||||
{
|
||||
combo.SelectionChangeCommitted += new EventHandler(dgvCbStatus_SelectionChangeCommitted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This event fires when the "status" combo box was changed
|
||||
* and that change was "committed"
|
||||
* This is needed to update the backend SQL db on demand,
|
||||
* then update the customer view screen.
|
||||
*/
|
||||
private void dgvCbStatus_SelectionChangeCommitted(object sender, EventArgs e)
|
||||
{
|
||||
DataGridViewComboBoxEditingControl dgvcbec = sender as DataGridViewComboBoxEditingControl;
|
||||
int CustomerId = Int32.Parse(dgvcbec.EditingControlDataGridView.CurrentRow.Cells[0].Value.ToString());
|
||||
|
||||
string new_status = dgvcbec.Text;
|
||||
|
||||
//Check to see if we need an update.
|
||||
SqliteDataAccess sdaEvView = new SqliteDataAccess();
|
||||
|
||||
List<StatusModel> cxStatus = new List<StatusModel>();
|
||||
cxStatus = sdaEvView.GetCxStatus(CustomerId);
|
||||
|
||||
// Update not required.
|
||||
if (cxStatus[0].status == new_status)
|
||||
return;
|
||||
|
||||
/* Update of the backend DB required beyond this point
|
||||
* Update the customer status on the backend db.
|
||||
*/
|
||||
sdaEvView.UpdateCustomerStatus(CustomerId, new_status);
|
||||
|
||||
//Invoke the delegate to update customer view with updated data.
|
||||
OnSendMessage?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user