-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormaRezultat.cs
123 lines (123 loc) · 4.69 KB
/
FormaRezultat.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
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;
namespace TestGenerator
{
public partial class FormaRezultat : Form
{
public FormaRezultat()
{
InitializeComponent();
}
private void ButonIesire_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void FormaRezultat_Load(object sender, EventArgs e)
{
float value = (100 / 2) + (100 / (int.Parse(FormaMeniu.Setup[0])));
if (FormaTest.punctaj < 0)
{
FormaTest.punctaj = 0;
}
using (TesteDBEntities db = new TesteDBEntities())
{
#region Adauga informatiile rezultatului
var info = new t_InformatiiRezultate()
{
Data = DateTime.Now,
ID_Cont = FormaLogare.ValoareID,
ID_Capitol = (db.t_Capitole.FirstOrDefault(x => x.Capitol == FormaMeniu.TextCapitol && x.t_Domenii.Domeniu == FormaMeniu.TextDomeniu)).ID_Capitol,
Punctaj = FormaTest.punctaj
};
if (FormaMeniu.ModAddRezultat)
{
if (FormaTest.punctaj >= value)
{
info.Nivel = 2;
}
else
{
info.Nivel = 1;
}
}
else
{
if (FormaTest.punctaj >= value)
{
info.Nivel = FormaMeniu.NivelUltimulRezultat + 1;
}
else
{
info.Nivel = FormaMeniu.NivelUltimulRezultat;
}
}
db.t_InformatiiRezultate.Add(info);
db.SaveChanges();
#endregion
#region Adauga Raspunsurile pe care le-a data utilizatorul
List<t_IntrebariRezultate> Values = db.t_IntrebariRezultate.ToList();
for (int i = 0; i < FormaTest.ListObj.Count; i++)
{
if (Values.Contains(FormaTest.ListObj[i]) == false)
{
db.t_IntrebariRezultate.Add(FormaTest.ListObj[i]);
}
db.SaveChanges();
}
#endregion
#region Adauga rezultatul
foreach (var item in FormaTest.ListObj)
{
db.t_Rezultate.Add(new t_Rezultate()
{
ID_InformatiiRezultat = (db.t_InformatiiRezultate.FirstOrDefault(x => x.ID_InformatiiRezultat == info.ID_InformatiiRezultat)).ID_InformatiiRezultat,
ID_IntrebareRezultat = (db.t_IntrebariRezultate.FirstOrDefault(x => x.ID_IntrebareRezultat == item.ID_IntrebareRezultat)).ID_IntrebareRezultat
});
db.SaveChanges();
}
FormaTest.ListObj.Clear();
Values.Clear();
#endregion
}
#region Afisare
if (FormaTest.punctaj <= 50)
{
this.MesajLB.Text = "Din pacate nu ai trecut testul :(";
this.RealizariLB.Text = "Ati obtinut doar ";
this.RealizariLB.Text += FormaTest.punctaj + " puncte ";
this.GlowingPanEditMethod(Color.Red);
}
else
{
this.MesajLB.Text = "Felicitari , ai trecut testul :)";
this.RealizariLB.Text = "Ati crescut in nivel , obtinand ";
this.RealizariLB.Text += FormaTest.punctaj + " puncte !!!";
this.GlowingPanEditMethod(Color.Green);
}
this.glowingPanel1.StartAnimation(); this.glowingPanel2.StartAnimation();
this.glowingPanel3.StartAnimation(); this.glowingPanel4.StartAnimation();
#endregion
}
private void GlowingPanEditMethod(Color c)
{
this.glowingPanel1.CuloareAnimatiePanel = c;
this.glowingPanel2.CuloareAnimatiePanel = c;
this.glowingPanel3.CuloareAnimatiePanel = c;
this.glowingPanel4.CuloareAnimatiePanel = c;
}
private void InapoiLaProfil_Click(object sender, EventArgs e)
{
this.Hide();
FormaProfil frm = new FormaProfil();
frm.ShowDialog();
this.Close();
}
}
}