public string FunCrearEmployee(SoftCob_EMPLOYEE _employee) { try { using (SoftCobEntities _db = new SoftCobEntities()) { _db.SoftCob_EMPLOYEE.Add(_employee); _db.SaveChanges(); } } catch (Exception ex) { _mensaje = ex.ToString(); } return(_mensaje); }
private void FunCargarMantenimiento() { try { SoftCob_EMPLOYEE _employee = new SoftCob_EMPLOYEE(); _employee = new EmployeeDAO().FunGetEmployeePorCodigo(int.Parse(ViewState["CodigoEmployee"].ToString())); Lbltitulo.Text = "Asignar Usuario a: " + _employee.empl_nombres + " " + _employee.empl_apellidos; TxtLogin.Text = _employee.empl_identificacion; ViewState["Identificacion"] = _employee.empl_identificacion; ViewState["Nombre"] = _employee.empl_nombres; ViewState["Apellido"] = _employee.empl_apellidos; } catch (Exception ex) { Lblerror.Text = ex.ToString(); } }
public SoftCob_EMPLOYEE FunGetEmployeePorCodigo(int _codigoemployee) { SoftCob_EMPLOYEE _employee = new SoftCob_EMPLOYEE(); try { using (SoftCobEntities _db = new SoftCobEntities()) { _employee = _db.SoftCob_EMPLOYEE.Where(e => e.EMPL_CODIGO == _codigoemployee).FirstOrDefault(); } } catch (Exception ex) { throw ex; } return(_employee); }
public string FunEditEmployee(SoftCob_EMPLOYEE _employee) { try { using (SoftCobEntities _db = new SoftCobEntities()) { _db.SoftCob_EMPLOYEE.Add(_employee); _db.Entry(_employee).State = System.Data.Entity.EntityState.Modified; foreach (SoftCob_ESTUDIOS _estu in _employee.SoftCob_ESTUDIOS) { if (_estu.ESTU_CODIGO != 0) { _db.Entry(_estu).State = System.Data.Entity.EntityState.Modified; } else { _db.Entry(_estu).State = System.Data.Entity.EntityState.Added; } } foreach (SoftCob_OTROSESTUDIOS _otros in _employee.SoftCob_OTROSESTUDIOS) { if (_otros.OTES_CODIGO == 0) { _db.Entry(_otros).State = System.Data.Entity.EntityState.Added; } } foreach (SoftCob_IDIOMAS _idiomas in _employee.SoftCob_IDIOMAS) { if (_idiomas.IDIO_CODIGO == 0) { _db.Entry(_idiomas).State = System.Data.Entity.EntityState.Added; } } foreach (SoftCob_EXPERIENCIA _experiencia in _employee.SoftCob_EXPERIENCIA) { if (_experiencia.EXPE_CODIGO == 0) { _db.Entry(_experiencia).State = System.Data.Entity.EntityState.Added; } } foreach (SoftCob_REFERENCIASLABORALES _reflaboral in _employee.SoftCob_REFERENCIASLABORALES) { if (_reflaboral.RELA_CODIGO == 0) { _db.Entry(_reflaboral).State = System.Data.Entity.EntityState.Added; } } foreach (SoftCob_REFERENCIASPERSONALES _refpersonal in _employee.SoftCob_REFERENCIASPERSONALES) { if (_refpersonal.REPE_CODIGO == 0) { _db.Entry(_refpersonal).State = System.Data.Entity.EntityState.Added; } } _db.SaveChanges(); } } catch (Exception ex /*DbEntityValidationException ex*/) { //foreach (var validationErrors in ex.EntityValidationErrors) //{ // foreach (var validationError in validationErrors.ValidationErrors) // { // Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); // } //} _mensaje = ex.ToString(); } return(_mensaje); }