-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormaStergere_EditareIntrebare.cs
90 lines (89 loc) · 3.95 KB
/
FormaStergere_EditareIntrebare.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
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace CreatorTeste
{
public partial class FormaStergere_EditareIntrebare : Form
{
public TesteDBEntities db { get; set; }
public FormaStergere_EditareIntrebare()
{
InitializeComponent();
//=====================
}
private void ButonIesire_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void FormaStergereIntrebare_Load(object sender, EventArgs e)
{
this.db = new TesteDBEntities();
List<t_Intrebari> Intr = new List<t_Intrebari>();
var Intrebari = FormaProfilAdministrator.ExtractUnique();
foreach (var item in db.t_Intrebari)
{
if (Intrebari.Contains(item.t_Capitole.t_Domenii.Domeniu) && !item.Stearsa)
{
Intr.Add(item);
}
}
if (Intr != null)
{
this.tIntrebariBindingSource.DataSource = Intr;
}
this.UpdateazaDataGridView();
}
private void UpdateazaDataGridView()
{
for (int i = 0; i < this.dataGridView.Rows.Count; i++)
{
this.dataGridView.Rows[i].Cells[2].Value = (this.dataGridView.Rows[i].Cells[9].Value as t_Variante).t_TexteVariante.TextVarianta;
this.dataGridView.Rows[i].Cells[3].Value = (this.dataGridView.Rows[i].Cells[10].Value as t_Variante).t_TexteVariante.TextVarianta;
this.dataGridView.Rows[i].Cells[4].Value = (this.dataGridView.Rows[i].Cells[11].Value as t_Variante).t_TexteVariante.TextVarianta;
this.dataGridView.Rows[i].Cells[5].Value = (this.dataGridView.Rows[i].Cells[12].Value as t_Variante).t_TexteVariante.TextVarianta;
this.dataGridView.Rows[i].Cells[6].Value = (this.dataGridView.Rows[i].Cells[13].Value as t_Capitole).t_Domenii.Domeniu;
this.dataGridView.Rows[i].Cells[7].Value = (this.dataGridView.Rows[i].Cells[13].Value as t_Capitole).Capitol;
this.dataGridView.Rows[i].Cells[8].Value = (this.dataGridView.Rows[i].Cells[14].Value as t_Dificultati).Dificultate;
}
}
private void ButonOK_Click(object sender, EventArgs e)
{
if (this.dataGridView.RowCount == 0)
{
MessageBox.Show("Nicio inregistrare gasita !", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (MessageBox.Show("Sunteti sigur(a) ca doriti sa stergeti intrebarea respectiva ?", "Intrebare", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
this.db.t_Intrebari.Attach(this.tIntrebariBindingSource.Current as t_Intrebari);
(this.tIntrebariBindingSource.Current as t_Intrebari).Stearsa = true;
this.tIntrebariBindingSource.RemoveCurrent();
this.db.SaveChanges();
}
}
}
private void ButonInapoiLaProfil_Click(object sender, EventArgs e)
{
this.Hide();
FormaProfilAdministrator frm = new FormaProfilAdministrator();
frm.ShowDialog();
this.Close();
}
private void ButonEditare_Click(object sender, EventArgs e)
{
if (this.tIntrebariBindingSource.Current as t_Intrebari != null)
{
this.db.Dispose();
this.Hide();
FormaEditareIntreabare frm = new FormaEditareIntreabare((this.tIntrebariBindingSource.Current as t_Intrebari));
frm.ShowDialog();
this.Close();
}
else
{
MessageBox.Show("Nicio inregistrare gasita !", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}