예제 #1
0
        public RespuestaServidor Delete(int id)
        {
            try
            {
                this.OpenConnection();

                SqlCommand cmdDelete = new SqlCommand("DELETE personas WHERE id_persona=@id", Con);
                cmdDelete.Parameters.Add("@id", SqlDbType.Int).Value = id;
                cmdDelete.ExecuteReader();
                rs.Mensaje = "Persona eliminada correctamente";
            }
            catch (Exception Ex)
            {
                if (rs.ContieneExcepcion(Ex, "FK_alumnos_inscripciones_personas"))
                {
                    rs.AgregarError("El alumno no puede ser eliminado porque está inscripto a un curso");
                }
                else if (rs.ContieneExcepcion(Ex, "FK_usuarios_personas"))
                {
                    rs.AgregarError("La persona tiene un usuario registrado en el sistema, no puede eliminarse");
                }
                else
                {
                    rs.AgregarExcepcion(Ex);
                }
            }
            finally
            {
                this.CloseConnection();
            }
            return(rs);
        }
        public RespuestaServidor Delete(int id)
        {
            try
            {
                this.OpenConnection();

                SqlCommand cmdDelete = new SqlCommand("DELETE cursos WHERE id_curso=@id", Con);
                cmdDelete.Parameters.Add("@id", SqlDbType.Int).Value = id;
                cmdDelete.ExecuteReader();
                rs.Mensaje = "Curso eliminado con èxito.";
            }
            catch (Exception Ex)
            {
                if (rs.ContieneExcepcion(Ex, "FK_alumnos_inscripciones_cursos"))
                {
                    rs.AgregarError("No se puede eliminar el curso, porque existen alumnos inscriptos.");
                }
                else if (rs.ContieneExcepcion(Ex, "FK_docentes_cursos_cursos"))
                {
                    rs.AgregarError("No se puede eliminar el curso, porque existen docentes asignados.");
                }
                else
                {
                    rs.AgregarExcepcion(Ex);
                }
            }
            finally
            {
                this.CloseConnection();
            }
            return(rs);
        }
예제 #3
0
        private RespuestaServidor ValidarCamposNulos()
        {
            RespuestaServidor rs = new RespuestaServidor();

            if ((this.formMode == FormModes.Alta || this.formMode == FormModes.Modificacion) && string.IsNullOrEmpty(this.listEspecialidad.SelectedValue))
            {
                rs.AgregarError("Seleccione una Especialidad");
            }
            if ((this.formMode == FormModes.Alta || this.formMode == FormModes.Modificacion) && string.IsNullOrEmpty(this.txtPlan.Text))
            {
                rs.AgregarError("Especifique la denominación del Plan");
            }
            return(rs);
        }
        private RespuestaServidor ValidarCamposNulos()
        {
            RespuestaServidor rs = new RespuestaServidor();
            int      validaInt;
            DateTime validaFecha;

            //if (string.IsNullOrEmpty(this.txtNombrePersona.Text))
            //{
            //    rs.AgregarError("Nombre obligatorio");
            //}
            //if (string.IsNullOrEmpty(this.txtApellidoPersona.Text))
            //{
            //    rs.AgregarError("Apellido obligatorio");
            //}
            //if (string.IsNullOrEmpty(this.txtLegajo.Text))
            //{
            //    rs.AgregarError("Legajo obligatorio");
            //}
            //if (!int.TryParse(this.txtLegajo.Text, out validaInt))
            //{
            //    rs.AgregarError("Legajo debe ser un número válido");
            //}
            //if (string.IsNullOrEmpty(this.txtFecha.Text))
            //{
            //    rs.AgregarError("Fecha obligatorio");
            //}
            //if (!DateTime.TryParse(this.txtFecha.Text, out validaFecha))
            //{
            //    rs.AgregarError("La fecha debe ser del formato yyyy/MM/dd");
            //}
            if (string.IsNullOrEmpty(this.listIdPersona.SelectedValue))
            {
                rs.AgregarError("Persona obligatorio");
            }
            if (string.IsNullOrEmpty(this.txtClave.Text))
            {
                rs.AgregarError("Ingrese la Contraseña");
            }
            if (string.IsNullOrEmpty(this.txtRepetirClave.Text))
            {
                rs.AgregarError("Repita la contraseña");
            }
            if (this.txtClave.Text != this.txtRepetirClave.Text)
            {
                rs.AgregarError("Las contraseñas no coinciden");
            }

            return(rs);
        }
