Bonjour a tous ,
Bon voilà j'ai une classe DIM_DATE qui a trois attributs en mode private, accompagnés par des propriétés pour get et set.
Sauf qu'au moment de l'exécution du programme, il m'affiche une erreur:
Voici le code de ma classeErreur 1 : Le type 'WebApplication1.DIM_DATE' contient déjà une définition pour 'cs'
et voici le programme principal
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
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 using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using Oracle.DataAccess.Client; using Oracle.DataAccess.Types; using System.Text; using System.Collections.Generic; namespace WebApplication1 { public class DIM_DATE { // Les attributs de l'objet date private string cs; private string req; private DateTime dat_sit; // Constructeur d'objet public DIM_DATE(string conn, string requete, DateTime date) { this.cs = conn; this.req = requete; this.dat_sit = date; } // Propriétés public string cs { get { return cs; } set { cs = value; } } public string req { get { return req; } set { req = value; } } public DateTime dat_sit { get { return dat_sit; } set { dat_sit = value; } } // La méthode de la préparation DATE SITUATION public DataTable Prep_DIM_DATE(string cs, string req, DateTime dat_sit) { OracleConnection connexion = new OracleConnection(cs); OracleDataAdapter adapter = new OracleDataAdapter(req, connexion); OracleCommandBuilder builder = new OracleCommandBuilder(adapter); DataSet dataset = new DataSet(); dataset.Clear(); adapter.Fill(dataset, "DIM_DATE"); DataTable TABLE_DATE = dataset.Tables["DIM_DATE"]; TABLE_DATE.Columns["num"].Unique = true; DataRow ligne; ligne = TABLE_DATE.NewRow(); ligne["num"] = TABLE_DATE.Rows.Count + 1; ligne["DAT_SIT"] = dat_sit; ligne["DAT_M_1"] = dat_sit.AddDays(-dat_sit.Day); string annee = Convert.ToString(dat_sit.Year - 1); string ch1 = "31/12/"; string ch2 = "00:00:00"; string fin = ch1 + annee + " " + ch2; DateTime date_dec = Convert.ToDateTime(fin); ligne["DAT_DEC_N_1"] = date_dec; if (dat_sit.Day == 28 && (dat_sit.Year - 1) % 4 == 0) { ligne["DAT_GLISSANTE"] = dat_sit.AddDays(-365); } else { ligne["DAT_GLISSANTE"] = dat_sit.AddYears(-1); } TABLE_DATE.Rows.Add(ligne); adapter.Update(dataset, "DIM_DATE"); return TABLE_DATE; } } }
Je travaille sur une application web!
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 using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace WebApplication1 { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { DIM_DATE Table_Date = new DIM_DATE(); Table_Date.cs = "DATA SOURCE=bdpbc;PERSIST SECURITY INFO=True;USER ID=bdpbcadmin;PASSWORD=bdpbcadmin123"; Table_Date.req = "select * from DIM_DATE"; Table_Date.dat_sit = Convert.ToDateTime(DateTime.Today.AddDays(-DateTime.Today.Day)); GridView1.DataSource = Table_Date.Prep_DIM_DATE(Table_Date.cs, Table_Date.req, Table_Date.dat_sit); GridView1.DataBind(); } } }
Est ce qu'il y a une personne qui pourrait m'aider sur ce point![]()
Merci
Partager