Ejemplo n.º 1
0
        //Metodo Modificar.
        private static bool Modificar(PrestamoMoras prestamoMoras)
        {
            Contexto contexto = new Contexto();
            bool     ok       = false;

            try
            {
                contexto.Database.ExecuteSqlRaw($"Delete FROM MorasDetalle Where MoraId={prestamoMoras.MoraId}");
                //foreach (var anterior in prestamoMoras.PrestamoMorasDetalle)
                {
                    //contexto.Entry(anterior).State = EntityState.Added;
                }
                contexto.Entry(prestamoMoras).State = EntityState.Modified;
                ok = (contexto.SaveChanges() > 0);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }

            return(ok);
        }
Ejemplo n.º 2
0
 //Metodo Guardar.
 public static bool Guardar(PrestamoMoras prestamo)
 {
     if (!Existe(prestamo.MoraId))
     {
         return(Insertar(prestamo));
     }
     else
     {
         return(Modificar(prestamo));
     }
 }
Ejemplo n.º 3
0
        private void BuscarButton_Click(object sender, RoutedEventArgs e)
        {
            if (!ValidarBuscar())
            {
                return;
            }

            PrestamoMoras moras = PrestamoMorasBLL.Buscar(int.Parse(MoraIdTextBox.Text));

            prestamoMoras = moras;
            Refrescar();
        }
Ejemplo n.º 4
0
        //Metodo Buscar
        public static PrestamoMoras Buscar(int id)
        {
            Contexto      contexto = new Contexto();
            PrestamoMoras moras    = new PrestamoMoras();

            try
            {
                //  moras = contexto.PrestamoMoras.Include(x => x.PrestamoMorasDetalle).Where(p => p.MoraId == id).SingleOrDefault();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }

            return(moras);
        }
Ejemplo n.º 5
0
        //Metodo Insertar.
        private static bool Insertar(PrestamoMoras prestamoMoras)
        {
            Contexto contexto = new Contexto();
            bool     ok       = false;

            try
            {
                if (contexto.PrestamoMoras.Add(prestamoMoras) != null)
                {
                    ok = contexto.SaveChanges() > 0;
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }

            return(ok);
        }
Ejemplo n.º 6
0
 public void Limpiar()
 {
     this.prestamoMoras = new PrestamoMoras();
     this.DataContext   = prestamoMoras;
 }