예제 #5
0
        public RespuestaServidor Delete(int ID)
        {
            try
            {
                this.OpenConnection();

                SqlCommand cmdDelete = new SqlCommand("DELETE especialidades WHERE id_especialidad=@id", Con);
                cmdDelete.Parameters.Add("@id", SqlDbType.Int).Value = ID;
                cmdDelete.ExecuteReader();
                rs.Mensaje = "Especialidad eliminada con éxito";
            }
            catch (Exception Ex)
            {
                if (rs.ContieneExcepcion(Ex, "FK_planes_especialidades"))
                {
                    rs.AgregarError("La especialidad no puede ser eliminada porque tiene cursos asignados");
                }
                else
                {
                    rs.AgregarExcepcion(Ex);
                }
            }
            finally
            {
                this.CloseConnection();
            }
            return(rs);
        }
예제 #6
0
        public RespuestaServidor Delete(int ID)
        {
            RespuestaServidor rs = new RespuestaServidor();

            try
            {
                this.OpenConnection();

                SqlCommand cmdDelete = new SqlCommand("DELETE planes WHERE id_plan=@id", Con);
                cmdDelete.Parameters.Add("@id", SqlDbType.Int).Value = ID;
                cmdDelete.ExecuteReader();
                rs.Mensaje = "Plan eliminado correctamente";
            }
            catch (Exception Ex)
            {
                if (rs.ContieneExcepcion(Ex, "FK_materias_planes"))
                {
                    rs.AgregarError("El plan no puede ser eliminado porque se esta usando.");
                }
                else
                {
                    rs.AgregarExcepcion(Ex);
                }
            }
            finally
            {
                this.CloseConnection();
            }
            return(rs);
        }
        public RespuestaServidor Save(AlumnoInscripcion alInscr)
        {
            RespuestaServidor rs = new RespuestaServidor();

            if (alInscr.State == EntidadBase.States.New)
            {
                if (alInscr.Curso == null)
                {
                    rs.AgregarError("No existe el curso");
                }
                else if (alumnoInscripcionData.GetOne(alInscr.Alumno.Id, alInscr.Curso.Id) != null)
                {
                    rs.AgregarError("La persona ya pertenece a este curso");
                }
                else if (alInscr.Curso.Cupo <= 0)
                {
                    rs.AgregarError("El curso no dispone de cupo para la inscripcion");
                }
                else
                {
                    alInscr.Curso.Cupo--;
                    (new CatalogoCursos()).Update(alInscr.Curso);
                }
            }
            else if (alInscr.State == EntidadBase.States.Deleted)
            {
                alInscr.Curso = new CatalogoCursos().GetOneByInscripcionAlumno(alInscr.Id);
                if (alInscr.Curso == null)
                {
                    rs.AgregarError("No existe el curso");
                }
                else
                {
                    alInscr.Curso.Cupo++;
                    (new CatalogoCursos()).Update(alInscr.Curso);
                }
            }
            else if (alInscr.State == EntidadBase.States.Modified)
            {
            }
            //El metodo rs.AgregarError(); setea el rs.Error en true
            if (!rs.Error)
            {
                rs = alumnoInscripcionData.Save(alInscr, rs);
            }
            return(rs);
        }
        private RespuestaServidor ValidarCamposNulos()
        {
            RespuestaServidor rs = new RespuestaServidor();

            if (string.IsNullOrEmpty(this.txtEspecialidad.Text))
            {
                rs.AgregarError("Descripción obligatoria");
            }
            return(rs);
        }
        private RespuestaServidor ValidarCamposNulos()
        {
            int validaInt;
            RespuestaServidor rs = new RespuestaServidor();

            if (string.IsNullOrEmpty(this.txtNota.Text))
            {
                rs.AgregarError("La nota es obligatoria");
            }
            else if (int.TryParse(this.txtNota.Text, out validaInt))
            {
                rs.AgregarError("La nota debe ser un entero válido");
            }
            if (string.IsNullOrEmpty(this.txtCondicion.Text))
            {
                rs.AgregarError("La condición es obligatoria");
            }
            return(rs);
        }
