Esempio n. 1
0
        public void save(CABECERA_DOCUMENTO obj)
        {
            using (gapharmaEntities1 db = new gapharmaEntities1()) {
                db.CABECERA_DOCUMENTO.Add(obj);
                db.SaveChanges();
                int id = obj.CABECERA_DOCUMENTO_ID;

                foreach (var item in obj.detalle)
                {
                    item.CABECERA_DOCUMENTO_ID = id;
                    db.DETALLE_DOCUMENTO.Add(item);
                    db.SaveChanges();
                }
            }
        }
Esempio n. 2
0
 public void save(PERSONA obj)
 {
     using (gapharmaEntities1 db = new gapharmaEntities1())
     {
         try
         {
             db.PERSONA.Add(obj);
             db.SaveChanges();
         }
         catch (DbEntityValidationException e)
         {
             foreach (var eve in e.EntityValidationErrors)
             {
                 Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                   eve.Entry.Entity.GetType().Name, eve.Entry.State);
                 foreach (var ve in eve.ValidationErrors)
                 {
                     Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                       ve.PropertyName, ve.ErrorMessage);
                 }
             }
             throw;
         }
     }
 }
Esempio n. 3
0
 public void save(DESTINATARIO obj)
 {
     using (gapharmaEntities1 db = new gapharmaEntities1()) {
         db.DESTINATARIO.Add(obj);
         db.SaveChanges();
     }
 }