-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
902 lines (800 loc) · 47.5 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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
using ClosedXML.Excel;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using System.Xml;
namespace Teklif_Listesi_Hazırlama_Modülü
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/// <summary>
/// Her ürün verilerine bölünüp gerekli listeye eklenir.
/// Ürünün sırası her listede aynıdır. İlk eklenen ürün tüm listelerde 0. elemandır.
/// </summary>
public List<string> searchname = new List<string>();
public List<string> productid = new List<string>();
public List<string> name = new List<string>();
public List<byte[]> picture = new List<byte[]>();
public List<string> brad = new List<string>();
public List<string> category = new List<string>();
public List<string> shoeupper = new List<string>();
public List<string> airlining = new List<string>();
public List<string> innersole = new List<string>();
public List<string> midsole = new List<string>();
public List<string> outsole = new List<string>();
public List<string> outsolefea = new List<string>();
public List<string> toeprotect = new List<string>();
public List<string> sizerange = new List<string>();
public List<string> price = new List<string>();
/// <summary>
/// Veritabanı bilgileri kullanıcı bilgileri kaydettikten sonra depolanır.
/// Liste oluştururken kullanılan firma logosu base64 olarak logo değişkeninde tutulur.
/// </summary>
public string dbip = Properties.Settings.Default.dbip;
public string dbname = Properties.Settings.Default.dbname;
public string dbuser = Properties.Settings.Default.dbuser;
public string dbpass = Properties.Settings.Default.dbpass;
public string logo = @"/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a
HBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy
MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAyAPMDASIA
AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm
p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8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vJBCT9oYNEu
EIcAAcHcF6cHJouIfHypqHlXFrIxt4VtQoRcSceY2SOx3cHgjGMGgDJ+DvgPWfAun6rBq5ti11LG
8fkSFhgAg54HrXp1ZOiQ6wn2x9XuFkZ5v3CIBtSMKPQZyTu61rUAFFFFAHH6+in4jeEGKgsqXuDj
kfItZHxvVT8LdQkKgvHJEyNjlTvAyPQ4JH40UUAdhokEKeE9PgWJFhFjGojCgLjYOMelcH8DYYo/
C2qMkaKx1OVSVUAkLgKPoBwPSiigDoLFVHxe1hto3f2RbjOOf9Y9ZvxKgim1zwv5sSP+9ufvKD/y
xaiigDY+GSqnw20IKoUfZ+gGO5rl/gwSH8VoOEXUztXsM5ziiigCpo8EK/GZ5xEgma/vlaQKNxAh
iwM1Z+LUUcmraSXjViIJMbhn+OOiigD1Zfuj6UtFFADWVW4ZQQDnkdx0p1FFACGkoopMB1FFFMAo
oooAKTvRRQAn8X4Udx9KKKAF7UUUUAFIaKKAFHSloooAKKKKAP/Z";
/// <summary>
/// Arama kutusunun boş olup olmadığı kontrol edilir. Boş ise veritabanındaki tüm veriler listelenir.
/// Değilse girilen yazıyı içeren ürünler bulunur.
/// </summary>
private void aratext_TextChanged(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(arabox.Text) == false)
{
araboxresult.Items.Clear();
foreach (string str in searchname)
{
if (str.ToLower().Contains(arabox.Text))
{
araboxresult.Items.Add(str);
}
}
}
else if (arabox.Text == "")
{
araboxresult.Items.Clear();
foreach (string str in searchname)
{
araboxresult.Items.Add(str);
}
}
}
/// <summary>
/// Anlık ekrana basmak için ürün urunimg değişkeninde tutulur.
/// Dolar ve euro kurları program açılırken merkez bankasından alınıp değişkene atanır.
/// </summary>
public string urunid;
public byte[] urunimg;
public float dolar;
public float euro;
/// <summary>
/// Kayıt edilen veritabanı bilgileri ile seçilen ada sahip ürünün bilgileri çekilir.
/// Çekilen veriler textbox ve picturebox'a yazılır. Fiyat boş ise 0, değilse ürünün fiyatı yazdırılır.
/// </summary>
private void dataselectbut_Click(object sender, EventArgs e)
{
try
{
string db = "server=" + dbip + "; uid=" + dbuser + "; pwd=" + dbpass + "; database=" + dbname + ";";
string selecturunname = araboxresult.SelectedItem.ToString();
string urunsorgu = "SELECT * FROM products WHERE name='" + selecturunname + "'";
MySqlConnection baglanti = new MySqlConnection(db);
MySqlCommand uruncek = new MySqlCommand();
baglanti.Open();
uruncek.Connection = baglanti;
uruncek.CommandText = urunsorgu;
MySqlDataReader result = uruncek.ExecuteReader();
result.Read();
byte[] img;
long size = result.GetBytes(2, 0, null, 0, 0);
img = new byte[size];
result.GetBytes(2, 0, img, 0, img.Length);
MemoryStream ms = new MemoryStream(img);
pictureBox1.Image = Image.FromStream(ms);
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
urunid = result.GetString(0);
namebox.Text = result.GetString(1);
urunimg = img;
bradbox.Text = result.GetString(3);
categorybox.Text = result.GetString(4);
shoeupperbox.Text = result.GetString(5);
airliningbox.Text = result.GetString(6);
innersolebox.Text = result.GetString(7);
midsolebox.Text = result.GetString(8);
outsolebox.Text = result.GetString(9);
outsolefeaturesbox.Text = result.GetString(10);
toeprotectbox.Text = result.GetString(11);
sizerangebox.Text = result.GetString(12);
if (result.IsDBNull(13))
{
priceboxtl.Text = "0";
}
else
{
priceboxtl.Text = result.GetString(13);
}
result.Close();
}
catch (Exception hata)
{
MessageBox.Show(hata.ToString(), "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
/// <summary>
/// Form yüklenirken boyut ayarları yapılır. Veritabanına bağlanarak tüm ürün adları arama listesine eklenir.
/// Dolar ve euro kuru program başlangıcında merkez bankasından alınarak gerekli değişkenlere atanır.
/// </summary>
private void Form1_Load(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.FixedSingle;
try
{
string db = "server=" + dbip + "; uid=" + dbuser + "; pwd=" + dbpass + "; database=" + dbname + ";";
MySqlConnection baglanti = new MySqlConnection(db);
MySqlCommand komut = new MySqlCommand();
baglanti.Open();
string tumurunlersorgu = "SELECT name FROM products";
komut.CommandText = tumurunlersorgu;
komut.Connection = baglanti;
MySqlDataReader result = komut.ExecuteReader();
while (result.Read())
{
searchname.Add(result.GetString("name"));
araboxresult.Items.Add(result.GetString("name"));
}
}
catch (Exception)
{
MessageBox.Show("Veritabanına Bağlanırken Hata Oluştu!", "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("https://www.tcmb.gov.tr/kurlar/today.xml");
XmlNodeList names = xmlDoc.GetElementsByTagName("Isim");
XmlNodeList currency = xmlDoc.GetElementsByTagName("BanknoteSelling");
for (int i = 0; i < names.Count; i++)
{
if (names[i].InnerText == "ABD DOLARI")
{
dolar = float.Parse(currency[i].InnerText, CultureInfo.InvariantCulture.NumberFormat);
}
if (names[i].InnerText == "EURO")
{
euro = float.Parse(currency[i].InnerText, CultureInfo.InvariantCulture.NumberFormat);
}
}
}
catch (Exception)
{
MessageBox.Show("KUR BİLGİLERİ ALINAMIYOR!");
}
}
/// <summary>
/// Excel oluşturulması için kullanılan buton.
/// </summary>
private void exportexcel_Click(object sender, EventArgs e)
{
// Butona basıldıktan sonra dosyayı kaydet seçeneği tıklanıp tıklanmadığı kontrol edilir.
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
string filename = saveFileDialog.FileName;
//Page 1 adında bir çalışma sayfası oluşturulur.
var wb = new XLWorkbook();
var ws = wb.Worksheets.Add("Page 1");
//Sayfa boyutu ve boşlukları ayarlanır.
ws.PageSetup.PaperSize = XLPaperSize.A4Paper;
ws.PageSetup.Margins.Top = 0.751;
ws.PageSetup.Margins.Left = 0.70;
ws.PageSetup.Margins.Bottom = 0.751;
ws.PageSetup.Margins.Right = 0.70;
ws.PageSetup.Margins.Header = 0.3;
ws.PageSetup.Margins.Footer = 0.3;
//Sütun ve satır boyutları ayarlanır.
ws.Columns().Width = 8.43;
ws.Rows().Height = 15;
ws.Column(5).Width = 11.29;
//Logo base64'ten bitmap'e dönüştürülür.
byte[] imageBytes = Convert.FromBase64String(logo);
var logoimg = new MemoryStream(imageBytes, 0, imageBytes.Length);
Bitmap logobmp = new Bitmap(logoimg);
//Ürünler döngü ile excel'e aktarılır.
int satir = 0;
for (int i = 0; i < name.Count; i++)
{
//Sayfada 3 ürün bulunduğundan sayfa başında olması için 3 üründe bir şirket logosu eklenir.
if (i % 3 == 0)
{
if (i > 2)
{
satir += 5;
}
//Logo ve yazının arkasındaki hücreler seçilir.
var logoarka = ws.Range(2 + satir, 1, 4 + satir, 3);
var officalarka = ws.Range(2 + satir, 4, 4 + satir, 9);
//Logo x=4, y=11 piksel soldan, x=-4, y=-11 piksel sağdan küçültülür. (Sağ taraf eksili olmalı)
ws.AddPicture(logobmp, "logo-" + (i + 1) + ".jpg").MoveTo(ws.Cell(2 + satir, 1), 4, 11, ws.Cell(5 + satir, 4), -4, -11);
logoarka.Merge();
//Yazı arkaplanındaki hücreler birleştirilir. Yazı kalın ve 18 punto yapılır.
//Dikey olarak ortalanır yatayda sağa yaslanır.
officalarka.Merge().Value = "OFFICAL PRICE OFFER";
officalarka.Style.Font.Bold = true;
officalarka.Style.Font.FontSize = 18;
officalarka.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
officalarka.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right);
}
//Veri girilecek hücreler seçilerek değişkene atanır. Satır değişkeni her veri girildikten sonra
//gerçekleşecek artışı ekler.
var urunbaslik = ws.Range(6 + satir, 1, 7 + satir, 9);
var resimarka = ws.Range(8 + satir, 1, 19 + satir, 4);
var enisoyazi = ws.Range(8 + satir, 5, 8 + satir, 9);
var categoryicer = ws.Range(9 + satir, 6, 9 + satir, 9);
var shoeuppericer = ws.Range(10 + satir, 6, 10 + satir, 9);
var liningicer = ws.Range(11 + satir, 6, 11 + satir, 9);
var innersolicer = ws.Range(12 + satir, 6, 12 + satir, 9);
var midsolicer = ws.Range(13 + satir, 6, 13 + satir, 9);
var outsolicer = ws.Range(14 + satir, 6, 14 + satir, 9);
var outsolefeaicer = ws.Range(15 + satir, 6, 15 + satir, 9);
var toeproticer = ws.Range(16 + satir, 6, 16 + satir, 9);
var sizerngicer = ws.Range(17 + satir, 6, 17 + satir, 9);
var priceicer = ws.Range(18 + satir, 5, 19 + satir, 9);
var categoryyazi = ws.Cell(9 + satir, 5);
var shoeupperyazi = ws.Cell(10 + satir, 5);
var liningyazi = ws.Cell(11 + satir, 5);
var innersoleyazi = ws.Cell(12 + satir, 5);
var midsoleyazi = ws.Cell(13 + satir, 5);
var outsoleyazi = ws.Cell(14 + satir, 5);
var outsolefeatyazi = ws.Cell(15 + satir, 5);
var toeprotectyazi = ws.Cell(16 + satir, 5);
var sizerangeyazi = ws.Cell(17 + satir, 5);
//Ürün başlığı için seçilen hücreler birleştirilir ve listeden "i" sırasındaki eleman hücreye yazdırılır.
//Kalın ve 16 punto yazıya çevrilir. Dikey ve yatay olarak ortalanıp ince çerçeve eklenir.
urunbaslik.Merge().Value = name[i];
urunbaslik.Style.Font.Bold = true;
urunbaslik.Style.Font.FontSize = 16;
urunbaslik.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
urunbaslik.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
urunbaslik.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
resimarka.Merge();
resimarka.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
resimarka.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
resimarka.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
//Ürün resmi listeden stream olarak alınır. Soldan x=10,y=1, sağdan x=-10,x=-1 olarak küçültülür.
var ms = new MemoryStream(picture[i]);
Bitmap bitmap = new Bitmap(ms);
ws.AddPicture(bitmap, i + ".jpg").MoveTo(ws.Cell(8 + satir, 1), 10, 1, ws.Cell(20 + satir, 5), -10, -1);
enisoyazi.Merge().Value = "EN ISO 20345:2011";
enisoyazi.Style.Font.Bold = true;
enisoyazi.Style.Font.FontSize = 11;
enisoyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
enisoyazi.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
enisoyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
categoryyazi.Value = "Category:";
categoryyazi.Style.Font.Bold = true;
categoryyazi.Style.Font.FontSize = 9;
categoryyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
categoryyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
categoryicer.Merge().Value = category[i];
categoryicer.Style.Font.FontSize = 9;
categoryicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
categoryicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
categoryicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
shoeupperyazi.Value = "Shoe Upper:";
shoeupperyazi.Style.Font.Bold = true;
shoeupperyazi.Style.Font.FontSize = 9;
shoeupperyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
shoeupperyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
shoeuppericer.Merge().Value = shoeupper[i];
shoeuppericer.Style.Font.FontSize = 9;
shoeuppericer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
shoeuppericer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
shoeuppericer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
liningyazi.Value = "Lining:";
liningyazi.Style.Font.Bold = true;
liningyazi.Style.Font.FontSize = 9;
liningyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
liningyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
liningicer.Merge().Value = airlining[i];
liningicer.Style.Font.FontSize = 9;
liningicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
liningicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
liningicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
innersoleyazi.Value = "Inner Sole:";
innersoleyazi.Style.Font.Bold = true;
innersoleyazi.Style.Font.FontSize = 9;
innersoleyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
innersoleyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
innersolicer.Merge().Value = innersole[i];
innersolicer.Style.Font.FontSize = 9;
innersolicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
innersolicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
innersolicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
midsoleyazi.Value = "Midsole:";
midsoleyazi.Style.Font.Bold = true;
midsoleyazi.Style.Font.FontSize = 9;
midsoleyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
midsoleyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
midsolicer.Merge().Value = midsole[i];
midsolicer.Style.Font.FontSize = 9;
midsolicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
midsolicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
midsolicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
outsoleyazi.Value = "Outsole:";
outsoleyazi.Style.Font.Bold = true;
outsoleyazi.Style.Font.FontSize = 9;
outsoleyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
outsoleyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
outsolicer.Merge().Value = outsole[i];
outsolicer.Style.Font.FontSize = 9;
outsolicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
outsolicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
outsolicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
outsolefeatyazi.Value = "Outsole Features:";
outsolefeatyazi.Style.Font.Bold = true;
outsolefeatyazi.Style.Font.FontSize = 9;
outsolefeatyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
outsolefeatyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
outsolefeaicer.Merge().Value = outsolefea[i];
outsolefeaicer.Style.Font.FontSize = 9;
outsolefeaicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
outsolefeaicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
outsolefeaicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
toeprotectyazi.Value = "Toe Protection:";
toeprotectyazi.Style.Font.Bold = true;
toeprotectyazi.Style.Font.FontSize = 9;
toeprotectyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
toeprotectyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
toeproticer.Merge().Value = toeprotect[i];
toeproticer.Style.Font.FontSize = 9;
toeproticer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
toeproticer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
toeproticer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
sizerangeyazi.Value = "Size Range:";
sizerangeyazi.Style.Font.Bold = true;
sizerangeyazi.Style.Font.FontSize = 9;
sizerangeyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
sizerangeyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
sizerngicer.Merge().Value = sizerange[i];
sizerngicer.Style.Font.FontSize = 9;
sizerngicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
sizerngicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
sizerngicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
priceicer.Merge().Value = "PRICE" + Environment.NewLine + price[i];
priceicer.Style.Font.Bold = true;
priceicer.Style.Font.FontSize = 11;
priceicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Top);
priceicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
priceicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
satir += 15;
}
//Çalışma kitabı dosyaya kayıt edilmeye çalışılır. Dosya bulunuyorsa veya yazma izni yoksa hata çıktılanır.
//Kayıt edilirse işlemin başarılı olduğuyla ilgili uyarı çıktılanır.
try
{
wb.SaveAs(filename);
}
catch (Exception)
{
MessageBox.Show("Dosya Oluşturulamadı!", "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
MessageBox.Show("Dosya Kaydedildi!", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
/// <summary>
/// Ürün ekle butonuna basıldıktan sonra dolar veya euro kurlarından birinin seçilip seçilmediği kontrol edilir.
/// Eğer ikiside seçilmediyse hata mesajı çıktılanır.
/// Tüm veriler düzenlendikten sonra textbox'lar ve picturebox'taki bilgiler gerekli listelere eklenir.
/// Ekli ürün listesi güncellenir.
/// </summary>
private void uruneklebutton_Click(object sender, EventArgs e)
{
if (euroradio.Checked == true)
{
price.Add(priceboxeuro.Text + " EUR");
}
else if (dolarradio.Checked == true)
{
price.Add(priceboxdolar.Text + " USD");
}
else
{
MessageBox.Show("Bir Fiyat Birimi Seçin!", "Hata!");
return;
}
productid.Add(urunid);
name.Add(namebox.Text);
picture.Add(urunimg);
brad.Add(bradbox.Text);
category.Add(categorybox.Text);
shoeupper.Add(shoeupperbox.Text);
airlining.Add(airliningbox.Text);
innersole.Add(innersolebox.Text);
midsole.Add(midsolebox.Text);
outsole.Add(outsolebox.Text);
outsolefea.Add(outsolefeaturesbox.Text);
toeprotect.Add(toeprotectbox.Text);
sizerange.Add(sizerangebox.Text);
ekliurunlistesi.Items.Add(namebox.Text);
}
/// <summary>
/// Alınan kur bilgilerine göre girilen TL fiyatı üzerinden hesap yapılır.
/// Virgülden sonra 2. basamağa kadar yuvarlanır. TL değeri yoksa hata çıktılanır.
/// </summary>
private void kurbuton_Click(object sender, EventArgs e)
{
try
{
float tlfiyat = float.Parse(priceboxtl.Text, CultureInfo.InvariantCulture.NumberFormat);
priceboxeuro.Text = Convert.ToString(Math.Round(tlfiyat / euro, 2));
priceboxdolar.Text = Convert.ToString(Math.Round(tlfiyat / dolar, 2));
}
catch (Exception)
{
MessageBox.Show("TL Değeri Girin!", "Hata");
}
}
/// <summary>
/// PDF oluşturulması için kullanılan buton. Excel için kullanılan butondaki işlemlerin aynısı yapar.
/// Ayarları birbirinden bağımsızdır. Birisinde değiştirilen ayar diğerinde yapılması isteniyorsa orada da değiştirilmelidir.
/// Fonksiyon geçici bir excel oluşturup excel'den yararlanarak PDF dönüşümü sağlar.
/// Bilgisayarda yüklü bir 2007 ve sonrası excel sürümü gerektirir.
/// </summary>
private void exportpdf_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
string filename = saveFileDialog1.FileName;
var wb = new XLWorkbook();
var ws = wb.Worksheets.Add("Page 1");
ws.PageSetup.PaperSize = XLPaperSize.A4Paper;
ws.PageSetup.Margins.Top = 0.751;
ws.PageSetup.Margins.Left = 0.70;
ws.PageSetup.Margins.Bottom = 0.751;
ws.PageSetup.Margins.Right = 0.70;
ws.PageSetup.Margins.Header = 0.3;
ws.PageSetup.Margins.Footer = 0.3;
ws.Columns().Width = 8.43;
ws.Rows().Height = 15;
ws.Column(5).Width = 11.29;
byte[] imageBytes = Convert.FromBase64String(logo);
var logoimg = new MemoryStream(imageBytes, 0, imageBytes.Length);
Bitmap logobmp = new Bitmap(logoimg);
int satir = 0;
for (int i = 0; i < name.Count; i++)
{
if (i % 3 == 0)
{
if (i > 2)
{
satir += 5;
}
var logoarka = ws.Range(2 + satir, 1, 4 + satir, 3);
var officalarka = ws.Range(2 + satir, 4, 4 + satir, 9);
ws.AddPicture(logobmp, "logo-" + (i + 1) + ".jpg").MoveTo(ws.Cell(2 + satir, 1), 4, 11, ws.Cell(5 + satir, 4), -4, -11);
logoarka.Merge();
officalarka.Merge().Value = "OFFICAL PRICE OFFER";
officalarka.Style.Font.Bold = true;
officalarka.Style.Font.FontSize = 18;
officalarka.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
officalarka.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right);
}
var urunbaslik = ws.Range(6 + satir, 1, 7 + satir, 9);
var resimarka = ws.Range(8 + satir, 1, 19 + satir, 4);
var enisoyazi = ws.Range(8 + satir, 5, 8 + satir, 9);
var categoryicer = ws.Range(9 + satir, 6, 9 + satir, 9);
var shoeuppericer = ws.Range(10 + satir, 6, 10 + satir, 9);
var liningicer = ws.Range(11 + satir, 6, 11 + satir, 9);
var innersolicer = ws.Range(12 + satir, 6, 12 + satir, 9);
var midsolicer = ws.Range(13 + satir, 6, 13 + satir, 9);
var outsolicer = ws.Range(14 + satir, 6, 14 + satir, 9);
var outsolefeaicer = ws.Range(15 + satir, 6, 15 + satir, 9);
var toeproticer = ws.Range(16 + satir, 6, 16 + satir, 9);
var sizerngicer = ws.Range(17 + satir, 6, 17 + satir, 9);
var priceicer = ws.Range(18 + satir, 5, 19 + satir, 9);
var categoryyazi = ws.Cell(9 + satir, 5);
var shoeupperyazi = ws.Cell(10 + satir, 5);
var liningyazi = ws.Cell(11 + satir, 5);
var innersoleyazi = ws.Cell(12 + satir, 5);
var midsoleyazi = ws.Cell(13 + satir, 5);
var outsoleyazi = ws.Cell(14 + satir, 5);
var outsolefeatyazi = ws.Cell(15 + satir, 5);
var toeprotectyazi = ws.Cell(16 + satir, 5);
var sizerangeyazi = ws.Cell(17 + satir, 5);
urunbaslik.Merge().Value = name[i];
urunbaslik.Style.Font.Bold = true;
urunbaslik.Style.Font.FontSize = 16;
urunbaslik.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
urunbaslik.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
urunbaslik.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
resimarka.Merge();
resimarka.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
resimarka.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
resimarka.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
var ms = new MemoryStream(picture[i]);
Bitmap bitmap = new Bitmap(ms);
ws.AddPicture(bitmap, i + ".jpg").MoveTo(ws.Cell(8 + satir, 1), 10, 2, ws.Cell(20 + satir, 5), -10, -2);
enisoyazi.Merge().Value = "EN ISO 20345:2011";
enisoyazi.Style.Font.Bold = true;
enisoyazi.Style.Font.FontSize = 11;
enisoyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
enisoyazi.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
enisoyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
categoryyazi.Value = "Category:";
categoryyazi.Style.Font.Bold = true;
categoryyazi.Style.Font.FontSize = 9;
categoryyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
categoryyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
categoryicer.Merge().Value = category[i];
categoryicer.Style.Font.FontSize = 9;
categoryicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
categoryicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
categoryicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
shoeupperyazi.Value = "Shoe Upper:";
shoeupperyazi.Style.Font.Bold = true;
shoeupperyazi.Style.Font.FontSize = 9;
shoeupperyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
shoeupperyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
shoeuppericer.Merge().Value = shoeupper[i];
shoeuppericer.Style.Font.FontSize = 9;
shoeuppericer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
shoeuppericer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
shoeuppericer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
liningyazi.Value = "Lining:";
liningyazi.Style.Font.Bold = true;
liningyazi.Style.Font.FontSize = 9;
liningyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
liningyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
liningicer.Merge().Value = airlining[i];
liningicer.Style.Font.FontSize = 9;
liningicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
liningicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
liningicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
innersoleyazi.Value = "Inner Sole:";
innersoleyazi.Style.Font.Bold = true;
innersoleyazi.Style.Font.FontSize = 9;
innersoleyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
innersoleyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
innersolicer.Merge().Value = innersole[i];
innersolicer.Style.Font.FontSize = 9;
innersolicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
innersolicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
innersolicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
midsoleyazi.Value = "Midsole:";
midsoleyazi.Style.Font.Bold = true;
midsoleyazi.Style.Font.FontSize = 9;
midsoleyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
midsoleyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
midsolicer.Merge().Value = midsole[i];
midsolicer.Style.Font.FontSize = 9;
midsolicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
midsolicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
midsolicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
outsoleyazi.Value = "Outsole:";
outsoleyazi.Style.Font.Bold = true;
outsoleyazi.Style.Font.FontSize = 9;
outsoleyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
outsoleyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
outsolicer.Merge().Value = outsole[i];
outsolicer.Style.Font.FontSize = 9;
outsolicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
outsolicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
outsolicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
outsolefeatyazi.Value = "Outsole Features:";
outsolefeatyazi.Style.Font.Bold = true;
outsolefeatyazi.Style.Font.FontSize = 9;
outsolefeatyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
outsolefeatyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
outsolefeaicer.Merge().Value = outsolefea[i];
outsolefeaicer.Style.Font.FontSize = 9;
outsolefeaicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
outsolefeaicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
outsolefeaicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
toeprotectyazi.Value = "Toe Protection:";
toeprotectyazi.Style.Font.Bold = true;
toeprotectyazi.Style.Font.FontSize = 9;
toeprotectyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
toeprotectyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
toeproticer.Merge().Value = toeprotect[i];
toeproticer.Style.Font.FontSize = 9;
toeproticer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
toeproticer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
toeproticer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
sizerangeyazi.Value = "Size Range:";
sizerangeyazi.Style.Font.Bold = true;
sizerangeyazi.Style.Font.FontSize = 9;
sizerangeyazi.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom);
sizerangeyazi.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
sizerngicer.Merge().Value = sizerange[i];
sizerngicer.Style.Font.FontSize = 9;
sizerngicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Center);
sizerngicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left);
sizerngicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
priceicer.Merge().Value = "PRICE" + Environment.NewLine + price[i];
priceicer.Style.Font.Bold = true;
priceicer.Style.Font.FontSize = 11;
priceicer.Style.Alignment.SetVertical(XLAlignmentVerticalValues.Top);
priceicer.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
priceicer.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
satir += 15;
}
wb.SaveAs("temp.xlsx");
var CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
Microsoft.Office.Interop.Excel.Application excelApplication;
Microsoft.Office.Interop.Excel.Workbook excelWorkbook;
excelApplication = new Microsoft.Office.Interop.Excel.Application();
excelApplication.ScreenUpdating = false;
excelApplication.DisplayAlerts = false;
excelWorkbook = excelApplication.Workbooks.Open(CurrentDirectory + "/temp.xlsx");
if (excelWorkbook == null)
{
excelApplication.Quit();
excelApplication = null;
excelWorkbook = null;
MessageBox.Show("PDF Oluşturulamadı!" + Environment.NewLine + "Tekrar Deneyin!", "HATA!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
excelWorkbook.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, filename);
}
catch (Exception)
{
MessageBox.Show("PDF Oluşturulamadı!" + Environment.NewLine + "Tekrar Deneyin!", "HATA!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
excelWorkbook.Close();
excelApplication.Quit();
excelApplication = null;
excelWorkbook = null;
}
//Geçici olarak oluşturulan excel dosyası silinir.
File.Delete("temp.xlsx");
//Dosya oluşturuldu ve ulaşılabilir ise dosyayı açar.
if (File.Exists(filename))
{
System.Diagnostics.Process.Start(filename);
}
}
}
//Silinecek ürünler deletelist listesine eklenir.
public List<string> deletelist = new List<string>();
/// <summary>
/// Sil butonuna basıldığında seçili olan ürünler listeye eklenir.
/// Referans olması için "name" listesindeki index'i bulunur.
/// Ardından bu indexe sahip ürün tüm listelerden silinir.
/// </summary>
private void urunsil_Click(object sender, EventArgs e)
{
try
{
foreach (var item in ekliurunlistesi.SelectedItems)
{
deletelist.Add(item.ToString());
}
for (int a = 0; a<deletelist.Count;a++) {
string silinecekurunadi = deletelist[a].ToString();
int index = name.IndexOf(silinecekurunadi);
ekliurunlistesi.Items.Remove(silinecekurunadi);
productid.RemoveAt(index);
name.RemoveAt(index);
picture.RemoveAt(index);
brad.RemoveAt(index);
category.RemoveAt(index);
shoeupper.RemoveAt(index);
airlining.RemoveAt(index);
innersole.RemoveAt(index);
midsole.RemoveAt(index);
outsole.RemoveAt(index);
outsolefea.RemoveAt(index);
toeprotect.RemoveAt(index);
sizerange.RemoveAt(index);
price.RemoveAt(index);
}
deletelist.Clear();
}
catch (Exception)
{
MessageBox.Show("Ürün Listesinde Ürün Bulunmuyor veya Ürün Seçmediniz!", "HATA", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
//Veritabanı bilgileri girilmesi için gereken formu açar.
private void veritabaniformac_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Show();
}
}
}