// GET: Administrador
        public ActionResult BaseDatos()
        {
            NProfesor temp   = new NProfesor();
            var       profes = temp.getProfesor();

            return(View(profes));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            NProfesor profe = new NProfesor();

            profe.eliminarProfesor(id);
            return(RedirectToAction("Index"));
        }
        // GET: Profesores/Details/5
        public ActionResult Details(int id)
        {
            NProfesor profesores = new NProfesor();
            var       profesor   = profesores.getProfesor().ToList().Where(x => x.IdProfesor == id).FirstOrDefault();

            Session["IdProfeTemp"]     = profesor.IdProfesor;
            Session["NombreProfeTemp"] = profesor.Nombre + " " + profesor.PrimerApellido + " " + profesor.SegundoApellido;
            return(View(profesor));
        }
        public ActionResult Calendario(int idProfesor)
        {
            NProfesor temp  = new NProfesor();
            var       profe = temp.getProfesor().Where(x => x.IdProfesor == idProfesor).FirstOrDefault();

            @Session["NombreProfe"] = profe.SegundoApellido + " " + profe.PrimerApellido + " " + profe.Nombre;
            @Session["IdProfesor"]  = idProfesor;

            NHorario horario       = new NHorario();
            var      listaHorarios = horario.getHorarioProfesor(idProfesor);

            return(View(listaHorarios));
        }
        // GET: Profesores/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NProfesor lista    = new NProfesor();
            var       profesor = lista.getProfesor2().ToList().Where(x => x.IdProfesor == id).FirstOrDefault();

            if (profesor == null)
            {
                return(HttpNotFound());
            }
            return(View(profesor));
        }
        // GET: Profesores/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NProfesor lista    = new NProfesor();
            var       profesor = lista.getProfesor2().ToList().Where(x => x.IdProfesor == id).FirstOrDefault();

            if (profesor == null)
            {
                return(HttpNotFound());
            }
            NLugares lugar = new NLugares();

            ViewBag.IdLugar = new SelectList(lugar.getLugares(), "IdLugar", "Nombre", profesor.IdLugar);
            return(View(profesor));
        }
        public ActionResult Edit([Bind(Include = "IdProfesor,Nombre,PrimerApellido,SegundoApellido,Usuario,CorreoElectronico,IdLugar")] Profesor profesor, HttpPostedFileBase Foto)
        {
            if (ModelState.IsValid)
            {
                if (Foto == null)
                {
                    profesor.Foto = null;
                }
                else
                {
                    profesor.Foto = new byte[Foto.ContentLength];
                    Foto.InputStream.Read(profesor.Foto, 0, Foto.ContentLength);
                }
                NProfesor profeTemp = new NProfesor();
                profeTemp.actualizarProfesor(profesor);
                return(RedirectToAction("Details", new { id = profesor.IdProfesor }));
            }
            NLugares lugar = new NLugares();

            ViewBag.IdLugar = new SelectList(lugar.getLugares(), "IdLugar", "Nombre", profesor.IdLugar);
            return(View(profesor));
        }
示例#8
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult Opcion;
                Opcion = MessageBox.Show("Realmente Desea Eliminar los Registros", "Sistema de Ventas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

                if (Opcion == DialogResult.OK)
                {
                    string Codigo;
                    string Rpta = "";

                    foreach (DataGridViewRow row in dataGridView1.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            Codigo = Convert.ToString(row.Cells[1].Value);
                            Rpta   = NProfesor.Eliminar(Convert.ToInt32(Codigo));

                            if (Rpta.Equals("OK"))
                            {
                                this.mensajeok("Se Eliminó Correctamente el registro");
                            }
                            else
                            {
                                this.mensajeerror(Rpta);
                            }
                        }
                    }
                    this.buscarnombre();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
示例#9
0
 private void buscarnombre()
 {
     this.dataGridView1.DataSource = NProfesor.buscarnombre(this.txtbuscar.Text, this.textBox5.Text);
     this.OcultarColumnas();
     label10.Text = "Total de Registros: " + Convert.ToString(dataGridView1.Rows.Count);
 }
示例#10
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length < 8)
            {
                MessageBox.Show("Ingrese 8 caracteres para el DNI");
            }
            else
            {
                try
                {
                    string rpta = "";

                    if (this.textBox3.Text == string.Empty)
                    {
                        mensajeerror("Falta ingresar algunos datos, serán remarcados");

                        if (this.textBox4.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox4, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox4, "");
                        }

                        if (this.textBox3.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox3, "ingrese el Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox3, "");
                        }

                        if (this.textBox1.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox1, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox1, "");
                        }
                        //

                        if (this.textBox24.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox24, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox24, "");
                        }

                        if (this.textBox20.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox20, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox20, "");
                        }

                        if (this.textBox7.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox7, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox7, "");
                        }

                        if (this.comboBox1.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.comboBox1, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.comboBox1, "");
                        }
                    }
                    else
                    {
                        if (this.isnuevo)
                        {
                            rpta = NProfesor.Insertar(textBox4.Text, textBox3.Text, textBox1.Text,
                                                      textBox24.Text, textBox20.Text, dateTimePicker1.Value, textBox7.Text, Convert.ToInt32(this.comboBox1.Text));
                        }
                        else
                        {
                            rpta = NProfesor.Editar(Convert.ToInt32(this.textBox2.Text), textBox4.Text, textBox3.Text, textBox1.Text,
                                                    textBox24.Text, textBox20.Text, dateTimePicker1.Value, textBox7.Text, Convert.ToInt32(this.comboBox1.Text));
                        }

                        if (rpta.Equals("OK"))
                        {
                            if (this.isnuevo)
                            {
                                this.mensajeok("Se Insertó de forma correcta el registro");
                            }
                            else
                            {
                                this.mensajeok("Se Actualizó de forma correcta el registro");
                            }
                        }
                        else
                        {
                            this.mensajeerror(rpta);
                        }

                        this.isnuevo  = false;
                        this.iseditar = false;
                        this.buscarnombre();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + ex.StackTrace);
                }
            }
        }
        // GET: Profesores
        public ActionResult Index()
        {
            NProfesor lista = new NProfesor();

            return(View(lista.getProfesor().ToList()));
        }
