public void listarTalleresxProfesor(int codPersona) { CtrProfesor ctrpro = new CtrProfesor(); DataSet dsProf = ctrpro.listarTallerxProfesor(codPersona); gv_profesores.DataSource = dsProf.Tables[0]; gv_profesores.DataBind(); if (gv_profesores.Rows.Count == 0) { lbl_mensaje_5.Text = "Este profesor no tiene talleres activos"; } }
protected void btnGuardar_Click(object sender, EventArgs e) { try { lbl_mensaje.Text = ""; if (validarDatos()) { DtoProfesor prof = new DtoProfesor(); prof.numDocumento = txtNumDoc.Text; prof.nombres = txtNombres.Text.Trim(); prof.apPaterno = txtApPAt.Text.Trim(); prof.apMaterno = txtApMat.Text.Trim(); prof.telefono = txtTelf.Text.Trim(); prof.email = txtEmail.Text.Trim(); prof.direccion = txtDireccion.Text.Trim(); prof.sexo = Convert.ToChar(ddlSexo.SelectedValue); prof.fechaNacimiento = Convert.ToDateTime(txt_fecha.Text); prof.codUsuario = null; prof.codDistrito = Convert.ToInt32(ddlDistrito.SelectedValue); prof.urlFoto = lbl_mensaje_1.Text; prof.fechaContrato = Convert.ToDateTime(txtContrato.Text); prof.duracionContrato = Convert.ToInt32(txtDuracion.Text.Trim()); prof.tipoTrabajador = "PROFESOR"; prof.estadoTrabajador = "1"; prof.latitud = Convert.ToDouble(lblLat.Text); prof.longitud = Convert.ToDouble(lblLng.Text); prof.diasDisponible = lblDisponible.Text; if (string.IsNullOrEmpty(lbl_mensaje_3.Text)) { prof.urlCV = null; } else { prof.urlCV = lbl_mensaje_3.Text; } prof.estadoProfesor = "CAPACITADO"; CtrProfesor ctrprof = new CtrProfesor(); ctrprof.registrarProfesor(prof); lbl_mensaje.Text = "Se registró exitósamente el profesor: " + prof.nombres + " " + prof.apPaterno + " " + prof.apMaterno; limpiar(); } } catch { lbl_mensaje.Text = "Error al intentar registrar el profesor"; } }
public void listarProfesores() { CtrProfesor negprof = new CtrProfesor(); lblmensaje.Text = ""; DataSet dsAux = negprof.listarProfTrabajadoresActivos(); //lista todos los profesores dentro del rango inicial 10km DataTable dsProfesores = evaluarCercanos(dsAux, maxDist); gv_profesores.DataSource = dsProfesores; gv_profesores.DataBind(); if (gv_profesores.Rows.Count == 0) { lblmensaje.Text = "No se encontró profesores"; } else { lblmensaje.Text = ""; } }
public void listarProfesores() { CtrProfesor negprof = new CtrProfesor(); lbl_mensaje.Text = ""; if (!check_visualizar.Checked) { DataSet dsProfesores = negprof.listarProfesores("1"); gv_profesores.DataSource = dsProfesores.Tables[0]; gv_profesores.DataBind(); if (gv_profesores.Rows.Count == 0) { lbl_mensaje.Text = "No se encontró profesores"; } else { lbl_mensaje.Text = ""; } } else { DataSet dsProfesores = negprof.listarProfesores("0"); gv_profesores.DataSource = dsProfesores.Tables[0]; gv_profesores.DataBind(); if (gv_profesores.Rows.Count == 0) { lbl_mensaje.Text = "No se encontró profesores"; } else { lbl_mensaje.Text = ""; } } }
private bool validarDatos() { bool ver = true; if (string.IsNullOrEmpty(txtNombres.Text)) { lbl_mensaje.Text = "Ingrese el nombre"; return(false); } if (string.IsNullOrEmpty(txtApPAt.Text)) { lbl_mensaje.Text = "Ingrese el apellido paterno"; return(false); } if (string.IsNullOrEmpty(txtApMat.Text)) { lbl_mensaje.Text = "Ingrese el apellido materno"; return(false); } if (string.IsNullOrEmpty(txtNumDoc.Text)) { lbl_mensaje.Text = "Ingrese el número de documento"; return(false); } if (txtNumDoc.Text.Trim().Length != 8) { lbl_mensaje.Text = "El número de documento debe contener 8 dígitos"; return(false); } int numdoc = 0; try { numdoc = int.Parse(txtNumDoc.Text); } catch { ver = false; } if (!ver) { lbl_mensaje.Text = "Ingrese correctamente el número de documento"; return(false); } if (numdoc <= 0) { lbl_mensaje.Text = "Ingrese correctamente el número de documento"; return(false); } CtrProfesor ctrprof = new CtrProfesor(); ver = !ctrprof.consultarNumDocxPersona(numdoc.ToString()); if (!ver) { lbl_mensaje.Text = "El número de documento ingresado ya está en uso"; return(false); } if (ddlSexo.SelectedValue == "0") { lbl_mensaje.Text = "Seleccione un género"; return(false); } if (string.IsNullOrEmpty(txt_fecha.Text)) { lbl_mensaje.Text = "Ingrese la fecha de nacimiento"; return(false); } DateTime fecha = DateTime.Now; try { fecha = Convert.ToDateTime(txt_fecha.Text); } catch { ver = false; } if (!ver) { lbl_mensaje.Text = "Ingrese correctamente la fecha de nacimiento"; return(false); } if (fecha.Year < DateTime.Now.Year - 60 || fecha.Year > DateTime.Now.Year - 21) { lbl_mensaje.Text = "El profesor debe tener de 21 a 60 años de edad"; return(false); } if (string.IsNullOrEmpty(txtDireccion.Text)) { lbl_mensaje.Text = "Ingrese la dirección"; return(false); } if (string.IsNullOrEmpty(txtTelf.Text)) { lbl_mensaje.Text = "Ingrese el número teléfono"; return(false); } if (txtTelf.Text.Trim().Length < 7) { lbl_mensaje.Text = "Ingrese un número teléfono"; return(false); } int tel = 0; try { tel = int.Parse(txtTelf.Text); } catch { ver = false; } if (!ver) { lbl_mensaje.Text = "Ingrese correctamente el número de teléfono"; return(false); } if (tel <= 0) { lbl_mensaje.Text = "Ingrese correctamente el número de teléfono"; return(false); } if (string.IsNullOrEmpty(txtEmail.Text)) { lbl_mensaje.Text = "Ingrese el correo electrónico"; return(false); } if (!IsValidEmail(txtEmail.Text)) { lbl_mensaje.Text = "No ha ingresado un correo electrónico correcto"; return(false); } ver = !ctrprof.consultarEmailxPersona(txtEmail.Text.Trim()); if (!ver) { lbl_mensaje.Text = "El correo electrónico ingresado ya está en uso"; return(false); } if (string.IsNullOrEmpty(txtContrato.Text)) { lbl_mensaje.Text = "Ingrese la fecha de contrato"; return(false); } DateTime contrato = DateTime.Now; try { contrato = Convert.ToDateTime(txtContrato.Text); } catch { ver = false; } if (!ver) { lbl_mensaje.Text = "Ingrese correctamente la fecha de contrato"; return(false); } if (contrato > DateTime.Now || contrato.Year < 2016) { lbl_mensaje.Text = "La fecha de contrato es inválida"; return(false); } if (string.IsNullOrEmpty(txtDuracion.Text)) { lbl_mensaje.Text = "Ingrese la duración del contrato"; return(false); } int duracion = 0; try { duracion = int.Parse(txtDuracion.Text.Trim()); } catch { ver = false; } if (!ver) { lbl_mensaje.Text = "Ingrese correctamente el número de meses del contrato"; return(false); } if (duracion < 6 || duracion > 60) { lbl_mensaje.Text = "Ingrese una duración entre 6 a 60 meses"; return(false); } lblDisponible.Text = ""; bool primero = true; for (int i = 0; i < cblDiasDisponible.Items.Count; i++) { if (cblDiasDisponible.Items[i].Selected) { if (!primero) { lblDisponible.Text = lblDisponible.Text + "-"; } lblDisponible.Text = lblDisponible.Text + cblDiasDisponible.Items[i].Value; if (primero) { primero = false; } } } if (string.IsNullOrEmpty(lblDisponible.Text)) { lbl_mensaje.Text = "Marque los dias disponibles"; return(false); } if (string.IsNullOrEmpty(lbl_mensaje_1.Text)) { lbl_mensaje.Text = "Suba una foto para el perfil"; return(false); } if (string.IsNullOrEmpty(lblLat.Text)) { lbl_mensaje.Text = "Consulte y verifique su dirección en el mapa"; return(false); } if (string.IsNullOrEmpty(lblLng.Text)) { lbl_mensaje.Text = "Consulte y verifique su dirección en el mapa"; return(false); } return(true); }
protected void btnGuardar_Click(object sender, EventArgs e) { try { lbl_mensaje.Text = ""; if (validarDatos()) { DtoProfesor prof = new DtoProfesor(); prof.codPersona = int.Parse(Request.Params["c"]); prof.numDocumento = txtNumDoc.Text; prof.nombres = txtNombres.Text.Trim(); prof.apPaterno = txtApPAt.Text.Trim(); prof.apMaterno = txtApMat.Text.Trim(); if (string.IsNullOrEmpty(txtTelf.Text)) { prof.telefono = null; } else { prof.telefono = txtTelf.Text.Trim(); } prof.email = txtEmail.Text.Trim(); prof.direccion = txtDireccion.Text.Trim(); prof.sexo = Convert.ToChar(ddlSexo.SelectedValue); prof.fechaNacimiento = Convert.ToDateTime(txt_fecha.Text); if (string.IsNullOrEmpty(lblcodUsuario.Text)) { prof.codUsuario = null; } else { prof.codUsuario = Convert.ToInt32(lblcodUsuario.Text); } prof.codDistrito = Convert.ToInt32(ddlDistrito.SelectedValue); prof.urlFoto = lbl_mensaje_1.Text; if (string.IsNullOrEmpty(txtContrato.Text.Trim())) { prof.fechaContrato = null; } else { prof.fechaContrato = Convert.ToDateTime(txtContrato.Text); } if (string.IsNullOrEmpty(txtDuracion.Text.Trim())) { prof.duracionContrato = null; } else { prof.duracionContrato = Convert.ToInt32(txtDuracion.Text.Trim()); } prof.tipoTrabajador = "PROFESOR"; if (string.IsNullOrEmpty(lblLat.Text)) { prof.latitud = null; } else { prof.latitud = Convert.ToDouble(lblLat.Text); } if (string.IsNullOrEmpty(lblLng.Text)) { prof.longitud = null; } else { prof.longitud = Convert.ToDouble(lblLng.Text); } prof.diasDisponible = null; prof.urlCV = lbl_mensaje_3.Text; prof.estadoProfesor = ddlEstado.SelectedValue.ToString(); if (prof.estadoProfesor == "ACTIVO") { prof.diasDisponible = lblDisponible.Text; } if (prof.estadoProfesor == "CAPACITADO" || prof.estadoProfesor == "ACTIVO" || prof.estadoProfesor == "INACTIVO") { prof.estadoTrabajador = "1"; } else { prof.estadoTrabajador = "0"; } DtoUsuario usu = new DtoUsuario(); CtrUsuario ctrubsu = new CtrUsuario(); if (prof.estadoProfesor == "ACTIVO" && string.IsNullOrEmpty(lblcodUsuario.Text)) { usu.usuario = txtUsuario.Text.Trim(); usu.clave = txtContraseña.Text.Trim(); usu.estado = "1"; usu.codPerfil = 5; ctrubsu.registrarUsuario(usu); prof.codUsuario = ctrubsu.consultarUltimoUsuario(); } else if (prof.estadoProfesor == "ACTIVO" && !string.IsNullOrEmpty(lblcodUsuario.Text)) { usu.codUsuario = Convert.ToInt32(lblcodUsuario.Text); ctrubsu.habilitarUsuario(usu); } else if (!string.IsNullOrEmpty(lblcodUsuario.Text)) { usu.codUsuario = Convert.ToInt32(lblcodUsuario.Text); ctrubsu.inhabilitarUsuario(usu); } CtrProfesor ctrprof = new CtrProfesor(); ctrprof.modificarProfesor(prof); lbl_mensaje.Text = "Se modificó exitósamente el profesor: " + prof.nombres + " " + prof.apPaterno + " " + prof.apMaterno; } } catch { lbl_mensaje.Text = "Error al intentar modificar el profesor"; } }
public void cargarDatos() { CtrProfesor ctrprof = new CtrProfesor(); CtrTrabajador ctrtrab = new CtrTrabajador(); CtrPersona ctrpers = new CtrPersona(); DtoProfesor prof = new DtoProfesor(); CtrUbigeo ctrubig = new CtrUbigeo(); prof.codPersona = int.Parse(Session["c"].ToString()); ctrpers.consultarPersona(prof); ctrtrab.consultarTrabajador(prof); ctrprof.consultarProfesor(prof); txtNombres.Text = prof.nombres; txtApPAt.Text = prof.apPaterno; txtApMat.Text = prof.apMaterno; txtNumDoc.Text = prof.numDocumento; txtTelf.Text = prof.telefono; txtEmail.Text = prof.email; txtDireccion.Text = prof.direccion; ddlSexo.SelectedValue = prof.sexo.ToString().Trim(); txt_fecha.Text = prof.fechaNacimiento.ToShortDateString(); lblcodUsuario.Text = prof.codUsuario.ToString(); lbl_mensaje_1.Text = prof.urlFoto; if (prof.fechaContrato != null) { txtContrato.Text = prof.fechaContrato.ToString().Substring(0, 10); } txtDuracion.Text = prof.duracionContrato.ToString(); if (prof.latitud != null && prof.longitud != null) { lblLat.Text = prof.latitud.ToString(); lblLng.Text = prof.longitud.ToString(); mostrarDireccion(prof.latitud.ToString(), prof.longitud.ToString()); } if (prof.estadoProfesor == "ACTIVO") { divEquisdeConOkeyno.Visible = true; listarTalleresxProfesor(int.Parse(Session["c"].ToString())); } string cadDisponibilidad = prof.diasDisponible; if (cadDisponibilidad.Contains("L")) { cblDiasDisponible.Items[0].Selected = true; } if (cadDisponibilidad.Contains("M")) { cblDiasDisponible.Items[1].Selected = true; } if (cadDisponibilidad.Contains("X")) { cblDiasDisponible.Items[2].Selected = true; } if (cadDisponibilidad.Contains("J")) { cblDiasDisponible.Items[3].Selected = true; } if (cadDisponibilidad.Contains("V")) { cblDiasDisponible.Items[4].Selected = true; } if (cadDisponibilidad.Contains("S")) { cblDiasDisponible.Items[5].Selected = true; } img_foto.ImageUrl = lbl_mensaje_1.Text; lbl_mensaje_3.Text = prof.urlCV; ddlEstado.SelectedValue = prof.estadoProfesor; if (prof.estadoProfesor == "ACTIVO" && string.IsNullOrEmpty(lblcodUsuario.Text)) { divXd.Visible = true; } int provincia = ctrubig.getProvincia(prof.codDistrito); ddlProvincia.SelectedValue = provincia.ToString(); listarDistritos(provincia); ddlDistrito.SelectedValue = prof.codDistrito.ToString(); }