/// <summary> /// Lee un registro de producto en la BBDD /// </summary> /// <returns></returns> public bool Read() { Datos.FerreteriaFermeEntities bbdd = new Datos.FerreteriaFermeEntities(); try { /* Se obtiene el primer registro coincidente con el id */ Datos.DIRECCION dir = bbdd.DIRECCION.First(e => e.ID_DIRECCION == ID_DIRECCION); /* Se copian las propiedades de datos al negocio */ CommonBC.Syncronize(dir, this); /* Carga descripción de los Tipos */ LeerNombreComuna(); LeerDescripcionCliente(); LeerDescripcionEmpresa(); LeerDescripcionRegion(); return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// Elimina un registro de producto en la BBDD /// </summary> /// <returns></returns> public bool Delete() { Datos.FerreteriaFermeEntities bbdd = new Datos.FerreteriaFermeEntities(); try { /* Se obtiene el primer registro coincidente con el id */ Datos.DIRECCION dir = bbdd.DIRECCION.First(e => e.ID_DIRECCION == ID_DIRECCION); /* Se elimina el registro del EDM */ bbdd.DIRECCION.Remove(dir); bbdd.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
//Agregar public bool Create() { Datos.FerreteriaFermeEntities bbdd = new Datos.FerreteriaFermeEntities(); Datos.DIRECCION dir = new Datos.DIRECCION(); try { CommonBC.Syncronize(this, dir); bbdd.DIRECCION.Add(dir); bbdd.SaveChanges(); return(true); } catch (Exception ex) { bbdd.DIRECCION.Remove(dir); return(false); } }
/// <summary> /// Actualiza un registro de producto en la BBDD /// </summary> /// <returns></returns> public bool Update() { Datos.FerreteriaFermeEntities bbdd = new Datos.FerreteriaFermeEntities(); try { /* Se obtiene el primer registro coincidente con el id */ Datos.DIRECCION dir = bbdd.DIRECCION.First(e => e.ID_DIRECCION == ID_DIRECCION); /* Se copian las propiedades del negocio a los datos */ CommonBC.Syncronize(this, dir); bbdd.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }