private void Submit_Click(object sender, EventArgs e)
        {
            if (!comboBoxTypes.Text.Equals("") && !comboBoxMarques.Text.Equals("") && !comboBoxModeles.Text.Equals("") && listeOptions != null && listeOptions.Count > 0)
            {
                WCFUtils.ServiceClient client   = new WCFUtils.ServiceClient();
                WCFUtils.Option[]      options  = new WCFUtils.Option[listeOptions.Count];
                WCFUtils.Vehicule      vehicule = new WCFUtils.Vehicule();

                if (listeOptions.Count > 0)
                {
                    using (MySqlConnection cn = new MySqlConnection(Program._cn))
                    {
                        cn.Open();
                        for (int i = 0; i < listeOptions.Count; i++)
                        {
                            MySqlCommand    cmd = new MySqlCommand("select caracteristique, prix, NOM_OPTION from toption where NOM_OPTION = '" + listeOptions[i].Nom + "'", cn);
                            MySqlDataReader dr  = cmd.ExecuteReader();
                            while (dr.Read())
                            {
                                options[i] = new WCFUtils.Option {
                                    Caracteristique = dr["caracteristique"].ToString(), Nom = dr["NOM_OPTION"].ToString(), Prix = Convert.ToInt32(dr["prix"])
                                };
                                vehicule.Options = options;
                            }
                            dr.Close();
                        }
                    }
                }
                vehicule.Marque    = comboBoxMarques.Text;
                vehicule.Categorie = comboBoxTypes.Text;
                vehicule.Model     = comboBoxModeles.Text;
                SelectClient select = new SelectClient(vehicule);
                select.Show();
                this.Dispose();
            }
            else
            {
                MessageBox.Show("Veuillez remplir tous les champs", "Erreur",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
 public SelectClient(Object vehicule)
 {
     InitializeComponent();
     this.vehicule = (WCFUtils.Vehicule)vehicule;
 }