-
Notifications
You must be signed in to change notification settings - Fork 0
/
FoodCategory.cs
277 lines (239 loc) · 9.22 KB
/
FoodCategory.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using WMPLib;
namespace CreateTech
{
public partial class FoodCategory : Form
{
WindowsMediaPlayer player = new WindowsMediaPlayer();
bool play = false;
public FoodCategory()
{
InitializeComponent();
}
private void backbtnicon_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure want to return to the sign out? If enabled, the remember me function will be disabled.", "Warning Question", MessageBoxButtons.YesNo,MessageBoxIcon.Warning) == DialogResult.Yes)
{
frmHome.saved = 'N';
StreamWriter sw = new StreamWriter("CreateTech.txt", false); //Writes to the file
foreach (User user in frmHome.userList)
{
if (user.Getemail() == frmHome.email)
{
user.Setsaved('N');
}
sw.WriteLine($"{user.Getemail()},{user.Getsurname()},{user.Getname()},{user.Getaccountname()},{user.Getpassword()},{user.Getsaved()},{user.Getprof()}");
}
sw.Close();
new frmHome().Show();
this.Close();
}
else
{
MessageBox.Show("Cancelled successfully, enjoy browsing CreateIT's food categories.", "Abort Confirmed.");
}
}
private void pnlCarbohydrates_Click(object sender, EventArgs e)
{
new Carbohydrates().Show();
this.Close();
}
private void pnlDairy_Click(object sender, EventArgs e)
{
new Dairy_Products().Show();
this.Close();
}
private void pnlFruits_Click(object sender, EventArgs e)
{
new Fruits().Show();
this.Close();
}
private void pnlFats_Click(object sender, EventArgs e)
{
new FatsandOils().Show();
this.Close();
}
private void pnlProtein_Click(object sender, EventArgs e)
{
new Protien().Show();
this.Close();
}
private void pnlVegetables_Click(object sender, EventArgs e)
{
new Vegetables().Show();
this.Close();
}
private void panel2_MouseMove(object sender, MouseEventArgs e)
{
lbltime.Text = DateTime.Now.ToLocalTime().ToShortTimeString(); // Changes the time
}
private void FoodCategory_Activated(object sender, EventArgs e)
{
player.URL = "Requim.mp3"; //GET MORE Music
player.controls.stop();
lblAccountName.Text =frmHome.accountname;
lblname.Text = frmHome.name;
lblsurname.Text = frmHome.surname;
lblemail.Text = frmHome.email;
if (frmHome.saved == 'Y')
{
lblremember.Text = "Yes";
}
else
lblremember.Text = "No";
Program.SetPro(profilepic,pros);
}
private void profilepic_Click(object sender, EventArgs e)
{
pnlDashboard.Visible = true;
pnlDashboard.Enabled= true;
pnlDashboard.Width = 230;
pnlDashboard.Height = 583;
//230, 583 ~ panel dashboard size
}
private void button5_Click(object sender, EventArgs e)
{
pnlDashboard.Visible = false;
pnlDashboard.Enabled = false;
}
private void btnexit_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure you want to exit CreateIT?", "Data Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
StreamWriter sw = new StreamWriter("CreateTech.txt", false); // The false is used to rewrite the data in the textfile
foreach (User user in frmHome.userList)
{
sw.WriteLine($"{user.Getemail()},{user.Getsurname()},{user.Getname()},{user.Getaccountname()},{user.Getpassword()},{user.Getsaved()},{user.Getprof()}");
}
sw.Close();
this.Close();
}
else
{
return; // Why is this here ? idk good question ¯\_(ツ)_/¯
}
}
private void btnshoppingcart_Click(object sender, EventArgs e)
{
new ShoppingCart().Show();
this.Close();
}
private void btnrecipes_Click(object sender, EventArgs e)
{
new Recipes().Show();
this.Close();
}
private void btnnewaccount_Click(object sender, EventArgs e)
{
new NewAccount().Show();
this.Close();
}
private void btnRemember_Click(object sender, EventArgs e)
{
if (frmHome.saved == 'Y')
{
frmHome.user.Setsaved('N');
frmHome.saved = 'N';
lblremember.Text = "No";
}
else
{
if ((MessageBox.Show("As much as CreateIT adores our customers, Please be aware that using the Remember Me function will auto-log you in everytime you open the app on your device. This will leave your account vulnerable to unauthorised access if your device is not in your control. You can turn off this feature any time. Would you like to proceed?", "Sensitive Data Warning", MessageBoxButtons.YesNo) == DialogResult.Yes))
{
frmHome.user.Setsaved('Y');
frmHome.saved = 'Y';
lblremember.Text = "Yes";
}
else
{
MessageBox.Show("Remember me functionality aborted🔓.", "Abort Confirmation❌");
}
}
}
private void searchicon_Click(object sender, EventArgs e)
{
pnlStores.Location = new Point(53, 120);
pnlStores.Width = 280;
pnlStores.Height = 115;
pnlStores.Visible = true;
pnlStores.Enabled = true;
}
private void button1_Click(object sender, EventArgs e)
{
if (txtSearch.Text!=null && txtSearch.Text!="Search Something...")
{
switch (cbxStores.SelectedIndex)
{
case 0:
{
Process.Start($"https://www.checkers.co.za/search/all?q={txtSearch.Text}");
break;
}
case 1:
{
Process.Start($"https://www.pnp.co.za/search/{txtSearch.Text}");
break;
}
case 2:
{
Process.Start($"https://www.spar.co.za/SpecialPages/Search.aspx?searchtext={txtSearch.Text}&searchmode=anyword");
break;
}
case 3:
{
Process.Start($"https://www.shoprite.co.za/search/all?q={txtSearch.Text}");
break;
}
case 4:
{
Process.Start($"https://www.woolworths.co.za/cat?Ntt={txtSearch.Text}&Dy=1");
break;
}
default:
{
MessageBox.Show("Please select a food store before proceeding to search🔓.", "DataNotification", MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
}
}
}
else
{
MessageBox.Show("Please type in a food item before proceeding to search something🔓.", "DataNotification", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtSearch.Focus();
}
pnlStores.Visible = false;
pnlStores.Enabled = false;
}
private void musicPlayer_Click(object sender, EventArgs e)
{
if(!play)
{
play = true;
musicPlayer.Image = Properties.Resources.Stop;
MessageBox.Show("Now playing Requiem drill remix, composed by Mozart and remixed by Blono.\nEnjoy😎🎧🔓.", "Music Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
player.controls.play();
}
else
{
play = false;
musicPlayer.Image = Properties.Resources.Play;
player.controls.stop();
}
}
private void btnsettings_Click(object sender, EventArgs e)
{
new Settings().Show();
this.Close();
}
}
}