public String ajouterFacture(facturevente lBl) { String resultat = "Ok"; using (NewCampusEntities db = new NewCampusEntities()) { if (this.testAjouterFacture(lBl) == false) { try { db.facturevente.Add(lBl); db.SaveChanges(); } catch (Exception e) { resultat = e.Message; } } else { resultat = "LF existante "; } } return(resultat); }
public void updatefact(facturevente fact) { using (NewCampusEntities db = new NewCampusEntities()) { db.facturevente.Attach(db.facturevente.Single(x => x.id == fact.id)); db.Entry(db.facturevente.Single(x => x.id == fact.id)).CurrentValues.SetValues(fact); //db.piece.ApplyCurrentValues(Cab); db.SaveChanges(); } }
public facturevente GetFactBynum(int num) { // NewCampusEntities db = new NewCampusEntities(); facturevente Bl = new facturevente(); try { using (NewCampusEntities db = new NewCampusEntities()) { return(db.facturevente.Where(aa => aa.numero_fact == num).FirstOrDefault()); } } catch (Exception) { Bl = new facturevente(); } return(Bl); }
public String supprimerFact(facturevente f) { String resultat = "Facture supprimé"; using (NewCampusEntities db = new NewCampusEntities()) { try { db.facturevente.Attach(f);// selectionne l'element dans la base pour le supprimer dans l'etape suivante db.facturevente.Remove(f); db.SaveChanges(); } catch (Exception) { resultat = resultat + "," + f.numero_fact; db.Dispose(); } } return(resultat); }
public Boolean testAjouterFacture(facturevente b) { Boolean trouve = true; //string s = cli.code; using (NewCampusEntities db = new NewCampusEntities()) { try { var cx = db.facturevente.Single(c => c.id.Equals(b.id)); if (cx == null) { trouve = false; } } catch (Exception) { trouve = false; } } return(trouve); }