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); } }
private List <Stock> GetStockArticle() { try { List <Stock> stock_info = new List <Stock>(); using (OdbcConnection connection = ConnexionManager.CreateOdbcConnexionSQL()) { connection.Open(); //connecting as handler with database OdbcCommand command = new OdbcCommand(QueryHelper.getStockInfo(true), connection); //Exécution de la requête permettant de récupérer les articles du dossier { using (IDataReader reader = command.ExecuteReader()) //reading lines fetched. { while (reader.Read()) { Stock stock = new Stock(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), "", "", ""); stock_info.Add(stock); } } } return(stock_info); } } 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 List <Stock> GetStockArticle(StreamWriter logFileWriter, List <Alert_Mail.Classes.Custom.CustomMailRecapLines> recapLinesList_new) { try { List <Stock> stock_info = new List <Stock>(); using (OdbcConnection connection = ConnexionManager.CreateOdbcConnexionSQL()) { connection.Open();//connecting as handler with database logFileWriter.WriteLine(DateTime.Now + " : GetStockArticle | SQL: " + QueryHelper.getStockInfo(true)); OdbcCommand command = new OdbcCommand(QueryHelper.getStockInfo(true), connection); //Exécution de la requête permettant de récupérer les articles du dossier { using (IDataReader reader = command.ExecuteReader()) //reading lines fetched. { while (reader.Read()) { Stock stock = new Stock(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), "", "", ""); stock_info.Add(stock); } } } return(stock_info); } } catch (Exception e) { //Exceptions pouvant survenir durant l'exécution de la requête SQL logFileWriter.WriteLine(DateTime.Now + " : GetStockArticle | " + 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 stock est annulée.", e.Message, e.StackTrace, "", logFileName_export)); return(null); } }
private List <OrderLine> getLigneCommande(string code, List <Alert_Mail.Classes.Custom.CustomMailRecapLines> recapLinesList_new) { try { using (OdbcConnection connection = ConnexionManager.CreateOdbcConnexionSQL()) { List <OrderLine> lines = new List <OrderLine>(); connection.Open(); //Exécution de la requête permettant de récupérer les articles du dossier Console.WriteLine("SQL: " + QueryHelper.getListLignesCommandes(true, code)); OdbcCommand command = new OdbcCommand(QueryHelper.getListLignesCommandes(true, 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]", "")); recapLinesList_new.Add(new Alert_Mail.Classes.Custom.CustomMailRecapLines(docRefMail, "", "L'export de la commande est annulée.", ex.Message, ex.StackTrace, "", logFileName_export)); return(null); } }
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); } }
/* * * 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); } }
/// <summary> /// Constructeur principal /// </summary> public Main() { InitializeComponent(); inject = new Injection(Log, this); Log.MdiParent = this; Log.Show(); ClientForm.MdiParent = this; desactiverMitm.Enabled = false; MITM = new ConnexionManager(new IPEndPoint(IPAddress.Parse("213.248.126.39"), 5555), Log, this); MITM.start(); }
private void getClientData_w() { using (OdbcConnection connexion = ConnexionManager.CreateOdbcConnexionSQL()) { try { connexion.Open(); OdbcCommand command = new OdbcCommand(QueryHelper.getAllProducts(true), connexion); using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) // reads lines/rows from the query { Article article = new Article(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()); article.DE_No = ""; article.DE_No_Name = ""; articleList.Add(article); } } connexion.Close(); } catch (OdbcException ex) { MessageBox.Show(ex.Message, "Erreur db client", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (articleList.Count == 0) { MessageBox.Show("Aucun client trouvé dans la base Sage", "Client", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // create file et populate it //logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : CommandeAExporter JSON => " + new Database.Database().JsonFormat(CommandeAExporter)); using (StreamWriter articleFileWriter = new StreamWriter(fileName, false, Encoding.Default)) { articleFileWriter.WriteLine("E;Client;" + string.Format("{0:ddMMyyyy}", DateTime.Now) + ";"); // E start line in doc articleFileWriter.Flush(); for (int i = 0; i < articleList.Count; i++) { articleFileWriter.WriteLine("L;" + articleList[i].AR_EdiCode + ";" + articleList[i].AR_CodeBarre + ";" + articleList[i].AR_Ref + ";" + articleList[i].AR_Design + ";" + articleList[i].AR_PoidsBrut + ";" + articleList[i].AR_PoidsNet + ";" + articleList[i].AR_PrixAch + ";" + articleList[i].AR_PrixVen + ";" + articleList[i].AR_PrixTTC + ";" + articleList[i].AR_Pays + ";"); // L => each line in doc articleFileWriter.Flush(); } articleFileWriter.WriteLine("F;" + articleList.Count + ";"); // F => end doc line articleFileWriter.Flush(); articleFileWriter.Close(); } } }
private void getClientData_w() { using (OdbcConnection connexion = ConnexionManager.CreateOdbcConnexionSQL()) { try { connexion.Open(); OdbcCommand command = new OdbcCommand(QueryHelper.getAllClients(true), connexion); using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) // reads lines/rows from the query { clientList.Add(new Client(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())); } } connexion.Close(); } catch (OdbcException ex) { MessageBox.Show(ex.Message, "Erreur db client", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (clientList.Count == 0) { MessageBox.Show("Aucun client trouvé dans la base Sage", "Client", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // create file et populate it //logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : CommandeAExporter JSON => " + new Database.Database().JsonFormat(CommandeAExporter)); using (StreamWriter clientFileWriter = new StreamWriter(fileName, false, Encoding.Default)) { clientFileWriter.WriteLine("E;Client;" + string.Format("{0:ddMMyyyy}", DateTime.Now) + ";"); // E start line in doc clientFileWriter.Flush(); for (int i = 0; i < clientList.Count; i++) { clientFileWriter.WriteLine("L;" + clientList[i].CT_Num + ";" + clientList[i].CG_NumPrinc + ";" + clientList[i].CT_NumPayeur + ";" + clientList[i].N_Condition + ";" + clientList[i].N_Devise + ";" + clientList[i].N_Expedition + ";" + clientList[i].CT_Langue + ";" + clientList[i].CT_Facture + ";" + clientList[i].N_Period + ";" + clientList[i].N_CatTarif + ";" + clientList[i].CT_Taux02 + ";" + clientList[i].N_CatCompta + ";" + clientList[i].CT_NumCentrale + ";" + clientList[i].CT_Intitule + ";" + clientList[i].CO_No + ";" + clientList[i].CT_EdiCode + ";"); // L => each line in doc clientFileWriter.Flush(); } clientFileWriter.WriteLine("F;" + clientList.Count + ";"); // F => end doc line clientFileWriter.Flush(); clientFileWriter.Close(); } } }
private List <DocumentVenteLine> getDocumentLine(StreamWriter writer, string codeDocument, List <Alert_Mail.Classes.Custom.CustomMailRecapLines> recapLinesList_new) { try { writer.WriteLine(DateTime.Now + " | getDocumentLine() : récupérer les lignes du documment => " + codeDocument); List <DocumentVenteLine> lignesDocumentVente = new List <DocumentVenteLine>(); using (OdbcConnection connection = ConnexionManager.CreateOdbcConnexionSQL()) { connection.Open(); //Exécution de la requête permettant de récupérer les articles du dossier writer.WriteLine(DateTime.Now + " | getDocumentLine() : SQL ===> " + QueryHelper.getListDocumentVenteLine(true, codeDocument)); writer.Flush(); OdbcCommand command = new OdbcCommand(QueryHelper.getListDocumentVenteLine(true, codeDocument), connection); { using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) { writer.WriteLine(DateTime.Now + " | getDocumentLine() : Ref => " + reader[3].ToString() + " ; Name => " + reader[4].ToString()); writer.Flush(); DocumentVenteLine ligne = new DocumentVenteLine(reader[0].ToString().Replace("00:00:00", ""), reader[1].ToString().Replace("00:00:00", ""), 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(), 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(), reader[34].ToString() ); lignesDocumentVente.Add(ligne); } } } writer.WriteLine(DateTime.Now + " | getDocumentLine() : ligne total => " + lignesDocumentVente.Count); writer.Flush(); return(lignesDocumentVente); } } 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]", "")); writer.WriteLine(DateTime.Now + " | getDocumentLine() : Erreur \n " + 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); } }
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)); } }
/// <summary> /// Génération du fichier d'import, lancement de l'application et import des commandes /// </summary> public List <Alert_Mail.Classes.Custom.CustomMailRecapLines> ExportCommande(List <Alert_Mail.Classes.Custom.CustomMailRecapLines> recapLinesList_new) { string path = ""; Init.Classes.SaveLoadInit setting = new Init.Classes.SaveLoadInit(); setting.Load(); path = setting.configurationGeneral.paths.EDI_Folder; string exportPath = path; string exportTo = ""; Order CommandeAExporter = null; if (!Directory.Exists(logDirectoryName_export)) { Directory.CreateDirectory(logDirectoryName_export); } logFileName_export = logDirectoryName_export + @"\" + string.Format("LOG_Export_Commande_{0:dd-MM-yyyy HH.mm.ss}.txt", DateTime.Now); var logFile_export = File.Create(logFileName_export); //Write in the log file logFileWriter = new StreamWriter(logFile_export); //logFileWriter.Write(string.Format("{0:HH:mm:ss}", DateTime.Now) + " \r\n"); logFileWriter.WriteLine("#####################################################################################"); logFileWriter.WriteLine("################################ ConnecteurSage Sage ################################"); logFileWriter.WriteLine("#####################################################################################"); logFileWriter.WriteLine(""); //Export all CMDs with status 1 //Get Doc Entette DO_Statut /* Get a list of 100 orders for Veolog with a DO_Statut == 1 * Export the 'Bon de Livraison' BC as .csv file * send the csv file to Velog */ string[,] lits_of_stock = new string[100, 2]; int countLimit = 0; using (OdbcConnection connexion = ConnexionManager.CreateOdbcConnexionSQL()) { Config_Export.ConfigurationSaveLoad settings = new Config_Export.ConfigurationSaveLoad(); try { settings.Load(); connexion.Open(); OdbcCommand command = new OdbcCommand(QueryHelper.getCommandeStatut(true, settings.configurationExport.Commande.Status), connexion); logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : SQL ===> " + QueryHelper.getCommandeStatut(true, settings.configurationExport.Commande.Status)); using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) // reads lines/rows from the query { //if (reader[1].ToString().Equals("1")) //{ if (countLimit < 100) { lits_of_stock[countLimit, 0] = reader[0].ToString(); // cbMarq lits_of_stock[countLimit, 1] = reader[1].ToString(); // DO_Statut logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : result " + countLimit + " => cbMarq : " + reader[0].ToString() + " | DO_Statut : " + reader[1].ToString()); //Console.WriteLine(DateTime.Now + " | ExportCommande() : cbMarq = " + reader[0].ToString() + " DO_Statut = " + reader[1].ToString()); countLimit++; } //} } } connexion.Close(); } catch (OdbcException ex) { logFileWriter.WriteLine(DateTime.Now + " : ExportCommande() | ********************** OdbcException *********************"); logFileWriter.WriteLine(DateTime.Now + " : ExportCommande() | SQL ===> " + QueryHelper.getCommandeStatut(true, settings.configurationExport.Commande.Status)); logFileWriter.WriteLine(DateTime.Now + " : ExportCommande() | Message : " + ex.Message + "."); logFileWriter.WriteLine(DateTime.Now + " : ExportCommande() | Scan annulée"); logFileWriter.Flush(); logFileWriter.Close(); recapLinesList_new.Add(new Alert_Mail.Classes.Custom.CustomMailRecapLines(docRefMail, "", "L'export de la commande est annulée.", ex.Message, ex.StackTrace, "", logFileName_export)); return(recapLinesList_new); } } logFileWriter.Flush(); Console.WriteLine(DateTime.Now + " | ExportCommande() :: countLimit:" + countLimit); logFileWriter.WriteLine(""); for (int index = 0; index < countLimit; index++) { //Console.WriteLine("OK2 index:" + index+ " countLimit:" + countLimit+" "); //CommandeAExporter using (OdbcConnection connexion = ConnexionManager.CreateOdbcConnexionSQL()) { //Console.WriteLine("OK3"); try { //string deliveryClientName = ""; connexion.Open(); OdbcCommand command = new OdbcCommand(QueryHelper.getCoommandeById(true, lits_of_stock[index, 0]), connexion); Console.WriteLine(DateTime.Now + " | ExportCommande() : SQL ===> " + QueryHelper.getCoommandeById(true, lits_of_stock[index, 0])); logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : SQL ===> " + QueryHelper.getCoommandeById(true, lits_of_stock[index, 0])); using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) // reads lines/rows from the query { // DO_Piece, cli.CT_Num, Adresse, cmd.DO_DEVISE, cmd.DO_Date, cmd.DO_DateLivr, cmd.DO_Condition, cmd.DO_TotalHT, cli.CT_Intitule, cmd.DO_Motif, cli.CT_EdiCode, cmd.N_CATCOMPTA, cmd.DO_MOTIF, liv.LI_Contact, cli.N_Expedition, cli.CT_Telephone, cli.CT_EMail, cli.CT_Commentaire CommandeAExporter = new Order(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()); CommandeAExporter.telephone = reader[13].ToString(); CommandeAExporter.email = reader[14].ToString(); CommandeAExporter.commentaires = ""; CommandeAExporter.Transporteur = ""; } } if (CommandeAExporter != null) { docRefMail = CommandeAExporter.NumCommande; if (!CommandeAExporter.NomClient.Equals("") && !CommandeAExporter.NomClient.Equals(" ")) { logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : Export Commande du client \"" + CommandeAExporter.NomClient + "\""); } else { logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : Export Commande du client \"...\""); } try { if (CommandeAExporter.deviseCommande == "0") { CommandeAExporter.deviseCommande = "1"; } if (CommandeAExporter.deviseCommande != "") { CommandeAExporter.deviseCommande = getDeviseIso(CommandeAExporter.deviseCommande); } if (CommandeAExporter.DO_MOTIF == "") { CommandeAExporter.DO_MOTIF = CommandeAExporter.NumCommande; } if (CommandeAExporter.DO_MOTIF == "") { CommandeAExporter.DO_MOTIF = ""; logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : N° de commande non enregistrer, valeur '" + CommandeAExporter.DO_MOTIF + "'."); } else { logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : N° de commande non enregistrer, valuer '" + CommandeAExporter.DO_MOTIF + "'."); } if (CommandeAExporter.codeClient == "") { CommandeAExporter.codeClient = ""; logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : Code GNL client n'est pas enregistrer, valeur '" + CommandeAExporter.codeClient + "'."); } else { logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : Code GNL client n'est pas enregistrer, valeur '" + CommandeAExporter.codeClient + "'."); } if (!IsNumeric(CommandeAExporter.DO_MOTIF) && CommandeAExporter.DO_MOTIF != "") { CommandeAExporter.DO_MOTIF = ""; logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : N° de commande est mal enregistrer, valeur '" + CommandeAExporter.DO_MOTIF + "'."); } else { logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : N° de commande est mal enregistrer, valeur '" + CommandeAExporter.DO_MOTIF + "'."); } if (!IsNumeric(CommandeAExporter.codeClient) && CommandeAExporter.codeClient != "") { CommandeAExporter.DO_MOTIF = ""; logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : Code GNL client est mal enregistrer."); } else { logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : N° de commande est mal enregistrer, valeur '" + CommandeAExporter.DO_MOTIF + "'."); } var fileName = string.Format("EDI_ORDERS." + CommandeAExporter.codeClient + "." + CommandeAExporter.NumCommande + "." + ConvertDate(CommandeAExporter.DateCommande) + "." + CommandeAExporter.adresseLivraison + ".{0:yyyyMMddhhmmss}.csv", DateTime.Now); fileName = fileName.Replace("...", "."); //Verifier le format utilise depuis le fichier de config Config_Export.ConfigurationSaveLoad settings = new Config_Export.ConfigurationSaveLoad(); settings.Load(); bool veolog_format = (settings.configurationExport.Commande.Format == "Véolog" ? true : false); Console.WriteLine("veolog_format : " + veolog_format); if (veolog_format) { exportTo = @"Export\Veolog_Commande"; if (!exportPath.Contains("Export_Veolog")) { exportPath = exportPath + @"\Export_Veolog"; } if (!Directory.Exists(exportPath)) { Directory.CreateDirectory(exportPath); } Connexion.ConnexionSaveLoad connexionSaveLoad = new Connexion.ConnexionSaveLoad(); connexionSaveLoad.Load(); veolog_format = true; fileName = string.Format("orders_" + connexionSaveLoad.configurationConnexion.SQL.PREFIX + "_{0:yyyyMMdd}_" + CommandeAExporter.NumCommande + ".csv", DateTime.Now); } else { exportTo = @"Export\Plat_Commande"; if (!exportPath.Contains("Export_Plat")) { exportPath = exportPath + @"\Export_Plat"; } if (!Directory.Exists(exportPath)) { Directory.CreateDirectory(exportPath); } veolog_format = false; fileName = fileName.Replace("..", "."); } bool veolog_file_check = false; using (StreamWriter orderFileWriter = new StreamWriter(exportPath + @"\" + fileName, false, Encoding.Default)) { logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : Ecrire le fichier dans : " + exportPath + @"\" + fileName); //Console.WriteLine("Export File Name: " + exportPath + @"\" + fileName); if (veolog_format) { //format Veolog string[] adresse = new string[5]; string[] date_time_delivery = new string[2]; adresse = CommandeAExporter.adresseLivraison.Split(','); date_time_delivery = CommandeAExporter.DateLivraison.Split(' '); //Split the adresse CommandeAExporter.adresse = adresse[0]; CommandeAExporter.adresse_2 = adresse[1]; CommandeAExporter.codepostale = adresse[2]; CommandeAExporter.ville = adresse[3]; // Get the country CommandeAExporter.pays = adresse[4]; //Get Country ISO CountryFormatISO iso = new CountryFormatISO(); string[,] country_iso = iso.getAllStaticCountryISOCode(); if (CommandeAExporter.pays == "") { CommandeAExporter.pays = "France"; } for (int i = 0; i < country_iso.GetLength(0); i++) { if (country_iso[i, 0].ToUpper().Equals(CommandeAExporter.pays.ToUpper())) { CommandeAExporter.pays = country_iso[i, 1]; } } //Split the DateTime DateTime date_delivery = Convert.ToDateTime(CommandeAExporter.DateLivraison); //CommandeAExporter.DateCommande = date_time[0].Replace("/", ""); //CommandeAExporter.DateLivraison = date_delivery.Year + "" + date_delivery.Month + "" + date_delivery.Day + ""; CommandeAExporter.DateLivraison = string.Format("{0:yyyyMMdd}", date_delivery); string[] time_delivery = date_time_delivery[1].Split(':'); CommandeAExporter.HeureLivraison = time_delivery[0] + "" + time_delivery[1]; orderFileWriter.WriteLine("E;" + CommandeAExporter.NumCommande + ";" + CommandeAExporter.codeClient + ";;" + CommandeAExporter.NomClient + ";" + CommandeAExporter.adresse + ";" + CommandeAExporter.adresse_2 + ";;" + CommandeAExporter.codepostale + ";" + CommandeAExporter.ville + ";" + CommandeAExporter.pays + ";" + CommandeAExporter.telephone + ";" + CommandeAExporter.email + ";" + CommandeAExporter.DateLivraison + ";" + CommandeAExporter.HeureLivraison + ";" + CommandeAExporter.Transporteur + ";;;" + CommandeAExporter.commentaires); // E line CommandeAExporter.Lines = getLigneCommande(CommandeAExporter.NumCommande, recapLinesList_new); // Maybe thisssss int qteTotal = 0; string[] declarerpourrien = new string[2]; for (int i = 0; i < CommandeAExporter.Lines.Count; i++) { if (!IsNumeric(CommandeAExporter.Lines[i].codeAcheteur)) { CommandeAExporter.Lines[i].codeAcheteur = ""; } if (!IsNumeric(CommandeAExporter.Lines[i].codeFournis)) { CommandeAExporter.Lines[i].codeFournis = ""; } declarerpourrien = CommandeAExporter.Lines[i].Quantite.Split(','); qteTotal = qteTotal + Convert.ToInt16(declarerpourrien[0]); //add zeros to the article reference only for ALDI Connexion.ConnexionSaveLoad connexionSaveLoad = new Connexion.ConnexionSaveLoad(); connexionSaveLoad.Load(); string dns = connexionSaveLoad.configurationConnexion.SQL.PREFIX; if (dns.Contains("CFCI") || dns.Contains("TABLEWEAR") && CommandeAExporter.NomClient.Contains("ALDI")) { int maxChar = 13; int refChar = CommandeAExporter.Lines[i].codeArticle.Length; int addZero = maxChar - refChar; for (int index1 = 0; index1 < addZero; index1++) { CommandeAExporter.Lines[i].codeArticle = "0" + CommandeAExporter.Lines[i].codeArticle; } } orderFileWriter.WriteLine("L;;" + ((CommandeAExporter.Lines[i].codeArticle.Length > 30) ? CommandeAExporter.Lines[i].codeArticle.Substring(0, 30) : CommandeAExporter.Lines[i].codeArticle) + ";;" + declarerpourrien[0] + ";"); // L line } orderFileWriter.WriteLine("F;" + CommandeAExporter.Lines.Count + ";" + qteTotal + ";"); // F line orderFileWriter.Close(); } else { //Format Fichier plat orderFileWriter.WriteLine("ORDERS;" + CommandeAExporter.DO_MOTIF + ";" + CommandeAExporter.codeClient + ";" + CommandeAExporter.codeAcheteur + ";" + CommandeAExporter.codeFournisseur + ";;;" + CommandeAExporter.nom_contact + "." + CommandeAExporter.adresseLivraison.Replace("..", ".").Replace("...", ".") + ";" + CommandeAExporter.deviseCommande + ";;"); if (CommandeAExporter.DateCommande != "") { CommandeAExporter.DateCommande = ConvertDate(CommandeAExporter.DateCommande); } //if (CommandeAExporter.DateCommande != " ") //{ // CommandeAExporter.conditionLivraison = ""; } } //Vérifier si le fichier a bien été créé et écrit if (File.Exists(exportPath + @"\" + fileName)) { if (new FileInfo(exportPath + @"\" + fileName).Length > 0) { veolog_file_check = true; //add to backup folder addFileToBackUp(path + @"\BackUp\" + exportTo, exportPath + @"\" + fileName, fileName, logFileWriter); } } else { Console.WriteLine("File: " + fileName + " does not exist!!!"); logFileWriter.WriteLine(DateTime.Now + " : File: " + fileName + " does not exist!!!"); //Console.ReadLine(); } //update veolog delivery date if (veolog_file_check) { try { string delivery_date_veolog = string.Format("{0:dd/MM/yyyy hh:mm:ss}", DateTime.Now); logFileWriter.WriteLine(""); logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : Ajouter la date de livraision \"" + delivery_date_veolog + "\" de Veolog de la commande \"" + CommandeAExporter.NumCommande + "\"."); logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : SQL ===> " + QueryHelper.updateVeologDeliveryDate(true, CommandeAExporter.NumCommande, delivery_date_veolog)); OdbcCommand command1 = new OdbcCommand(QueryHelper.updateVeologDeliveryDate(true, CommandeAExporter.NumCommande, delivery_date_veolog), connexion); { using (IDataReader reader = command1.ExecuteReader()) { logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : Date de livraison veolog à jour !"); } } } catch (Exception ex) { logFileWriter.WriteLine(""); logFileWriter.WriteLine(DateTime.Now + " ********** Erreur ********** "); if (File.Exists(exportPath + @"\" + fileName)) { try { File.Delete(exportPath + @"\" + fileName); logFileWriter.WriteLine(DateTime.Now + " Le fichier \" " + exportPath + @"\" + fileName + " \" est supprimer !."); } catch (Exception exf) { logFileWriter.WriteLine(DateTime.Now + " ********** Erreur Delete File ********** "); logFileWriter.WriteLine(DateTime.Now + " Impossible de supprimer le fichier \" " + exportPath + @"\" + fileName + " \"."); logFileWriter.WriteLine(DateTime.Now + " Message: " + exf.Message); } } else { logFileWriter.WriteLine(DateTime.Now + " Le fichier \" " + exportPath + @"\" + fileName + " \" n'existe plus (peut déjà être envoyé en EDI)."); } logFileWriter.WriteLine(DateTime.Now + " Message: " + 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]", "")); logFileWriter.WriteLine(DateTime.Now + " Export Annuler."); logFileWriter.Flush(); logFileWriter.Close(); if (ex.Message.Contains("Cet élément est en cours d'utilisation !")) { logFileWriter.WriteLine(""); logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : Cet élément est en cours d'utilisation ! Impossible de changer le statut de la commande \"" + CommandeAExporter.NumCommande + "\"."); recapLinesList_new.Add(new Alert_Mail.Classes.Custom.CustomMailRecapLines(docRefMail, "", "L'export de la commande est annulée. Cet élément est en cours d'utilisation ! Veuillez fermer la fenêtre de commande dans Sage afin que la commande puisse être exportée.", "Cet élément est en cours d'utilisation ! Impossible de mettre la date de livraison veolog à jour dans le champs \"Veolog\".", ex.StackTrace, "", logFileName_export)); } else { logFileWriter.WriteLine(""); logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : " + ex.Message); recapLinesList_new.Add(new Alert_Mail.Classes.Custom.CustomMailRecapLines(docRefMail, "", "L'export de la commande est annulée.", ex.Message, ex.StackTrace, "", logFileName_export)); } return(recapLinesList_new); } //update order statut try { logFileWriter.WriteLine(""); logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : Changer le statut de la commande \"" + CommandeAExporter.NumCommande + "\"."); logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : SQL ===> " + QueryHelper.changeOrderStatut(true, CommandeAExporter.NumCommande)); OdbcCommand command1 = new OdbcCommand(QueryHelper.changeOrderStatut(true, CommandeAExporter.NumCommande), connexion); { using (IDataReader reader = command1.ExecuteReader()) { while (reader.Read()) { //Statut Update } } } } catch (Exception ex) { //Exceptions pouvant survenir durant l'exécution de la requête SQL logFileWriter.WriteLine(""); logFileWriter.WriteLine(DateTime.Now + " ********** Erreur ********** "); if (File.Exists(exportPath + @"\" + fileName)) { try { File.Delete(exportPath + @"\" + fileName); logFileWriter.WriteLine(DateTime.Now + " Le fichier \" " + exportPath + @"\" + fileName + " \" est supprimer !."); } catch (Exception exf) { logFileWriter.WriteLine(DateTime.Now + " ********** Erreur Delete File ********** "); logFileWriter.WriteLine(DateTime.Now + " Impossible de supprimer le fichier \" " + exportPath + @"\" + fileName + " \"."); logFileWriter.WriteLine(DateTime.Now + " Message: " + exf.Message); } } else { logFileWriter.WriteLine(DateTime.Now + " Le fichier \" " + exportPath + @"\" + fileName + " \" n'existe plus (peut déjà être envoyé en EDI)."); } logFileWriter.WriteLine(DateTime.Now + " Message: " + 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]", "")); logFileWriter.WriteLine(DateTime.Now + " Export Annuler."); logFileWriter.Flush(); // logFileWriter.Close(); if (ex.Message.Contains("Cet élément est en cours d'utilisation !")) { logFileWriter.WriteLine(""); logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : Cet élément est en cours d'utilisation ! Impossible de changer le statut de la commande \"" + CommandeAExporter.NumCommande + "\"."); recapLinesList_new.Add(new Alert_Mail.Classes.Custom.CustomMailRecapLines(docRefMail, "", "L'export de la commande est annulée. Cet élément est en cours d'utilisation ! Veuillez fermer la fenêtre de commande dans Sage afin que la commande puisse être exportée.", "Cet élément est en cours d'utilisation ! Impossible de changer le statut de la commande \"" + CommandeAExporter.NumCommande + "\".", ex.StackTrace, "", logFileName_export)); } else { logFileWriter.WriteLine(""); logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : " + ex.Message); recapLinesList_new.Add(new Alert_Mail.Classes.Custom.CustomMailRecapLines(docRefMail, "", "L'export de la commande est annulée.", ex.Message, ex.StackTrace, "", logFileName_export)); } //recapLinesList_new.Add(new CustomMailRecapLines(docRefMail, "L'export de la commande est annulée.", ex.Message, ex.StackTrace, "", logFileName_export)); return(recapLinesList_new); } } logFileWriter.WriteLine(""); logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : Commande exportée avec succés."); //jamp:; //logFileWriter.Close(); //Close(); } catch (Exception ex) { //Exception pouvant survenir si lorsque l'accès au disque dur est refusé logFileWriter.WriteLine(DateTime.Now + " | ExportCommande() : ERREUR :: " + ex.Message); logFileWriter.Flush(); logFileWriter.Close(); Console.WriteLine(DateTime.Now + " | ExportCommande() : ERREUR :: " + ex.Message); recapLinesList_new.Add(new Alert_Mail.Classes.Custom.CustomMailRecapLines(docRefMail, "", "L'export de la commande est annulée.", ex.Message, ex.StackTrace, "", logFileName_export)); } } else { Console.WriteLine("CommandeAExporter == null"); } //Console.WriteLine(DateTime.Now + " | ExportCommande() : Connexion close."); connexion.Close(); } catch (OdbcException ex) { logFileWriter.WriteLine(""); logFileWriter.WriteLine(DateTime.Now + " : ExportCommande() | ********************** OdbcException *********************"); logFileWriter.WriteLine(DateTime.Now + " : ExportCommande() | Message : " + ex.Message + "."); logFileWriter.WriteLine(DateTime.Now + " : ExportCommande() | Scan annulée"); logFileWriter.Flush(); logFileWriter.Close(); recapLinesList_new.Add(new Alert_Mail.Classes.Custom.CustomMailRecapLines(docRefMail, "", "L'export de la commande est annulée.", ex.Message, ex.StackTrace, "", logFileName_export)); return(recapLinesList_new); } } logFileWriter.Flush(); } logFileWriter.Close(); return(recapLinesList_new); }
private List <Alert_Mail.Classes.Custom.CustomMailRecapLines> UpdateDocumentVente(StreamWriter writer, string do_piece, string fileLocation) { using (OdbcConnection connexion = ConnexionManager.CreateOdbcConnexionSQL()) { List <Alert_Mail.Classes.Custom.CustomMailRecapLines> recapLinesList_ = new List <Alert_Mail.Classes.Custom.CustomMailRecapLines>(); connexion.Open(); //update order statut try { writer.WriteLine(""); writer.WriteLine(DateTime.Now + " | ExportCommande() : Changer le statut de la commande \"" + do_piece + "\"."); writer.WriteLine(DateTime.Now + " | ExportCommande() : SQL ===> " + QueryHelper.changeBLStatut(true, do_piece)); OdbcCommand command1 = new OdbcCommand(QueryHelper.changeBLStatut(true, do_piece), connexion); { using (IDataReader reader = command1.ExecuteReader()) { while (reader.Read()) { //Statut Update } } } writer.WriteLine(DateTime.Now + " Le statut du documment \" " + fileLocation + " \" est à jour."); writer.Flush(); } catch (Exception ex) { //Exceptions pouvant survenir durant l'exécution de la requête SQL writer.WriteLine(""); writer.WriteLine(DateTime.Now + " ********** Erreur ********** "); if (File.Exists(fileLocation)) { try { File.Delete(fileLocation); writer.WriteLine(DateTime.Now + " Le fichier \" " + fileLocation + " \" est supprimer !."); } catch (Exception exf) { writer.WriteLine(DateTime.Now + " ********** Erreur Delete File ********** "); writer.WriteLine(DateTime.Now + " Impossible de supprimer le fichier \" " + fileLocation + " \"."); writer.WriteLine(DateTime.Now + " Message: " + exf.Message); } } else { writer.WriteLine(DateTime.Now + " Le fichier \" " + do_piece + " \" n'existe plus (peut déjà être envoyé en EDI)."); } writer.Flush(); writer.WriteLine(DateTime.Now + " Message: " + 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]", "")); writer.WriteLine(DateTime.Now + " Export Annuler."); writer.Flush(); if (ex.Message.Contains("Cet élément est en cours d'utilisation !")) { writer.WriteLine(""); writer.WriteLine(DateTime.Now + " | ExportCommande() : Cet élément est en cours d'utilisation ! Impossible de changer le statut de la commande \"" + do_piece + "\"."); recapLinesList_.Add(new Alert_Mail.Classes.Custom.CustomMailRecapLines(docRefMail, "", "L'export de la commande est annulée. Cet élément est en cours d'utilisation ! Veuillez fermer la fenêtre de commande dans Sage afin que la commande puisse être exportée.", "Cet élément est en cours d'utilisation ! Impossible de changer le statut de la commande \"" + do_piece + "\".", ex.StackTrace, "", logFileName_export)); } else { writer.WriteLine(""); writer.WriteLine(DateTime.Now + " | ExportCommande() : " + ex.Message); recapLinesList_.Add(new Alert_Mail.Classes.Custom.CustomMailRecapLines(docRefMail, "", "L'export de la commande est annulée.", ex.Message, ex.StackTrace, "", logFileName_export)); } writer.Flush(); //recapLinesList_new.Add(new CustomMailRecapLines(docRefMail, "L'export de la commande est annulée.", ex.Message, ex.StackTrace, "", logFileName_export)); } writer.WriteLine(""); writer.Flush(); return(recapLinesList_); } }
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); } }
public static bool initDOC_Numerotation() { //writer.WriteLine(""); //writer.WriteLine(DateTime.Now + " | initDOC_Numerotation() : Init"); bool result = false; try { OdbcConnection connexion = ConnexionManager.CreateOdbcConnexionSQL(); connexion.Open(); int check = checkDOC_Numerotation(connexion); OdbcCommand command = null; if (check == 0 || check == 1) //if the DOC_Numerotation do nothing { result = true; //writer.WriteLine(DateTime.Now + " | initDOC_Numerotation() : Table DOC_Numerotation existe!"); DialogResult resultDialog5 = MessageBox.Show("La table \"DOC_NumerotationTable\" existe !\n\nVoulez-vous vider et réinitialiser tous les données dans cette table ?", "Information !", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (resultDialog5 == DialogResult.Yes) { try { command = new OdbcCommand(QueryHelper.deleteDOC_NumerotationTable(true), connexion); command.ExecuteReader(); command = new OdbcCommand(QueryHelper.insertDOC_NumerotationTable(true, "BC200000", "BCF200000", "CF200000", "BL200000", "ME200000", "MS200000"), connexion); command.ExecuteReader(); } // Récupération d'une possible SDKException catch (SDKException ex) { MessageBox.Show(" ERROR[Init 3] : " + ex.Message, "Erreur!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); result = false; } } if (resultDialog5 == DialogResult.No) { result = true; } } else if (check == -1) //if the tDOC_Numerotation doesn't exist then create it { //writer.WriteLine(DateTime.Now + " | initDOC_Numerotation() : Table DOC_Numerotation does not existe, so create the table!"); try { //Create DOC_Numerotation Table command = new OdbcCommand(QueryHelper.createDOC_NumerotationTable(true), connexion); using (IDataReader reader = command.ExecuteReader()) { //writer.WriteLine(DateTime.Now + " | initDOC_Numerotation() : Table DOC_Numerotation created!"); } //Set up the first init Numérotation command = new OdbcCommand(QueryHelper.insertDOC_NumerotationTable(true, "BC200000", "BCF200000", "CF200000", "BL200000", "ME200000", "MS200000"), connexion); using (IDataReader reader = command.ExecuteReader()) { result = true; //writer.WriteLine(DateTime.Now + " | initDOC_Numerotation() : Table DOC_Numerotation created!"); } connexion.Close(); } catch (Exception ex) { result = false; MessageBox.Show("Erreur[200]" + ex.Message.Replace("[CBase]", "").Replace("[Microsoft]", "").Replace("[Gestionnaire de pilotes ODBC]", "").Replace("[Simba]", " ").Replace("[Simba ODBC Driver]", "").Replace("[SimbaEngine ODBC Driver]", " ").Replace("[DRM File Library]", "").Replace("ERROR", ""), "Erreur !", MessageBoxButtons.OK, MessageBoxIcon.Error); //writer.WriteLine(DateTime.Now + " | initDOC_Numerotation() : ******************** Erreur ********************"); //writer.WriteLine(DateTime.Now + " : Erreur[200]" + ex.Message.Replace("[CBase]", "").Replace("[Microsoft]", "").Replace("[Gestionnaire de pilotes ODBC]", "").Replace("[Simba]", " ").Replace("[Simba ODBC Driver]", "").Replace("[SimbaEngine ODBC Driver]", " ").Replace("[DRM File Library]", "").Replace("ERROR", "")); } } connexion.Close(); } catch (Exception ex) { MessageBox.Show("ERROR[Init 4] : " + ex.Message, "Erreur!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); result = false; } //writer.WriteLine(""); return(result); }