public bool read() { try { Datos.ESTABLECIMIENTO establecimiento = null; establecimiento = CommonBC.ModeloCEM.ESTABLECIMIENTO.Where(u => u.ID_TRIBUTARIO.Equals(this.Id_tributario)).FirstOrDefault(); if (establecimiento != null) { this.Id_establecimiento = (int)establecimiento.ID_ESTABLECIMIENTO; this.Nombre = establecimiento.NOMBRE_ESTABLECIMIENTO; this.Fono = establecimiento.TELEFONO; this.Email = establecimiento.EMAIL; this.Direccion = establecimiento.DIRECCION; this.Id_ciudad = (int)establecimiento.ID_CIUDAD; return(true); } else { return(false); } } catch (Exception) { return(false); } }
public string crud(int accion) { try { if (accion == 3) { if (CommonBC.ModeloCEM.PROGRAMA.Where(p => p.ESTABLECIMIENTO.Where(e => e.ID_TRIBUTARIO.Equals(this.Id_tributario)).Count() > 0).Count() > 0) { return("No se puede Borrar Establecimientos en uso"); } } string nombreAccion = ""; CommonBC.ModeloCEM.PROC_CRUDESTABLECIMIENTO(this.Id_tributario, this.Nombre, this.Fono, this.Email, this.Direccion, this.Id_ciudad, accion); switch (accion) { case 1: nombreAccion = "Creacion"; break; case 2: nombreAccion = "Actualizacion"; break; case 3: nombreAccion = "Eliminacion"; break; } Datos.ESTABLECIMIENTO establecimiento = null; establecimiento = CommonBC.ModeloCEM.ESTABLECIMIENTO.Where(e => e.ID_TRIBUTARIO == this.Id_tributario).FirstOrDefault(); establecimiento.NOMBRE_ESTABLECIMIENTO = this.Nombre; establecimiento.TELEFONO = this.Fono; establecimiento.EMAIL = this.Email; establecimiento.DIRECCION = this.Direccion; establecimiento.ID_CIUDAD = this.Id_ciudad; CommonBC.ModeloCEM.SaveChanges(); return(nombreAccion + " Exitosa."); } catch (Exception e) { return("Error: " + e); } }