private void button1_Click(object sender, EventArgs e) { FonctionGenerique fg = new FonctionGenerique(); fg.designation = this.textBox1.Text; fg.rubrique = this.comboBox1.Text; fg.description = this.richTextBox1.Text; if (IhmManager.ajouter) { int nbligne = fgm.ajouterFonctionGen(fg); if (nbligne > 0) { MessageBox.Show("Ajout effectué avec succès !"); this.Close(); } ; } else { fg.idFonction = IhmManager.fctGenSelect.idFonction; int nbligne = fgm.modifierFctGen(fg); if (nbligne > 0) { MessageBox.Show("Modifcation effectuée avec succès !"); this.Close(); } ; } }
/// <summary> /// Supprimer un <paramref name="fctGen"/> dans la table Fonction_Générique de la base de données. /// </summary> /// <returns> /// Nombre de lignes affectées /// </returns> /// <param name="fctGen">un objet FonctionGenerique</param> public int supprimerFctGen(FonctionGenerique fctGen) { DbCommand cmd = db.CreerCommande(); cmd.CommandType = CommandType.Text; cmd.CommandText = "DELETE FROM Fonction_Générique " + "WHERE id_fonction =" + fctGen.idFonction; return(db.ExecuterRequete(cmd)); }
private void comboBoxFonction_SelectedIndexChanged(object sender, EventArgs e) { try { FonctionGenerique fg = (FonctionGenerique)this.comboBoxFonction.SelectedItem; this.toolTipFonction.SetToolTip(this.comboBoxFonction, fg.description); } catch { } }
/// <summary> /// Ajouter un <paramref name="fctGen"/> dans la table Fonction_Générique de la base de données. /// </summary> /// <returns> /// Nombre de lignes affectées /// </returns> /// <param name="fctGen">un objet FonctionGenerique</param> public int ajouterFonctionGen(FonctionGenerique fctGen) { DbCommand cmd = db.CreerCommande(); cmd.CommandType = CommandType.Text; cmd.CommandText = "INSERT INTO Fonction_Générique(id_fonction , rubrique , désignation, description ) " + "VALUES ('" + fctGen.idFonction + "', '" + fctGen.rubrique + "', '" + fctGen.designation + "', '" + fctGen.description + "')"; return(db.ExecuterRequete(cmd)); }
/// <summary> /// Modifier un <paramref name="fctGen"/> dans la table Fonction_Générique de la base de données. /// </summary> /// <returns> /// Nombre de lignes affectées /// </returns> /// <param name="fctGen">un objet FonctionGenerique</param> public int modifierFctGen(FonctionGenerique fctGen) { DbCommand cmd = db.CreerCommande(); cmd.CommandType = CommandType.Text; cmd.CommandText = "UPDATE Fonction_Générique " + "SET rubrique = '" + fctGen.rubrique + "', désignation = '" + fctGen.designation + "', description='" + fctGen.description + "' " + "WHERE id_fonction = " + fctGen.idFonction; return(db.ExecuterRequete(cmd)); }
//controler les caractères d'échappement pour l'insertion SQL private FonctionGenerique echappementFctGen(FonctionGenerique fctGen) { FonctionGenerique f = new FonctionGenerique(); f.idFonction = fctGen.idFonction; f.designation = fctGen.designation.Replace("'", "''").Replace(@"\", "\\"); f.rubrique = fctGen.rubrique.Replace("'", "''").Replace(@"\", "\\"); f.description = fctGen.description.Replace("'", "''").Replace(@"\", "\\"); return(f); }
/// <summary> /// Modifier un <paramref name="fctGen"/> dans la table Fonction_Générique de la base de données. /// </summary> /// <returns> /// Nombre de lignes affectées /// </returns> /// <param name="fctGen">un objet FonctionGenerique</param> public int modifierFctGen(FonctionGenerique fctGen) { if (fctGen.designation.Trim() == "") { return(0); } else { fctGen.rubrique = fctGen.rubrique[0].ToString().ToUpper() + fctGen.rubrique.Substring(1).ToLower(); fctGen.designation = fctGen.designation[0].ToString().ToUpper() + fctGen.designation.Substring(1).ToLower(); return(fgd.modifierFctGen(this.echappementFctGen(fctGen))); } }
/// <summary> /// Obtenir un objet FonctionGenerique par son <paramref name="idFonction"/> /// </summary> /// <returns> /// Un objet FonctionGenerique /// </returns> /// <param name="idFonction">Identifiant de la fonction</param> public FonctionGenerique getFonctionGenById(int idFonction) { FonctionGenerique fonction = new FonctionGenerique(); DbCommand cmd = db.CreerCommande(); cmd.CommandType = CommandType.Text; cmd.CommandText = "Select * from Fonction_Générique where id_fonction='" + idFonction + "'"; DataTable table = db.CreerDatatable(cmd); if (table.Rows.Count >= 1) { fonction.idFonction = (int)table.Rows[0][0]; fonction.rubrique = (string)table.Rows[0][1].ToString(); fonction.designation = (string)table.Rows[0][2].ToString(); fonction.description = (string)table.Rows[0][3].ToString(); } return(fonction); }
public void modifierObj(metier m, Object ob) { IhmManager.ajouter = false; Form form; switch (m) { case metier.Projet: IhmManager.projetSelect = (Projet)ob; form = new FenCrudProjet(); form.ShowDialog(); break; case metier.Personnel: IhmManager.persSelect = (Personnel)ob; form = new FenCrudPersonnel(); form.ShowDialog(); break; case metier.FonctionGen: IhmManager.fctGenSelect = (FonctionGenerique)ob; form = new FenCrudFctGen(); form.ShowDialog(); break; case metier.IoPhysGen: IhmManager.ioPhysGenSelect = (IoPhysiqueGenerique)ob; form = new FenCrudIoPhysiqueGen(); form.ShowDialog(); break; case metier.CritGen: IhmManager.critGenSelect = (CritereGenerique)ob; form = new FenCrudCritGen(); form.ShowDialog(); break; default: break; } }
/// <summary> /// Obtenir une liste d'objet FonctionGenerique /// </summary> /// <returns> /// Une liste d'objet FonctionGenerique /// </returns> public List <FonctionGenerique> getListFonctionGen() { List <FonctionGenerique> listFctGen = new List <FonctionGenerique>(); DbCommand cmd = db.CreerCommande(); cmd.CommandType = CommandType.Text; cmd.CommandText = "Select * from Fonction_Générique"; DataTable table = db.CreerDatatable(cmd); if (table != null) { foreach (DataRow row in table.Rows) { FonctionGenerique fctGen = new FonctionGenerique(); fctGen.idFonction = (int)row[0]; fctGen.rubrique = (string)row[1]; fctGen.designation = (string)row[2]; fctGen.description = (string)row[3].ToString(); listFctGen.Add(fctGen); } } return(listFctGen); }
public void supprimerObj(metier m, Object ob) { DialogResult dialogResult; switch (m) { case metier.Projet: IhmManager.projetSelect = (Projet)ob; dialogResult = MessageBox.Show("Etes-vous sur de vouloir supprimer le projet #" + IhmManager.projetSelect + " ?", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { //do something this.projetManager.supprimerProjet(IhmManager.projetSelect); } break; case metier.Personnel: IhmManager.persSelect = (Personnel)ob; dialogResult = MessageBox.Show("Etes-vous sur de vouloir supprimer le personnel #" + IhmManager.persSelect + " ?", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { //do something this.persManager.supprimerPersonne(IhmManager.persSelect); } break; case metier.FonctionGen: IhmManager.fctGenSelect = (FonctionGenerique)ob; dialogResult = MessageBox.Show("Etes-vous sur de vouloir supprimer la fonction #" + IhmManager.fctGenSelect + " ?", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { //do something this.fctGenManager.supprimerFctGen(IhmManager.fctGenSelect); } break; case metier.IoPhysGen: IhmManager.ioPhysGenSelect = (IoPhysiqueGenerique)ob; dialogResult = MessageBox.Show("Etes-vous sur de vouloir supprimer l'IO physique #" + IhmManager.ioPhysGenSelect + " ?", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { //do something this.ioPhysGenManager.supprimerIoPhysiqueGen(IhmManager.ioPhysGenSelect); } break; case metier.CritGen: IhmManager.critGenSelect = (CritereGenerique)ob; dialogResult = MessageBox.Show("Etes-vous sur de vouloir supprimer le critère #" + IhmManager.critGenSelect + " ?", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { //do something this.critGenManager.supprimerCritGen(IhmManager.critGenSelect); } break; default: break; } }
/// <summary> /// Supprimer un <paramref name="fctGen"/> dans la table Fonction_Générique de la base de données. /// </summary> /// <returns> /// Nombre de lignes affectées /// </returns> /// <param name="fctGen">un objet FonctionGenerique</param> public int supprimerFctGen(FonctionGenerique fctGen) { return(fgd.supprimerFctGen(this.echappementFctGen(fctGen))); }