public bool InsertRange(List <CMetodopago> lista)
 {
     try
     {
         using (var db = new DymContext())
         {
             db.AddRange(lista);
             return(db.SaveChanges() > 0 ? true : false);
         }
     }
     catch (Exception ex)
     {
         Ambiente.Mensaje("Algo salio mal con: " + MethodBase.GetCurrentMethod().Name + "@" + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }
Beispiel #2
0
 public bool InsertRange(List <InformeCategoria> lista)
 {
     try
     {
         using (var db = new DymContext())
         {
             db.AddRange(lista);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Ambiente.Mensaje(Ambiente.CatalgoMensajes[-1] + "@" + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }
 public bool InsertaPartidas(ICollection <Cxpp> partidas)
 {
     try
     {
         using (var db = new DymContext())
         {
             db.AddRange(partidas);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Ambiente.Mensaje(Ambiente.CatalgoMensajes[-1] + "@" + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }
 public bool InsertRange(List <Actualizacion> lista)
 {
     try
     {
         using (var db = new DymContext())
         {
             db.AddRange(lista);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show("Algo salio mal @ " + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }
Beispiel #5
0
        public string InsertRange(List <ProductoImpuesto> lista)
        {
            var           listaCorrectos = new List <ProductoImpuesto>();
            List <string> errores        = new List <string>();
            string        correctos      = string.Empty;

            try
            {
                using (var db = new DymContext())
                {
                    foreach (var item in lista)
                    {
                        var producto = db.Producto.FirstOrDefault(x => x.ProductoId == item.ProductoId);
                        var impuesto = db.Impuesto.FirstOrDefault(x => x.ImpuestoId == item.ImpuestoId);
                        if (producto != null && impuesto != null)
                        {
                            var prodImp = new ProductoImpuesto();
                            prodImp.ProductoId = producto.ProductoId;
                            prodImp.ImpuestoId = impuesto.ImpuestoId;
                            listaCorrectos.Add(prodImp);
                        }
                        else
                        {
                            errores.Add(item.ImpuestoId + ", NO EXISTE EN LOS IMPUESTOS o, " + item.ProductoId + ", NO EXISTE EN LOS PRODUCTOS");
                        }
                    }
                    db.AddRange(listaCorrectos);
                    db.SaveChanges();
                    correctos += "SE GUARDARON " + listaCorrectos.Count + " REGISTOS\n\n";
                    correctos += "SE OMITIERON " + errores.Count + " REGISTOS\n\n";
                    correctos += "COPIE Y PEGUE LOS DETALLES\n\n ";
                    var result = String.Join(" \n ", errores.ToArray());
                    correctos += result;
                }
            }
            catch (Exception ex)
            {
                Ambiente.Mensaje(Ambiente.CatalgoMensajes[-1] + "@" + GetType().Name + "\n" + ex.ToString());
            }

            return(correctos);
        }