// TODO
 public static Client ClientExiste(string nom, Ville ville)
 {
     Client client = null;
     Agent agent;
     if (DBConnect())
     {
         string requete = "SELECT NUM_C, NOM_C, ADRESSE_C, TEL_C, NUM_A, NUM_V FROM CLIENTS WHERE NOM_C=N'"+nom+"' AND NUM_V=N'"+ville.Index+"'";
         OleDbCommand command = new OleDbCommand(requete, connect);
         OleDbDataReader reader = command.ExecuteReader();
         // ajout des noms des clients dans la liste
         while (reader.Read())
         {
             try
             {
                 agent = SqlDataProvider.trouverAgent(reader.GetInt16(4));
             }
             catch (Exception) { agent = null; }
             try
             {
                 Ville villeC = SqlDataProvider.trouverVille(reader.GetInt16(5));
                 client = new Client(reader.GetInt16(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), agent, villeC);
             }
             catch (Exception) { client = null; }
         }
         // déconnexion
         reader.Close();
         connect.Close();
     }
     return client;
 }
Example #2
0
 public static bool ajouterBienEtClient(Client c, Bien b)
 {
     //pour l'instant, il n'y a que l'ajout de client
     bool ajout;
     // si pas de connexion
     if (!DBConnect())
         ajout = false;
     // si connexion
     else
     {
         string requete;
         if (c.Agent == null)
         {
             requete = string.Format("INSERT INTO CLIENTS (NOM_C, ADRESSE_C, NUM_V, TEL_C) VALUES (N'{0}',N'{1}',N'{2}',N'{3}')", c.Nom, c.Adresse, c.Ville.Index, c.Telephone);
         }
         else
         {
             requete = string.Format("INSERT INTO CLIENTS (NOM_C, ADRESSE_C, NUM_V, TEL_C, NUM_A) VALUES (N'{0}',N'{1}',N'{2}',N'{3}',N'{4}')", c.Nom, c.Adresse, c.Ville.Index, c.Telephone, c.Agent.Index);
         }
         OleDbCommand command = new OleDbCommand(requete, connect);
         int rowCount = command.ExecuteNonQuery();
         if (rowCount == 1)
         {
             ajout = true;  // ajout effectué
         }
         else
             ajout = false; // ajout non effectué
         // déconnexion
         connect.Close();
     }
     return ajout;
 }
Example #3
0
 /// <summary>
 /// Constructeur en venant de la liste de clients
 /// </summary>
 /// <param name="client">Client qui a été selectionné</param>
 public UCSouhaitsDe(Client client)
 {
     InitializeComponent();
     comboBoxClients.Items.Add(client);
     comboBoxClients.SelectedItem = client;
     comboBoxClients.Enabled = false;
     buttonRechercher.Enabled = false;
 }
 public UCAjouterBien(Client c)
 {
     InitializeComponent();
     loadClients();
     loadVilles();
     comboBoxProprietaire.SelectedText = c.ToString();
     comboBoxProprietaire.Enabled = false;
 }
Example #5
0
        public static Agent GetAgent(Client client)
        {
            Agent agent = null;
            // TODO rechercher l'agent du client fournit en paramètre
            // hmm en fait pas besoin si l'agent fait parti du client ...

            return agent;
        }
 public UCAjouterSouhait(Client c)
 {
     InitializeComponent();
     loadClients();
     loadVilles();
     comboBoxAcheteur.SelectedText = c.Nom;
     comboBoxAcheteur.Enabled = false;
 }
