Add delegate for updating customer view from the employee add button.
This commit is contained in:
parent
4fe9f84f7e
commit
9c26d0519e
@ -23,6 +23,12 @@ namespace QueueSys
|
||||
RefreshCustomerView();
|
||||
}
|
||||
|
||||
// Triggered by Employee View form add buttom as a delegate.
|
||||
public void MessageReceived(object sender, EventArgs e)
|
||||
{
|
||||
RefreshCustomerView();
|
||||
}
|
||||
|
||||
private void RefreshCustomerView()
|
||||
{
|
||||
SqliteDataAccess sdaCxView = new SqliteDataAccess();
|
||||
|
@ -8,6 +8,10 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
/* References */
|
||||
// Using a delegate to trigger method on the customer view form
|
||||
// https://www.coderslexicon.com/passing-data-between-forms-using-delegates-and-events/
|
||||
|
||||
namespace QueueSys
|
||||
{
|
||||
public partial class frmEmployeeView : Form
|
||||
@ -17,18 +21,28 @@ namespace QueueSys
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
// Our delegate (which "points" at any method which takes an object and EventArgs)
|
||||
// Look familiar? This is the signature of most control events on a form
|
||||
public delegate void SendMessage(object obj, EventArgs e);
|
||||
|
||||
// Here is the event we trigger to send messages out to listeners
|
||||
public event SendMessage OnSendMessage;
|
||||
|
||||
/* Execute when program / main form loads.
|
||||
* Pop up the customer view screen to drag onto second monitor */
|
||||
* Pop up the customer view screen to drag onto second monitor
|
||||
* creates our second form, says "attach its MessageReceived function to the event"
|
||||
*/
|
||||
private void frmEmployeeView_Load(object sender, EventArgs e)
|
||||
{
|
||||
Form frm = new frmCustomerView();
|
||||
frmCustomerView frm = new frmCustomerView();
|
||||
OnSendMessage += frm.MessageReceived;
|
||||
frm.Show();
|
||||
}
|
||||
|
||||
/* Enable options menu. */
|
||||
private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Form frm = new frmOptions();
|
||||
frmOptions frm = new frmOptions();
|
||||
frm.Show();
|
||||
frm.Activate();
|
||||
}
|
||||
@ -52,7 +66,8 @@ namespace QueueSys
|
||||
|
||||
sda.SaveCustomer(evNewCx);
|
||||
|
||||
//sda.LoadEmployeeView();
|
||||
//Invoke the delegate to update customer view.
|
||||
OnSendMessage?.Invoke(this, e);
|
||||
|
||||
tbCustomerName.Text = "";
|
||||
cbNumBags.Text = "";
|
||||
|
@ -26,3 +26,11 @@ C:\Users\kougyoku\Google Drive\TINFO 220_ HCI Group Project\QueueSys\QueueSys\bi
|
||||
C:\Users\kougyoku\Google Drive\TINFO 220_ HCI Group Project\QueueSys\QueueSys\bin\Debug\System.Data.SQLite.xml
|
||||
C:\Users\kougyoku\Google Drive\TINFO 220_ HCI Group Project\QueueSys\QueueSys\bin\Debug\System.Data.SQLite.dll.config
|
||||
C:\Users\kougyoku\Google Drive\TINFO 220_ HCI Group Project\QueueSys\QueueSys\obj\Debug\QueueSys.csproj.CopyComplete
|
||||
C:\Users\kougyoku\source\repos\QueueSys\QueueSys\bin\Debug\QueueSys.db
|
||||
C:\Users\kougyoku\source\repos\QueueSys\QueueSys\bin\Debug\Dapper.dll
|
||||
C:\Users\kougyoku\source\repos\QueueSys\QueueSys\bin\Debug\System.Data.SQLite.dll
|
||||
C:\Users\kougyoku\source\repos\QueueSys\QueueSys\bin\Debug\Dapper.xml
|
||||
C:\Users\kougyoku\source\repos\QueueSys\QueueSys\bin\Debug\System.Data.SQLite.xml
|
||||
C:\Users\kougyoku\source\repos\QueueSys\QueueSys\bin\Debug\System.Data.SQLite.dll.config
|
||||
C:\Users\kougyoku\source\repos\QueueSys\QueueSys\obj\Debug\QueueSys.frmOptions.resources
|
||||
C:\Users\kougyoku\source\repos\QueueSys\QueueSys\obj\Debug\QueueSys.csproj.CopyComplete
|
||||
|
Loading…
Reference in New Issue
Block a user