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
|
try//TESTS POUR VERIFICATION DU NOM ET REMPLISSAGE DES TEXTBOX OBLIGATOIRES:
{
if(TBNom.Text.Length != 8)//La longeur du nom ne doit pas être < ou >8 OU =0
{
Form1.RTBlog.Text="Le nombre de caractères du nom du matériel doit être égal à 8!";
}
else
{
if( (TBNom.Text.Substring(0,3)!= "LAN") && (TBNom.Text.Substring(0,3) != "MAC") && (TBNom.Text.Substring(0,3)!=" HP") && (TBNom.Text.Substring(0,3) != "FJE") )
{
Form1.RTBlog.Text="Le nom n'est pas correct!";
}
if( (Convert.ToChar(TBNom.Text.Substring(3,1))!='W') && (Convert.ToChar(TBNom.Text.Substring(3,1)) != 'L') && (Convert.ToChar(TBNom.Text.Substring(3,1)) != 'S'))
{
Form1.RTBlog.Text="Le type de matériel n'est pas correct!";
}
if( ( Convert.ToInt16(TBNom.Text.Substring(4,4))>9999) || (Convert.ToInt16(TBNom.Text.Substring(4,4))==0000) )
{
Form1.RTBlog.Text="Le numéro du matériel doit être compris entre 0001 et 9999!";
}
if( (TBNom.Text.Length == 0) || (TBSN.Text.Length ==0) || (TBDE.Text.Length==0) || (TBCde.Text.Length==0))
{
Form1.RTBlog.Text="Veillez à remplir tous les champ obligatoires(Nom,SN,Date Entrée et N°Commande)";
}
}
}
catch
{
Form1.RTBlog.Text="Attention, erreur(s) sur le nom, Veuillez corriger!\n\nNote à l'utilisateur:\nSI vous voulez enregistrer un matériel en HP"+
", veillez à saisir un espace avant le HP comme, par exemple: ' HPL0001'";
}
//Connexion à la base de données:
Cnx2.ConnectionString = "Data Source=LANS0004; Initial Catalog=HW_INVENTORY; Integrated Security=True";
SqlCommand cmd;
string req;
//REQUÊTE PARAMETREE POUR LA MISE A JOUR:
try
{
Cnx2.Open();
req = "UPDATE MATERIELS SET Nom=@nom,SN=@sn,Type=@type,Modele=@modele,Site=@site"+
",Service=@service,Date_Entree=@dateE,Date_Sortie=@dateS"+
",Fin_Leasing=@fleas,IP=@ip,MAC=@mac,Num_Cde=@cde,Num_Immo"+
"=@nimmo,Num_Contrat=@con,Date_Inventaire=@inv,Commentaires=@comm "+
"WHERE ID="+Form1.dataGrid1[Form1.dataGrid1.CurrentCell.RowNumber,0];
cmd = new SqlCommand(req,Cnx2);
//ETC,ETC... |