/// <summary> /// Ajouter un client dans la table Client /// </summary> /// <param name="client">Le client à ajouter</param> /// <returns>True si le client à été ajouté ; False sinon</returns> public Boolean addClient(client client) { bool isAdded = false; // valeur par défaut client.permis_conduire_num = "0000000000"; client.assurance = "0000000000"; client.date_enregistrement = DateTime.Now; // mot de passe temporaire (prenom + nom + jour de l'inscription) client.password = client.prenom.ToLower() + client.nom.ToLower() + DateTime.Now.Day; try { ClientsEntitie.clients.Add(client); ClientsEntitie.SaveChanges(); MessageBox.Show("client added"); isAdded = true; } catch { MessageBox.Show("Le client n'a pas pu etre ajoute"); } return isAdded; }
// Méthodes /// <summary> /// Création d'un nouveau client à l'aide des informations inscrites dans les champs /// </summary> private void btnClientCreate_add_Click(object sender, EventArgs e) { if (!btnClientCreate_add.Text.Equals(ClientForm.OPERATION_CLIENT_UPDATE)) { client addClient = new client(); addClient.nom = txtClientCreate_nom.Text; addClient.prenom = txtClientCreate_prenom.Text; addClient.telephone = txtClientCreate_phone.Text; addClient.adresse_client = txtClientCreate_adresse.Text; addClient.courriel = txtClientCreate_email.Text; if (clientServices.addClient(addClient)) { emptyClientFormFields(); this.Close(); } else { MessageBox.Show("Une erreur est survenue lors de la creation du client"); } } else { string idToUpdate = txtClientCreate_idSearch.Text; List<client> listeClients = clientServices.find(idToUpdate, ClientForm.FIND_BY_CLIENT_ID); if(listeClients.Count > 0) { client clientToUpdate = listeClients[0]; clientToUpdate.nom = txtClientCreate_nom.Text; clientToUpdate.prenom = txtClientCreate_prenom.Text; clientToUpdate.telephone = txtClientCreate_phone.Text; clientToUpdate.adresse_client = txtClientCreate_adresse.Text; clientToUpdate.courriel = txtClientCreate_email.Text; } clientServices.Save(); MessageBox.Show("Le client a été modifé"); } }
public void addClient(client client) { // TODO }
public void addClient(client client) { }