예제 #10
0
        private RespuestaServidor ValidarCamposNulos()
        {
            RespuestaServidor rs = new RespuestaServidor();

            if (string.IsNullOrEmpty(this.listIdCurso.SelectedValue))
            {
                rs.AgregarError("Curso es obligatorio");
            }
            return(rs);
        }
        private RespuestaServidor ValidarCamposNulos()
        {
            RespuestaServidor rs = new RespuestaServidor();
            int validaInt;
            int validaInt2;

            if (string.IsNullOrEmpty(this.txtMateria.Text))
            {
                rs.AgregarError("Descripción obligatoria");
            }
            if (string.IsNullOrEmpty(this.txtHsSemanales.Text))
            {
                rs.AgregarError("Horas Semanales obligatorio");
            }
            if (string.IsNullOrEmpty(this.txtHorasTotales.Text))
            {
                rs.AgregarError("Horas Totales obligatorio");
            }
            if (!int.TryParse(this.txtHorasTotales.Text, out validaInt))
            {
                rs.AgregarError("Las Horas totales deben ser un número válido");
            }
            if (!int.TryParse(this.txtHorasTotales.Text, out validaInt2))
            {
                rs.AgregarError("Las Horas totales deben ser un número válido");
            }
            if (string.IsNullOrEmpty(this.listIdPlan.SelectedValue))
            {
                rs.AgregarError("Plan obligatorio");
            }
            return(rs);
        }
예제 #12
0
        private RespuestaServidor ValidarCamposNulos()
        {
            int validaInt;
            RespuestaServidor rs = new RespuestaServidor();

            if (string.IsNullOrEmpty(this.txtDenominacion.Text))
            {
                rs.AgregarError("Denominacion es obligatoria");
            }
            if (string.IsNullOrEmpty(this.listIdMateria.SelectedValue))
            {
                rs.AgregarError("Materia es obligatoria");
            }
            if (string.IsNullOrEmpty(this.txtAnioCalendario.Text))
            {
                rs.AgregarError("Año calendario es obligatorio");
            }
            if (!int.TryParse(this.txtAnioCalendario.Text, out validaInt))
            {
                rs.AgregarError("Año calendario debe ser un entero válido");
            }
            if (string.IsNullOrEmpty(this.txtCupo.Text))
            {
                rs.AgregarError("Cupo es obligatorio");
            }
            if (!int.TryParse(this.txtCupo.Text, out validaInt))
            {
                rs.AgregarError("Cupo debe ser un entero válido");
            }
            return(rs);
        }
예제 #13
0
        private RespuestaServidor ValidarCamposNulos()
        {
            RespuestaServidor rs = new RespuestaServidor();
            int      validaInt;
            DateTime validaFecha;

            if (string.IsNullOrEmpty(this.txtNombrePersona.Text))
            {
                rs.AgregarError("Nombre obligatorio");
            }
            if (string.IsNullOrEmpty(this.txtApellidoPersona.Text))
            {
                rs.AgregarError("Apellido obligatorio");
            }
            if (string.IsNullOrEmpty(this.txtLegajo.Text))
            {
                rs.AgregarError("Legajo obligatorio");
            }
            if (!int.TryParse(this.txtLegajo.Text, out validaInt))
            {
                rs.AgregarError("Legajo debe ser un número válido");
            }
            if (!string.IsNullOrEmpty(this.txtEmail.Text) && !Util.ValidarEmails.esMailValido(txtEmail.Text))
            {
                rs.AgregarError("El email debe tener el formato [email protected]");
            }
            if (string.IsNullOrEmpty(this.txtFecha.Text))
            {
                rs.AgregarError("Fecha obligatorio");
            }
            if (!DateTime.TryParse(this.txtFecha.Text, out validaFecha))
            {
                rs.AgregarError("La fecha debe ser del formato yyyy/MM/dd");
            }
            if (string.IsNullOrEmpty(this.listIdPlan.SelectedValue))
            {
                rs.AgregarError("Plan obligatorio");
            }
            return(rs);
        }
