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); }
//=====================================================[ 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); }
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); }
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); }
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(); } }
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); }
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); }
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); }
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); }
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); }
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; } }
private bool ExisteDB() { mora = MorasBLL.Buscar(Convert.ToInt32(IdTextBox.Text)); return(mora != null); }
private void Limpiar() { mora = new Moras(); Actualizar(); }
public void Limpiar() { this.Mora = new Moras(); this.DataContext = Mora; }
public void BuscarTest() { Moras encontrado = MorasBLL.Buscar(1); Assert.IsTrue(encontrado != null); }
private bool ExisteDB() { mora = MorasBLL.Buscar(Utilities.ToInt(MoraIdTextBox.Text)); return(mora != null); }
private void Limpiar() { moras = new Moras(); MoraIdTextBox.Text = ""; this.DataContext = moras; }
public void BuscarTest() { Moras mora = new Moras(); mora = MorasBLL.Buscar(1); }
public void BuscarTest() { Moras moras = MorasBLL.Buscar(1); Assert.IsTrue(moras != null); }
private bool Existe() { Moras esValido = MorasBLL.Buscar(moras.MoraId); return(esValido != null); }
private void Limpiar() { this.Mora = new Moras(); this.Mora.Fecha = DateTime.Now; this.DataContext = Mora; }
private void Limpiar() { this.moras = new Moras(); this.DataContext = moras; }
private bool ExisteEnLaBaseDeDatos() { Moras esValido = MorasBLL.Buscar(moras.MoraId); return(esValido != null); }