Bonjour à tous,
Je suis confronter à un léger problème. Je fais une application C# et mes données sont stockées dans Access. Jusque la pas de problème pour accéder et rentrer de nouvelles données.
Mais maintenant je souhaite utiliser des dates et la ça devient très problématique.
J'extrait une DataTable de ma base et j'instancie un objet Contrat avec.
Pour les String, les booleens et les numérique pas de problème (enfin pas d'erreur mais je n'ai pas encore vu ce que ça donnait par la suite).
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 public Contrat(DataTable contratCharge) { this.coCateg = contratCharge.Rows[0]["coCateg"].ToString(); this.coCoeff = contratCharge.Rows[0]["coCoeff"].ToString(); this.cocommentaire = contratCharge.Rows[0]["cocommentaire"].ToString(); //this.codateDebut.Add(contratCharge.Rows[0]["codateDebut"]); this.codatedebut = ((DateTime)contratCharge.Rows[0]["codateDebut"]).Date; this.codateFin = ((DateTime)contratCharge.Rows[0]["codateFin"]); this.codateFinPrevue = ((DateTime)contratCharge.Rows[0]["codateFinPrevue"]); this.coDateFinProlong = ((DateTime)contratCharge.Rows[0]["coDateFinProlong"]); this.coDateSignature = ((DateTime)contratCharge.Rows[0]["coDateSignature"]); this.CoDI = contratCharge.Rows[0]["CoDI"].ToString(); this.coEchelon = contratCharge.Rows[0]["coEchelon"].ToString(); this.coInsertC2 = ((bool)contratCharge.Rows[0]["coInsertC2"]); this.comotif = contratCharge.Rows[0]["comotif"].ToString(); this.comotifcourt = contratCharge.Rows[0]["comotifcourt"].ToString(); this.coNiv = contratCharge.Rows[0]["coNiv"].ToString(); this.coNumContrat = contratCharge.Rows[0]["coNumContrat"].ToString(); this.coOA = contratCharge.Rows[0]["coOA"].ToString(); this.coregistreEntree = ((bool)contratCharge.Rows[0]["coregistreEntree"]); this.coregistreSortie = ((bool)contratCharge.Rows[0]["coregistreSortie"]); this.coSalaire = ((Double)contratCharge.Rows[0]["coSalaire"]); this.cosoldeRtt = ((bool)contratCharge.Rows[0]["cosoldeRtt"]); this.cosouplesseMaxi = ((int)contratCharge.Rows[0]["cosouplesseMaxi"]); this.cosouplesseMini = ((int)contratCharge.Rows[0]["cosouplesseMini"]); this.coStatReception = ((bool)contratCharge.Rows[0]["coStatReception"]); this.costatutContrat = contratCharge.Rows[0]["costatutContrat"].ToString(); this.inAlps = contratCharge.Rows[0]["inAlps"].ToString(); this.secode = contratCharge.Rows[0]["secode"].ToString(); this.socoFourBaan = contratCharge.Rows[0]["socoFourBaan"].ToString(); this.meid = contratCharge.Rows[0]["meid"].ToString(); }
Par contre je n'arrive pas du tout à insérer les champs date dans ma classe...
Quelqu'un saurait il comment je dois faire ?
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 public class Contrat { public String coCateg { get; set; } public String CoDI { get; set; } public String coNumContrat { get; set; } public String meid { get; set; } public String socoFourBaan { get; set; } public String inAlps { get; set; } public String secode { get; set; } public String coNiv { get; set; } public String coEchelon { get; set; } public String coCoeff { get; set; } public String costatutContrat { get; set; } public bool coregistreEntree { get; set; } public bool coregistreSortie { get; set; } public DateTime codateDebut { get; set; } public DateTime codateFin { get; set; } public int cosouplesseMini { get; set; } public int cosouplesseMaxi { get; set; } public DateTime codateFinPrevue { get; set; } public DateTime coDateFinProlong { get; set; } public String cocommentaire { get; set; } public bool cosoldeRtt { get; set; } public String comotifcourt { get; set; } public String comotif { get; set; } public bool coStatReception { get; set; } public DateTime coDateSignature { get; set; } public Double coSalaire { get; set; } public String coOA { get; set; } public bool coInsertC2 { get; set; } public Metier cometier;
Partager