public bool Update() { try { Datos.FACTURA factura = Conexion.ModeloEntities.FACTURA.First(em => em.ID == ID); factura.ID = ID; factura.ORDEN_COMPRA_ID = ORDEN_COMPRA_ID; factura.EMPRESA_ID = EMPRESA_ID; factura.TOTAL = TOTAL; factura.HABITACION_FACTURA = factura.HABITACION_FACTURA; factura.SERVICIO_FACTURA = factura.SERVICIO_FACTURA; Conexion.ModeloEntities.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool Read() { try { Datos.FACTURA factura = Conexion.ModeloEntities.FACTURA.First(em => em.ID == ID); ID = factura.ID; ORDEN_COMPRA_ID = factura.ORDEN_COMPRA_ID; EMPRESA_ID = factura.EMPRESA_ID; TOTAL = factura.TOTAL; factura.HABITACION_FACTURA = factura.HABITACION_FACTURA; factura.SERVICIO_FACTURA = factura.SERVICIO_FACTURA; return(true); } catch (Exception) { return(false); } }
public bool Create() { try { Datos.FACTURA factura = new Datos.FACTURA() { ID = ID, ORDEN_COMPRA_ID = ORDEN_COMPRA_ID, EMPRESA_ID = EMPRESA_ID, TOTAL = TOTAL }; Conexion.ModeloEntities.FACTURA.Add(factura); Conexion.ModeloEntities.SaveChanges(); return(true); } catch (Exception) { return(false); } }
//Agregar public bool Create() { Datos.FerreteriaFermeEntities bbdd = new Datos.FerreteriaFermeEntities(); Datos.FACTURA fac = new Datos.FACTURA(); try { CommonBC.Syncronize(this, fac); bbdd.FACTURA.Add(fac); bbdd.SaveChanges(); return(true); } catch (Exception ex) { bbdd.FACTURA.Remove(fac); 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.FACTURA fac = bbdd.FACTURA.First(e => e.ID_FACTURA == ID_FACTURA); /* Se elimina el registro del EDM */ bbdd.FACTURA.Remove(fac); bbdd.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// Actualiza un registro de cargo 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.FACTURA fac = bbdd.FACTURA.First(e => e.ID_FACTURA == ID_FACTURA); /* Se copian las propiedades del negocio a los datos */ CommonBC.Syncronize(this, fac); bbdd.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// Lee un registro de cargi 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.FACTURA fac = bbdd.FACTURA.First(e => e.ID_FACTURA == ID_FACTURA); /* Se copian las propiedades de datos al negocio */ CommonBC.Syncronize(fac, this); /* Carga descripción de los Tipos */ LeerNombreEmpresa(); LeerNombreMedio(); return(true); } catch (Exception ex) { return(false); } }