bool IntfDalUSVoyage.updateUSVoyage(crlUSVoyage voyage) { #region declaration bool isUpdate = false; int nbUpdate = 0; string matriculeAgentArrive = "NULL"; string matriculeAgentControleur = "NULL"; string numFacture = "NULL"; string numAppareil = "NULL"; #endregion #region implementation if (voyage != null) { if (voyage.MatriculeAgentArrive != "") { matriculeAgentArrive = "'" + voyage.MatriculeAgentArrive + "'"; } if (voyage.MatriculeAgentControleur != "") { matriculeAgentControleur = "'" + voyage.MatriculeAgentControleur + "'"; } if (voyage.NumFacture != "") { numFacture = "'" + voyage.NumFacture + "'"; } if (voyage.NumAppareil != "") { numAppareil = "'" + voyage.NumAppareil + "'"; } this.strCommande = "UPDATE `usvoyage` SET `dateHeureDepart`='" + voyage.DateHeureDepart.ToString("yyyy-MM-dd HH:mm:ss") + "',"; this.strCommande += " `dateHeureArrive`='" + voyage.DateHeureArrive.ToString("yyyy-MM-dd HH:mm:ss") + "',"; this.strCommande += " `numLicence`='" + voyage.NumLicence + "',`matriculeAgentDepart`='" + voyage.MatriculeAgentDepart + "',"; this.strCommande += " `matriculeAgentArrive`=" + matriculeAgentArrive + ","; this.strCommande += " `matriculeAgentChauffeur`='" + voyage.MatriculeAgentChauffeur + "',"; this.strCommande += " `matriculeAgentReceveur`='" + voyage.MatriculeAgentReceveur + "',"; this.strCommande += " `matriculeAgentControleur`=" + matriculeAgentControleur + ","; this.strCommande += " `numLigne`='" + voyage.NumLigne + "',"; this.strCommande += " `numAppareil`=" + numAppareil + ","; this.strCommande += " `numFacture`=" + numFacture; this.strCommande += " WHERE `numVoyage`='" + voyage.NumVoyage + "'"; this.serviceConnectBase.openConnection(); nbUpdate = this.serviceConnectBase.requete(this.strCommande); if (nbUpdate == 1) { isUpdate = true; } this.serviceConnectBase.closeConnection(); } #endregion return(isUpdate); }
string IntfDalUSVoyage.insertUSVoyage(crlUSVoyage voyage, string sigleAgence) { #region declaration string numVoyage = ""; IntfDalUSVoyage serviceUSVoyage = new ImplDalUSVoyage(); string matriculeAgentArrive = "NULL"; string matriculeAgentControleur = "NULL"; string numFacture = "NULL"; string numAppareil = "NULL"; int nbInsert = 0; #endregion #region implementation if (voyage != null) { if (voyage.MatriculeAgentArrive != "") { matriculeAgentArrive = "'" + voyage.MatriculeAgentArrive + "'"; } if (voyage.MatriculeAgentControleur != "") { matriculeAgentControleur = "'" + voyage.MatriculeAgentControleur + "'"; } if (voyage.NumFacture != "") { numFacture = "'" + voyage.NumFacture + "'"; } if (voyage.NumAppareil != "") { numAppareil = "'" + voyage.NumAppareil + "'"; } voyage.NumVoyage = serviceUSVoyage.getNumUSVoyage(sigleAgence); this.strCommande = "INSERT INTO `usvoyage` (`numVoyage`,`dateHeureDepart`,`dateHeureArrive`,"; this.strCommande += " `numLicence`,`matriculeAgentDepart`,`matriculeAgentArrive`,`matriculeAgentChauffeur`,"; this.strCommande += " `matriculeAgentReceveur`,`matriculeAgentControleur`,`numLigne`,`numFacture`,`numAppareil`)"; this.strCommande += " VALUES ('" + voyage.NumVoyage + "','" + voyage.DateHeureDepart.ToString("yyyy-MM-dd HH:mm:ss") + "',"; this.strCommande += " '" + voyage.DateHeureArrive.ToString("yyyy-MM-dd HH:mm:ss") + "','" + voyage.NumLicence + "',"; this.strCommande += " '" + voyage.MatriculeAgentDepart + "'," + matriculeAgentArrive + ","; this.strCommande += " '" + voyage.MatriculeAgentChauffeur + "','" + voyage.MatriculeAgentReceveur + "',"; this.strCommande += " " + matriculeAgentControleur + ",'" + voyage.NumLigne + "'," + numFacture + "," + numAppareil + ")"; this.serviceConnectBase.openConnection(); nbInsert = this.serviceConnectBase.requete(this.strCommande); if (nbInsert == 1) { numVoyage = voyage.NumVoyage; } this.serviceConnectBase.closeConnection(); } #endregion return(numVoyage); }
crlUSVoyage IntfDalUSVoyage.selectUSVoyage(string numVoyage) { #region declaration crlUSVoyage voyage = null; IntfDalAgent serviceAgent = new ImplDalAgent(); #endregion #region implementation if (numVoyage != "") { this.strCommande = "SELECT * FROM `usvoyage` WHERE `numVoyage`='" + numVoyage + "'"; this.serviceConnectBase.openConnection(); this.reader = this.serviceConnectBase.select(this.strCommande); if (this.reader != null) { if (this.reader.HasRows) { if (this.reader.Read()) { voyage = new crlUSVoyage(); try { voyage.DateHeureArrive = Convert.ToDateTime(this.reader["dateHeureArrive"].ToString()); } catch (Exception) { } try { voyage.DateHeureDepart = Convert.ToDateTime(this.reader["dateHeureDepart"].ToString()); } catch (Exception) { } voyage.MatriculeAgentArrive = this.reader["matriculeAgentArrive"].ToString(); voyage.MatriculeAgentChauffeur = this.reader["matriculeAgentChauffeur"].ToString(); voyage.MatriculeAgentControleur = this.reader["matriculeAgentControleur"].ToString(); voyage.MatriculeAgentDepart = this.reader["matriculeAgentDepart"].ToString(); voyage.MatriculeAgentReceveur = this.reader["matriculeAgentReceveur"].ToString(); voyage.NumLicence = this.reader["numLicence"].ToString(); voyage.NumVoyage = this.reader["numVoyage"].ToString(); voyage.NumLigne = this.reader["numLigne"].ToString(); voyage.NumFacture = this.reader["numFacture"].ToString(); voyage.NumAppareil = this.reader["numAppareil"].ToString(); } } this.reader.Dispose(); } this.serviceConnectBase.closeConnection(); if (voyage != null) { if (voyage.MatriculeAgentArrive != "") { voyage.agentArrive = serviceAgent.selectAgent(voyage.MatriculeAgentArrive); } if (voyage.MatriculeAgentChauffeur != "") { voyage.agentChauffeur = serviceAgent.selectAgent(voyage.MatriculeAgentChauffeur); } if (voyage.MatriculeAgentControleur != "") { voyage.agentControleur = serviceAgent.selectAgent(voyage.MatriculeAgentControleur); } if (voyage.MatriculeAgentDepart != "") { voyage.agentDepart = serviceAgent.selectAgent(voyage.MatriculeAgentDepart); } if (voyage.MatriculeAgentReceveur != "") { voyage.agentReceveur = serviceAgent.selectAgent(voyage.MatriculeAgentReceveur); } } } #endregion return(voyage); }