public static bool Insertar(Moras mora)
        {
            bool     paso = false;
            Contexto db   = new Contexto();

            try
            {
                db.Moras.Add(mora);
                paso = db.SaveChanges() > 0;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                db.Dispose();
            }
            return(paso);
        }
예제 #2
0
        //=====================================================[ INSERTAR ]=====================================================
        private static bool Insertar(Moras moras)
        {
            bool     paso     = false;
            Contexto contexto = new Contexto();

            try
            {
                contexto.Moras.Add(moras);
                paso = contexto.SaveChanges() > 0;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }
            return(paso);
        }
예제 #3
0
        public static Moras Buscar(int id)
        {
            Contexto contexto = new Contexto();
            Moras    moras    = new Moras();

            try
            {
                moras = contexto.Moras.Include(x => x.MorasDetalle).Where(x => x.MoraId == id).SingleOrDefault();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }

            return(moras);
        }
        public static bool Modificar(Moras mora)
        {
            bool     paso     = false;
            Contexto contexto = new Contexto();

            try
            {
                contexto.Entry(mora).State = EntityState.Modified;
                paso = contexto.SaveChanges() > 0;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }

            return(paso);
        }
예제 #5
0
        public static bool Modificar(Moras moras)
        {
            bool     Modificado = false;
            Contexto contexto   = new Contexto();

            try{
                contexto.Database.ExecuteSqlRaw($"Delete FROM MorasDetalle Where MoraId = {moras.MoraId}");
                foreach (var anterior in moras.MorasDetalle)
                {
                    contexto.Entry(anterior).State = EntityState.Added;
                }
                contexto.Entry(moras).State = EntityState.Modified;
                Modificado = (contexto.SaveChanges() > 0);
            }
            catch (Exception) {
                throw;
            } finally{
                contexto.Dispose();
            }
            return(Modificado);
        }
예제 #6
0
        private void BuscarButton_Click(object sender, RoutedEventArgs e)
        {
            if (MoraIdTextBox.Text.Length <= 0)
            {
                return;
            }

            Moras encontrado = MorasBLL.Buscar(int.Parse(MoraIdTextBox.Text));

            if (encontrado != null)
            {
                moras = encontrado;
                Cargar();
                MessageBox.Show("Mora Encontrada", "Exito", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show($"Esta Id de Mora no fue encontrada.\n\nAsegurese que existe o cree una nueva.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Warning);
                Limpiar();
            }
        }
예제 #7
0
        public static Moras Buscar(int id)
        {
            Contexto db    = new Contexto();
            Moras    moras = new Moras();

            try
            {
                moras = db.moras.Where(o => o.MoraId == id)
                        .Include(o => o.MorasDetalles)
                        .SingleOrDefault();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                db.Dispose();
            }

            return(moras);
        }
예제 #8
0
        private static bool Insertar(Moras mora)
        {
            bool     paso     = false;
            Contexto contexto = new Contexto();

            try
            {
                //Agregar la entidad que se desea insertar al contexto
                contexto.Moras.Add(mora);
                paso = contexto.SaveChanges() > 0;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }

            return(paso);
        }
예제 #9
0
        public static Moras Buscar(int id)
        {
            Moras    mora     = new Moras();
            Contexto contexto = new Contexto();

            try
            {
                mora = contexto.Moras
                       .Where(e => e.MoraId == id)
                       .Include(e => e.Detalle)
                       .FirstOrDefault();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }
            return(mora);
        }
예제 #10
0
        public static Moras Buscar(int id)
        {
            Contexto contexto = new Contexto();
            Moras    mora     = new Moras();

            try
            {
                mora = contexto.Moras
                       .Where(m => m.MoraId == id)
                       .Include(m => m.MoraDetalle)
                       .FirstOrDefault();
            }
            catch
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }
            return(mora);
        }
예제 #11
0
        private static bool Insertar(Moras moras)
        {
            Contexto contexto = new Contexto();
            bool     ok       = false;

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

            return(ok);
        }
예제 #12
0
        private static void AsignarMoraIdNueva(List <MorasDetalle> detalle)
        {
            Moras    mora     = new Moras();
            Contexto contexto = new Contexto();

            try
            {
                mora = contexto.Moras.OrderByDescending(m => m.MoraId).First();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }

            foreach (var item in detalle)
            {
                item.MoraId = mora.MoraId;
            }
        }
예제 #13
0
        private bool ExisteDB()
        {
            mora = MorasBLL.Buscar(Convert.ToInt32(IdTextBox.Text));

            return(mora != null);
        }
예제 #14
0
 private void Limpiar()
 {
     mora = new Moras();
     Actualizar();
 }
예제 #15
0
 public void Limpiar()
 {
     this.Mora        = new Moras();
     this.DataContext = Mora;
 }
예제 #16
0
        public void BuscarTest()
        {
            Moras encontrado = MorasBLL.Buscar(1);

            Assert.IsTrue(encontrado != null);
        }
예제 #17
0
        private bool ExisteDB()
        {
            mora = MorasBLL.Buscar(Utilities.ToInt(MoraIdTextBox.Text));

            return(mora != null);
        }
예제 #18
0
 private void Limpiar()
 {
     moras = new Moras();
     MoraIdTextBox.Text = "";
     this.DataContext   = moras;
 }
예제 #19
0
        public void BuscarTest()
        {
            Moras mora = new Moras();

            mora = MorasBLL.Buscar(1);
        }
        public void BuscarTest()
        {
            Moras moras = MorasBLL.Buscar(1);

            Assert.IsTrue(moras != null);
        }
예제 #21
0
        private bool Existe()
        {
            Moras esValido = MorasBLL.Buscar(moras.MoraId);

            return(esValido != null);
        }
예제 #22
0
 private void Limpiar()
 {
     this.Mora        = new Moras();
     this.Mora.Fecha  = DateTime.Now;
     this.DataContext = Mora;
 }
예제 #23
0
 private void Limpiar()
 {
     this.moras       = new Moras();
     this.DataContext = moras;
 }
예제 #24
0
        private bool ExisteEnLaBaseDeDatos()
        {
            Moras esValido = MorasBLL.Buscar(moras.MoraId);

            return(esValido != null);
        }