private int ensererAdresse() { mtxtCep.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; // Supprimer le formatage string vmtxtCep = mtxtCep.Text; //Le texte n'est pas formatage mtxtCep.TextMaskFormat = MaskFormat.IncludePromptAndLiterals; // retourner le formatage Adresse objAdresse = new Adresse(vmtxtCep, cmbCidade.SelectedItem, cmbUF.SelectedItem, txtBairro.Text, txtTipoLogradouro.Text, txtLogradouro.Text, txtNumero.Text, txtComplemento.Text, codeClient); LaConnexion objConectar = new LaConnexion(Properties.Settings.Default.ManiaDeSushiConnectionString); try { objConectar.ouvertConnexion(); objConectar.insererLogradouro("tb_logradouro", objAdresse); this.codeLogradouro = objConectar.retounerCodeLogradouro("tb_logradouro", objAdresse); objConectar.insererAdresse("tb_endereco", objAdresse, this.codeLogradouro); objConectar.fermerLaConnexion(); return this.codeLogradouro; } catch (Exception) { MessageBox.Show("Impossível Inserir este Cliente!. Verifique os dados"); throw; } }
public void insererAdresse(string tableBD, Adresse objAdresse, int codeLogradouro) { try { // Objet pour l'exécution d'une commande SQL. SqlCommand objComandoSQL = new SqlCommand(); objComandoSQL.CommandText = "INSERT INTO " + tableBD + " VALUES ('" + objAdresse.Numero + "','" + objAdresse.Complemento + "'," + objAdresse.CodeClient + "," + codeLogradouro + ")"; objComandoSQL.CommandType = CommandType.Text; objComandoSQL.Connection = objConexao; objComandoSQL.ExecuteNonQuery(); } catch(Exception) { throw; } }
public int retounerCodeLogradouro(string tableBD, Adresse objAdresse) { try { SqlCommand objComandoSQL = new SqlCommand(); int code; objComandoSQL.CommandText = "SELECT log_id FROM " + tableBD + " WHERE tb_frete_fre_bairro = '" + objAdresse.Bairro + "'"; objComandoSQL.CommandType = CommandType.Text; objComandoSQL.Connection = objConexao; objComandoSQL.ExecuteNonQuery(); //// Objet créé pour lire les donné de base SqlDataReader DR; // Effectue la lecture de retourner un objet SqlDataReader DR = objComandoSQL.ExecuteReader(); DR.Read(); code = DR.GetInt32(0); DR.Close(); return code; } catch (Exception) { throw; } }
/// <summary> /// Il a inséré un donné du Adresse du client dans le Base de données /// </summary> /// <param name="tableBD">table du Base de donnés</param> public void insererLogradouro(string tableBD, Adresse objAdresse) { try { // Objet pour l'exécution d'une commande SQL. SqlCommand objComandoSQL = new SqlCommand(); objComandoSQL.CommandText = "INSERT INTO " + tableBD + " VALUES ('" + objAdresse.Cep + "','" + objAdresse.UF + "','" + objAdresse.Cidade + "','" + objAdresse.TipoLogradouro + "','" + objAdresse.Logradouro + "','" + objAdresse.Bairro + "')"; objComandoSQL.CommandType = CommandType.Text; objComandoSQL.Connection = objConexao; objComandoSQL.ExecuteNonQuery(); } catch (Exception) { throw; } }