Ejemplo n.º 1
0
        public async Task <ActionResult <TblAlumno> > PostTblAlumno(TblAlumno tblAlumno)
        {
            _context.Alumnos.Add(tblAlumno);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTblAlumno", new { id = tblAlumno.IdAlumno }, tblAlumno));
        }
Ejemplo n.º 2
0
        protected TblAlumno GetDatosVista(TblAlumno alum)
        {
            var          random    = new Random();
            var          value     = random.Next(0, 999999);
            TblDireccion direccion = new TblDireccion();

            direccion.strestado      = txtDirecEstado.Text.ToUpper();
            direccion.strmunicipio   = txtDirecMunicipio.Text.ToUpper();
            direccion.strcolonia     = txtDirecColonia.Text.ToUpper();
            direccion.strcalle       = txtDirecCalle.Text.ToUpper();
            direccion.intcodpost     = Int32.Parse(txtpostal.Text);
            direccion.strnumInt      = txtDirecInter.Text.ToUpper();
            direccion.strnumExt      = txtDirecExt.Text.ToUpper();
            direccion.strreferencias = TxtReferencia.Text.ToUpper();

            TblTelefono telefono = new TblTelefono();

            telefono.strcelular = txtTelCelular.Text.ToUpper();
            telefono.strtelCasa = txtTelCasa.Text.ToUpper();
            telefono.strotro    = txtTelotro.Text.ToUpper();

            TblUser login = new TblUser();

            login.strusuario     = txtCorreoAgregar.Text.ToString();
            login.strpass        = value.ToString();
            login.strtipoUsuario = "ALUMNO";

            alum.TblDireccion = direccion;
            alum.TblTelefono  = telefono;
            alum.TblUser      = login;

            return(alum);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutTblAlumno(int id, TblAlumno tblAlumno)
        {
            if (id != tblAlumno.IdAlumno)
            {
                return(BadRequest());
            }

            _context.Entry(tblAlumno).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TblAlumnoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 4
0
        public void Editar(TblAlumno alum, TblTelefono tel, TblDireccion dom)
        {
            TblAlumno alumBd = contexto.TblAlumno
                               .Where(t => t.id == alum.id).FirstOrDefault();

            if (alumBd != null)
            {
                alumBd.strCorreo = alum.strCorreo;
                contexto.SubmitChanges();
            }

            TblTelefono telBd = contexto.TblTelefono
                                .Where(t => t.id == tel.id).FirstOrDefault();

            if (telBd != null)
            {
                telBd.strcelular = tel.strcelular;
                telBd.strtelCasa = tel.strtelCasa;
                telBd.strotro    = tel.strotro;
                contexto.SubmitChanges();
            }

            TblDireccion domBd = contexto.TblDireccion
                                 .Where(t => t.id == dom.id).FirstOrDefault();

            if (domBd != null)
            {
                domBd.strcalle     = dom.strcalle;
                domBd.strcolonia   = dom.strcolonia;
                domBd.strmunicipio = dom.strmunicipio;
                contexto.SubmitChanges();
            }
        }
Ejemplo n.º 5
0
        protected void btnAceptarAgregar_Click(object sender, EventArgs e)
        {
            var sex     = cmbSexo.SelectedItem.Value;
            var carrera = ddlCarrera.SelectedValue;
            var cuatri  = ddlCuatri.SelectedValue;
            var grupo   = ddlGrupo.SelectedValue;

            if (FotoAlumno.HasFile)
            {
                string path = Server.MapPath("~/images/AlumRegistrado/" + FotoAlumno.FileName);
                FotoAlumno.SaveAs(path);

                TblAlumno alum = new TblAlumno();
                alum.strNombre    = txtNombreAgregar.Text.ToUpper();
                alum.strApellidoP = txtPaternoAgregar.Text.ToUpper();
                alum.strApellidoM = txtMaternoAgregar.Text.ToUpper();
                alum.intEdad      = Int32.Parse(txtEdadAgregar.Text);
                alum.strSexo      = sex;
                alum.strCorreo    = txtCorreoAgregar.Text;
                alum.bitFoto      = path;
                alum.idCarrera    = int.Parse(carrera);
                alum.idCuatri     = int.Parse(cuatri);
                alum.idGrupo      = int.Parse(grupo);

                var maximo = (from max in contexto.TblGrupo
                              where max.id == Convert.ToInt32(ddlGrupo.SelectedValue)
                              select max.strCapacidad).FirstOrDefault();

                var cuenta = (from cue in contexto.TblAlumno
                              where cue.idGrupo == Convert.ToInt32(ddlGrupo.SelectedValue) &&
                              cue.idCarrera == Convert.ToInt32(ddlCarrera.SelectedValue)
                              select cue.idGrupo).Count();

                var cuenta1 = cuenta + 1;
                if (maximo >= cuenta1)
                {
                    ControllerAlumno ctrlAlum = new ControllerAlumno();
                    ctrlAlum.InsertarAlum(GetDatosVista(alum));
                    alertBien.Visible = true;
                }
                else
                {
                    alertError.Visible = true;
                }
            }
            this.Response.Redirect("./Alumnosadmin.aspx", true);
        }
Ejemplo n.º 6
0
        public bool InsertarAlum(TblAlumno _TBL_Alum)
        {
            bool respuesta = false;

            try
            {
                contexto.TblAlumno.InsertOnSubmit(_TBL_Alum);
                contexto.SubmitChanges();
                respuesta = true;
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.ToString());
                respuesta = false;
            }
            return(respuesta);
        }
Ejemplo n.º 7
0
 public Alumno Get(int _iduser)
 {
     using (var dcTemp = new PaslumBaseDatoDataContext())
     {
         TblAlumno AluAlumno =
             dcTemp.GetTable <TblAlumno>().Where(c => c.idUser == _iduser).FirstOrDefault();
         if (AluAlumno != null)
         {
             var objTemp = new Alumno();
             objTemp.ID                  = AluAlumno.id;
             objTemp.nombre              = AluAlumno.strNombre;
             objTemp.apellidoP           = AluAlumno.strApellidoP;
             objTemp.apellidoM           = AluAlumno.strApellidoM;
             objTemp.edad                = AluAlumno.intEdad.Value;
             objTemp.sexo                = AluAlumno.strSexo;
             objTemp.correo              = AluAlumno.strCorreo;
             objTemp.intIdDireccion      = AluAlumno.idDireccion.Value;
             objTemp.strDireccionCalle   = AluAlumno.TblDireccion.strcalle;
             objTemp.strDireccionColonia = AluAlumno.TblDireccion.strcolonia;
             objTemp.intDireccionCP      = AluAlumno.TblDireccion.intcodpost.Value;
             objTemp.strDireccionMun     = AluAlumno.TblDireccion.strmunicipio;
             objTemp.strDireccionEst     = AluAlumno.TblDireccion.strestado;
             objTemp.strDireccionNoEx    = AluAlumno.TblDireccion.strnumExt;
             objTemp.strDireccionNoInt   = AluAlumno.TblDireccion.strnumInt;
             objTemp.strCarrera          = AluAlumno.TblCarrera.strNombre;
             objTemp.strCuatri           = AluAlumno.TblCuatri.strNombre;
             objTemp.strGrupo            = AluAlumno.TblGrupo.strNombre;
             objTemp.intIdTelefono       = AluAlumno.idTelefono.Value;
             objTemp.strTelefonoCasa     = AluAlumno.TblTelefono.strtelCasa;
             objTemp.strTelefonoCelular  = AluAlumno.TblTelefono.strcelular;
             objTemp.strOtro             = AluAlumno.TblTelefono.strotro;
             return(objTemp);
         }
         else
         {
             return(new Alumno());
         }
     }
 }
Ejemplo n.º 8
0
        protected void BtnEditar_Click(object sender, EventArgs e)
        {
            TblAlumno alum = new TblAlumno();

            alum.id = Convert.ToInt32(Session["id"]);
            if (TxtCorreo.Text.Length > 1)
            {
                alum.strCorreo = TxtCorreo.Text;
            }
            else
            {
                alum.strCorreo = lbcorreo.Text;
            }

            TblTelefono tel = new TblTelefono();

            tel.id = Convert.ToInt32(Session["forTel"]);
            if (TxtCelular.Text.Length > 1)
            {
                tel.strcelular = TxtCelular.Text;
            }
            else
            {
                tel.strcelular = lbCelular.Text;
            }
            if (TxtTelefono.Text.Length > 1)
            {
                tel.strtelCasa = TxtTelefono.Text;
            }
            else
            {
                tel.strtelCasa = lbTelefono.Text;
            }
            if (TxtOtro.Text.Length > 1)
            {
                tel.strotro = TxtOtro.Text;
            }
            else
            {
                tel.strotro = lbOtro.Text;
            }

            TblDireccion dom = new TblDireccion();

            dom.id = Convert.ToInt32(Session["forDom"]);
            if (TxtCalle.Text.Length > 1)
            {
                dom.strcalle = TxtCalle.Text;
            }
            else
            {
                dom.strcalle = lbCalle.Text;
            }
            if (TxtColonia.Text.Length > 1)
            {
                dom.strcolonia = TxtColonia.Text;
            }
            else
            {
                dom.strcolonia = lbColonia.Text;
            }
            if (TxtMunicipio.Text.Length > 1)
            {
                dom.strmunicipio = TxtMunicipio.Text;
            }
            else
            {
                dom.strmunicipio = lbMunicipio.Text;
            }
            ControllerAlumno ctrlAlum = new ControllerAlumno();

            ctrlAlum.Editar(alum, tel, dom);
            this.Response.Redirect("./DatosPersonales.aspx", true);
        }