-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
377 lines (309 loc) · 11.3 KB
/
Form1.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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Сайтец.Admin;
using MySql.Data.MySqlClient;
namespace Сайтец
{
public partial class Form1 : Form
{
public static int maxPrice;
public static int minnPrice;
public static bool successLogin = false;
public static int admin = 0;
public static moneyControl money = new moneyControl();
public static LoginControl1 login = new LoginControl1();
List<Image> banners = new List<Image>();
int bannerIndex = 0;
public Form1()
{
InitializeComponent();
showFilterPanel(null, null);
login.Location = new Point(422, 11);
panel1.Controls.Add(login);
money.Visible = false;
money.Location = new Point(500, 14);
panel1.Controls.Add(money);
tableLayoutPanel1.ColumnStyles[1].Width = 0;
banners.Add(Properties.Resources.banner1);
banners.Add(Properties.Resources.banner2);
banners.Add(Properties.Resources.banner3);
}
private void timer1_Tick(object sender, EventArgs e)
{
bannerIndex++;
if (bannerIndex >= banners.Count)
{
bannerIndex = 0;
}
AdminButton.Visible = (admin == 1);
ModerButton.Visible = (admin == 1);
if (admin == 1)
{
AdminButton.ContextMenuStrip = buttonContextMenuStrip;
}
else
{
AdminButton.ContextMenuStrip = null;
}
label7.Text = korzina.TotalPrice.ToString() + " р";
label5.Text = korzina.TotalCount.ToString() + " товаров";
}
public static string CONNECTION_STRING =
"SslMode=none;" +
"Server=db4free.net;" +
"database=ingenerka;" +
"port=3306;" +
"uid=ingenerka;" +
"pwd=Beavis1989;" +
"old guids=true;";
public static MySqlConnection CONN;
/// <summary>
/// Update-запрос
/// </summary>
public static void Update(string zapros)
{
MySqlCommand q = new MySqlCommand(zapros, CONN);
MySqlDataReader r = q.ExecuteReader();
r.Close();
}
/// <summary>
/// Select-запрос
/// </summary>
/// <param name="sqlzapros"></param>
/// <returns></returns>
public static List<string> Select(string sqlzapros)
{
List<string> res = new List<string>();
MySqlCommand q = new MySqlCommand(sqlzapros, Form1.CONN);
MySqlDataReader r = q.ExecuteReader();
while (r.Read())
{
for (int inc = 0; inc < r.FieldCount; inc++)
{
res.Add(r[inc].ToString());
}
}
r.Close();
return res;
}
void connect()
{
while (CONN.State != ConnectionState.Open)
{
try
{
CONN.Open();
}
catch (Exception)
{
connect();
}
}
}
bool skidka = false;
public void Filterrr()
{
String zapros = "SELECT id FROM Products WHERE 1=1";
if (minprice.Text != "")
zapros += " AND price >= " + Convert.ToInt32(minprice.Text);
if (maxpricebutton.Text != "")
zapros += " AND price <=" + Convert.ToInt32(maxpricebutton.Text);
if (skidka == true)
{
zapros += " AND price >= OldPrice ";
}
/* if (textBox1.Text != "")
zapros += " AND upper(Title) like upper ('"+ textBox1.Text + "%')";*/
List<string> products = Select(zapros);
panel3.Controls.Clear();
int x = 10;
int y = 20;
for (int i = 0; i < products.Count; i = i + 1)
{
ProductUserControl product = new ProductUserControl(products[i]);
product.Location = new Point(x, y);
product.Size = new Size(280, 190);
//if (KuplennyeTovary.Contains(products[i]))
{
panel3.Controls.Add(product);
x = x + 290;
if (x > this.Width - 450)
{
y = y + 200;
x = 10;
}
}
}
panel3.Visible = true;
panel4.Visible = false;
label1.ForeColor = Color.FromArgb(93, 110, 134);
}
private void Form1_Load(object sender, EventArgs e)
{
CONN = new MySqlConnection(CONNECTION_STRING);
connect();
Filterrr();
foreach (Control ctrl in Controls)
{
if (ctrl is ns1.BunifuThinButton2)
{
string btn = ctrl.Name;
string type = ctrl.GetType().ToString();
string form = this.Name;
List<string> fontSize = Select(
"SELECT Value FROM UniqueDesign " +
"WHERE ObjectName = '" + btn + "'" +
//And FOrm = And objectType=...
" AND Parameter = 'FontSize'");
List<string> fontName = Select(
"SELECT Value FROM UniqueDesign " +
"WHERE ObjectName = '" + btn + "'" +
//And FOrm = And objectType=...
" AND Parameter = 'FontName'");
if (fontName.Count > 0 && fontSize.Count > 0)
{
ctrl.Font = new Font(fontName[0],
(float)Convert.ToDouble(fontSize[0]));
//ctrl.BackgroundImage = Image.FromFile(fontSize[0]);
}
}
}
}
private Point MouseHook;
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
Cursor = Cursors.Default;
if (e.Button != MouseButtons.Left) MouseHook = e.Location;
else
{
Location = new Point((Size)Location - (Size)MouseHook + (Size)e.Location);
Cursor = Cursors.Hand;
}
}
private void label1_Click(object sender, EventArgs e)
{
panel3.Visible = true;
panel4.Visible = false;
label6.ForeColor = Color.FromArgb(73, 90, 114);
label2.ForeColor = Color.FromArgb(73, 90, 114);
label1.ForeColor = Color.FromArgb(93, 110, 134);
}
private void bunifuFlatButton2_Click(object sender, EventArgs e)
{
SignInForm f = new SignInForm();
f.ShowDialog();
}
private void bunifuFlatButton3_Click(object sender, EventArgs e)
{
LoginForm l = new LoginForm();
l.ShowDialog();
}
private void earn_Click(object sender, EventArgs e)
{
earn e1 = new earn();
e1.ShowDialog();
}
private void pictureBox3_Click(object sender, EventArgs e)
{
korzina k1 = new korzina();
k1.ShowDialog();
}
private void Label2_Click(object sender, EventArgs e)
{
label6.ForeColor = Color.FromArgb(73, 90, 114);
label1.ForeColor = Color.FromArgb(73, 90, 114);
label2.ForeColor = Color.FromArgb(93, 110, 134);
panel3.Visible = false;
panel4.Visible = true;
}
private void Label3_Click(object sender, EventArgs e)
{
UserControl2 loading = new UserControl2();
loading.Location = new Point(233, 33);
loading.Size = new Size(152, 21);
Controls.Add(loading);
label6.ForeColor = Color.FromArgb(73, 90, 114);
label2.ForeColor = Color.FromArgb(73, 90, 114);
label1.ForeColor = Color.FromArgb(73, 90, 114);
panel4.Visible = false;
panel3.Visible = false;
}
private void AdminButton_Click(object sender, EventArgs e)
{
ButtonDesign D = new ButtonDesign();
D.Show();
}
private void Panel2_Click(object sender, EventArgs e)
{
Filterrr();
}
/// <summary>
/// Покпазываем панель фильтра
/// </summary>
private void showFilterPanel(object sender, EventArgs e)
{
if (tableLayoutPanel1.ColumnStyles[1].Width != 0)
tableLayoutPanel1.ColumnStyles[1].Width = 0;
else
tableLayoutPanel1.ColumnStyles[1].Width = 35;
}
private void Button4_Click(object sender, EventArgs e)
{
Filterrr();
}
private void BunifuTrackbar2_ValueChanged(object sender, EventArgs e)
{
maxpricebutton.Text = bunifuTrackbar2.Value.ToString();
maxPrice = Convert.ToInt32(maxpricebutton.Text);
}
private void BunifuTrackbar1_ValueChanged(object sender, EventArgs e)
{
minprice.Text = bunifuTrackbar1.Value.ToString();
minnPrice = Convert.ToInt32(minprice.Text);
}
private void button5_Click(object sender, EventArgs e)
{
Close();
}
private void поменятьДизайнToolStripMenuItem_Click(object sender, EventArgs e)
{
ContextMenuStrip c1 = (ContextMenuStrip)((ToolStripMenuItem)sender).Owner;
ns1.BunifuThinButton2 btn = (ns1.BunifuThinButton2)(c1.SourceControl);
OneButtonForm form = new OneButtonForm(btn);
form.ShowDialog();
}
private void buttonContextMenuStrip_Opening(object sender, CancelEventArgs e)
{
}
private void panel3_Paint(object sender, PaintEventArgs e)
{
}
private void bunifuFlatButton1_Click(object sender, EventArgs e)
{
ModeratorForm r = new ModeratorForm();
r.Show();
}
private void bunifuCheckbox1_OnChange(object sender, EventArgs e)
{
}
private void bunifuCheckbox2_OnChange(object sender, EventArgs e)
{
if (bunifuCheckbox2.Checked)
{
skidka = false;
bunifuCheckbox2.Checked = false;
} else
{
skidka = true;
bunifuCheckbox2.Checked = true;
}
}
}
}