forked from elizabethadegbaju/QuickLaundry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.cs
137 lines (128 loc) · 4.7 KB
/
profile.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace quicklaundry
{
public partial class profile : Form
{
public profile()
{
InitializeComponent();
this.FormClosing += Profile_FormClosing;
}
private void Profile_FormClosing(object sender, FormClosingEventArgs e)
{
foreach (Form oForm in Application.OpenForms)
{
if (oForm is login)
{
oForm.Show();
break;
}
}
}
private void profile_Load(object sender, EventArgs e)
{
status.Hide();
balance.Hide();
address.Hide();
address_.Hide();
time.Hide();
time_.Hide();
order.Hide();
try
{
string conn = "datasource=127.0.0.1;port=3306;username=root;password=lizzy2000;database=quicklaundry";
string query = "SELECT * FROM users WHERE username = '" + login.user + "' AND password= '" + login.pass + "';";
MySqlConnection connect = new MySqlConnection(conn);
MySqlCommand go = new MySqlCommand(query, connect);
go.CommandTimeout = 60;
MySqlDataReader reader;
connect.Open();
reader = go.ExecuteReader();
while (reader.Read())
{
name.Text = reader.GetString("fName")+" "+reader.GetString("lName");
email.Text = reader.GetString("email");
username.Text = reader.GetString("username");
}
connect.Close();
query = "SELECT * FROM laundry WHERE username = '"+login.user+"';";
MySqlCommand another = new MySqlCommand(query, connect);
another.CommandTimeout = 60;
MySqlDataReader newreader;
connect.Open();
newreader = another.ExecuteReader();
while (newreader.Read())
{
if (newreader.HasRows)
{
status.Show();
balance.Show();
addnew.Hide();
}
if (newreader.GetString("status") == "completed")
{
address.Show();
address_.Show();
time.Show();
time_.Show();
order.Show();
}
Laundry.Text = Laundry.Text + " No" + newreader.GetString("orderNo");
balance.Text = "Outstanding balance: " + newreader.GetString("bill");
status.Text = "Current status: " + newreader.GetString("status");
}
connect.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"Error");
}
}
private void order_Click_1(object sender, EventArgs e)
{
try
{
string c = "datasource=127.0.0.1;port=3306;username=root;password=lizzy2000;database=quicklaundry";
string query = "UPDATE laundry SET dropoffAddress = '" + address_.Text + "', dropoffTime = '" + time_.Value + "', status = 'dropoff' WHERE username = '" + login.user + "';"; ;
MySqlConnection con = new MySqlConnection(c);
MySqlCommand write = new MySqlCommand(query, con);
write.CommandTimeout = 60;
MySqlDataReader checker;
con.Open();
checker = write.ExecuteReader();
MessageBox.Show("Successfully updated! Expect delivery within 48 hours.", "Order Drop-off");
address.Hide();
address_.Hide();
time.Hide();
time_.Hide();
order.Hide();
status.Text = "Current status: Dropoff";
while (checker.Read())
{
}
con.Close();
}
catch (Exception except)
{
MessageBox.Show(except.Message);
}
}
private void logout__Click_1(object sender, EventArgs e)
{
this.Close();
}
private void addnew_Click_1(object sender, EventArgs e)
{
newlaundry adder = new newlaundry();
adder.Show();
}
}
}