bool IntfDalRecu.deleteRecu(crlRecu Recu) { #region declaration bool isDelete = false; int nombreDelete = 0; #endregion #region implementation if (Recu != null) { if (Recu.NumRecu != "") { this.strCommande = "DELETE FROM `recu` WHERE (`numRecu` = '" + Recu.NumRecu + "')"; this.serviceConnectBase.openConnection(); nombreDelete = this.serviceConnectBase.requete(this.strCommande); if (nombreDelete == 1) { isDelete = true; } this.serviceConnectBase.closeConnection(); } } #endregion return(isDelete); }
string IntfDalRecu.insertRecu(crlRecu Recu) { #region declaration IntfDalRecu serviceRecu = new ImplDalRecu(); int nombreInsertion = 0; string numRecu = ""; #endregion #region implementation if (Recu != null) { Recu.NumRecu = serviceRecu.getNumRecu(); this.strCommande = "INSERT INTO `recu` (`numRecu`,`libele`,`montant`,`date`,`modePaiement`,`matriculeAgent`)"; this.strCommande += " VALUES ('" + Recu.NumRecu + "', '" + Recu.Libele + "', '" + Recu.Montant + "',"; this.strCommande += " '" + Recu.Date.ToString("yyyy-MM-dd") + "','" + Recu.ModePaiement + "','" + Recu.MatriculeAgent + "')"; this.serviceConnectBase.openConnection(); nombreInsertion = this.serviceConnectBase.requete(this.strCommande); if (nombreInsertion == 1) { numRecu = Recu.NumRecu; } this.serviceConnectBase.closeConnection(); } #endregion return(numRecu); }
bool IntfDalRecu.updateRecu(crlRecu Recu) { #region declaration bool isUpdate = false; int nombreUpdate = 0; #endregion #region implementation if (Recu != null) { if (Recu.NumRecu != "") { this.strCommande = "UPDATE `recu` SET `libele`='" + Recu.Libele + "', `modePaiement`='" + Recu.ModePaiement + "', "; this.strCommande += "`montant`='" + Recu.Montant + "', `date`='" + Recu.Date.ToString("yyyy-MM-dd") + "',`matriculeAgent`='" + Recu.MatriculeAgent + "'"; this.strCommande += "WHERE (`numRecu`='" + Recu.NumRecu + "')"; this.serviceConnectBase.openConnection(); nombreUpdate = this.serviceConnectBase.requete(this.strCommande); if (nombreUpdate == 1) { isUpdate = true; } this.serviceConnectBase.closeConnection(); } } #endregion return(isUpdate); }
crlRecu IntfDalRecu.isValideRecu(string numRecu) { #region declaration crlRecu Recu = null; IntfDalAgent serviceAgent = new ImplDalAgent(); #endregion #region implementation if (numRecu != "") { this.strCommande = "SELECT recu.numRecu, recu.libele, recu.montant, recu.`date`,"; this.strCommande += " recu.modePaiement, recu.matriculeAgent FROM recu"; this.strCommande += " Left Join bagage ON bagage.numRecu = recu.numRecu"; this.strCommande += " Left Join commission ON commission.numRecu = recu.numRecu"; this.strCommande += " WHERE bagage.numRecu IS NULL AND commission.numRecu IS NULL AND"; this.strCommande += " recu.numRecu ='" + numRecu + "'"; this.serviceConnectBase.openConnection(); this.reader = this.serviceConnectBase.select(this.strCommande); if (reader != null) { if (reader.HasRows) { Recu = new crlRecu(); reader.Read(); Recu.NumRecu = reader["numRecu"].ToString(); Recu.Libele = reader["libele"].ToString(); Recu.Montant = reader["montant"].ToString(); Recu.ModePaiement = reader["modePaiement"].ToString(); Recu.MatriculeAgent = reader["matriculeAgent"].ToString(); try { Recu.Date = Convert.ToDateTime(reader["date"].ToString()); } catch (Exception) { } } reader.Dispose(); } this.serviceConnectBase.closeConnection(); if (Recu != null) { if (Recu.MatriculeAgent != "") { Recu.agent = serviceAgent.selectAgent(Recu.MatriculeAgent); } } } #endregion return(Recu); }
crlRecu IntfDalRecu.selectRecu(string numRecu) { #region declaration crlRecu Recu = null; IntfDalAgent serviceAgent = new ImplDalAgent(); #endregion #region implementation if (numRecu != "") { this.strCommande = "SELECT * FROM `recu` WHERE (`numRecu`='" + numRecu + "')"; this.serviceConnectBase.openConnection(); this.reader = this.serviceConnectBase.select(this.strCommande); if (reader != null) { if (reader.HasRows) { Recu = new crlRecu(); reader.Read(); Recu.NumRecu = reader["numRecu"].ToString(); Recu.Libele = reader["libele"].ToString(); Recu.Montant = reader["montant"].ToString(); Recu.ModePaiement = reader["modePaiement"].ToString(); Recu.MatriculeAgent = reader["matriculeAgent"].ToString(); try { Recu.Date = Convert.ToDateTime(reader["date"].ToString()); } catch (Exception) { } } reader.Dispose(); } this.serviceConnectBase.closeConnection(); if (Recu != null) { if (Recu.MatriculeAgent != "") { Recu.agent = serviceAgent.selectAgent(Recu.MatriculeAgent); } } } #endregion return(Recu); }