string IntfDalCooperative.isCooperative(crlCooperative cooperative) { #region declaration string numCooperative = ""; #endregion #region implementation if (cooperative != null) { this.strCommande = "SELECT * FROM `cooperative` WHERE `numCooperative`<>'" + cooperative.NumCooperative + "' AND"; this.strCommande += " `nomCooperative`='" + cooperative.NomCooperative + "' AND `nomResponsable`='" + cooperative.NomResponsable + "' AND"; this.strCommande += " `prenomResponsable`='" + cooperative.PrenomResponsable + "' AND `cinResponsable`='" + cooperative.CinResponsable + "'"; this.serviceConnection.openConnection(); this.reader = this.serviceConnection.select(this.strCommande); if (this.reader != null) { if (this.reader.HasRows) { if (this.reader.Read()) { numCooperative = this.reader["numCooperative"].ToString(); } } this.reader.Dispose(); } this.serviceConnection.closeConnection(); } #endregion return(numCooperative); }
bool IntfDalCooperative.updateCooperative(crlCooperative cooperative) { #region declaration bool isUpdate = false; int nombreUpdate = 0; #endregion #region implementation if (cooperative != null) { this.strCommande = "UPDATE `cooperative` SET `nomCooperative`='" + cooperative.NomCooperative + "',"; this.strCommande += " `sigleCooperative`='" + cooperative.SigleCooperative + "',"; this.strCommande += " `adresseCooperative`='" + cooperative.AdresseCooperative + "',"; this.strCommande += " `zone`='" + cooperative.Zone + "',`telephoneFixeCooperative`='" + cooperative.TelephoneFixeCooperative + "',"; this.strCommande += " `telephoneMobileCooperative`='" + cooperative.TelephoneMobileCooperative + "',"; this.strCommande += " `numVille`='" + cooperative.NumVille + "',`nomResponsable`='" + cooperative.NomResponsable + "',"; this.strCommande += " `prenomResponsable`='" + cooperative.PrenomResponsable + "',`cinResponsable`='" + cooperative.CinResponsable + "',"; this.strCommande += " `adressseResponsable`='" + cooperative.AdressseResponsable + "',`telephoneFixeResponsable`='" + cooperative.TelephoneFixeResponsable + "',"; this.strCommande += " `telephoneMobileResponsable`='" + cooperative.TelephoneMobileResponsable + "'"; this.strCommande += " WHERE `numCooperative`='" + cooperative.NumCooperative + "'"; this.serviceConnection.openConnection(); nombreUpdate = this.serviceConnection.requete(this.strCommande); if (nombreUpdate == 1) { isUpdate = true; } this.serviceConnection.closeConnection(); } #endregion return(isUpdate); }
protected void btnValider_Click(object sender, EventArgs e) { #region declaration crlCooperative cooperative = null; string strIndication = ""; #endregion #region implementation cooperative = new crlCooperative(); this.insertToObjet(cooperative); cooperative.NumCooperative = serviceCooperative.isCooperative(cooperative); if (cooperative.NumCooperative.Equals("")) { cooperative.NumCooperative = serviceCooperative.insertCooperative(cooperative, agent.agence.SigleAgence); if (cooperative.NumCooperative != "") { this.initialiseGridCooperative(); this.initialiseFormulaire(); strIndication = "Coopéartive " + cooperative.NomCooperative + " bien enregistrer!"; this.divIndicationText(strIndication, "Black"); } else { strIndication = "Une erreur ce produit durant l'enregistrement!"; this.divIndicationText(strIndication, "Red"); } } else { strIndication = "Le cooperative " + cooperative.NomCooperative + " est déjà dans le base de donnée!"; this.divIndicationText(strIndication, "Red"); } #endregion }
crlCooperative IntfDalCooperative.selectCooperative(string numCooperative) { #region declaration crlCooperative cooperative = null; #endregion #region implementation if (numCooperative != "") { this.strCommande = "SELECT * FROM `cooperative` WHERE (`numCooperative`='" + numCooperative + "')"; this.serviceConnection.openConnection(); if (this.serviceConnection.IsConnection) { this.reader = this.serviceConnection.select(this.strCommande); if (this.reader != null) { if (this.reader.HasRows) { if (this.reader.Read()) { cooperative = new crlCooperative(); cooperative.NumCooperative = this.reader["numCooperative"].ToString(); cooperative.AdresseCooperative = this.reader["adresseCooperative"].ToString(); cooperative.NomCooperative = this.reader["nomCooperative"].ToString(); cooperative.SigleCooperative = this.reader["sigleCooperative"].ToString(); cooperative.Zone = this.reader["zone"].ToString(); cooperative.TelephoneFixeCooperative = this.reader["telephoneFixeCooperative"].ToString(); cooperative.TelephoneMobileCooperative = this.reader["telephoneMobileCooperative"].ToString(); cooperative.NumVille = this.reader["numVille"].ToString(); cooperative.NomResponsable = this.reader["nomResponsable"].ToString(); cooperative.PrenomResponsable = this.reader["prenomResponsable"].ToString(); cooperative.CinResponsable = this.reader["cinResponsable"].ToString(); cooperative.AdresseCooperative = this.reader["adresseCooperative"].ToString(); cooperative.TelephoneFixeResponsable = this.reader["telephoneFixeResponsable"].ToString(); cooperative.TelephoneMobileResponsable = this.reader["telephoneMobileResponsable"].ToString(); } } this.reader.Dispose(); } while (this.serviceConnection.IsConnection) { this.serviceConnection.closeConnection(); } } } #endregion return(cooperative); }
private void afficheCooperative(string numCooperative) { #region declaration crlCooperative cooperative = null; #endregion #region implementation if (numCooperative != "") { cooperative = serviceCooperative.selectCooperative(numCooperative); if (cooperative != null) { TextAdresse.Text = cooperative.AdresseCooperative; TextNomCooperative.Text = cooperative.NomCooperative; TextSigle.Text = cooperative.SigleCooperative; try { ddlZone.SelectedValue = cooperative.Zone; } catch (Exception) { } try { ddlVille.SelectedValue = cooperative.NumVille; } catch (Exception) { } TextFixeCooperative.Text = cooperative.TelephoneFixeCooperative; TextMobileCooperative.Text = cooperative.TelephoneMobileCooperative; TextNomResponsable.Text = cooperative.NomResponsable; TextPrenomResponsable.Text = cooperative.PrenomResponsable; TextCINResponsable.Text = cooperative.CinResponsable; TextAdresseResponsable.Text = cooperative.AdresseCooperative; TextTelephoneResponsable.Text = cooperative.TelephoneFixeResponsable; TextMobileResponsable.Text = cooperative.TelephoneMobileResponsable; hfNumCooperative.Value = cooperative.NumCooperative; btnModifier.Enabled = true; btnValider.Enabled = false; ConfirmButtonExtender_btnModifier.ConfirmText = "Vouler vous vraiment modifier le coopérative " + cooperative.NomCooperative + "?"; } } #endregion }
protected void btnModifier_Click(object sender, EventArgs e) { #region declaration crlCooperative cooperative = null; string strIndication = ""; #endregion #region implementation if (hfNumCooperative.Value != "") { cooperative = serviceCooperative.selectCooperative(hfNumCooperative.Value); if (cooperative != null) { this.insertToObjet(cooperative); if (serviceCooperative.isCooperative(cooperative).Equals("")) { if (serviceCooperative.updateCooperative(cooperative)) { this.initialiseGridCooperative(); this.initialiseFormulaire(); strIndication = "Modification de la coopéartive " + cooperative.NomCooperative + " bien enregistrer!"; this.divIndicationText(strIndication, "Black"); } else { strIndication = "Une erreur ce produit durant l'enregistrement!"; this.divIndicationText(strIndication, "Red"); } } else { strIndication = "Le cooperative " + cooperative.NomCooperative + " est déjà dans le base de donnée!"; this.divIndicationText(strIndication, "Red"); } } } else { // } #endregion }
private void insertToObjet(crlCooperative cooperative) { #region implementation if (cooperative != null) { cooperative.AdresseCooperative = TextAdresse.Text; cooperative.NomCooperative = TextNomCooperative.Text; cooperative.SigleCooperative = TextSigle.Text; cooperative.Zone = ddlZone.SelectedValue; cooperative.NumVille = ddlVille.SelectedValue; cooperative.TelephoneFixeCooperative = TextFixeCooperative.Text; cooperative.TelephoneMobileCooperative = TextMobileCooperative.Text; cooperative.NomResponsable = TextNomResponsable.Text; cooperative.PrenomResponsable = TextPrenomResponsable.Text; cooperative.CinResponsable = TextCINResponsable.Text; cooperative.AdressseResponsable = TextAdresseResponsable.Text; cooperative.TelephoneFixeResponsable = TextTelephoneResponsable.Text; cooperative.TelephoneMobileResponsable = TextMobileResponsable.Text; } #endregion }
string IntfDalCooperative.insertCooperative(crlCooperative cooperative, string sigleAgence) { #region decalration string numCooperative = ""; int nombreInsert = 0; IntfDalCooperative serviceCooperative = new ImplDalCooperative(); #endregion #region implementation if (cooperative != null && sigleAgence != "") { cooperative.NumCooperative = serviceCooperative.getNumCooperative(sigleAgence); this.strCommande = "INSERT INTO `cooperative` (`numCooperative`, `nomCooperative`,"; this.strCommande += " `sigleCooperative`,`adresseCooperative`, `zone`,`telephoneFixeCooperative`,"; this.strCommande += " `telephoneMobileCooperative`,`numVille`,`nomResponsable`,`prenomResponsable`,"; this.strCommande += " `cinResponsable`,`adressseResponsable`,`telephoneFixeResponsable`,"; this.strCommande += " `telephoneMobileResponsable`) VALUES"; this.strCommande += " ('" + cooperative.NumCooperative + "','" + cooperative.NomCooperative + "',"; this.strCommande += " '" + cooperative.SigleCooperative + "','" + cooperative.AdresseCooperative + "',"; this.strCommande += " '" + cooperative.Zone + "','" + cooperative.TelephoneFixeCooperative + "',"; this.strCommande += " '" + cooperative.TelephoneMobileCooperative + "','" + cooperative.NumVille + "',"; this.strCommande += " '" + cooperative.NomResponsable + "','" + cooperative.PrenomResponsable + "',"; this.strCommande += " '" + cooperative.CinResponsable + "','" + cooperative.AdressseResponsable + "',"; this.strCommande += " '" + cooperative.TelephoneFixeResponsable + "','" + cooperative.TelephoneMobileResponsable + "')"; this.serviceConnection.openConnection(); nombreInsert = this.serviceConnection.requete(this.strCommande); if (nombreInsert == 1) { numCooperative = cooperative.NumCooperative; } this.serviceConnection.closeConnection(); } #endregion return(numCooperative); }