/
MainForm.cs
61 lines (51 loc) · 1.75 KB
/
MainForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using CoffeeShop.Enum;
using CoffeeShop.Forms;
using CoffeeShop.Model;
using System;
using System.Windows.Forms;
namespace CoffeeShop
{
public partial class Form1 : Form
{
private UserSimulation UserSimulation;
public Form1()
{
InitUserSimulationClass();
InitializeComponent();
IntializeContextMenu();
}
private void InitUserSimulationClass()
{
UserSimulation = new UserSimulation();
UserSimulation.User = new User();
}
private void IntializeContextMenu()
{
this.ContextMenuStrip = new ContextMenuStrip();
ToolStripMenuItem exitMenuItem = new ToolStripMenuItem("Exit App",null, onClick: exitMenuItem_Click);
ToolStripMenuItem timeMenuItem = new ToolStripMenuItem("Get Time", null, onClick: timeMenuItem_Click);
this.ContextMenuStrip.Items.Add(exitMenuItem);
this.ContextMenuStrip.Items.Add(timeMenuItem);
}
private void exitMenuItem_Click(object sender, EventArgs e)
{
if(UserSimulation.User.Role == UserRole.Super)
Application.Exit();
}
private void timeMenuItem_Click(object sender, EventArgs e)
{
if (!(UserSimulation.User.Role == UserRole.Super))
MessageBox.Show(DateTime.Now.ToString());
}
private void button1_Click(object sender, EventArgs e)
{
AddProductForm addProductForm = new AddProductForm();
addProductForm.ShowDialog();
}
private void button3_Click(object sender, EventArgs e)
{
TillForm tillForm = new TillForm();
tillForm.ShowDialog();
}
}
}