public EntidadPersona ConsultarPersonaPorId(int _idPersona) { EntidadPersona _objPersona = new EntidadPersona(); foreach (var item in _entitiesPosgrado.spPersonaConsultarXIDNSMIT(_idPersona)) { _objPersona = new EntidadPersona() { IdPersona = item.Id_Persona, Nombres = item.ApellidoPaterno + " " + item.ApellidoMaterno + " " + item.Nombres + " " + item.SegundoNombre, NumeroIdentificacion = item.Cedula, TipoIdentificacion = new EntidadTipoIdentificacion() { IdTipoIdentificacion = Convert.ToInt32(item.tipoDocumentoId), Etiqueta = item.descTipoDocumento }, Sexo = new EntidadSexo() { IdSexo = Convert.ToInt32(item.sexoId), Descripcion = item.descSexo }, Eliminado = item.Eliminado }; } return(_objPersona); }
Resultado GuardarEstudiante() { NegocioEstudiante negocioEstudiante = new NegocioEstudiante(); EntidadEstudiante entidadEstudiante = new EntidadEstudiante(); EntidadPersona entidadPersona = new EntidadPersona(); entidadPersona.PER_CEDULA = txtPerCedula.Text; entidadPersona.PER_PRIMER_NOMBRE = txtPerPrimerNombre.Text; entidadPersona.PER_SEGUNDO_NOMBRE = txtPerSegundoNombre.Text; entidadPersona.PER_PRIMER_APELLIDO = txtPerPrimerApellido.Text; entidadPersona.PER_SEGUNDO_APELLIDO = txtPerSegundoApellido.Text.Trim(); entidadPersona.PER_FECHA_NACIMIENTO = DateTime.Parse(txtPerFechaNacimiento.Value.ToString()); entidadPersona.PER_ESTADO = true; entidadPersona.PER_IMAGEN = ObtenerIMagenByteArray(FilUpImagen.PostedFile.InputStream); entidadEstudiante.TBL_PERSONA = entidadPersona; entidadEstudiante.CUA_ID = int.Parse(ddlNumeroCuarto.SelectedValue); entidadEstudiante.EST_CARNET = txtEstCarnet.Text.Trim(); entidadEstudiante.EST_ESTADO = true; return(negocioEstudiante.GuardarNuevoEstudiante(entidadEstudiante)); }
public Resultado GuardarNuevaPersona(EntidadPersona entidadPersona) { resultado = new Resultado(); using (var dbContextTransaction = dbResidencia.Database.BeginTransaction()) { try { resultado.esError = false; TBL_PERSONA TBL_PERSONA = new TBL_PERSONA(); TBL_PERSONA.PER_IDENTIFICACION = entidadPersona.PER_CEDULA; TBL_PERSONA.PER_PRIMER_NOMBRE = entidadPersona.PER_PRIMER_NOMBRE; TBL_PERSONA.PER_SEGUNDO_NOMBRE = entidadPersona.PER_SEGUNDO_NOMBRE; TBL_PERSONA.PER_PRIMER_APELLIDO = entidadPersona.PER_PRIMER_APELLIDO; TBL_PERSONA.PER_SEGUNDO_APELLIDO = entidadPersona.PER_SEGUNDO_APELLIDO; TBL_PERSONA.PER_FECHA_NACIMIENTO = entidadPersona.PER_FECHA_NACIMIENTO; TBL_PERSONA.PER_ESTADO = entidadPersona.PER_ESTADO; TBL_PERSONA.PER_IMAGEN = entidadPersona.PER_IMAGEN; dbResidencia.TBL_PERSONA.Add(TBL_PERSONA); dbResidencia.SaveChanges(); dbContextTransaction.Commit(); resultado.esError = false; } catch (Exception ex) { dbContextTransaction.Rollback(); resultado.esError = true; resultado.mensaje = ex.Message; } } return(resultado); }
public List <EntidadPersona> ObtenerPersonas() { List <EntidadPersona> personas = new List <EntidadPersona>(); List <int> idEstudiantesRegistrados = new List <int>(); idEstudiantesRegistrados = dbResidencia.TBL_ESTUDIANTE.ToList().Select(dr => dr.EST_ID).ToList <int>(); //se extrae lista ordenada ascendente y personas que estén activas dbResidencia.TBL_PERSONA.OrderBy(fila => fila.PER_PRIMER_NOMBRE).Where(fila => fila.PER_ESTADO == true).ToList().ForEach(fila => { EntidadPersona cadaPersona = new EntidadPersona(); if (!idEstudiantesRegistrados.Contains(fila.PER_ID)) { cadaPersona.PER_ID = fila.PER_ID; cadaPersona.PER_CEDULA = fila.PER_IDENTIFICACION; cadaPersona.PER_PRIMER_NOMBRE = fila.PER_PRIMER_NOMBRE; cadaPersona.PER_SEGUNDO_NOMBRE = fila.PER_SEGUNDO_NOMBRE; cadaPersona.PER_PRIMER_APELLIDO = fila.PER_PRIMER_APELLIDO; cadaPersona.PER_SEGUNDO_APELLIDO = fila.PER_SEGUNDO_APELLIDO; cadaPersona.PER_FECHA_NACIMIENTO = fila.PER_FECHA_NACIMIENTO; cadaPersona.PER_NOMBRE_COMPLETO = fila.PER_PRIMER_NOMBRE + " " + fila.PER_SEGUNDO_NOMBRE + " " + fila.PER_PRIMER_APELLIDO + " " + fila.PER_SEGUNDO_APELLIDO; cadaPersona.PER_ESTADO = fila.PER_ESTADO; personas.Add(cadaPersona); } else { } }); return(personas); }
public void UpdateDatosAlumno(EntidadPersona personas) { SqlCommand command = new SqlCommand("PROC_CAMBIO_datos_alumno", conexion.AbrirConexion()); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@matricula", personas.Matricula); command.Parameters.AddWithValue("@carrera", personas.Carrera); command.Parameters.AddWithValue("@especialidad", personas.Especialidad); command.ExecuteNonQuery(); conexion.CerrarConexion(); }
public int DeletePersonaProfesores(EntidadPersona persona) { SqlCommand command = new SqlCommand("PROC_BAJAusp_profesoresDelete", conexion.AbrirConexion()); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@id_profesor", persona.Matricula); command.ExecuteNonQuery(); conexion.CerrarConexion(); command = new SqlCommand("PROC_BAJAusp_personasDelete", conexion.AbrirConexion()); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p", persona.Id_persona); command.ExecuteNonQuery(); conexion.CerrarConexion(); return(1); }
protected void btnIngresar_Click(object sender, EventArgs e) { EntidadPersona ep = new EntidadPersona(); ep.nom_usuario = txtUsuario.Text.Trim(); ep.password = txtPassw.Text.Trim(); DaoPersona dao_usu = new DaoPersona(); DataTable dt = new DataTable(); dt = dao_usu.login(ep); if (dt.Rows.Count > 0) { string[] fecha = dt.Rows[0]["fechaNacimiento"].ToString().Split('/'); int tc = Convert.ToInt32(dt.Rows[0]["idTipoCuenta"]); Session["nombresC"] = dt.Rows[0]["apePaterno"] + " " + dt.Rows[0]["apeMaterno"] + ", " + dt.Rows[0]["nombres"]; Session["edad"] = Convert.ToInt32(DateTime.Today.Year) - Convert.ToInt32(fecha[2].Substring(0, 4)); Session["dni"] = dt.Rows[0]["dni"]; Session["cel"] = dt.Rows[0]["celular"]; Session["email"] = dt.Rows[0]["email"]; Session["foto"] = dt.Rows[0]["imagenPerfil"]; Session["estado"] = dt.Rows[0]["estadoCuenta"]; Session["nombre"] = dt.Rows[0]["nombres"]; Session["usuario"] = dt.Rows[0]["nom_usuario"]; if (tc == 1) { Session["tipoCuenta"] = "Administrador"; Response.Redirect("VistaAdmin/Default.aspx"); } else if (tc == 2) { Session["tipoCuenta"] = "Maestro"; Response.Redirect("VistaMaestro/Default.aspx"); } else { Session["tipoCuenta"] = "Visitante"; } } else { Response.Write("<script>alert('Usuario y contraseña inválida')</script>"); } }
public EntidadPersona MostrarPersonaProfesor(String matricula) { SqlCommand command = new SqlCommand("PROC_MOSTRAR_personas_profesor", conexion.AbrirConexion()); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@matricula", matricula); leer = command.ExecuteReader(); tablaPersona.Load(leer); conexion.CerrarConexion(); DataRow row = tablaPersona.Rows[0]; Persona = new EntidadPersona( row[1].ToString(), row[2].ToString(), row[3].ToString(), row[5].ToString(), row[4].ToString(), row[6].ToString(), Convert.ToInt32(row[0].ToString()) ); return(Persona); }
public int UpdatePersona(EntidadPersona persona) { try { SqlCommand command = new SqlCommand("PROC_CAMBIO_personas", conexion.AbrirConexion()); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@id_personas", persona.Id_persona); command.Parameters.AddWithValue("@nombre", persona.Nombre); command.Parameters.AddWithValue("@apellido_paterno", persona.Apellido_paterno); command.Parameters.AddWithValue("@apellido_materno", persona.Apellido_materno); command.Parameters.AddWithValue("@sexo", persona.Sexo); command.Parameters.AddWithValue("@curp", persona.Curp); command.Parameters.AddWithValue("@fecha_nacimiento", persona.Fecha_nacimiento); command.ExecuteNonQuery(); conexion.CerrarConexion(); return(1); } catch { return(0); } }
public EntidadPersona InsertPersonaAlumno(EntidadPersona persona) { SqlCommand command = new SqlCommand("PROC_ALTA_personas_alumno", conexion.AbrirConexion()); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@nombre", persona.Nombre); command.Parameters.AddWithValue("@apellido_paterno", persona.Apellido_paterno); command.Parameters.AddWithValue("@apellido_materno", persona.Apellido_materno); command.Parameters.AddWithValue("@sexo", persona.Sexo); command.Parameters.AddWithValue("@curp", persona.Curp); command.Parameters.AddWithValue("@fecha_nacimiento", persona.Fecha_nacimiento); leer = command.ExecuteReader(); tablaPersona.Load(leer); DataRow datarow = tablaPersona.Rows[0]; persona.Matricula = datarow["Matricula"].ToString(); persona.Id_persona = Convert.ToInt32(datarow[2].ToString()); conexion.CerrarConexion(); return(persona); }