Example #1
0
        public void inhabilitarProfesor(DtoProfesor prof)
        {
            DtoTrabajador tra = prof;

            daotra.disableTrabajador(tra);

            datprof.disableProfesor(prof);
        }
Example #2
0
        public void modificarProfesor(DtoProfesor prof)
        {
            DtoPersona pers = prof;

            daopers.updatePersona(pers);

            DtoTrabajador tra = prof;

            daotra.updateTrabajador(tra);

            datprof.updateProfesor(prof);
        }
Example #3
0
        public void disableProfesor(DtoProfesor prof)
        {
            SqlCommand cmd = new SqlCommand("sp_disableProfesor", conexion);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@codPersona", prof.codPersona);

            conexion.Open();
            cmd.ExecuteNonQuery();
            conexion.Close();
        }
Example #4
0
        public void registrarProfesor(DtoProfesor prof)
        {
            DtoPersona pers = prof;

            daopers.insertPersona(pers);

            DtoTrabajador tra = prof;

            try { daotra.insertTrabajador(tra); }
            catch { daopers.deleteLastPersona(pers); }

            try { datprof.insertProfesor(prof); }
            catch { daotra.deleteLastTrabajador(tra); daopers.deleteLastPersona(pers); }
        }
Example #5
0
        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"; }
        }
Example #6
0
        public bool getProfesor(DtoProfesor trab)
        {
            SqlCommand cmd = new SqlCommand("sp_getProfesor", conexion);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@codPersona", trab.codPersona);

            conexion.Open();
            bool hayRegistros;

            SqlDataReader reader = cmd.ExecuteReader();

            hayRegistros = reader.Read();

            if (hayRegistros)
            {
                if (reader[1] == DBNull.Value)
                {
                    trab.latitud = null;
                }
                else
                {
                    trab.latitud = Convert.ToDouble(reader[1].ToString());
                }
                if (reader[2] == DBNull.Value)
                {
                    trab.longitud = null;
                }
                else
                {
                    trab.longitud = Convert.ToDouble(reader[2].ToString());
                }
                trab.diasDisponible = reader[3].ToString();
                trab.urlCV          = reader[4].ToString();
                trab.estadoProfesor = reader[5].ToString();
            }

            conexion.Close();
            return(hayRegistros);
        }
Example #7
0
        public bool getLastProfesor(DtoProfesor prof)
        {
            SqlCommand cmd = new SqlCommand("sp_getProfesor", conexion);

            cmd.CommandType = CommandType.StoredProcedure;

            conexion.Open();
            bool hayRegistros;

            SqlDataReader reader = cmd.ExecuteReader();

            hayRegistros = reader.Read();

            if (hayRegistros)
            {
                prof.codPersona      = Convert.ToInt32(reader[0].ToString());
                prof.numDocumento    = reader[1].ToString();
                prof.nombres         = reader[2].ToString();
                prof.apPaterno       = reader[3].ToString();
                prof.apMaterno       = reader[4].ToString();
                prof.telefono        = reader[5].ToString();
                prof.email           = reader[6].ToString();
                prof.direccion       = reader[7].ToString();
                prof.sexo            = Convert.ToChar(reader[8].ToString());
                prof.fechaNacimiento = Convert.ToDateTime(reader[9].ToString());
                if (reader[10] == DBNull.Value)
                {
                    prof.codUsuario = null;
                }
                else
                {
                    prof.codUsuario = Convert.ToInt32(reader[10].ToString());
                }
                prof.codDistrito = Convert.ToInt32(reader[11].ToString());
            }

            conexion.Close();
            return(hayRegistros);
        }
Example #8
0
        public void updateProfesor(DtoProfesor prof)
        {
            SqlCommand cmd = new SqlCommand("sp_updateProfesor", conexion);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@codPersona", prof.codPersona);
            if (prof.latitud == null)
            {
                cmd.Parameters.AddWithValue("@latitud", DBNull.Value);
            }
            else
            {
                cmd.Parameters.AddWithValue("@latitud", prof.latitud);
            }
            if (prof.longitud == null)
            {
                cmd.Parameters.AddWithValue("@longitud", DBNull.Value);
            }
            else
            {
                cmd.Parameters.AddWithValue("@longitud", prof.longitud);
            }
            if (prof.diasDisponible == null)
            {
                cmd.Parameters.AddWithValue("@diasDisponible", DBNull.Value);
            }
            else
            {
                cmd.Parameters.AddWithValue("@diasDisponible", prof.diasDisponible);
            }
            cmd.Parameters.AddWithValue("@urlCV", prof.urlCV);
            cmd.Parameters.AddWithValue("@estadoProfesor", prof.estadoProfesor);

            conexion.Open();
            cmd.ExecuteNonQuery();
            conexion.Close();
        }
Example #9
0
        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"; }
        }
Example #10
0
        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();
        }
Example #11
0
 public bool consultarProfesor(DtoProfesor prof)
 {
     return(datprof.getProfesor(prof));
 }