private void BuscarButton_Click(object sender, RoutedEventArgs e) { LLamada anterior = LlamadasBLL.Buscar(Convert.ToInt32(LlamadaIdTextBox.Text)); if (anterior != null) { llamada = anterior; Recargar(); } else { MessageBox.Show("llamadas no encontrada"); } }
public static LLamada Buscar(int id) { Contexto db = new Contexto(); LLamada llamada = new LLamada(); try { llamada = db.Llamadas.Where(x => x.LlamadaId == id).Include(o => o.Llamadas).FirstOrDefault(); }catch (Exception) { throw; }finally { db.Dispose(); } return(llamada); }
public static bool Guardar(LLamada llamada) { bool paso = false; Contexto db = new Contexto(); try { if (db.Llamadas.Add(llamada) != null) { paso = db.SaveChanges() > 0; } }catch (Exception) { throw; }finally { db.Dispose(); } return(paso); }
public static bool Modificar(LLamada llamada) { bool paso = false; Contexto db = new Contexto(); try { db.Database.ExecuteSqlRaw($"DELETE FROM LlamadaDetalle Where LlamadaId = {llamada.LlamadaId}"); foreach (var item in llamada.Llamadas) { db.Entry(item).State = EntityState.Added; } db.Entry(llamada).State = EntityState.Modified; paso = (db.SaveChanges() > 0); }catch (Exception) { throw; }finally { db.Dispose(); } return(paso); }
private bool ExisteBD() { LLamada LlamadaAnterior = LlamadasBLL.Buscar(llamada.LlamadaId); return(LlamadaAnterior != null); }