private void btnAceptar_Click(object sender, EventArgs e)
        {
            try
            {
                validarEntidad();

                InscripcionService s = new InscripcionService();

                if (inscripcion.Id != 0)
                {
                    s.Update(inscripcion);
                }
                else
                {
                    s.Insert(inscripcion);
                }

                CommonHelper.ShowInfo("Inscripción guardada correctamente.");

                this.DialogResult = DialogResult.OK;
            }
            catch (WarningException ex)
            {
                CommonHelper.ShowWarning(ex.Message);
            }
            catch (Exception ex)
            {
                CommonHelper.ShowError(ex.Message);
            }
        }
Beispiel #2
0
        public HelperController(IConfiguration configuration, IMailService mailService)
        {
            Configuration     = configuration;
            _connectionString = Configuration["ConnectionStrings:DefaultConnection"];
            //this.mailService = mailService;

            service = new InscripcionService(_connectionString, mailService);
        }
        protected void btnInscripciones_Click(object sender, EventArgs e)
        {
            InscripcionService s = new InscripcionService();

            if (s.GetAllByActualDate().Count == 0)
            {
                CrearModal("Atención", "No se encuentra habilitado el período de inscripciones a materias.");
            }
            else
            {
                Response.Redirect("~/Inscripciones.aspx");
            }
        }
        private void validarEntidad()
        {
            string errores = "";

            if (cmbCuatrimestre.Enabled && cmbCuatrimestre.SelectedItem == null)
            {
                errores += "Debe especificar el cuatrimestre" + Environment.NewLine;
            }

            if (dtpApertura.Value >= dtpCierre.Value)
            {
                errores += "La fecha de apertura no puede ser mayor o igual a la fecha de cierre. " + Environment.NewLine;
            }

            if (errores != "")
            {
                throw new WarningException(errores);
            }

            if (inscripcion == null)
            {
                inscripcion = new Inscripcion();
            }
            inscripcion.Año           = dtpAño.Value.Year;
            inscripcion.Cuatrimestre  = (byte?)cmbCuatrimestre.SelectedItem ?? null;
            inscripcion.FechaApertura = dtpApertura.Value;
            inscripcion.FechaCierre   = dtpCierre.Value;

            InscripcionService s = new InscripcionService();

            var inscripciones = s.GetAll();

            foreach (var Inscripcion in inscripciones)
            {
                if (Inscripcion.Id != inscripcion.Id)
                {
                    if (Inscripcion.Año == inscripcion.Año &&
                        Inscripcion.Cuatrimestre == inscripcion.Cuatrimestre)
                    {
                        throw new WarningException("Ya existe un período de inscripción para las materias " +
                                                   (Inscripcion.Cuatrimestre == null ? "anuales" : "del " +
                                                    (Inscripcion.Cuatrimestre == 1 ? "primer" : "segundo") +
                                                    " cuatrimestre") +
                                                   " para el año " + Inscripcion.Año + ". Modifique el existente.");
                    }
                }
            }
        }
        private void cargarGrilla()
        {
            InscripcionService s = new InscripcionService();

            try
            {
                Inscripciones        = s.GetAll();
                dgvGrilla.DataSource = Inscripciones
                                       .OrderByDescending(x => x.Año)
                                       .ThenBy(x => x.Cuatrimestre).ToList();
                dgvGrilla.Columns["Id"].Visible = false;
                dgvGrilla.Columns["FechaApertura"].HeaderText = "Fecha de apertura";
                dgvGrilla.Columns["FechaCierre"].HeaderText   = "Fecha de cierre";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public InscripcionController(ExposoftwareContext context)
 {
     _inscripcionService = new InscripcionService(context);
 }