-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrmAdminDashboard.cs
More file actions
192 lines (175 loc) · 6.38 KB
/
Copy pathFrmAdminDashboard.cs
File metadata and controls
192 lines (175 loc) · 6.38 KB
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
using System;
using System.Data.SqlClient;
using System.Linq;
using System.Windows.Forms;
using System.Xml.Linq;
namespace PharmacyAutomation
{
public partial class FrmAdminDashboard : Form
{
public FrmAdminDashboard()
{
InitializeComponent();
}
SqlConnection connection = new SqlConnection("Data Source=DESKTOP-2H5V0KB\\SQLEXPRESS;Initial Catalog=DbPharmacy;Integrated Security=True");
public string username;
public string personID;
static string myApi = "2cd512a81a207c80a98260dea6a3d0e9";
private static string city = "istanbul";
static string conc =
"https://api.openweathermap.org/data/2.5/weather?q=" + city + "&mode=xml&lang=tr&units=metric&appid=" + myApi;
static XDocument weather = XDocument.Load(conc);
string temp = weather.Descendants("temperature").ElementAt(0).Attribute("value").Value;
string weatherstate = weather.Descendants("weather").ElementAt(0).Attribute("value").Value;
public void SellerCount()
{
connection.Open();
SqlCommand command = new SqlCommand("Select COUNT(*) From TblSeller", connection);
SqlDataReader dataReader = command.ExecuteReader();
if (dataReader.Read())
{
lblSellerCount.Text = dataReader[0].ToString();
}
connection.Close();
}
public void SalesCount()
{
connection.Open();
SqlCommand command = new SqlCommand("Select COUNT(*) From TblSales", connection);
SqlDataReader dataReader = command.ExecuteReader();
if (dataReader.Read())
{
lblSalesCount.Text = dataReader[0].ToString();
}
connection.Close();
}
public void MoneyEarned()
{
connection.Open();
SqlCommand command = new SqlCommand("select SUM(Gain) from TblSales", connection);
SqlDataReader dataReader = command.ExecuteReader();
if (dataReader.Read())
{
lblMoneyEarned.Text = dataReader[0].ToString() + " TL";
}
connection.Close();
}
public void MedicineCount()
{
connection.Open();
SqlCommand command = new SqlCommand("Select COUNT(*) From TblMedicine", connection);
SqlDataReader dataReader = command.ExecuteReader();
if (dataReader.Read())
{
lblMedicineCount.Text = dataReader[0].ToString();
}
connection.Close();
}
public void SalesMedicineCount()
{
connection.Open();
SqlCommand command = new SqlCommand("Select SUM(MedicineCount) from TblSalesSellerMedicine", connection);
SqlDataReader dataReader = command.ExecuteReader();
if (dataReader.Read())
{
lblSalesMedicineCount.Text = dataReader[0].ToString();
}
connection.Close();
}
public void Gain()
{
connection.Open();
SqlCommand command = new SqlCommand("Select SUM(MedicineCount*(SalePrice-PurchasePrice)) from TblMedicine inner join TblSalesSellerMedicine on TblMedicine.MedicineID=TblSalesSellerMedicine.MedicineID", connection);
SqlDataReader dataReader = command.ExecuteReader();
if (dataReader.Read())
{
lblGain.Text = dataReader[0].ToString() + " TL";
}
connection.Close();
}
public void Notification()
{
connection.Open();
SqlCommand command = new SqlCommand("Select Count(*) from TblPerson where PersonID not in (select PersonID from TblPersonAuthority)", connection);
SqlDataReader dataReader = command.ExecuteReader();
if (dataReader.Read())
{
lblNotification.Text = dataReader[0].ToString();
}
connection.Close();
}
private void FrmAdminDashboard_Load(object sender, EventArgs e)
{
timer1.Start();
lblWeather.Text = temp + " " + weatherstate;
lblCity.Text = city.ToUpper();
timer2.Enabled = true;
SqlCommand command = new SqlCommand("Select * From ");
lblUserName.Text = username;
SalesCount();
SellerCount();
MoneyEarned();
MedicineCount();
SalesMedicineCount();
Gain();
Notification();
}
private void timer1_Tick(object sender, EventArgs e)
{
lblDate.Text = DateTime.Now.ToShortDateString();
lblTime.Text = DateTime.Now.ToLongTimeString();
}
private void timer2_Tick(object sender, EventArgs e)
{
if (label13.Left > -295)
{
label13.Left -= 3;
}
else
{
label13.Left = 13;
}
if (lblUserName.Text.Length > 5)
{
if (lblUserName.Left > 30)
{
lblUserName.Left -= 1;
}
else
{
lblUserName.Left = 59;
}
}
}
private void SignOut_Click(object sender, EventArgs e)
{
Close();
}
private void btnEditProfile_Click(object sender, EventArgs e)
{
FrmEditProfile frmEditProfile = new FrmEditProfile();
frmEditProfile.personID = personID;
frmEditProfile.Show();
Close();
}
private void btnSellerInfo_Click(object sender, EventArgs e)
{
}
private void btnMedicineDetails_Click(object sender, EventArgs e)
{
FrmMedicineAndDetail frmMedicineAndDetail = new FrmMedicineAndDetail();
frmMedicineAndDetail.personID = personID;
frmMedicineAndDetail.username = username;
frmMedicineAndDetail.Show();
Close();
}
private void lblNotification_Click(object sender, EventArgs e)
{
FrmAuthorize frmAuthorize = new FrmAuthorize();
frmAuthorize.personID = personID;
frmAuthorize.username = username;
frmAuthorize.Show();
Close();
}
}
}