-
Notifications
You must be signed in to change notification settings - Fork 0
/
TacheProjet.cs
278 lines (229 loc) · 8.07 KB
/
TacheProjet.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
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 System.Data.SqlClient;
using System.Configuration;
namespace GestionTâche
{
public partial class TacheProjet : Form
{
public TacheProjet()
{
}
string connectionString = ConfigurationManager.ConnectionStrings["cnxSqlServer"].ConnectionString;
public int id;//id projet
public int idUti;//id UtilisateurConn
private void labelClose_MouseEnter(object sender, EventArgs e)
{
labelClose.ForeColor = Color.Red;
}
public TacheProjet(int a,int idU)
{
InitializeComponent();
this.id = a;
this.idUti = idU;
}
private void TacheProjet_MouseLeave(object sender, EventArgs e)
{
labelClose.ForeColor = Color.Black;
}
private void labelClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void TacheProjet_Load(object sender, EventArgs e)
{
Projet();
listTache();
}
public void TacheContrôle_Click(object sender, EventArgs e)
{
}
public void Projet()
{
int idP = id;
SqlConnection cnx = new SqlConnection();
cnx.ConnectionString = connectionString;
String Query = "SELECT * FROM Projet where id_projet='" +idP+ "';";
SqlCommand cmd = new SqlCommand(Query, cnx);
cnx.Open();
SqlDataReader rd = cmd.ExecuteReader();
if (rd.HasRows)
{
while (rd.Read())
{
TitreP.Text = (string)rd[1];
}
cnx.Close();
}
else
{
MessageBox.Show("Error");
}
}
public void listTache()
{
SqlConnection cnx = new SqlConnection();
cnx.ConnectionString = connectionString;
Boolean a;
string mailAtt ;
string mailCree ;
int Ma;
String Query = "SELECT Tache.id_Tache , Tache.TitreT From Projet INNER JOIN Statut ON Projet.id_projet = Statut.id_projet INNER JOIN Tache ON Statut.id_Tache = Tache.id_Tache INNER JOIN journalisation ON journalisation.id_Tache = Tache.id_Tache where Projet.id_projet = " + id + " and journalisation.Terminer = 0;";
SqlCommand cmd = new SqlCommand(Query, cnx);
cnx.Open();
SqlDataReader rd = cmd.ExecuteReader();
flowLayoutPanel1.Controls.Clear();
if (rd.HasRows)
{
while (rd.Read())
{
TacheContrôle t = new TacheContrôle(id,idUti);
t.ID = (int)rd[0];
t.Title = (string)rd[1];
mailCree = MailUtiliCrr();
t.CreePar = mailCree;
Ma = IdUtiliAttri((int)rd[0]);
mailAtt = MailUtiliAttri(Ma);
t.AttribuéA = mailAtt;
flowLayoutPanel1.Controls.Add(t);
}
cnx.Close();
}
}
private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e)
{
}
private void btnAjouterT_Click(object sender, EventArgs e)
{
AjouterTache t = new AjouterTache();
t.Show();
}
public int IdUtiliAttri(int idUta)
{
int a =0;
SqlConnection cnx = new SqlConnection();
cnx.ConnectionString = connectionString;
String Query = "select Journalisation.id_Utilisateur_aff From Journalisation INNER JOIN Tache ON journalisation.id_Tache = Tache.id_Tache where journalisation.id_Tache =" + idUta + "; ";
SqlCommand cmd = new SqlCommand(Query, cnx);
cnx.Open();
SqlDataReader rd = cmd.ExecuteReader();
if (rd.HasRows)
{
while (rd.Read())
{
a = (int)rd[0];
return a;
}
cnx.Close();
}
return a;
}
public String MailUtiliAttri(int idU)
{
int a;
string mail = " ";
SqlConnection cnx = new SqlConnection();
cnx.ConnectionString = connectionString;
a = IdUtiliAttri(idU);
String Query = "select Utilisateur.Mail from Utilisateur where id_Utilisateur=" + a + ";";
SqlCommand cmd = new SqlCommand(Query, cnx);
cnx.Open();
SqlDataReader rd = cmd.ExecuteReader();
if (rd.HasRows)
{
while (rd.Read())
{
mail = (string)rd[0];
return mail;
}
cnx.Close();
}
return mail;
}
public String MailUtiliCrr()
{
int a;
string mail = " ";
SqlConnection cnx = new SqlConnection();
cnx.ConnectionString = connectionString;
String Query = "select Utilisateur.Mail from Utilisateur where id_Utilisateur=" + idUti + ";";
SqlCommand cmd = new SqlCommand(Query, cnx);
cnx.Open();
SqlDataReader rd = cmd.ExecuteReader();
if (rd.HasRows)
{
while (rd.Read())
{
mail = (string)rd[0];
}
cnx.Close();
}
return mail;
}
private void labelClose_MouseEnter_1(object sender, EventArgs e)
{
labelClose.ForeColor = Color.Red;
}
private void labelClose_MouseLeave(object sender, EventArgs e)
{
labelClose.ForeColor = Color.Black;
}
private void labelClose_Click_1(object sender, EventArgs e)
{
this.Close();
}
//"Delete from Projet where id_projet" + id + ";"
private void button1_Click(object sender, EventArgs e)
{
SqlConnection cnx = new SqlConnection();
cnx.ConnectionString = connectionString;
String Query = "Delete from Statut where id_projet=" + id + ";";
SqlCommand cmd = new SqlCommand(Query, cnx);
if (cnx.State == ConnectionState.Open)
cnx.Close();
cnx.Open();
cmd.ExecuteNonQuery();
Supprimerprojet();
Projet ta = new Projet(id);
ta.MdiParent = Acceuil.ActiveForm;
ta.Dock = DockStyle.Fill;
ta.Show();
}
public void Supprimerprojet()
{
SqlConnection cnx = new SqlConnection();
cnx.ConnectionString = connectionString;
String Query = "Delete from Projet where id_projet=" + id + ";";
SqlCommand cmd = new SqlCommand(Query, cnx);
if (cnx.State == ConnectionState.Open)
cnx.Close();
cnx.Open();
if (cmd.ExecuteNonQuery() == 1)
{
MessageBox.Show("Projet est supprimer ", "Projet", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
else
{
MessageBox.Show("ERROR");
}
}
private void linkTerminer_Click(object sender, EventArgs e)
{
TacheProjetTerminer ta = new TacheProjetTerminer(id,idUti);
ta.MdiParent = Acceuil.ActiveForm;
ta.Dock = DockStyle.Fill;
ta.Show();
}
private void linkTerminer_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
}
}
}