private List <OrderLine> getLigneCommande(string code) { try { using (OdbcConnection connection = ConnexionManager.CreateOdbcConnextion()) { List <OrderLine> lines = new List <OrderLine>(); connection.Open(); //Exécution de la requête permettant de récupérer les articles du dossier OdbcCommand command = new OdbcCommand(QueryHelper.getListLignesCommandes(false, code), connection); { using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) { lines.Add(new OrderLine(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].ToString(), reader[8].ToString())); } return(lines); } } } } catch (Exception ex) { //Exceptions pouvant survenir durant l'exécution de la requête SQL Console.WriteLine("" + ex.Message.Replace("[CBase]", "").Replace("[Simba]", " ").Replace("[Simba ODBC Driver]", "").Replace("[Microsoft]", " ").Replace("[Gestionnaire de pilotes ODBC]", "").Replace("[SimbaEngine ODBC Driver]", " ").Replace("[DRM File Library]", "")); return(null); } }
private string getDeviseIso(string code) { try { using (OdbcConnection connection = ConnexionManager.CreateOdbcConnextion()) { connection.Open(); //Exécution de la requête permettant de récupérer les articles du dossier OdbcCommand command = new OdbcCommand(QueryHelper.getDeviseIso(false, code), connection); { using (IDataReader reader = command.ExecuteReader()) { if (reader.Read()) { return(reader[0].ToString()); } } } return(null); } } catch (Exception ex) { //Exceptions pouvant survenir durant l'exécution de la requête SQL Console.WriteLine("" + ex.Message.Replace("[CBase]", "").Replace("[Simba]", " ").Replace("[Simba ODBC Driver]", "").Replace("[Microsoft]", " ").Replace("[Gestionnaire de pilotes ODBC]", "").Replace("[SimbaEngine ODBC Driver]", " ").Replace("[DRM File Library]", "")); return(null); } }
/* * * GET ALL LIST OF CUSTOMERS TO ADD INTO THE COMBOLIST */ private List <Customer> GetListClients() { try { List <Customer> listClient = new List <Customer>(); using (OdbcConnection connection = ConnexionManager.CreateOdbcConnextion()) { connection.Open(); //Exécution de la requête permettant de récupérer les articles du dossier OdbcCommand command = new OdbcCommand(QueryHelper.getListClient(false), connection); { using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Customer client = new Customer(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].ToString(), reader[8].ToString(), reader[9].ToString(), reader[10].ToString(), reader[11].ToString(), reader[12].ToString(), reader[13].ToString(), reader[14].ToString(), reader[15].ToString(), reader[16].ToString()); listClient.Add(client); } } } return(listClient); } } catch (Exception e) { //Exceptions pouvant survenir durant l'exécution de la requête SQL MessageBox.Show("" + e.Message.Replace("[CBase]", "").Replace("[Simba]", " ").Replace("[Simba ODBC Driver]", "").Replace("[Microsoft]", " ").Replace("[Gestionnaire de pilotes ODBC]", "").Replace("[SimbaEngine ODBC Driver]", " ").Replace("[DRM File Library]", ""), "Erreur!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); } }
private void test_connexion_button_Click(object sender, EventArgs e) { bool odbc_conn = false; bool sql_conn = false; string msg_error = ""; try { using (OdbcConnection connexion = ConnexionManager.CreateOdbcConnextion()) { connexion.Open(); OdbcCommand command = new OdbcCommand(QueryHelper.testConnection(false), connexion); command.ExecuteReader(); odbc_conn = true; } } catch (Exception ex) { msg_error += "* ODBC Error\n" + ex.Message + "\n"; } try { using (OdbcConnection connexion = ConnexionManager.CreateOdbcConnexionSQL()) { connexion.Open(); OdbcCommand command = new OdbcCommand(QueryHelper.testConnection(true), connexion); command.ExecuteReader(); sql_conn = true; } } catch (Exception ex) { msg_error += "* SQL Error\n" + ex.Message + "\n"; } if (!odbc_conn || !sql_conn) { MessageBox.Show(msg_error, "Test Connexion", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("La connexion avec le driver ODBC et SQL fonctionne.", "Test Connexion", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private List<Order> GetCommandesFromDataBase() { try { //DocumentVente Facture = new DocumentVente(); List<Order> listCommande = new List<Order>(); using (OdbcConnection connection = ConnexionManager.CreateOdbcConnextion()) { connection.Open(); //Exécution de la requête permettant de récupérer les articles du dossier OdbcCommand command = new OdbcCommand(QueryHelper.getListCommandes(false), connection); { using (IDataReader reader = command.ExecuteReader()) { while(reader.Read()) { Order order = new Order(reader[0].ToString(), reader[1].ToString(), reader[2].ToString().Replace(", ",",")+"."+reader[3].ToString()+"."+reader[6].ToString()+"."+reader[7].ToString(), reader[8].ToString(), reader[9].ToString().Replace("00:00:00",""), reader[10].ToString(), reader[11].ToString(), reader[12].ToString(), reader[13].ToString(), reader[15].ToString(), (reader[14].ToString().Split(';').Length == 2 ? reader[14].ToString().Split(';')[0] : null), (reader[14].ToString().Split(';').Length == 2 ? reader[14].ToString().Split(';')[1] : null), reader[16].ToString() ); listCommande.Add(order); } } } return listCommande; } } catch (Exception e) { //Exceptions pouvant survenir durant l'exécution de la requête SQL Console.WriteLine(e.Message); return null; } }
private void UpdateDocumentVente(string do_piece) { try { //List<Customer> listClient = new List<Customer>(); using (OdbcConnection connection = ConnexionManager.CreateOdbcConnextion()) { connection.Open(); //Exécution de la requête permettant de récupérer les articles du dossier OdbcCommand command = new OdbcCommand(QueryHelper.updateDocumentdeVente(false, do_piece), connection); command.ExecuteNonQuery(); } } catch (Exception e) { //Exceptions pouvant survenir durant l'exécution de la requête SQL Console.WriteLine("" + e.Message.Replace("[CBase]", "").Replace("[Simba]", " ").Replace("[Simba ODBC Driver]", "").Replace("[Microsoft]", " ").Replace("[Gestionnaire de pilotes ODBC]", "").Replace("[SimbaEngine ODBC Driver]", " ").Replace("[DRM File Library]", "")); } }
private Customer GetClient(StreamWriter writer, string do_tiers) { try { writer.WriteLine(DateTime.Now + " | GetClient() : ref => " + do_tiers); //List<Customer> listClient = new List<Customer>(); using (OdbcConnection connection = ConnexionManager.CreateOdbcConnextion()) { connection.Open(); //Exécution de la requête permettant de récupérer les articles du dossier writer.WriteLine(DateTime.Now + " | GetClient() : SQL => " + QueryHelper.getCustomer(false, do_tiers)); OdbcCommand command = new OdbcCommand(QueryHelper.getCustomer(false, do_tiers), connection); { using (IDataReader reader = command.ExecuteReader()) { if (reader.Read()) { writer.WriteLine(DateTime.Now + " | GetClient() : Client trouvé!"); writer.Flush(); return(new Customer(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].ToString(), reader[8].ToString(), reader[9].ToString(), reader[10].ToString(), reader[11].ToString(), reader[12].ToString(), reader[13].ToString(), reader[14].ToString(), reader[15].ToString(), reader[16].ToString())); } else { writer.WriteLine(DateTime.Now + " | GetClient() : Aucun réponse."); writer.Flush(); return(null); } } } } } catch (Exception e) { //Exceptions pouvant survenir durant l'exécution de la requête SQL writer.WriteLine(DateTime.Now + " | GetClient() : ref => " + do_tiers); writer.Flush(); Console.WriteLine("" + e.Message.Replace("[CBase]", "").Replace("[Simba]", " ").Replace("[Simba ODBC Driver]", "").Replace("[Microsoft]", " ").Replace("[Gestionnaire de pilotes ODBC]", "").Replace("[SimbaEngine ODBC Driver]", " ").Replace("[DRM File Library]", "")); return(null); } }
private void UpdateDocumentVente(string do_piece, List <Alert_Mail.Classes.Custom.CustomMailRecapLines> recapLinesList_new) { try { //List<Customer> listClient = new List<Customer>(); using (OdbcConnection connection = ConnexionManager.CreateOdbcConnextion()) { connection.Open(); //Exécution de la requête permettant de récupérer les articles du dossier OdbcCommand command = new OdbcCommand(QueryHelper.updateDocumentdeVente(false, do_piece), connection); command.ExecuteNonQuery(); } } catch (Exception e) { //Exceptions pouvant survenir durant l'exécution de la requête SQL Console.WriteLine("" + e.Message.Replace("[CBase]", "").Replace("[Simba]", " ").Replace("[Simba ODBC Driver]", "").Replace("[Microsoft]", " ").Replace("[Gestionnaire de pilotes ODBC]", "").Replace("[SimbaEngine ODBC Driver]", " ").Replace("[DRM File Library]", "")); recapLinesList_new.Add(new Alert_Mail.Classes.Custom.CustomMailRecapLines(docRefMail, "", "L'export du bon de livraison est annulée.", e.Message, e.StackTrace, "", logFileName_export)); } }
private List <DocumentVente> GetBonLivraisonFromDataBase(StreamWriter writer, List <Alert_Mail.Classes.Custom.CustomMailRecapLines> recapLinesList_new, string statut) { writer.Flush(); writer.WriteLine(""); writer.WriteLine(DateTime.Now + " | GetBonLivraisonFromDataBase() : Called!"); try { //DocumentVente Facture = new DocumentVente(); List <DocumentVente> listDocumentVente = new List <DocumentVente>(); using (OdbcConnection connection = ConnexionManager.CreateOdbcConnextion()) { DocumentVente documentVente; connection.Open(); //Exécution de la requête permettant de récupérer les articles du dossier writer.Flush(); writer.WriteLine(DateTime.Now + " | GetBonLivraisonFromDataBase() : SQL ===> " + QueryHelper.getListDocumentVente_v2(false, 3, statut)); writer.Flush(); OdbcCommand command = new OdbcCommand(QueryHelper.getListDocumentVente_v2(false, 3, statut), connection); { using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) { documentVente = new DocumentVente(reader[0].ToString(), reader[1].ToString(), reader[2].ToString().Replace("00:00:00", ""), reader[3].ToString().Replace("00:00:00", ""), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].ToString(), reader[8].ToString(), reader[9].ToString(), reader[10].ToString(), reader[11].ToString(), reader[12].ToString(), reader[13].ToString(), reader[14].ToString(), reader[15].ToString(), reader[16].ToString(), reader[17].ToString(), reader[18].ToString(), reader[19].ToString(), reader[20].ToString(), reader[21].ToString(), reader[22].ToString(), reader[23].ToString(), reader[24].ToString(), reader[25].ToString(), reader[26].ToString(), reader[27].ToString(), reader[28].ToString(), reader[29].ToString(), reader[30].ToString(), reader[31].ToString(), reader[32].ToString(), reader[33].ToString() ); if (documentVente.DO_Statut == "0") { documentVente.DO_Statut = "Saisie"; } if (documentVente.DO_Statut == "1") { documentVente.DO_Statut = "Confirmé"; } if (documentVente.DO_Statut == "2") { documentVente.DO_Statut = "Accepté"; } listDocumentVente.Add(documentVente); } } } writer.WriteLine(DateTime.Now + " | GetBonLivraisonFromDataBase() : Numéro de facture trouvé : " + listDocumentVente.Count()); return(listDocumentVente); } } catch (Exception e) { //Exceptions pouvant survenir durant l'exécution de la requête SQL writer.WriteLine(DateTime.Now + " | GetBonLivraisonFromDataBase() : " + e.Message.Replace("[CBase]", "").Replace("[Simba]", " ").Replace("[Simba ODBC Driver]", "").Replace("[Microsoft]", " ").Replace("[Gestionnaire de pilotes ODBC]", "").Replace("[SimbaEngine ODBC Driver]", " ").Replace("[DRM File Library]", "")); writer.Flush(); recapLinesList_new.Add(new Alert_Mail.Classes.Custom.CustomMailRecapLines(docRefMail, "", "L'export du bon de livraison est annulée.", e.Message, e.StackTrace, "", logFileName_export)); return(null); } }