public bool Update() { try { Datos.EMPLEADO empleadoDatos = Conexion.ModeloEntities.EMPLEADO.First(e => e.RUT == _rut); // * Lambda * empleadoDatos.ID = ID_EMPLEADO; empleadoDatos.DV = _dv; empleadoDatos.NOMBRE = NOMBRE_EMPLEADO; empleadoDatos.APELLIDO = APELLIDO_EMPLEADO; empleadoDatos.CARGO = CARGO_EMPLEADO; Conexion.ModeloEntities.SaveChanges(); return(true); } catch (Exception) { return(false); } }
//Agregar public bool Create() { Datos.FerreteriaFermeEntities bbdd = new Datos.FerreteriaFermeEntities(); Datos.EMPLEADO emp = new Datos.EMPLEADO(); try { CommonBC.Syncronize(this, emp); bbdd.EMPLEADO.Add(emp); bbdd.SaveChanges(); return(true); } catch (Exception ex) { bbdd.EMPLEADO.Remove(emp); return(false); } }
/// <summary> /// Elimina un registro de proveedor 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.EMPLEADO emp = bbdd.EMPLEADO.First(e => e.RUT_EMPLEADO == RUT_EMPLEADO); /* Se elimina el registro del EDM */ bbdd.EMPLEADO.Remove(emp); bbdd.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// Actualiza un registro de proveedor 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.EMPLEADO emp = bbdd.EMPLEADO.First(e => e.RUT_EMPLEADO == RUT_EMPLEADO); /* Se copian las propiedades del negocio a los datos */ CommonBC.Syncronize(this, emp); bbdd.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public bool Read() { try { Datos.EMPLEADO empleadoDatos = ( from emp in Conexion.ModeloEntities.EMPLEADO where emp.RUT == _rut select emp ).First(); ID_EMPLEADO = empleadoDatos.ID; _dv = empleadoDatos.DV; NOMBRE_EMPLEADO = empleadoDatos.NOMBRE; APELLIDO_EMPLEADO = empleadoDatos.APELLIDO; CARGO_EMPLEADO = empleadoDatos.CARGO; return(true); } catch (Exception) { return(false); } }
public bool Create() { try { Datos.EMPLEADO nuevoEmpleado = new Datos.EMPLEADO() { ID = ID_EMPLEADO, RUT = _rut, DV = _dv, NOMBRE = NOMBRE_EMPLEADO, APELLIDO = APELLIDO_EMPLEADO, CARGO = CARGO_EMPLEADO }; Conexion.ModeloEntities.EMPLEADO.Add(nuevoEmpleado); Conexion.ModeloEntities.SaveChanges(); return(true); } catch (Exception) { return(false); } }
/// <summary> /// Lee un registro de proveedor 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.EMPLEADO emp = bbdd.EMPLEADO.First(e => e.RUT_EMPLEADO == RUT_EMPLEADO); /* Se copian las propiedades de datos al negocio */ CommonBC.Syncronize(emp, this); /* Carga descripción de los Tipos */ LeerNombreCargo(); LeerNombreUsuario(); return(true); } catch (Exception ex) { return(false); } }