public static List <Formulaires> listFormulaires(string query) { NpgsqlConnection con = Connexion.Connection(); try { NpgsqlCommand Lcmd = new NpgsqlCommand(query, con); NpgsqlDataReader lect = Lcmd.ExecuteReader(); List <Formulaires> l = new List <Formulaires>(); if (lect.HasRows) { while (lect.Read()) { Formulaires y = oneFormulaires((Int32)((lect["id"] != null) ? (!lect["id"].ToString().Trim().Equals("") ? lect["id"] : 0) : 0)); l.Add(y); } } return(l); } catch (NpgsqlException e) { Messages.Exception(e); return(null); } finally { Connexion.Deconnection(con); } }
private void dgv_form_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { if (dgv_form.Rows.Count > 0) { if (dgv_form.CurrentRow.Cells["id_form_"].Value != null) { Int32 id = (Int32)dgv_form.CurrentRow.Cells["id_form_"].Value; if (id > 0) { Formulaires f = new Formulaires(id); bool b = (bool)dgv_form.CurrentRow.Cells[e.ColumnIndex].Value; AutorisationFormulaire a = AutorisationFormulaireBLL.One(AutorisationFormulaireBLL.Current(new AutorisationFormulaire(current, f, b))); if (a != null ? a.Id > 0 : false) { AutorisationFormulaireBLL.Update(new AutorisationFormulaire(a.Id, current, f, b)); } else { AutorisationFormulaireBLL.Save(new AutorisationFormulaire(current, f, b)); } } } } } catch (Exception ex) { Messages.Exception(ex); } }
public static Int32 currentFormulaires(Formulaires f) { NpgsqlConnection con = Connexion.Connection(); try { String search = "select * from formulaires where code = '" + f.Code + "' and libelle = '" + f.Libelle + "'"; NpgsqlCommand Lcmd = new NpgsqlCommand(search, con); NpgsqlDataReader lect = Lcmd.ExecuteReader(); Int32 id = new Int32(); if (lect.HasRows) { while (lect.Read()) { id = (Int32)((lect["id"] != null) ? (!lect["id"].ToString().Trim().Equals("") ? lect["id"] : 0) : 0); } } return(id); } catch (NpgsqlException e) { Messages.Exception(e); return(0); } finally { Connexion.Deconnection(con); } }
public static Formulaires oneFormulaires(Int32 id) { NpgsqlConnection con = Connexion.Connection(); try { String search = "select * from formulaires where id = " + id; NpgsqlCommand Lcmd = new NpgsqlCommand(search, con); NpgsqlDataReader lect = Lcmd.ExecuteReader(); Formulaires y = new Formulaires(); if (lect.HasRows) { while (lect.Read()) { y.Id = id; y.Code = lect["code"].ToString(); y.Libelle = lect["libelle"].ToString(); } } return(y); } catch (NpgsqlException e) { Messages.Exception(e); return(null); } finally { Connexion.Deconnection(con); } }
private void archiverFormulaire(Formulaire formulaireToArchive) { formulaireToArchive.Statut = new Statut() { Id = 4, Code = CodeStatut.ARC, Libelle = "Archivé" }; Formulaires.Remove(formulaireToArchive); }
public static Int32 Current(Formulaires y) { try { return(FormulairesDAO.currentFormulaires(y)); } catch (Exception ex) { throw new Exception("Retour Impossible", ex); } }
public static bool Update(Formulaires y) { try { return(FormulairesDAO.updateFormulaires(y)); } catch (Exception ex) { throw new Exception("Modification Impossible", ex); } }
public static Formulaires Save(Formulaires y) { try { return(FormulairesDAO.saveFormulaires(y)); } catch (Exception ex) { throw new Exception("Insertion Impossible", ex); } }
public static bool Delete(Formulaires y) { try { return(FormulairesDAO.deleteFormulaires(y)); } catch (Exception ex) { throw new Exception("Suppression Impossible", ex); } }
public async Task <IActionResult> PostFormulairesAsync([FromBody] Formulaires f) { if (ModelState.IsValid) { _sc.addF(f); if (await _sc.SaveChangesAsync()) { return(Created($"api/Formuliare/{f.sujet}", f)); } } return(BadRequest("failed to save the trip")); }
private void LoadRessource(NiveauAcces n, Formulaires f) { dgv_ress.Rows.Clear(); string query = "select * from ressources where formulaire = " + f.Id + " order by code"; List <Ressources> l = RessourcesBLL.List(query); foreach (Ressources r in l) { r.Update = AutorisationRessourceBLL.One(AutorisationRessourceBLL.Current(new AutorisationRessource(n, r))).Update; AddRowRessource(r); } }
public static bool deleteFormulaires(Formulaires f) { NpgsqlConnection con = Connexion.Connection(); try { string delete = "delete from formulaires where id = " + f.Id; NpgsqlCommand cmd = new NpgsqlCommand(delete, con); cmd.ExecuteNonQuery(); return(true); } catch (NpgsqlException e) { Messages.Exception(e); return(false); } finally { Connexion.Deconnection(con); } }
public static bool updateFormulaires(Formulaires f) { NpgsqlConnection con = Connexion.Connection(); try { string update = "update formulaires set code ='" + f.Code + "' , libelle = '" + f.Libelle + "' where id = " + f.Id; NpgsqlCommand cmd = new NpgsqlCommand(update, con); cmd.ExecuteNonQuery(); return(true); } catch (NpgsqlException e) { Messages.Exception(e); return(false); } finally { Connexion.Deconnection(con); } }
private void Load() { Formulaires[] l = formulaires; formulaires = new Formulaires[l.Length]; for (int i = 0; i < l.Length; i++) { Formulaires f = l[i]; Int32 id = FormulairesBLL.Current(f); if (id < 1) { Formulaires f_ = FormulairesBLL.Save(f); f.Id = f_.Id; } else { f.Id = id; } Ressources[] t = f.Ressources; f.Ressources = new Ressources[t.Length]; for (int j = 0; j < t.Length; j++) { Ressources r = t[j]; id = RessourcesBLL.Current(r); if (id < 1) { r.Formulaire = f; Ressources r_ = RessourcesBLL.Save(r); r.Id = r_.Id; } else { r.Id = id; } f.Ressources[j] = r; } formulaires[i] = f; } }
public static Formulaires saveFormulaires(Formulaires f) { NpgsqlConnection con = Connexion.Connection(); try { string insert = "insert into formulaires (code, libelle) values ('" + f.Code + "','" + f.Libelle + "')"; NpgsqlCommand cmd = new NpgsqlCommand(insert, con); cmd.ExecuteNonQuery(); f.Id = currentFormulaires(f); return(f); } catch (NpgsqlException e) { Messages.Exception(e); return(null); } finally { Connexion.Deconnection(con); } }
private void dgv_form_SelectionChanged(object sender, EventArgs e) { try { if (dgv_form.Rows.Count > 0) { if (dgv_form.CurrentRow.Cells["id_form_"].Value != null) { Int32 id = (Int32)dgv_form.CurrentRow.Cells["id_form_"].Value; if (id > 0) { Formulaires f = FormulairesBLL.One(id); LoadRessource(current, f); } } } } catch (Exception ex) { Messages.Exception(ex); } }
private void supprimerFormulaire(Formulaire formulaireToDelete) { Formulaires.Remove(formulaireToDelete); }
private void AddRowFormulaire(Formulaires f) { dgv_form.Rows.Add(new object[] { f.Id, f.Code, f.Libelle, f.Update }); }