예제 #14
0
 public RespuestaServidor Delete(int ID, RespuestaServidor rs)
 {
     try
     {
         this.OpenConnection();
         SqlCommand cmdDelete = new SqlCommand("delete alumnos_inscripciones where id_inscripcion = @id", Con);
         cmdDelete.Parameters.Add("@id", SqlDbType.Int).Value = ID;
         cmdDelete.ExecuteNonQuery();
         rs.Mensaje = "Inscripción eliminada con éxito";
     }
     catch (Exception)
     {
         rs.AgregarError("Error al eliminar la inscripción");
     }
     finally
     {
         this.CloseConnection();
     }
     return(rs);
 }
        private RespuestaServidor ValidarCamposNulos()
        {
            RespuestaServidor rs = new RespuestaServidor();

            if ((this.formMode == FormModes.Alta || this.formMode == FormModes.Modificacion) && string.IsNullOrEmpty(this.txtNombrePersona.Text))
            {
                rs.AgregarError("Ingrese el nombre");
            }
            if ((this.formMode == FormModes.Alta || this.formMode == FormModes.Modificacion) && string.IsNullOrEmpty(this.txtApellidoPersona.Text))
            {
                rs.AgregarError("Seleccione el apellido");
            }
            if ((this.formMode == FormModes.Alta || this.formMode == FormModes.Modificacion) && string.IsNullOrEmpty(this.txtLegajo.Text))
            {
                rs.AgregarError("Ingrese el legajo");
            }
            if ((this.formMode == FormModes.Alta || this.formMode == FormModes.Modificacion) && string.IsNullOrEmpty(this.txtTelefono.Text))
            {
                rs.AgregarError("Ingrese un teléfono");
            }
            if ((this.formMode == FormModes.Alta || this.formMode == FormModes.Modificacion) && !string.IsNullOrEmpty(this.txtEmail.Text) && !Util.ValidarEmails.esMailValido(txtEmail.Text))
            {
                rs.AgregarError("El email debe tener el formato [email protected]");
            }
            if ((this.formMode == FormModes.Alta || this.formMode == FormModes.Modificacion) && string.IsNullOrEmpty(this.txtFecha.Text))
            {
                rs.AgregarError("Ingrese la fecha de nacimiento");
            }
            if ((this.formMode == FormModes.Alta || this.formMode == FormModes.Modificacion) && string.IsNullOrEmpty(this.txtDireccion.Text))
            {
                rs.AgregarError("Ingrese la dirección");
            }
            if ((this.formMode == FormModes.Alta || this.formMode == FormModes.Modificacion) && string.IsNullOrEmpty(this.listIdPlan.SelectedValue))
            {
                rs.AgregarError("Seleccione un Plan");
            }
            return(rs);
        }
예제 #16
0
 protected RespuestaServidor Insert(AlumnoInscripcion AlumnoInscripcion, RespuestaServidor rs)
 {
     try
     {
         this.OpenConnection();
         SqlCommand cmdSave = new SqlCommand("INSERT into alumnos_inscripciones (id_alumno,id_curso,condicion,nota) values(@id_alumno,@id_curso,@condicion,@nota) select @@identity", Con);
         cmdSave.Parameters.Add("@id_alumno", SqlDbType.Int).Value         = AlumnoInscripcion.Alumno.Id;
         cmdSave.Parameters.Add("@id_curso", SqlDbType.Int).Value          = AlumnoInscripcion.Curso.Id;
         cmdSave.Parameters.Add("@condicion", SqlDbType.VarChar, 50).Value = AlumnoInscripcion.Condicion;
         cmdSave.Parameters.Add("@nota", SqlDbType.Int).Value = AlumnoInscripcion.Nota;
         AlumnoInscripcion.Id = Decimal.ToInt32((decimal)cmdSave.ExecuteScalar());
         rs.Mensaje           = "Inscripción cargada con éxito";
     }
     catch (Exception)
     {
         rs.AgregarError("Error al crear la inscripcion de un alumno");
     }
     finally
     {
         this.CloseConnection();
     }
     return(rs);
 }