Remove diacritics (accents) from a string / retirer accent – c#

1
2
3
4
5
6
7
8
9
public static string RemoveDiacritics(this string text)
{
    if (string.IsNullOrWhiteSpace(text))
        return text;

    text = text.Normalize(NormalizationForm.FormD);
    var chars = text.Where(c => CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark).ToArray();
    return new string(chars).Normalize(NormalizationForm.FormC);
}
Please follow and like us:

Suppression Multiple List PostgreSQl- c#

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
public Boolean DeleteMultiplesNewChocCommissionsOrder(List<long> ListIdCommissionOrder) {
 Boolean succes = true;
 string sqlQuery = "WITH new_values (IdCommissionOrder) as ( values ";

 var words = ListIdCommissionOrder.Select(w => String.Format("({0}),", w));
 sqlQuery += String.Join("", words);

 sqlQuery += ")";
 sqlQuery = sqlQuery.Replace(",)", ")");

 try {
  sqlQuery += " DELETE FROM " + NomTable;
  sqlQuery += " USING new_values nv ";
  sqlQuery += " WHERE ID" + NomTable + " = nv.IdCommissionOrder "; // Principal

  using(NpgsqlConnection Connection = new NpgsqlConnection(Adresse)) {
   Connection.Open();
   NpgsqlCommand oCmd = new NpgsqlCommand(sqlQuery, Connection);

   oCmd.ExecuteNonQuery();
  }
 } catch (Exception ex) {
  MessageBox.Show("Erreur DeleteMultiplesNewChocCommissionsOrder : " + ex);
  succes = false;
 }

 return succes;
}
Please follow and like us:

C# – Demander la saisie d’un Entier

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int Nbr = 0;
Boolean Succes = true;
do {
 Succes = true;
 using(var form = new InputBox("Titre Nbr", "Description Nbr", "Valeur Nbr")) {
  var result = form.ShowDialog();
  if (result == DialogResult.OK) {
   try {
    Nbr = Convert.ToInt32(form.value);
   } catch {
    Succes = false;
   }
  }
 }
} while (!Succes);

#C# #saisir #entier

Please follow and like us: