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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
|
public class Client
{
private decimal _idClient;
public decimal IdClient
{
get { return _idClient; }
set { _idClient = value; }
}
private string _nomClient;
public string NomClient
{
get { return _nomClient; }
set
{
_nomClient = value;
if (String.IsNullOrEmpty(value))
{
throw new ApplicationException("Champs obligatoire.");
}
}
}
private string _prenomClient;
public string PrenomClient
{
get { return _prenomClient; }
set
{
_prenomClient = value;
if (String.IsNullOrEmpty(value))
{
throw new ApplicationException("Champs obligatoire.");
}
}
}
private string _raisonSocialeClient;
public string RaisonSocialeClient
{
get { return _raisonSocialeClient; }
set
{
_raisonSocialeClient = value;
if (String.IsNullOrEmpty(value))
{
throw new ApplicationException("Champs obligatoire.");
}
}
}
private string _adresseClient;
public string AdresseClient
{
get { return _adresseClient; }
set { _adresseClient = value; }
}
private string _cpClient;
public string CpClient
{
get { return _cpClient; }
set
{
_cpClient = value;
if (!string.IsNullOrEmpty(value))
{
if (CpClient.Length != 5)
{
throw new ApplicationException("Le code postal doit comporter 5 chiffres. Ex : '14000'");
}
}
else
{
throw new ApplicationException("Ce champs ne peut pas être vide");
}
}
}
private string _villeClient;
public string VilleClient
{
get { return _villeClient; }
set
{
_villeClient = value;
if (String.IsNullOrEmpty(value))
{
throw new ApplicationException("Champs obligatoire.");
}
}
}
private string _telFixeClient;
public string TelFixeClient
{
get { return _telFixeClient; }
set
{
_telFixeClient = value;
if (!string.IsNullOrEmpty(value))
{
if (value.Length != 10)
{
throw new ApplicationException("Le numéro de téléphone doit être composé de 10 chiffres. Ex : 0678969696");
}
else
{
if (!char.Equals(value[0],'0'))
{
throw new ApplicationException("Le numéro de téléphone fixe doit commencer par 0.");
}
else
{
if (char.Equals(value[1], '6'))
{
throw new ApplicationException("Le numéro de téléphone fixe ne doit pas commencer par 06.");
}
}
}
}
}
}
private string _telPortableClient;
public string TelPortableClient
{
get { return _telPortableClient; }
set
{
_telPortableClient = value;
if (!string.IsNullOrEmpty(value))
{
if (value.Length != 10 )
{
throw new ApplicationException(value[0].ToString());
}
else
{
if (!char.Equals(value[0], '0'))
{
throw new ApplicationException("Le numéro de téléphone portable doit commencer par 0.");
}
else
{
if (!char.Equals(value[1], '6'))
{
throw new ApplicationException("Le numéro de téléphone portable doit commencer par 06.");
}
}
}
}
}
}
private string _faxClient;
public string FaxClient
{
get { return _faxClient; }
set
{
_faxClient = value;
if (!string.IsNullOrEmpty(value))
{
if (value.Length != 10)
{
throw new ApplicationException("Le numéro de téléphone doit être composé de 10 chiffres. Ex : 0678969696");
}
else
{
if (!char.Equals(value[0], '0'))
{
throw new ApplicationException("Le numéro de Fax doit commencer par 0.");
}
else
{
if (char.Equals(value[1], '6'))
{
throw new ApplicationException("Le numéro de Fax ne doit pas commencer par 06.");
}
}
}
}
}
}
private string _emailClient;
public string EmailClient
{
get { return _emailClient; }
set { _emailClient = value; }
}
//Constructeur de la classe métier CLIENT
public Client()
{
}
public Client(decimal idClient,string nom, string prenom)
{
IdClient = idClient;
NomClient = nom;
PrenomClient = prenom;
}
public Client(string nomClient, string prenomClient, string raisonSocialeClient, string adresseClient, string cpClient, string villeClient, string telFixeClient, string telPortableClient, string faxClient, string emailclient)
{
NomClient = nomClient;
PrenomClient = prenomClient;
RaisonSocialeClient = raisonSocialeClient;
AdresseClient = adresseClient;
CpClient = cpClient;
VilleClient = villeClient;
TelFixeClient = telFixeClient;
TelPortableClient = telPortableClient;
FaxClient = faxClient;
EmailClient = emailclient;
}
public Client(decimal idClient,string nomClient, string prenomClient, string raisonSocialeClient, string adresseClient, string cpClient, string villeClient, string telFixeClient, string telPortableClient, string faxClient, string emailclient)
{
IdClient = idClient;
NomClient = nomClient;
PrenomClient = prenomClient;
RaisonSocialeClient = raisonSocialeClient;
AdresseClient = adresseClient;
CpClient = cpClient;
VilleClient = villeClient;
TelFixeClient = telFixeClient;
TelPortableClient = telPortableClient;
FaxClient = faxClient;
EmailClient = emailclient;
}
//Override de toString()
public override string ToString()
{
return string.Format("{0} {1}", NomClient, PrenomClient);
}
} |
Partager