Пример #1
0
        public override bool Validar()
        {
            var validador = new Validador();

            if (!DocCurLogic.isInscripcionValid(cBDocente.Text, cBCurso.Text))
            {
                validador.AgregarError("El docente ya esta inscripto en ese curso");
            }
            if (cBCargo.SelectedItem == null)
            {
                validador.AgregarError("Elija un cargo");
            }
            if (cBDocente.SelectedItem == null)
            {
                validador.AgregarError("Elija un Docente");
            }
            if (cBCurso.SelectedItem == null)
            {
                validador.AgregarError("Elija un curso");
            }
            if (!validador.EsValido())
            {
                BusinessLogic.Notificar("DocenteCurso", validador.Errores, MessageBoxButtons.OK, MessageBoxIcon.Error);                       //Si no es valido, mustra el error
            }
            return(validador.EsValido());
        }
        private void LoadGrid()
        {
            List <DocenteCurso> cur;

            if (UsuarioLogueado.ID != 0 && UsuarioLogueado.TiposUsuario.ToString() == "Docente")
            {
                this.GridView1.DataSource = this.Logic.GetMisCursos(UsuarioLogueado.ID);
                cur = new DocCurLogic().GetMisCursos(UsuarioLogueado.ID);
            }
            else
            {
                this.GridView1.DataSource = this.Logic.GetAll();
                cur = new DocCurLogic().GetAll();
            }
            this.GridView1.DataBind();
            for (int i = 0; i < cur.Count; i++)
            {
                var mat = new UsuarioLogic().getOne(Convert.ToInt32(this.GridView1.Rows[i].Cells[2].Text));
                this.GridView1.Rows[i].Cells[5].Text = mat.NombreUsuario;
            }
            for (int i = 0; i < cur.Count; i++)
            {
                var com = new CursosLogic().getOne(Convert.ToInt32(this.GridView1.Rows[i].Cells[1].Text));
                this.GridView1.Rows[i].Cells[4].Text = com.Descripcion;
            }
        }
        protected void aceptarLinkButton_Click(object sender, EventArgs e)
        {
            switch (this.FormMode)
            {
            case FormModes.Baja:
                this.DeleteEntity(this.SelectedID);
                this.LoadGrid();
                break;

            case FormModes.Modificacion:
                if (DocCurLogic.isInscripcionValid(ddlDocente.Text, ddlCurso.Text))
                {
                    this.Entity       = new DocenteCurso();
                    this.Entity.ID    = this.SelectedID;
                    this.Entity.State = BusinessEntity.States.Modified;
                    this.LoadEntity(this.Entity);
                    this.SaveEntity(this.Entity);
                    this.LoadGrid();
                    this.formPanel.Visible = false;
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "No se pudo anotar", "alert('Este usuario ya está anotado')", true);
                }
                break;

            case FormModes.Alta:
                if (DocCurLogic.isInscripcionValid(ddlDocente.Text, ddlCurso.Text))
                {
                    this.Entity = new DocenteCurso();
                    this.LoadEntity(this.Entity);
                    this.SaveEntity(this.Entity);
                    this.LoadGrid();
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "No se pudo anotar", "alert('Este usuario ya está anotado')", true);
                }
                break;

            default:
                break;
            }
            this.formPanel.Visible = false;
        }
 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.SelectedID = (int)this.GridView1.SelectedValue;
     if (UsuarioLogueado.ID != 0 && UsuarioLogueado.TiposUsuario.ToString() == "Docente")
     {
         var docCur = new DocCurLogic().getOne(this.SelectedID);
         Session["idcurso"] = docCur.IDCurso;
         Response.Redirect("~/AlumnosInscripciones.aspx");
     }
     else
     {
         if (this.FormMode == FormModes.Modificacion)
         {
             if (this.IsEntitySelected)
             {
                 this.formPanel.Visible = true;
                 this.FormMode          = FormModes.Modificacion;
                 this.LoadForm(this.SelectedID);
                 this.EnableForm(true);
             }
         }
         if (this.FormMode == FormModes.Baja)
         {
             if (this.IsEntitySelected)
             {
                 this.formPanel.Visible = true;
                 this.FormMode          = FormModes.Baja;
                 this.EnableForm(false);
                 this.LoadForm(this.SelectedID);
             }
         }
         if (this.FormMode == FormModes.Alta)
         {
             if (this.IsEntitySelected)
             {
                 this.formPanel.Visible = true;
                 this.FormMode          = FormModes.Modificacion;
                 this.LoadForm(this.SelectedID);
                 this.EnableForm(true);
             }
         }
     }
 }