bool IntfDalUSTrajet.updateUSTrajet(crlUSTrajet trajet) { #region declaration bool isUpdate = false; int nbUpdate = 0; #endregion #region implementation if (trajet != null) { this.strCommande = "UPDATE `ustrajet` SET `distanceTrajet`='" + trajet.DistanceTrajet + "',"; this.strCommande += " `dureeTrajet`='" + trajet.DureeTrajet + "',"; this.strCommande += " `numArretD`='" + trajet.NumArretD + "',`numArretF`='" + trajet.NumArretF + "' WHERE"; this.strCommande += " `numTrajet`='" + trajet.NumTrajet + "'"; this.serviceConnectBase.openConnection(); nbUpdate = this.serviceConnectBase.requete(this.strCommande); if (nbUpdate == 1) { isUpdate = true; } this.serviceConnectBase.closeConnection(); } #endregion return(isUpdate); }
string IntfDalUSTrajet.insertUSTrajet(crlUSTrajet trajet, string sigleAgence) { #region declaration string numTrajet = ""; IntfDalUSTrajet serviceUSTrajet = new ImplDalUSTrajet(); int nbInsert = 0; #endregion #region implemenation if (trajet != null && sigleAgence != "") { trajet.NumTrajet = serviceUSTrajet.getNumUSTrajet(sigleAgence); this.strCommande = "INSERT INTO `ustrajet` (`numTrajet`,`distanceTrajet`,`dureeTrajet`,`numArretD`,`numArretF`)"; this.strCommande += " VALUES ('" + trajet.NumTrajet + "','" + trajet.DistanceTrajet + "','" + trajet.DureeTrajet + "',"; this.strCommande += " '" + trajet.NumArretD + "','" + trajet.NumArretF + "')"; this.serviceConnectBase.openConnection(); nbInsert = this.serviceConnectBase.requete(this.strCommande); if (nbInsert == 1) { numTrajet = trajet.NumTrajet; } this.serviceConnectBase.closeConnection(); } #endregion return(numTrajet); }
string IntfDalUSTrajet.isUSTrajet(crlUSTrajet trajet) { #region declaration string numTrajet = ""; #endregion #region implementation if (trajet != null) { this.strCommande = "SELECT * FROM `ustrajet` WHERE"; this.strCommande += " `distanceTrajet`=" + trajet.DistanceTrajet + " AND"; this.strCommande += " `dureeTrajet`='" + trajet.DureeTrajet + "' AND"; this.strCommande += " `numArretD`='" + trajet.NumArretD + "' AND"; this.strCommande += " `numArretF`='" + trajet.NumArretF + "' AND"; this.strCommande += " `numTrajet`<>'" + trajet.NumTrajet + "'"; this.serviceConnectBase.openConnection(); this.reader = this.serviceConnectBase.select(this.strCommande); if (this.reader != null) { if (this.reader.HasRows) { if (this.reader.Read()) { numTrajet = this.reader["numTrajet"].ToString(); } } this.reader.Dispose(); } this.serviceConnectBase.closeConnection(); } #endregion return(numTrajet); }
crlUSTrajet IntfDalUSTrajet.getTrajet(string numArretD, string numArretF) { #region declaration crlUSTrajet trajet = null; #endregion #region implementation if (numArretD != "" && numArretF != "") { this.strCommande = "SELECT ustrajet.numTrajet, ustrajet.distanceTrajet, ustrajet.dureeTrajet,"; this.strCommande += " ustrajet.numArretD, ustrajet.numArretF FROM ustrajet"; this.strCommande += " WHERE (ustrajet.numArretD = '" + numArretD + "' AND"; this.strCommande += " ustrajet.numArretF = '" + numArretF + "') OR"; this.strCommande += " (ustrajet.numArretD = '" + numArretF + "' AND"; this.strCommande += " ustrajet.numArretF = '" + numArretD + "')"; this.serviceConnectBase.openConnection(); this.reader = this.serviceConnectBase.select(this.strCommande); if (this.reader != null) { if (this.reader.HasRows) { if (this.reader.Read()) { trajet = new crlUSTrajet(); try { trajet.DistanceTrajet = double.Parse(this.reader["distanceTrajet"].ToString()); } catch (Exception) { } trajet.DureeTrajet = this.reader["dureeTrajet"].ToString(); trajet.NumArretD = this.reader["numArretD"].ToString(); trajet.NumArretF = this.reader["numArretF"].ToString(); trajet.NumTrajet = this.reader["numTrajet"].ToString(); } } this.reader.Dispose(); } this.serviceConnectBase.closeConnection(); } #endregion return(trajet); }
crlUSTrajet IntfDalUSTrajet.selectUSTrajet(string numTrajet) { #region declaration crlUSTrajet trajet = null; IntfDalUSArret serviceUSArret = new ImplDalUSArret(); #endregion #region implementation if (numTrajet != "") { this.strCommande = "SELECT * FROM `ustrajet` WHERE (`numTrajet`='" + numTrajet + "')"; this.serviceConnectBase.openConnection(); this.reader = this.serviceConnectBase.select(this.strCommande); if (this.reader != null) { if (this.reader.HasRows) { if (this.reader.Read()) { trajet = new crlUSTrajet(); trajet.NumArretD = this.reader["numArretD"].ToString(); trajet.NumArretF = this.reader["numArretF"].ToString(); try { trajet.DistanceTrajet = double.Parse(this.reader["distanceTrajet"].ToString()); } catch (Exception) { } trajet.DureeTrajet = this.reader["dureeTrajet"].ToString(); trajet.NumTrajet = this.reader["numTrajet"].ToString(); } } this.reader.Dispose(); } this.serviceConnectBase.closeConnection(); if (trajet != null) { trajet.arretD = serviceUSArret.selectUSArret(trajet.NumArretD); trajet.arretF = serviceUSArret.selectUSArret(trajet.NumArretF); } } #endregion return(trajet); }