Bonjour,

Voila, j'ai un datagrid dans le quel je peut modifier, supprimer et ajouter des lignes.
Puis, je fait une vérification des données saisies dans la datagrid par l'utilisateur, dont voici le code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
nomn = dataGrid1[dataGrid1.CurrentCell.RowNumber,1].ToString();
			typen = dataGrid1[dataGrid1.CurrentCell.RowNumber,1].ToString();
			nbn = dataGrid1[dataGrid1.CurrentCell.RowNumber,1].ToString();
			sn = dataGrid1[dataGrid1.CurrentCell.RowNumber,2].ToString();
			type =  dataGrid1[dataGrid1.CurrentCell.RowNumber,3].ToString();
			modele= dataGrid1[dataGrid1.CurrentCell.RowNumber,4].ToString();
			site = dataGrid1[dataGrid1.CurrentCell.RowNumber,5].ToString();
			serv = dataGrid1[dataGrid1.CurrentCell.RowNumber,6].ToString();
			dateE = dataGrid1[dataGrid1.CurrentCell.RowNumber,7].ToString();
			ncde = dataGrid1[dataGrid1.CurrentCell.RowNumber,12].ToString();
 
			do
			{
				if((nomn.Length<8)||(nomn.Length ==0)||(nomn.Length >8))
				{
					MessageBox.Show("Le nombre de caractères du nom n'est pas valide!");
					break;
				}
				else
				{
					type1n = Convert.ToChar(typen.Substring(3,1));
 
					if(nomn.Substring(0,3) != "LAN")
					{
						MessageBox.Show("Le site ( " + nomn.Substring(0,3) + " ) déclaré dans le nom est incorrecte!");
						break;
 
					}
					if ((type1n != 'W') && (type1n != 'L') && (type1n != 'S'))
					{
						MessageBox.Show("Le type " +type1n+ " est incorrect! Saisir les types 'W' 'L' ou 'S'! ");
						break;
					}
					if((Convert.ToInt16(nbn.Substring(4,4))<0001) && (Convert.ToInt16(nbn.Substring(4,4)) < 9999))
					{
						MessageBox.Show("Le nombre qui a été saisi dans le nom n'est pas valide");
						break;
					}
					if(sn.Length == 0)
					{
						MessageBox.Show("Remplir le champ SN!");
						break;
					}
 
					if(type.Length == 0)
					{
						MessageBox.Show("Remmplir le champ Type!");
						break;
					}
 
					if(modele.Length ==0)
					{
						MessageBox.Show("Remplir le champ Modele!");
						break;
					}
 
					if(site.Length ==0)
					{
						MessageBox.Show("Remplir le champ Site!");
						break;
					}
 
					if(serv.Length ==0)
					{
						MessageBox.Show("Remplir le champ Service!");
						break;
					}
 
					if(dateE.Length ==0)
					{
						MessageBox.Show("Remplir le champ date_entrée!");
						break;
					}
 
					if(ncde.Length ==0)
					{
						MessageBox.Show("Remplir le champ num_cde");
						break;
					}
				}
			}while((nomn.Length>8) || (nomn.Length==0) || (nomn.Length < 8) && (nomn.Substring(0,3) != "LAN") && (Convert.ToChar(typen.Substring(3,1)) != 'W') || (Convert.ToChar(typen.Substring(3,1)) != 'L') || (Convert.ToChar(typen.Substring(3,1)) != 'S') && (Convert.ToInt16(nbn.Substring(4,4))<0001) || (Convert.ToInt16(nbn.Substring(4,4)) < 9999) && (sn.Length == 0)&& (type.Length == 0) && (modele.Length ==0) && (site.Length ==0) && (serv.Length ==0)&& (dateE.Length ==0) && (ncde.Length ==0));
(Ne faites pas attention à la longeur, et au nombreux "if", je ne l'ai pas encore optimisé...)^^

Bref, ce que je voudrais faire, c'est qu'après l'affichage du MessageBox comme dans cet exemple:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
if(sn.Length == 0)
					{
						MessageBox.Show("Remplir le champ SN!");
						break;
					}
Je voudrais interrompre momentanément cette boucle do...while, le temps que l'utilisateur puisse corriger son erreur...

Help me please...