string IntfDalRouteNationale.isRouteNationale(crlRouteNationale routeNationale, string strRouteNationale) { #region declaration string strRN = ""; #endregion #region implementation if (routeNationale != null) { this.strCommande = "SELECT * FROM `routenationale` WHERE (`routeNationale`='" + routeNationale.RouteNationale + "' AND"; this.strCommande += " `routeNationale`<>'" + strRouteNationale + "')"; this.serviceConnectBase.openConnection(); this.reader = this.serviceConnectBase.select(this.strCommande); if (this.reader != null) { if (this.reader.HasRows) { if (this.reader.Read()) { strRN = this.reader["routeNationale"].ToString(); } } this.reader.Dispose(); } this.serviceConnectBase.closeConnection(); } #endregion return(strRN); }
string IntfDalRouteNationale.insertRouteNationale(crlRouteNationale routeNationale) { #region declaration string strRouteNationale = ""; int nbInsert = 0; #endregion #region implementation if (routeNationale != null) { this.strCommande = "INSERT INTO `routenationale` (`routeNationale`,`distanceRN`)"; this.strCommande += " VALUES ('" + routeNationale.RouteNationale + "','" + routeNationale.DistanceRN + "')"; this.serviceConnectBase.openConnection(); nbInsert = this.serviceConnectBase.requete(this.strCommande); if (nbInsert == 1) { strRouteNationale = routeNationale.RouteNationale; } this.serviceConnectBase.closeConnection(); } #endregion return(strRouteNationale); }
bool IntfDalRouteNationale.updateRouteNationale(crlRouteNationale routeNationale, string strRouteNationale) { #region declaration bool isUpdate = false; int nbUpdate = 0; #endregion #region implementation if (routeNationale != null) { this.strCommande = "UPDATE `routenationale` SET `routeNationale`='" + routeNationale.RouteNationale + "',"; this.strCommande += " `distanceRN`='" + routeNationale.DistanceRN.ToString("0") + "'"; this.strCommande += " WHERE `routeNationale`='" + strRouteNationale + "'"; this.serviceConnectBase.openConnection(); nbUpdate = this.serviceConnectBase.requete(this.strCommande); if (nbUpdate == 1) { isUpdate = true; } this.serviceConnectBase.closeConnection(); } #endregion return(isUpdate); }
bool IntfDalRouteNationale.isRouteNationale(crlRouteNationale routeNationale) { #region declaration bool isRN = false; #endregion #region implementation if (routeNationale != null) { this.strCommande = "SELECT * FROM `routenationale` WHERE (`routeNationale`='" + routeNationale.RouteNationale + "')"; this.serviceConnectBase.openConnection(); this.reader = this.serviceConnectBase.select(this.strCommande); if (this.reader != null) { if (this.reader.HasRows) { while (this.reader.Read()) { if (routeNationale.RouteNationale.Trim().ToLower().Equals(this.reader["routeNationale"].ToString().Trim().ToLower())) { isRN = true; break; } } } this.reader.Dispose(); } this.serviceConnectBase.closeConnection(); } #endregion return(isRN); }
private void afficheRN(string routeNationale) { #region declaration crlRouteNationale routeNationaleObj = null; string strConfirm = ""; #endregion #region implementation if (routeNationale != "") { routeNationaleObj = serviceRouteNationale.selectRouteNationale(routeNationale); if (routeNationaleObj != null) { TextRN.Text = routeNationaleObj.RouteNationale; TextDistance.Text = routeNationaleObj.DistanceRN.ToString("0"); LabRN.Text = routeNationaleObj.RouteNationale; strConfirm = "Voulez vous vraiment modifier la route nationale " + routeNationaleObj.RouteNationale + "?"; btnModifier_ConfirmButtonExtender.ConfirmText = strConfirm; btnModifier.Enabled = true; btnValider.Enabled = false; } } #endregion }
List <crlRouteNationale> IntfDalRouteNationale.selectRNForItineraire(string idItineraire) { #region declaration List <crlRouteNationale> routeNationales = null; crlRouteNationale tempRouteNationaleObj = null; IntfDalVille serviceVille = new ImplDalVille(); #endregion #region implementation if (idItineraire != "") { this.strCommande = "SELECT routenationale.routeNationale, routenationale.distanceRN FROM routenationale"; this.strCommande += " Inner Join assoitineraireroutenationale ON assoitineraireroutenationale.routeNationale = routenationale.routeNationale"; this.strCommande += " WHERE assoitineraireroutenationale.idItineraire = '" + idItineraire + "'"; this.serviceConnectBase.openConnection(); this.reader = this.serviceConnectBase.select(this.strCommande); if (this.reader != null) { if (this.reader.HasRows) { routeNationales = new List <crlRouteNationale>(); while (this.reader.Read()) { tempRouteNationaleObj = new crlRouteNationale(); tempRouteNationaleObj.RouteNationale = this.reader["routeNationale"].ToString(); try { tempRouteNationaleObj.DistanceRN = double.Parse(this.reader["distanceRN"].ToString()); } catch (Exception) { } routeNationales.Add(tempRouteNationaleObj); } } this.reader.Dispose(); } this.serviceConnectBase.closeConnection(); if (routeNationales != null) { for (int i = 0; i < routeNationales.Count; i++) { routeNationales[i].villes = serviceVille.selectVillesForRN(routeNationales[i].RouteNationale); } } } #endregion return(routeNationales); }
crlRouteNationale IntfDalRouteNationale.selectRouteNationale(string routeNationale) { #region declaration crlRouteNationale routeNationaleObj = null; IntfDalVille serviceVille = new ImplDalVille(); #endregion #region implementation if (routeNationale != "") { this.strCommande = "SELECT * FROM `routenationale` WHERE (`routeNationale`='" + routeNationale + "')"; this.serviceConnectBase.openConnection(); this.reader = this.serviceConnectBase.select(this.strCommande); if (this.reader != null) { if (this.reader.HasRows) { if (this.reader.Read()) { routeNationaleObj = new crlRouteNationale(); routeNationaleObj.RouteNationale = this.reader["routeNationale"].ToString(); try { routeNationaleObj.DistanceRN = double.Parse(this.reader["distanceRN"].ToString()); } catch (Exception) { } } } this.reader.Dispose(); } this.serviceConnectBase.closeConnection(); if (routeNationaleObj != null) { routeNationaleObj.villes = serviceVille.selectVillesForRN(routeNationaleObj.RouteNationale); } } #endregion return(routeNationaleObj); }
protected void btnModifier_Click(object sender, EventArgs e) { #region declaration crlRouteNationale routeNationale = new crlRouteNationale(); string strRouteNationale = ""; #endregion #region implementation if (LabRN.Text != "") { routeNationale = serviceRouteNationale.selectRouteNationale(LabRN.Text); if (routeNationale != null) { routeNationale.RouteNationale = TextRN.Text; routeNationale.DistanceRN = double.Parse(TextDistance.Text); strRouteNationale = serviceRouteNationale.isRouteNationale(routeNationale, LabRN.Text); if (strRouteNationale.Equals("")) { if (serviceRouteNationale.updateRouteNationale(routeNationale, LabRN.Text)) { this.afficheRN(routeNationale.RouteNationale); this.initialiseGridVille(); this.initialiseGridVilleRN(); this.initialiseGridRN(); } else { // } } else { // } } } #endregion }
protected void btnValider_Click(object sender, EventArgs e) { #region declaration crlRouteNationale routeNationale = new crlRouteNationale(); string strRouteNationale = ""; string strIndication = ""; #endregion #region implementation routeNationale.RouteNationale = TextRN.Text; routeNationale.DistanceRN = double.Parse(TextDistance.Text); if (!serviceRouteNationale.isRouteNationale(routeNationale)) { strRouteNationale = serviceRouteNationale.insertRouteNationale(routeNationale); if (strRouteNationale != "") { this.afficheRN(strRouteNationale); this.initialiseGridVille(); this.initialiseGridVilleRN(); this.initialiseGridRN(); strIndication = "La route nationale " + strRouteNationale + " est bien enregistrer!<br/>"; strIndication += "Maintenant sélectionner les villes de la route nationale " + strRouteNationale + "!"; this.divIndicationText(strIndication, "black"); } else { //erreu pandant insertion strIndication = "Une erreur ce produit durant l'enregistrement!"; this.divIndicationText(strIndication, "red"); } } else { strIndication = "La route nationale " + routeNationale.RouteNationale + " est déjà dans la base de données!"; this.divIndicationText(strIndication, "red"); //route nationale deja dans la base } #endregion }