-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cs
280 lines (229 loc) · 8.32 KB
/
Main.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
278
279
280
using System;
using System.Data.SQLite;
using System.Drawing;
using System.Windows.Forms;
namespace LabadaPOS
{
public partial class Main : Form
{
public double formula { get; set; }
public static Main instance;
public Main()
{
InitializeComponent();
tabControl.Appearance = TabAppearance.FlatButtons;
tabControl.ItemSize = new Size(0, 1);
tabControl.SizeMode = TabSizeMode.Fixed;
}
public void ChangeLabelText()
{
double lt = 35;
double md = 55;
double hvy = 75;
double ltkilo = double.Parse(ltqty_txt.Text);
double hvykilo = double.Parse(hvyqty_txt.Text);
double mdkilo = double.Parse(mdqty_txt.Text);
double kilos = ltkilo + hvykilo + mdkilo;
double lttotal = ltkilo * lt;
double mdtotal = mdkilo * md;
double hvytotal = hvykilo * hvy;
double kilototal = lttotal + mdtotal + hvytotal;
double addons = kilos * 15;
double delivery;
if (pikupmthd_txt.Text == "Delivery")
{
delivery = 30;
}
else
{
delivery = 0;
}
if (addons_txt.Text == "Laundry Detergent" && pikupmthd_txt.Text == "Delivery")
{
formula = kilototal + addons + delivery;
}
else if (addons_txt.Text != "Laundry Detergent" && pikupmthd_txt.Text == "Delivery")
{
formula = kilototal + delivery;
}
else if (addons_txt.Text == "Laundry Detergent" && pikupmthd_txt.Text != "Delivery")
{
formula = kilototal + addons;
}
else
{
formula = kilototal;
}
total_txt.Text = formula.ToString("F2");
}
private void exitbtn_Click(object sender, EventArgs e)
{
System.Environment.Exit(1);
}
private void exitbtn_MouseHover(object sender, EventArgs e)
{
exitbtn.BackColor = Color.SkyBlue;
}
private void exitbtn_MouseLeave(object sender, EventArgs e)
{
exitbtn.BackColor = Color.DeepSkyBlue;
}
private void timer1_Tick(object sender, EventArgs e)
{
date_time.Text = DateTime.Now.ToString("dddd , MMM dd yyyy,hh:mm:ss");
}
private void button1_Click(object sender, EventArgs e)
{
tabControl.SelectTab(0);
}
private void tab2_btn_Click(object sender, EventArgs e)
{
tabControl.SelectTab(1);
}
private void tab3_btn_Click(object sender, EventArgs e)
{
tabControl.SelectTab(2);
}
private void tab4_btn_Click(object sender, EventArgs e)
{
tabControl.SelectTab(3);
}
private void settingsbtn_Click(object sender, EventArgs e)
{
var adminlogin = new AdminLogin();
adminlogin.Show();
}
private void machinewash_btn_Click(object sender, EventArgs e)
{
lndrymthd_txt.Text = "Machine Wash";
}
private void dryclean_btn_Click(object sender, EventArgs e)
{
lndrymthd_txt.Text = "Dry Clean (currently unavailable)";
MessageBox.Show("Dry Clean is currently unavailable.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void detergentbtn_Click(object sender, EventArgs e)
{
if (addons_txt.Text == "none")
{
addons_txt.Text = "Laundry Detergent";
}
else
{
addons_txt.Text = "none";
}
}
private void confirm_btn_Click(object sender, EventArgs e)
{
string day = DateTime.Now.ToString("dd");
string month = DateTime.Now.ToString("MMMM");
string year = DateTime.Now.ToString("yyyy");
DialogResult dr = MessageBox.Show(
"Confirm transaction?", "LabadaPOS", MessageBoxButtons.YesNo, MessageBoxIcon.Question
);
if (dr == DialogResult.Yes)
{
try
{
//string fileName = "sales.db";
//string path = Path.Combine(Environment.CurrentDirectory, @"Data\", fileName);
string myConnection = @"Data Source=sales.db;Version=3;";
SQLiteConnection con = new SQLiteConnection(myConnection, true);
string insert = "INSERT INTO SALES(MONTH, DAY, YEAR, INCOME) VALUES(@MONTH,@DAY,@YEAR,@INCOME);";
SQLiteCommand cmd = new SQLiteCommand(insert, con);
cmd.Parameters.AddWithValue("@MONTH", month);
cmd.Parameters.AddWithValue("@DAY", day);
cmd.Parameters.AddWithValue("@YEAR", year);
cmd.Parameters.AddWithValue("@INCOME", total_txt.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
if (i == 1)
{
MessageBox.Show("Transaction complete.", "LabadaPOS", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
con.Close();
ltqty_txt.Text = "0";
mdqty_txt.Text = "0";
hvyqty_txt.Text = "0";
lndrymthd_txt.Text = "Machine Wash";
addons_txt.Text = "none";
pikupmthd_txt.Text = "Pickup";
numericUpDown_light.Value = 0;
numericUpDown_medium.Value = 0;
numericUpDown_heavy.Value = 0;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else
{
}
}
private void deliverybtn_Click(object sender, EventArgs e)
{
pikupmthd_txt.Text = "Delivery";
}
private void pickupbtn_Click(object sender, EventArgs e)
{
pikupmthd_txt.Text = "Pickup";
}
private void numericUpDown_light_ValueChanged(object sender, EventArgs e)
{
string ltqty = numericUpDown_light.Value.ToString();
ltqty_txt.Text = ltqty;
}
private void numericUpDown_medium_ValueChanged(object sender, EventArgs e)
{
string mdqty = numericUpDown_medium.Value.ToString();
mdqty_txt.Text = mdqty;
}
private void numericUpDown_heavy_ValueChanged(object sender, EventArgs e)
{
string hvyqty = numericUpDown_heavy.Value.ToString();
hvyqty_txt.Text = hvyqty;
}
private void ltqty_txt_TextChanged(object sender, EventArgs e)
{
ChangeLabelText();
}
private void mdqty_txt_TextChanged(object sender, EventArgs e)
{
ChangeLabelText();
}
private void hvyqty_txt_TextChanged(object sender, EventArgs e)
{
ChangeLabelText();
}
private void lndrymthd_txt_TextChanged(object sender, EventArgs e)
{
ChangeLabelText();
}
private void addons_txt_TextChanged(object sender, EventArgs e)
{
ChangeLabelText();
}
private void pikupmthd_txt_TextChanged(object sender, EventArgs e)
{
ChangeLabelText();
}
private void cancelbtn_Click(object sender, EventArgs e)
{
DialogResult cancel = MessageBox.Show("Cancel Order?", "LabadaPOS", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (cancel == DialogResult.Yes)
{
ltqty_txt.Text = "0";
mdqty_txt.Text = "0";
hvyqty_txt.Text = "0";
lndrymthd_txt.Text = "Machine Wash";
addons_txt.Text = "none";
pikupmthd_txt.Text = "Pickup";
numericUpDown_light.Value = 0;
numericUpDown_medium.Value = 0;
numericUpDown_heavy.Value = 0;
}
else { }
}
}
}