Ejemplo n.º 1
0
        public static DataTable Generar(List <Materia> materias)
        {
            DataTable Listado = new DataTable();

            Listado.Columns.Add("ID", typeof(int));
            Listado.Columns.Add("Descripcion", typeof(string));
            Listado.Columns.Add("HSSemanales", typeof(int));
            Listado.Columns.Add("HSTotales", typeof(int));
            Listado.Columns.Add("Plan", typeof(string));

            List <Plan>         planes         = PlanLogic.GetAll();
            List <Especialidad> especialidades = EspLogic.GetAll();

            foreach (Materia mat in materias)
            {
                DataRow Linea = Listado.NewRow();

                Linea["ID"]          = mat.ID;
                Linea["Descripcion"] = mat.Descripcion;
                Linea["HSSemanales"] = mat.HSSemanales;
                Linea["HSTotales"]   = mat.HSTotales;

                Plan         plan = planes.FirstOrDefault(x => x.ID == mat.IDPlan);
                Especialidad esp  = especialidades.FirstOrDefault(x => x.ID == plan.IDEspecialidad);
                Linea["Plan"] = esp.Descripcion + " - " + plan.Descripcion;

                Listado.Rows.Add(Linea);
            }
            return(Listado);
        }
Ejemplo n.º 2
0
 public override bool Validar()
 {
     if (PlanActual == null)
     {
         this.Notificar("Advertencia", "No se completaron todos los campos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return(false);
     }
     else
     {
         bool      valid = true;
         PlanLogic pl    = new PlanLogic();
         foreach (Plan p in pl.GetAll())
         {
             if (p.IDEespecialidad == PlanActual.IDEespecialidad && p.Descripcion == PlanActual.Descripcion)
             {
                 valid = false;
             }
         }
         if (valid)
         {
             return(true);
         }
         else
         {
             this.Notificar("Advertencia", "Ya existe este plan", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
     }
 }
        public override void GuardarCambios()
        {
            MapearADatos();
            PlanLogic p = new PlanLogic();

            if (this.Modo == ModoForm.Baja)
            {
                var resultado = MessageBox.Show("¿Desea eliminar el registro?", "Confirmar eliminación",
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (resultado == DialogResult.Yes)
                {
                    try
                    {
                        p.Delete(PlanActual.ID);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            else
            {
                try
                {
                    p.Save(PlanActual);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 4
0
        public override void MapearADatos()
        {
            if (Modo == ModoForm.Alta)
            {
                Plan PlanNuevo = new Plan();

                PlanNuevo.Descripcion    = this.txtDescripcion.Text;
                PlanNuevo.IDEspecialidad = Convert.ToInt32(this.cbEspecialidades.SelectedValue.ToString());
                PlanLogic nuevoplan = new PlanLogic();
                PlanActual      = PlanNuevo;
                PlanNuevo.State = BusinessEntity.States.New;
                nuevoplan.Save(PlanActual);
            }

            else if (Modo == ModoForm.Modificacion)
            {
                PlanActual.Descripcion    = this.txtDescripcion.Text;
                PlanActual.IDEspecialidad = Convert.ToInt32(this.cbEspecialidades.SelectedValue.ToString());
                PlanLogic nuevoplan = new PlanLogic();
                PlanActual.State = BusinessEntity.States.Modified;
                nuevoplan.Save(PlanActual);
            }
            else if (Modo == ModoForm.Baja)
            {
                PlanLogic nuevoplan = new PlanLogic();
                PlanActual.State = BusinessEntity.States.Deleted;
                nuevoplan.Save(PlanActual);
            }
            else
            {
                btnAceptar.Text = "Aceptar";
            }
        }
Ejemplo n.º 5
0
        public void Listar()
        {
            PlanLogic pl = new PlanLogic();

            this.dgvPlanes.AutoGenerateColumns = false;
            this.dgvPlanes.DataSource          = pl.GetAll();
        }
Ejemplo n.º 6
0
        public List <DatosComisiones> ObtenerDatos()
        {
            List <DatosComisiones> datosComisiones = new List <DatosComisiones>();

            try
            {
                List <Comision> comisiones = ComLog.GetAll();

                foreach (Comision c in comisiones)
                {
                    DatosComisiones datosComision = new DatosComisiones();
                    datosComision.ID          = c.ID;
                    datosComision.Descripcion = c.Descripcion;
                    datosComision.Anio        = c.AnioEspecialidad;

                    PlanLogic pl   = new PlanLogic();
                    Plan      plan = pl.GetOne(c.IDPlan);
                    datosComision.DescPlan = plan.Descripcion;

                    EspecialidadLogic el           = new EspecialidadLogic();
                    Especialidad      especialidad = el.GetOne(plan.IDEspecialidad);
                    datosComision.DescEspecialidad = especialidad.Descripcion;

                    datosComisiones.Add(datosComision);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(datosComisiones);
        }
Ejemplo n.º 7
0
 public Materias(AcademyContext context)
 {
     InitializeComponent();
     _materiaLogic = new MateriaLogic(new MateriaAdapter(context));
     _planLogic    = new PlanLogic(new PlanAdapter(context));
     _context      = context;
 }
Ejemplo n.º 8
0
        public void LlenarDropMateria()
        {
            ddlPlanes.Items.Clear();
            PlanLogic pl = new PlanLogic();

            if (this.Entity != null)
            {
                List <Plan> planes = pl.TraerPorEspecialidad(pl.GetOne(Entity.IDPlan).IDEspecialidad);
                foreach (Plan plan in planes)
                {
                    ListItem item = new ListItem();
                    item.Text  = plan.Descripcion;
                    item.Value = Convert.ToString(plan.ID);

                    ddlPlanes.Items.Add(item);
                }
            }
            else
            {
                List <Plan> planes = pl.GetAll();
                foreach (Plan plan in planes)
                {
                    ListItem item = new ListItem();
                    item.Text  = plan.Descripcion;
                    item.Value = Convert.ToString(plan.ID);

                    ddlPlanes.Items.Add(item);
                }
            }
        }
Ejemplo n.º 9
0
        private void LoadGrid()
        {
            //this.gridViewMaterias.DataSource = this.Materia.GetAll();
            //this.gridViewMaterias.DataBind();
            PlanLogic pl = new PlanLogic();
            DataTable dt = new DataTable();

            if (dt.Columns.Count == 0)
            {
                dt.Columns.Add("ID", typeof(string));
                dt.Columns.Add("Descripcion", typeof(string));
                dt.Columns.Add("HSSemanales", typeof(string));
                dt.Columns.Add("HSTotales", typeof(string));
                dt.Columns.Add("IDPlan", typeof(string));
            }
            List <Materia> materias = this.Materia.GetAll();

            foreach (Materia materia in materias)
            {
                DataRow NewRow = dt.NewRow();
                NewRow[0] = Convert.ToString(materia.ID);
                NewRow[1] = materia.Descripcion;
                NewRow[2] = Convert.ToString(materia.HSSemanales);
                NewRow[3] = Convert.ToString(materia.HSTotales);
                NewRow[4] = pl.GetOne(materia.IDPlan).Descripcion;
                dt.Rows.Add(NewRow);
            }
            this.gridViewMaterias.DataSource = dt;
            this.gridViewMaterias.DataBind();
        }
Ejemplo n.º 10
0
        public virtual void GuardarCambios()
        {
            MapearADatos();
            PlanLogic usuario = new PlanLogic();

            usuario.Save(PlanActual);
        }
        public void Listar()
        {
            ComisionLogic cl = new ComisionLogic();
            PlanLogic     pl = new PlanLogic();

            try
            {
                List <Comision> comisiones         = cl.GetAll();
                List <Plan>     planes             = pl.GetAll();
                var             consultaComisiones =
                    from c in comisiones
                    join p in planes
                    on c.IDPlan equals p.ID
                    select new
                {
                    ID               = c.ID,
                    Descripcion      = c.Descripcion,
                    AnioEspecialidad = c.AnioEspecialidad,
                    Plan             = p.Descripcion
                };
                this.dgvComisiones.DataSource = consultaComisiones.ToList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 12
0
        public void SetCBMateria()
        {
            PlanLogic   pl     = new PlanLogic();
            List <Plan> planes = new List <Plan>();

            if (MateriaActual != null)
            {
                planes = pl.TraerPorEspecialidad(pl.GetOne(MateriaActual.IDPlan).IDEspecialidad);

                foreach (Plan espe in planes)
                {
                    ComboboxItem item = new ComboboxItem();
                    item.Text  = espe.Descripcion;
                    item.Value = espe.ID;

                    cbDescPlan.Items.Add(item);
                }
                string plstr = pl.GetOne(MateriaActual.IDPlan).Descripcion;
                cbDescPlan.SelectedIndex = cbDescPlan.FindStringExact(plstr);
            }
            else
            {
                cbDescPlan.DataSource    = pl.GetAll();
                cbDescPlan.DisplayMember = "Descripcion";
                cbDescPlan.ValueMember   = "ID";
                cbDescPlan.SelectedValue = -1;
            }
        }
Ejemplo n.º 13
0
        public new void MapearDeDatos()
        {
            //Carga combo
            PlanLogic planLogic = new PlanLogic();

            this.ComboBoxPlanes.DataSource    = planLogic.GetAll();
            this.ComboBoxPlanes.DisplayMember = "descripcion";
            this.ComboBoxPlanes.ValueMember   = "id";

            //Seteo campos form
            if (this.Modo != ModoForm.Alta)
            {
                this.TextBoxID.Text               = this.ComisionActual.ID.ToString();
                this.TextBoxDescripcion.Text      = this.ComisionActual.Descripcion;
                this.TextBoxAñoEsp.Text           = this.ComisionActual.AñoEspecialidad.ToString();
                this.ComboBoxPlanes.SelectedValue = this.ComisionActual.IdPlan;
            }

            //seteo de texto boton
            if (this.Modo == ModoForm.Baja)
            {
                this.BotonAceptar.Text = "Eliminar";
            }
            else if (this.Modo == ModoForm.Alta || this.Modo == ModoForm.Modificacion)
            {
                this.BotonAceptar.Text = "Guardar";
            }
            else
            {
                this.BotonAceptar.Text = "Aceptar";
            }
        }
Ejemplo n.º 14
0
        public void CargaPlanes(int ID)
        {
            List<Plan> listado = new List<Plan>();
            PlanLogic pl = new PlanLogic();
            foreach (Plan i in pl.GetAll())
            {
                if (i.IDEespecialidad == ID)
                {
                    listado.Add(i);
                }

            }
            if (listado.Count == 0)
            {
                this.cmbPlan.Enabled = false;
                this.cmbPlan.Text = "";
            }
            else
            {
                this.cmbPlan.Enabled = true;
            }
            cmbPlan.DataSource = listado;
            cmbPlan.ValueMember = "ID";
            cmbPlan.DisplayMember = "Descripcion";
            listado = null;
        }
Ejemplo n.º 15
0
 private void CargarPlan(int IdEspecialidad)
 {
     try
     {
         PlanLogic pl = new PlanLogic();
         if (pl.GetAll().Count > 1)
         {
             List <Plan> planes = pl.GetAll(IdEspecialidad);
             ddlPlan.Enabled        = true;
             ddlPlan.DataSource     = planes;
             ddlPlan.DataTextField  = "Descripcion";
             ddlPlan.DataValueField = "ID";
             ddlPlan.DataBind();
             ddlPlan.Items.Insert(0, "Seleccione Plan");
             ddlPlan.SelectedIndex      = 0;
             this.ddlMaterias.Enabled   = true;
             this.ddlComisiones.Enabled = true;
         }
         else
         {
             this.lblPlanVacio.Visible  = true;
             this.lblPlanVacio.Text     = "No existen Planes para asociar";
             this.ddlPlan.Visible       = false;
             this.ddlComisiones.Enabled = true;
             this.ddlComisiones.Enabled = true;
         }
     }
     catch (Exception ex)
     {
         Session["error"] = ex.Message;
         Page.Response.Redirect("../Error.aspx");
     }
 }
Ejemplo n.º 16
0
 public PlanController(ILogger <PlanController> logger, EspecialidadLogic especialidadLogic, PlanLogic planLogic)
 {
     _logger = logger;
     _logger.LogDebug("Inicializado controlador PlanController");
     _especialidadLogic = especialidadLogic;
     _planLogic         = planLogic;
 }
Ejemplo n.º 17
0
    public override void MapearDeDatos()
    {
        try
        {
            PlanLogic     pl   = new PlanLogic();
            MateriaLogic  ml   = new MateriaLogic();
            ComisionLogic cl   = new ComisionLogic();
            Plan          plan = new Plan();
            this.CursoActual  = this.Logic.GetOne(SelectedID);
            this.txtAno.Text  = this.CursoActual.AnioCalendario.ToString();
            this.txtCupo.Text = this.CursoActual.Cupo.ToString();

            foreach (Plan p in pl.GetAll())
            {
                if (p.ID == ml.GetOne(this.CursoActual.IdMateria).IdPlan&& p.ID == cl.GetOne(this.CursoActual.IdComision).IdPlan)
                {
                    plan = p;
                }
            }

            this.CargarEspecialidad();
            this.ddlEspecialidad.SelectedValue = plan.IDEespecialidad.ToString(); this.CargarPlan(plan.IDEespecialidad);
            this.ddlPlan.SelectedValue         = plan.ID.ToString(); this.CargaMateria(plan.ID); this.CargaComisiones(plan.ID);
            this.ddlMaterias.SelectedValue     = this.CursoActual.IdMateria.ToString();
            this.ddlComisiones.SelectedValue   = this.CursoActual.IdComision.ToString();
        }
        catch (Exception ex)
        {
            Session["error"] = ex.Message;
            Page.Response.Redirect("../Error.aspx");
        }
    }
Ejemplo n.º 18
0
        private void BtnEditar_ButtonClick(object sender, EventArgs e)
        {
            try
            {
                this.GetCurso();

                MateriaLogic ml  = new MateriaLogic();
                Materia      mat = ml.GetOne(CursoActual.IDMateria);

                PlanLogic pl   = new PlanLogic();
                Plan      plan = pl.GetOne(mat.IDPlan);

                EspecialidadLogic el           = new EspecialidadLogic();
                Especialidad      especialidad = el.GetOne(plan.IDEspecialidad);

                this.Context.Items["Carrera"] = especialidad.ID;
                this.Context.Items["Plan"]    = plan.ID;
                this.Context.Items["Modo"]    = ModoForm.Modificacion;
                Session["Curso"] = CursoActual;
                Server.Transfer("CursoWeb.aspx", true);
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + ex.Message + "')", true);
            }
        }
Ejemplo n.º 19
0
        public void Listar()
        {
            MateriaLogic ml = new MateriaLogic();
            PlanLogic    pl = new PlanLogic();

            try
            {
                List <Materia> materias = ml.GetAll();
                List <Plan>    planes   = pl.GetAll();

                var query =
                    from m in materias
                    join p in planes
                    on m.IDPlan equals p.ID
                    select new
                {
                    ID           = m.ID,
                    Descripcion  = m.Descripcion,
                    Hs_Semanales = m.HSSemanales,
                    Hs_Totales   = m.HSTotales,
                    Plan         = p.Descripcion
                };
                dgvMateria.DataSource = query.ToList();
            }
            catch (Exception Ex)
            {
                Exception ExcepcionManejada =
                    new Exception("Error al recuperar lista de Materias", Ex);
                MessageBox.Show("Error al recuperar lista de Materias", "Materia", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw ExcepcionManejada;
            }
        }
Ejemplo n.º 20
0
        private void PersonaDesktop_Load(object sender, EventArgs e)
        {
            PlanLogic   planLogic = new PlanLogic();
            List <Plan> planes    = planLogic.GetAll();

            foreach (var pl in planes)
            {
                cbxIdPlan.Items.Add(pl.ID.ToString());
            }

            for (int i = 0; i < 4; i++)
            {
                cbxTipoPersona.Items.Add(i.ToString());
            }

            switch (this.ModoFormulario)
            {
            case ModoForm.Alta:
                this.btnAceptar.Text = "Guardar";
                break;

            case ModoForm.Baja:
                this.btnAceptar.Text = "Eliminar";
                break;

            case ModoForm.Modificacion:
                this.btnAceptar.Text = "Guardar";
                break;

            case ModoForm.Consulta:
                this.btnAceptar.Text = "Aceptar";
                break;
            }
        }
Ejemplo n.º 21
0
        public override void GuardarCambios()
        {
            MapearADatos();
            PlanLogic PL = new PlanLogic();

            PL.Save(PlanActual);
        }
Ejemplo n.º 22
0
        public MateriaDesktop()
        {
            InitializeComponent();
            PlanLogic p = new PlanLogic();

            try
            {
                List <Plan> plan   = p.GetAll();
                DataTable   planes = new DataTable();
                planes.Columns.Add("id_plan", typeof(int));
                planes.Columns.Add("desc_plan", typeof(string));
                foreach (var e in plan)
                {
                    planes.Rows.Add(new object[] { e.ID, e.Descripcion });
                }
                this.boxPlan.DataSource    = planes;
                this.boxPlan.ValueMember   = "id_plan";
                this.boxPlan.DisplayMember = "desc_plan";
                this.boxPlan.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 23
0
 protected override void btnEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.dgvBase.SelectedRows.Count > 0)
         {
             if (MessageBox.Show("Esta seguro que desea eliminar esta especialidad?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 PlanLogic plaLog = new PlanLogic();
                 Plan      plan   = new Plan();
                 plan = (Plan)this.dgvBase.SelectedRows[0].DataBoundItem;
                 plaLog.Delete(plan);
                 MessageBox.Show("Se ha eliminado correctamente el plan", "Eliminación plan", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 this.Listar();
             }
         }
         else
         {
             MessageBox.Show("Debe seleccionar una fila", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 24
0
        public void Listar()
        {
            Personalogic   logica   = new Personalogic();
            List <Persona> personas = logica.GetAll();
            PlanLogic      plogic   = new PlanLogic();

            try
            {
                List <Plan> planes       = plogic.GetAll();
                var         listapersona = from persona in personas
                                           join plan in planes
                                           on persona.IDPlan equals plan.ID
                                           select new
                {
                    persona.ID,
                    Plan = plan.Descripcion,
                    persona.Nombre,
                    persona.Apellido,
                    persona.Direccion,
                    persona.Telefono,
                    persona.FechaNacimiento,
                    persona.Legajo,
                    persona.TipoPersona,
                    persona.IDPlan
                };
                dgvPersonas.DataSource = listapersona.ToList();
            }
            catch (Exception Ex)
            {
                Exception ExcepcionManejada =
                    new Exception("Error al recuperar lista de personas", Ex);
                MessageBox.Show("Error al recuperar lista de personas", "personas", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw ExcepcionManejada;
            }
        }
Ejemplo n.º 25
0
        private void Adaptar(ModoForm modo)
        {
            Modo = modo;
            PlanLogic pl = new PlanLogic();

            try
            {
                this.cmbPlan.DataSource         = pl.GetAll();
                this.cmbPlan.DisplayMember      = "Descripcion";
                this.cmbPlan.AutoCompleteMode   = AutoCompleteMode.Suggest;
                this.cmbPlan.AutoCompleteSource = AutoCompleteSource.ListItems;
            }
            catch (Exception ExcepcionManejada)
            {
                Notificar(ExcepcionManejada.Message, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            switch (Modo)
            {
            case ModoForm.Alta:
                btnAceptar.Text = "Guardar";
                break;

            case ModoForm.Baja:
                btnAceptar.Text = "Eliminar";
                break;

            case ModoForm.Consulta:
                btnAceptar.Text = "Aceptar";
                break;

            case ModoForm.Modificacion:
                btnAceptar.Text = "Guardar";
                break;
            }
        }
Ejemplo n.º 26
0
        public override void GuardarCambios()
        {
            this.MapearADatos();
            PlanLogic planLogic = new PlanLogic();

            planLogic.Save(_PlanActual);
        }
Ejemplo n.º 27
0
        public override void GuardarCambios()
        {
            MapearADatos();
            PlanLogic plan = new PlanLogic();

            plan.Save(this.PlanActual);
        }
Ejemplo n.º 28
0
 public ComisionController(ILogger <ComisionController> logger, ComisionLogic comisionLogic, PlanLogic planLogic)
 {
     _logger = logger;
     _logger.LogDebug("Inicializado controlador ComisionController");
     _comisionLogic = comisionLogic;
     _planLogic     = planLogic;
 }
Ejemplo n.º 29
0
        private void tsbEliminar_Click(object sender, EventArgs e)
        {
            if (dgvPlanes.SelectedRows != null && dgvPlanes.MultiSelect == false && dgvPlanes.SelectionMode == DataGridViewSelectionMode.FullRowSelect)
            {
                int       ID = ((Plan)dgvPlanes.SelectedRows[0].DataBoundItem).ID;
                PlanLogic pl = new PlanLogic(); //controlador :)
                PlanActual = pl.GetOne(ID);
                DialogResult dr = MessageBox.Show("¿Seguro que quiere eliminar el plan?", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (dr == DialogResult.Yes)
                {
                    try
                    {
                        PlanActual.State = BusinessEntity.States.Deleted;
                        pl.Save(PlanActual);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }

                Listar();
            }
        }
Ejemplo n.º 30
0
        public static DataTable Generar(List <Comision> comisiones)
        {
            DataTable Listado = new DataTable();

            Listado.Columns.Add("ID", typeof(int));
            Listado.Columns.Add("Descripcion", typeof(string));
            Listado.Columns.Add("AnioEspecialidad", typeof(int));
            Listado.Columns.Add("Plan", typeof(string));

            List <Plan>         planes         = PlanLogic.GetAll();
            List <Especialidad> especialidades = EspLogic.GetAll();

            foreach (Comision com in comisiones)
            {
                DataRow Linea = Listado.NewRow();

                Linea["ID"]               = com.ID;
                Linea["Descripcion"]      = com.Descripcion;
                Linea["AnioEspecialidad"] = com.AnioEspecialidad;

                Plan         plan = planes.FirstOrDefault(x => x.ID == com.IDPlan);
                Especialidad esp  = especialidades.FirstOrDefault(x => x.ID == plan.IDEspecialidad);
                Linea["Plan"] = esp.Descripcion + " - " + plan.Descripcion;

                Listado.Rows.Add(Linea);
            }

            return(Listado);
        }