示例#12
0
        public ActionResult Ingresar(List <String> Datos, string returnUrl)
        {
            string _Usuario    = Datos[0];
            string _Contraseña = Datos[1];

            Seguridad wsseg = new Seguridad();

            WSSeguridadTec.TEC_IWCF_SeguridadClient wssegTec = new TEC_IWCF_SeguridadClient();
            TEC_Credenciales credenciales = new TEC_Credenciales();

            credenciales.CodigoAplicacionLogueado            = 1;
            credenciales.ContrasenaUsuarioAplicacionLogueado = "";
            credenciales.UsuarioAplicacionLogueado           = "";
            credenciales.IpAddress = "1.0.0.0";


            var respuestaAutenticacion = wssegTec.Usu_AutenticarUsuario(_Usuario, _Contraseña, credenciales);

            var Foto = new wsFotosEstudiantes.wsUtilitarios();

            //int codTipoUsuario = Convert.ToInt32(Datos[2]);
            //int codTipoUsuario = codTipoUsuario_funtion(_Usuario, _Contraseña);
            Session["COD_SEDE"] = "SJ";                     //funciona solo para Cartago ahorita
            int codTipoUsuario = Convert.ToInt32(Datos[2]); //funciona solo para funcionarios ahorita

            try
            {
                if ((_Usuario != "") && (_Contraseña != ""))
                {
                    switch (codTipoUsuario)
                    {
                    case 1:    //Funcionario
                    {
                        if (wsseg.ValidarFuncionario(_Usuario, _Contraseña))
                        {
                            //wsseg.ValidarFuncionario(_Usuario, _Contraseña);
                            Session.Add("ID_USUARIO", _Usuario);
                            Session.Add("COD_USUARIO", "FUNCIONARIO");
                            Session.Add("NOM_USUARIO", wsseg.ObtenerNombreUsuario(_Usuario));         //obtener nombre completo del usuario.
                            Session.Add("COD_SEDE", Session["COD_SEDE"].ToString());
                            Session.Add("NOM_DEPARTAMENTO", wsseg.ObtenerDepartamento(_Usuario));
                            User.Identity.Name.Equals(_Usuario);

                            int idEstudiante;
                            if (int.TryParse(_Usuario, out idEstudiante))
                            {
                                var obtieneFoto = Foto.CargarFoto("200");
                                var foto        = Convert.ToBase64String(Foto.CargarFoto("200"));
                                Session["FOTO"] = foto;
                            }
                            else
                            {
                                var obtieneFoto = Foto.CargarFoto("200");
                                Session["FOTO"] = null;
                            }

                            Seguridad wsSeg = new Seguridad();
                            string    _Cedula = "", _Correo = "";
                            _Cedula               = wsSeg.ObtenerCedula(_Usuario);
                            _Correo               = _Usuario + "@itcr.ac.cr";
                            Session["Email"]      = _Correo;
                            Session["NUM_CEDULA"] = _Cedula;
                            NAdministrador usuario     = new NAdministrador();
                            var            tipoUsuario = usuario.getAdministradores().Where(x => x.Usuario == _Usuario).FirstOrDefault();
                            NProfesor      temp        = new NProfesor();

                            var tipoUsuario2 = temp.getProfesor().Where(x => x.Usuario == _Usuario).FirstOrDefault();
                            if (tipoUsuario == null)
                            {
                                if (tipoUsuario2 != null)
                                {
                                    Session["IdProfesor"]  = tipoUsuario2.IdProfesor;
                                    Session["CorreoProfe"] = tipoUsuario2.CorreoElectronico;
                                    Session["TipoUsuario"] = 2;
                                    Session["Permisos"]    = 0;
                                    var res = new { Success = "True" };
                                    return(Json(res, JsonRequestBehavior.AllowGet));
                                }
                                else
                                {
                                    var res = new { Success = "False" };
                                    return(Json(res, JsonRequestBehavior.AllowGet));
                                }
                            }
                            else
                            {
                                if (tipoUsuario2 != null)
                                {
                                    Session["IdProfesor"]  = tipoUsuario2.IdProfesor;
                                    Session["TipoUsuario"] = 2;
                                    Session["Permisos"]    = 1;
                                    var res = new { Success = "True" };
                                    return(Json(res, JsonRequestBehavior.AllowGet));
                                }
                                else
                                {
                                    Session["TipoUsuario"] = 2;
                                    Session["Permisos"]    = 1;
                                    var res = new { Success = "True" };
                                    return(Json(res, JsonRequestBehavior.AllowGet));
                                }
                            }
                        }

                        else
                        {
                            var res = new { Success = "False" };
                            return(Json(res, JsonRequestBehavior.AllowGet));
                        }
                    }

                    case 2:
                    {
                        //Valida que el estudiante exista
                        if (!wsseg.ValidarEstudianteBit(_Usuario, _Contraseña, MvcApplication.CodAplicación, Session["COD_SEDE"].ToString()))
                        {
                            //throw new ITCRException("El Pin es incorrecto.");
                            var res = new { Success = "False" };
                            return(Json(res, JsonRequestBehavior.AllowGet));
                        }
                        //validar que sea estudiante activo
                        if (!EsEstudianteActivo(_Usuario))
                        {
                            var res = new { Success = "False" };
                            return(Json(res, JsonRequestBehavior.AllowGet));
                        }
                        int idEstudiante;
                        if (int.TryParse(_Usuario, out idEstudiante))
                        {
                            //var obtieneFoto = Foto.CargarFoto(_Usuario);
                            if (Foto.CargarFoto(_Usuario) != null)
                            {
                                var foto = Convert.ToBase64String(Foto.CargarFoto(_Usuario));
                                Session["FOTO"] = foto;
                            }
                            else
                            {
                                Session["Foto"] = null;
                            }
                        }
                        else
                        {
                            Session["FOTO"] = null;
                        }

                        Session["Tipo_Usuario"] = 2;

                        if (true)
                        {
                            Session.Add("ID_USUARIO", "USR_Timpresion");
                            Session.Add("CARNE", _Usuario);
                            Session.Add("COD_USUARIO", "ESTUDIANTE");
                            Session.Add("NUM_CEDULA", wsseg.ObtenerCedula(_Usuario));         //obtener número de cédula si tiene.
                            Session.Add("NOM_USUARIO", wsseg.ObtenerNombreUsuario(_Usuario)); //obtener nombre completo del usuario.


                            Session.Add("COD_SEDE", Session["COD_SEDE"].ToString());
                            Session["TipoUsuario"] = 3;
                            var res = new { Success = "True" };
                            return(Json(res, JsonRequestBehavior.AllowGet));
                        }
                    }
                    break;

                    case 3:

                        Session["Tipo_Usuario"] = 3;

                        if (true)
                        {
                            wsseg.ValidarUsuarioSistema(_Usuario, _Contraseña, MvcApplication.CodAplicación, Session["COD_SEDE"].ToString());
                            Session.Add("ID_USUARIO", _Usuario);

                            Session.Add("NUM_CEDULA", wsseg.ObtenerCedula(_Usuario));         //obtener número de cédula si tiene.
                            Session.Add("NOM_USUARIO", wsseg.ObtenerNombreUsuario(_Usuario)); //obtener nombre completo del usuario.
                            Session.Add("COD_SEDE", Session["COD_SEDE"].ToString());
                            Session["FOTO"] = null;
                            var res = new { Success = "True" };
                            return(Json(res, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            var res = new { Success = "False" };
                            return(Json(res, JsonRequestBehavior.AllowGet));
                        }
                    }
                }
            }
            catch (FaultException ex)
            {
                string error = ex.Message.ToString();
                Response.Write("<script>alert('" + error + "');</script>");
                return(View(""));
            }
            var result = new { Success = "False" };

            //return null;
            return(Content("Datos incorrectos"));
        }