-
Notifications
You must be signed in to change notification settings - Fork 0
/
BLayer.cs
555 lines (548 loc) · 23 KB
/
BLayer.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using Web_Misthodosia_Opliton;
namespace Web_Misthodosia_Opliton
{
public class BLayer
{
public BLayer() { }
public decimal anadromikaCalcLogoKatigorias(Oplitis myOplitis)
{
Katigoria myKatigoria = new Katigoria();
Change myChange = new Change();
BLayer myBlayer = new BLayer();
myKatigoria = myBlayer.get_diafora_posou(myOplitis);
decimal poso = myKatigoria.katDiafora;
myChange = myBlayer.getChangeById(myOplitis);
DateTime isxysMetabolis = myChange.changeIsxysDate;
DateTime metaboliDate = myChange.changeDate;
int monthIsxys = isxysMetabolis.Month;
int monthMetaboli = metaboliDate.Month;
int diafora = monthMetaboli - monthIsxys;
decimal anadromika = poso * diafora;
return anadromika;
}
public decimal anadromikaCalcLogoApousias(Oplitis myOplitis)
{
BLayer myBlayer = new BLayer();
Katigoria category = new Katigoria();
category = myBlayer.get_Katigoria_By_Id(myOplitis);
decimal poso = category.katPliroteo;
Pliromi myPliromi = new Pliromi();
myPliromi = myBlayer.get_Last_Pliromi_By_Opid(myOplitis);
DateTime lastPayDate = myPliromi.PayDay;
DateTime currentDate = DateTime.Now;
int diafora = currentDate.Month - lastPayDate.Month;
decimal anadromika = diafora * poso;
return anadromika;
}
public SqlDataReader get_Dikaiologitika()
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getDikaiologitika();
return dr;
}
public SqlDataReader get_Xrimatikos_Logismos()
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getXrimatikosLogismos();
return dr;
}
public SqlDataReader get_Biblio_Pliromon()
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getBiblioPliromon();
return dr;
}
public Katigoria get_Katigoria_From_Dikaiologitika()
{
Dal myDal = new Dal();
Katigoria myKatigoria = new Katigoria();
DataTable dt = new DataTable();
SqlDataReader dr = myDal.getDikaiologitikaFromKatigoria();
if (dr.HasRows)
{
dt.Load(dr);
}
foreach (DataRow row in dt.Rows)
{
myKatigoria.katPerigrafi = row["kat_name"].ToString();
myKatigoria.katKatalogisteo = Convert.ToDecimal(row["kat_katalogisteo"].ToString());
myKatigoria.katKratiseis = Convert.ToDecimal(row["kat_kratiseis"].ToString());
myKatigoria.katPliroteo = Convert.ToDecimal(row["kat_pliroteo"].ToString());
myKatigoria.katDXmas = Convert.ToDecimal(row["kat_dx"].ToString());
myKatigoria.katDPasxa = Convert.ToDecimal(row["kat_dp"].ToString());
}
return myKatigoria;
}
public void add_Fermena_Dikaiologitika(Dikaiologitika FermenaDik)
{
Dal myDal = new Dal();
myDal.insertFermenaDikaiologitika(FermenaDik);
}
public void add_Pliromi(Pliromi myPliromi)
{
Dal myDal = new Dal();
myDal.insertPliromi(myPliromi);
}
public SqlDataReader get_Katigoria()
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getKatigoria();
return dr;
}
public SqlDataReader get_Diagrammenos_Oplitis()
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getDiagrammenosOplitis();
return dr;
}
public SqlDataReader get_Katigoria_From_Change(Oplitis fantaros)
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getKatigoriaFromChange(fantaros);
return dr;
}
public SqlDataReader get_Oplitis()
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getOplitis();
return dr;
}
public Katigoria get_Katigoria_By_Id(Oplitis myOplitis)
{
Dal myDal = new Dal();
Katigoria myKatigoria = new Katigoria();
DataTable dt = new DataTable();
SqlDataReader dr = myDal.getKatigoriaById(myOplitis);
if (dr.HasRows)
{
dt.Load(dr);
}
foreach (DataRow row in dt.Rows)
{
myKatigoria.katPerigrafi = row["kat_name"].ToString();
myKatigoria.katKatalogisteo = Convert.ToDecimal(row["kat_katalogisteo"].ToString());
myKatigoria.katKratiseis = Convert.ToDecimal(row["kat_kratiseis"].ToString());
myKatigoria.katPliroteo = Convert.ToDecimal(row["kat_pliroteo"].ToString());
myKatigoria.katDXmas = Convert.ToDecimal(row["kat_dx"].ToString());
myKatigoria.katDPasxa = Convert.ToDecimal(row["kat_dp"].ToString());
}
return myKatigoria;
}
public Oplitis get_Last_Inserted_Oplitis()
{
Dal myDal = new Dal();
Oplitis myOplitis = new Oplitis();
DataTable dt = new DataTable();
SqlDataReader dr = myDal.getLastInsertedOplitis();
if (dr.HasRows)
{
dt.Load(dr);
}
foreach (DataRow row in dt.Rows)
{
myOplitis.id = Convert.ToInt32(row["op_id"].ToString());
myOplitis.katigoria = row["kat_name"].ToString();
myOplitis.bathmos = row["r_perigrafi"].ToString();
myOplitis.eponymo = row["op_eponymo"].ToString();
myOplitis.onoma = row["op_onoma"].ToString();
myOplitis.eggrafi = Convert.ToDateTime(row["op_eggrafi"].ToString());
myOplitis.asm = Convert.ToInt32(row["op_asm"].ToString());
myOplitis.loxos = row["op_loxos"].ToString();
myOplitis.paratiriseis = row["op_paratiriseis"].ToString();
myOplitis.katalogisteo = Convert.ToDecimal(row["kat_katalogisteo"].ToString());
myOplitis.kratiseis = Convert.ToDecimal(row["kat_kratiseis"].ToString());
myOplitis.pliroteo = Convert.ToDecimal(row["kat_pliroteo"].ToString());
myOplitis.dXmas = Convert.ToDecimal(row["kat_dx"].ToString());
myOplitis.dPasxa = Convert.ToDecimal(row["kat_dp"].ToString());
myOplitis.fdmDate = Convert.ToDateTime(row["fdmDate"].ToString());
}
return myOplitis;
}
public Pliromi get_Last_Pliromi()
{
Dal myDal = new Dal();
Pliromi myPliromi = new Pliromi();
DataTable dt = new DataTable();
SqlDataReader dr = myDal.getLastPliromi();
if (dr.HasRows)
{
dt.Load(dr);
}
foreach (DataRow row in dt.Rows)
{
myPliromi.Pliromi_opid = Convert.ToInt32(row["op_id"].ToString());
myPliromi.PliromiId = Convert.ToInt32(row["p_id"].ToString());
myPliromi.PayDay = Convert.ToDateTime(row["p_date"].ToString());
myPliromi.p_opasm = Convert.ToInt32(row["op_asm"].ToString());
myPliromi.bathmos = row["r_perigrafi"].ToString();
myPliromi.onoma = row["op_onoma"].ToString();
myPliromi.eponymo = row["op_eponymo"].ToString();
myPliromi.loxos = row["op_loxos"].ToString();
myPliromi.katName = row["kat_name"].ToString();
myPliromi.katalogisteo = Convert.ToDecimal(row["kat_katalogisteo"].ToString());
myPliromi.kratiseis = Convert.ToDecimal(row["kat_kratiseis"].ToString());
myPliromi.pliroteo = Convert.ToDecimal(row["kat_pliroteo"].ToString());
myPliromi.mPerigrafi = row["m_perigrafi"].ToString();
float temp = Convert.ToSingle(row["p_posoPliromis"].ToString());
myPliromi.Poso = Convert.ToDecimal(temp);
}
return myPliromi;
}
public Pliromi get_Last_Pliromi_By_Opid(Oplitis myOplitis)
{
Dal myDal = new Dal();
Pliromi myPliromi = new Pliromi();
DataTable dt = new DataTable();
SqlDataReader dr = myDal.getLastPliromiByOpid(myOplitis);
if (dr.HasRows)
{
dt.Load(dr);
}
foreach (DataRow row in dt.Rows)
{
myPliromi.Pliromi_opid = Convert.ToInt32(row["op_id"].ToString());
myPliromi.PliromiId = Convert.ToInt32(row["p_id"].ToString());
myPliromi.PayDay = Convert.ToDateTime(row["p_date"].ToString());
myPliromi.p_opasm = Convert.ToInt32(row["op_asm"].ToString());
myPliromi.bathmos = row["r_perigrafi"].ToString();
myPliromi.onoma = row["op_onoma"].ToString();
myPliromi.eponymo = row["op_eponymo"].ToString();
myPliromi.loxos = row["op_loxos"].ToString();
myPliromi.katName = row["kat_name"].ToString();
myPliromi.katalogisteo = Convert.ToDecimal(row["kat_katalogisteo"].ToString());
myPliromi.kratiseis = Convert.ToDecimal(row["kat_kratiseis"].ToString());
myPliromi.pliroteo = Convert.ToDecimal(row["kat_pliroteo"].ToString());
myPliromi.mPerigrafi = row["m_perigrafi"].ToString();
if (string.IsNullOrEmpty(row["p_posoPliromis"].ToString()))
{
myPliromi.Poso = Convert.ToDecimal("0,00");
}
else
myPliromi.Poso = Convert.ToDecimal(row["p_posoPliromis"].ToString());
}
return myPliromi;
}
public Oplitis get_last_updated_oplitis()
{
Dal myDal = new Dal();
Oplitis myOplitis = new Oplitis();
DataTable dt = new DataTable();
SqlDataReader dr = myDal.getLastUpdatedOplitis();
if (dr.HasRows)
{
dt.Load(dr);
}
foreach (DataRow row in dt.Rows)
{
myOplitis.id = Convert.ToInt32(row["op_id"].ToString());
myOplitis.katigoria = row["kat_name"].ToString();
myOplitis.bathmos = row["r_perigrafi"].ToString();
myOplitis.eponymo = row["op_eponymo"].ToString();
myOplitis.onoma = row["op_onoma"].ToString();
myOplitis.asm = Convert.ToInt32(row["op_asm"].ToString());
myOplitis.loxos = row["op_loxos"].ToString();
myOplitis.paratiriseis = row["op_paratiriseis"].ToString();
myOplitis.katalogisteo = Convert.ToDecimal(row["kat_katalogisteo"].ToString());
myOplitis.kratiseis = Convert.ToDecimal(row["kat_kratiseis"].ToString());
myOplitis.pliroteo = Convert.ToDecimal(row["kat_pliroteo"].ToString());
myOplitis.dXmas = Convert.ToDecimal(row["kat_dx"].ToString());
myOplitis.dPasxa = Convert.ToDecimal(row["kat_dp"].ToString());
myOplitis.metaboli = Convert.ToDateTime(row["op_metaboli"].ToString());
myOplitis.isxysDate = Convert.ToDateTime(row["c_isxys_date"].ToString());
}
return myOplitis;
}
public SqlDataReader get_last_payment(Oplitis myOplitis)
{
Dal myDal = new Dal();
SqlDataReader myDtr = myDal.getLastPayment(myOplitis);
return myDtr;
}
public SqlDataReader get_Misthodosia()
{
Dal myDal = new Dal();
SqlDataReader myDtr = myDal.getMisthodosia();
return myDtr;
}
public SqlDataReader get_Rank()
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getRank();
return dr;
}
public SqlDataReader get_dikaiologitika_pou_exei_proskomisei()
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getDikaiologitikaPouExeiProskomisei();
return dr;
}
public SqlDataReader get_dikaiologitika_pou_exei_proskomisei_by_id(Oplitis myOplitis)
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getDikaiologitikaPouExeiProskomiseiById(myOplitis);
return dr;
}
public SqlDataReader get_pliromi_diagrammenou_opliti_by_id_opliti(Oplitis myOplitis)
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getPliromiDiagarammenouOplitiByIdOpliti(myOplitis);
return dr;
}
public Katigoria get_diafora_posou(Oplitis myOplitis)
{
Dal myDal = new Dal();
Katigoria myKatigoria = new Katigoria();
SqlDataReader dr = myDal.getDiaforaPosou(myOplitis);
DataTable dt = new DataTable();
if (dr.HasRows)
{
dt.Load(dr);
}
foreach (DataRow row in dt.Rows)
{
myKatigoria.katDiafora = Convert.ToDecimal(row["diafora"].ToString());
myKatigoria.katPliroteoNew = Convert.ToDecimal(row["katPliroteo_new"].ToString());
myKatigoria.katPliroteoOld = Convert.ToDecimal(row["katPliroteo_old"].ToString());
myKatigoria.newKatName = row["katName_new"].ToString();
myKatigoria.oldKatName = row["katName_old"].ToString();
}
return myKatigoria;
}
public void addOplitis(Oplitis fantaros)
{
Dal myDal = new Dal();
myDal.insertOplitis(fantaros);
}
public void deleteOplitis(Oplitis fantaros)
{
Dal myDal = new Dal();
myDal.deleteOplitis(fantaros);
}
public void updateOplitis(Oplitis fantaros)
{
Dal myDal = new Dal();
myDal.updateOplitis(fantaros);
}
public List<Katigoria> getMoney()
{
Dal myDal = new Dal();
DataTable dt = new DataTable();
List<Katigoria> category = new List<Katigoria>();
SqlDataReader mSq = myDal.getMoney();
if (mSq.HasRows)
{
dt.Load(mSq);
}
foreach (DataRow dr in dt.Rows)
{
Katigoria myKatigoria = new Katigoria();
myKatigoria.katId = Convert.ToInt32(dr["kat_id"].ToString());
myKatigoria.katPerigrafi = dr["kat_name"].ToString();
myKatigoria.katKatalogisteo = Convert.ToDecimal(dr["kat_katalogisteo"].ToString());
myKatigoria.katKratiseis = Convert.ToDecimal(dr["kat_kratiseis"].ToString());
myKatigoria.katPliroteo = Convert.ToDecimal(dr["kat_pliroteo"].ToString());
myKatigoria.katDXmas = Convert.ToDecimal(dr["kat_dx"].ToString());
myKatigoria.katDPasxa = Convert.ToDecimal(dr["kat_dp"].ToString());
category.Add(myKatigoria);
}
return category;
}
public Oplitis getRankById(Oplitis myOplitis)
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getRankByID(myOplitis);
DataTable dt = new DataTable();
if (dr.HasRows)
{
dt.Load(dr);
}
foreach (DataRow row in dt.Rows)
{
myOplitis.rankID = Convert.ToInt32(row["op_rid"].ToString());
}
return myOplitis;
}
public Change getChangeById(Oplitis myOplitis)
{
Dal myDal = new Dal();
Change myChange = new Change();
SqlDataReader dr = myDal.getChangeById(myOplitis);
DataTable dt = new DataTable();
if (dr.HasRows)
{
dt.Load(dr);
}
foreach (DataRow row in dt.Rows)
{
myChange.changeId = Convert.ToInt32(row["c_id"].ToString());
myChange.changeDate = Convert.ToDateTime(row["c_date"].ToString());
myChange.changeOldKatid = Convert.ToInt32(row["kat_id_old"].ToString());
myChange.changeOpid = Convert.ToInt32(row["c_opid"].ToString());
myChange.changeIsxysDate = Convert.ToDateTime(row["c_isxysDate"].ToString());
}
return myChange;
}
public SqlDataReader get_last_updated_oplitis_dik(Oplitis myOplitis)
{
Dal myDal = new Dal();
SqlDataReader dr = myDal.getLastUpdatedOplitisDik(myOplitis);
return dr;
}
public Pliromi get_Pliromi_By_Id(Pliromi myPliromi)
{
Dal myDal = new Dal();
Pliromi otherPliromi = new Pliromi();
DataTable dt = new DataTable();
SqlDataReader dr = myDal.getPliromiById(myPliromi);
if (dr.HasRows)
{
dt.Load(dr);
}
foreach (DataRow row in dt.Rows)
{
otherPliromi.Pliromi_opid = Convert.ToInt32(row["op_id"].ToString());
otherPliromi.PliromiId = Convert.ToInt32(row["p_id"].ToString());
otherPliromi.PayDay = Convert.ToDateTime(row["p_date"].ToString());
otherPliromi.p_opasm = Convert.ToInt32(row["op_asm"].ToString());
otherPliromi.bathmos = row["r_perigrafi"].ToString();
otherPliromi.onoma = row["op_onoma"].ToString();
otherPliromi.eponymo = row["op_eponymo"].ToString();
otherPliromi.loxos = row["op_loxos"].ToString();
otherPliromi.katName = row["kat_name"].ToString();
otherPliromi.katalogisteo = Convert.ToDecimal(row["kat_katalogisteo"].ToString());
otherPliromi.kratiseis = Convert.ToDecimal(row["kat_kratiseis"].ToString());
otherPliromi.pliroteo = Convert.ToDecimal(row["kat_pliroteo"].ToString());
otherPliromi.mPerigrafi = row["m_perigrafi"].ToString();
float temp = Convert.ToSingle(row["p_posoPliromis"].ToString());
otherPliromi.Poso = Convert.ToDecimal(temp);
}
return otherPliromi;
}
public int login(string username, string password)
{
Dal myDal = new Dal();
int value = myDal.LogIn(username, password);
return value;
}
public int register(User myUser)
{
Dal myDal = new Dal();
int value = myDal.Register(myUser);
return value;
}
}
public class Date
{
int day, month, year;
public Date(int day, int month, int year)
{
this.day = day;
this.month = month;
this.year = year;
}
public Date myDate(DateTime myDT)
{
day = myDT.Day;
month = myDT.Month;
year = myDT.Year;
Date date = new Date(day,month,year);
return date;
}
public string toString()
{
return day + "/" + month + "/" + year;
}
}
public struct Pliromi
{
public int PliromiId { get; set; }
public DateTime lastPaymentDay { get; set; }
public DateTime PayDay { get; set; }
public decimal Poso { get; set; }
public int pmid { get; set; }
public string bathmos { get; set; }
public string onoma { get; set; }
public string eponymo { get; set; }
public string loxos { get; set; }
public string katName { get; set; }
public decimal katalogisteo { get; set; }
public decimal kratiseis { get; set; }
public decimal pliroteo { get; set; }
public string mPerigrafi { get; set; }
public int p_opasm { get; set; }
public int Pliromi_opid { get; set; }
public bool Paid { get; set; }
}
public struct Dikaiologitika
{
public int id { get; set; }
public string dik_perigrafi { get; set; }
}
public struct Rank
{
public int rankId { get; set; }
public string bathmos_perigrafi { get; set; }
}
public struct Change
{
public int changeId { get; set; }
public DateTime changeDate { get; set; }
public DateTime changeIsxysDate { get; set; }
public int changeOpid { get; set; }
public int changeOldKatid { get; set; }
}
public struct Katigoria
{
public int katId { get; set; }
public string katPerigrafi { get; set; }
public decimal katKatalogisteo { get; set; }
public decimal katKratiseis { get; set; }
public decimal katPliroteo { get; set; }
public decimal katDXmas { get; set; }
public decimal katDPasxa { get; set; }
public decimal katDiafora { get; set; }
public string oldKatName { get; set; }
public string newKatName { get; set; }
public decimal katPliroteoOld { get; set; }
public decimal katPliroteoNew { get; set; }
}
public struct Oplitis
{
public int id { get; set; }
public int asm { get; set; }
public string onoma { get; set; }
public string eponymo { get; set; }
public string loxos { get; set; }
public DateTime eggrafi { get; set; }
public DateTime diagrafi { get; set; }
public string paratiriseis { get; set; }
public string bathmos { get; set; }
public string katigoria { get; set; }
public DateTime metaboli { get; set; }
public DateTime lastPayDay { get; set; }
public decimal katalogisteo { get; set; }
public decimal kratiseis { get; set; }
public decimal pliroteo { get; set; }
public decimal dXmas { get; set; }
public decimal dPasxa { get; set; }
public DateTime fdmDate { get; set; }
public int rankID { get; set; }
public DateTime isxysDate { get; set; }
public int katigoriaFDM { get; set; }
}
public struct User
{
public string username { get; set; }
public string password { get; set; }
public string userRank { get; set; }
public string userOnoma { get; set; }
public string userEponymo { get; set; }
public string userMonada { get; set; }
}
}