Example #7
0
 public Bien(int prix, DateTime dateMiseEnVente, int surfaceHabitable, int surfaceJardin, Ville ville, Client client)
 {
     m_prix = prix;
     m_dateMiseEnVente = dateMiseEnVente;
     m_surfaceHabitable = surfaceHabitable;
     m_surfaceJardin = surfaceJardin;
     m_ville = ville;
     m_client = client;
 }
        // TEST pas au point pour la création
        // A FINIR
        private void buttonCreer_Click(object sender, EventArgs e)
        {
            if (textBoxNom.Text != "" && textBoxAdresse.Text != "" && textBoxTelephone.Text != "" && comboBoxVilles.SelectedItem != null)
            {
                Client client = SqlDataProvider.ClientExiste(textBoxNom.Text, (Ville)comboBoxVilles.SelectedItem);
                // si client existe, on bascule directement sur UCAjouterBien avec ce client
                if (client != null)
                {
                    // limite rajouter un truc pour choisir entre continuer ou modifier les infos client saisies ?
                    MessageBox.Show("Attention, ce client existe déjà.", "Alerte", MessageBoxButtons.YesNoCancel);
                }
                else
                {
                    client = new Client(-1, textBoxNom.Text, textBoxAdresse.Text, textBoxTelephone.Text, ((Ville)comboBoxVilles.SelectedItem).Index);
                }

                if (radioButtonBien.Checked)
                {
                    /*
                    UserControl ajouterBien = new UCAjouterBien(c);
                    ajouterBien.Parent = this.Parent;
                    ajouterBien.Dock = DockStyle.Fill;
                    ajouterBien.Show();
                    this.Hide();
                    */

                    this.Hide();
                    UserControl ajouterBien = new UCAjouterBien(client);

                    ajouterBien.Parent = Application.OpenForms["FenetrePrincipale"];
                    //this.Parent.MdiChild = ajouterBien;
                    //ajouterBien.Parent = this.Parent;

                    ajouterBien.Dock = DockStyle.Fill;
                    ajouterBien.Show();
                }
                else
                {
                    // vérification si ce client a déjà un agent assigné dans le cas où il existe déjà
                    client.Agent = (Agent)comboBoxAgents.SelectedItem;

                    UserControl ajouterSouhait = new UCAjouterSouhait(client);
                    FenetrePrincipale parent = (FenetrePrincipale)this.Parent;
                    parent.MdiChild = null;
                    parent.MdiChild = ajouterSouhait;
                    ajouterSouhait.Dock = DockStyle.Fill;
                    ajouterSouhait.Show();
                }
            }
        }
Example #9
0
 public static bool ajouterClient(Client c)
 {
     bool ajout;
     // si pas de connexion
     if (!DBConnect())
         ajout = false;
     // si connexion
     else
     {
         string requete = string.Format("INSERT INTO CLIENTS (NOM_C, CODE_POSTAL_V) VALUES (N'{0}',N'{1}')", ville.Nom, ville.CodePostal);
         OleDbCommand command = new OleDbCommand(requete, connect);
         int rowCount = command.ExecuteNonQuery();
         if (rowCount == 1)
             ajout = true;  // ajout effectué
         else
             ajout = false; // ajout non effectué
         // déconnexion
         connect.Close();
     }
     return ajout;
 }
Example #10
0
 public UCAjouterSouhait(Client client)
 {
     InitializeComponent();
     loadVilles();
     loadAgents();
     // Chargement comboBox propriétaire avec ce client
     comboBoxAcheteur.Items.Clear();
     comboBoxAcheteur.Items.Add(client);
     comboBoxAcheteur.SelectedItem = client;
     comboBoxAcheteur.Enabled = false;
     if (client.Agent != null)
     {
         comboBoxAgent.SelectedItem = client.Agent;
         comboBoxAgent.Enabled = false;
     }
     else
         comboBoxAgent.SelectedIndex = -1;
     buttonAjouter.Enabled = false;
     disableNumericUpDowns();
     InitialisationParametres();
 }
        private void buttonCreer_Click(object sender, EventArgs e)
        {
            if (textBoxNom.Text != "" && textBoxAdresse.Text != "" && textBoxTelephone.Text != "" && comboBoxVilles.SelectedItem != null)
            {
                Client c = new Client(textBoxNom.Text, textBoxAdresse.Text, textBoxTelephone.Text, comboBoxVilles.SelectedIndex);
                if (radioButtonBien.Checked)
                {
                    MessageBox.Show("Attention", "erreur BIEN OK BdD");
                    //UCAjouterBien(c)
                }
                else
                {
                    if (comboBoxAgents != null)
                    {
                        if (SqlDataProvider.ajouterClient(c))
                            MessageBox.Show("OK", "Ajout client OK");
                        else
                            MessageBox.Show("KO", "Ajout client KO !!!");

                        //UCAjouterSouhait(c)
                    }
                }
            }
        }
Example #12
0
 public static List<Client> GetListeClients()
 {
     Client client;
     Agent agent;
     Ville ville;
     List<Client> listeClients = new List<Client>() ;
     if (DBConnect())
     {
         string requete = "SELECT NUM_C, NOM_C, ADRESSE_C, TEL_C, NUM_A, NUM_V FROM CLIENTS ORDER BY NOM_C";
         OleDbCommand command = new OleDbCommand(requete, connect);
         OleDbDataReader reader = command.ExecuteReader();
         // ajout des noms des clients dans la liste
         while (reader.Read())
         {
             try
             {
                 agent = SqlDataProvider.trouverAgent(reader.GetInt16(4));
             }
             catch(Exception)  { agent = null; }
             ville = SqlDataProvider.trouverVille(reader.GetInt16(5));
             client = new Client(reader.GetInt16(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), agent, ville);
             listeClients.Add(client);
         }
         // déconnexion
         reader.Close();
         connect.Close();
     }
     return listeClients;
 }