Ejemplo n.º 1
0
 private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
 {
     investigacion = (Investigacion)this.DataContext;
     //Cargar datos
     cmbAutor.ItemsSource       = autores.regresarTodos();
     cmbAutor.DisplayMemberPath = "nombre";
     cmbAutor.SelectedValuePath = "id";
     //Si es para modificar
     if (modificar == true)
     {
         lblOperacion.Content = "Modificar Investigación";
         //ArrayList listado = investigacion.regresarPiezas();
         List <string> lista = new List <string>();
         foreach (LinkInvestigacion link in investigacion.regresarLinkInvestigacion())
         {
             lista.Add(link.link);
         }
         LinksReferencia.LoadOptions(lista);
         gvPiezasGuardadas.ItemsSource = investigacion.regresarPiezas();
         cmbAutor.SelectedValue        = investigacion.autor;
     }
     else
     {
         lblOperacion.Content          = "Nueva Investigación";
         gvPiezasGuardadas.ItemsSource = new ArrayList();
     }
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Libreria      libreria  = new Libreria();
            Libreria      libreria2 = new Libreria();
            Cuento        c1        = new Cuento("Argonauta", "Pinocho", 525, "Incluye ilustraciones");
            Novela        n1        = new Novela("Bajo la luna", "Poema del Mio Cid", 210, true);
            Investigacion i1        = new Investigacion("Apagogue", "Autonomia Cientifica", 460, 4);    //Instancio libros
            Novela        n2        = new Novela("Bajo la luna", "Poema del Mio Cid", 410, false);
            Investigacion i2        = new Investigacion("Baltasara", "Fundamentos de la Economia", 1000, 4);

            libreria += c1;
            libreria += n1;
            libreria += i1;          //agrego los libros a la libreria
            libreria += n2;

            if (libreria.Xml(libreria, "TesteoLibreriaXml.xml"))
            {
                Console.WriteLine("La libreria se serializo correctamente");        //testeo que se este guardando correctamente
                                                                                    //la libreria en un archivo xml
            }

            if (libreria.GuardarTexto("TesteoLibreriaTxt.txt"))
            {
                Console.WriteLine("La libreria se guardo en txt correctamente");    //testeo que se este guardando correctamente
                                                                                    //la libreria en un archivo de texto
            }


            Console.WriteLine(libreria.ToString());            //muestro la libreria


            Console.ReadLine();
        }
Ejemplo n.º 3
0
        public void updateInvestigacion(Investigacion inv)
        {
            try
            {
                var invTmp = ctx.Investigacion
                             .Where(w => w.id == inv.id)
                             .SingleOrDefault();

                if (invTmp != null)
                {
                    var costos = new List <Entities.Costo>();
                    foreach (var c in invTmp.getCosto())
                    {
                        costos.Add(c);
                    }
                    invTmp.nombre           = inv.nombre;
                    invTmp.descripcion      = inv.descripcion;
                    invTmp.foto             = inv.foto;
                    invTmp.costos           = costos;
                    invTmp.tiempoInicial    = inv.tiempoInicial;
                    invTmp.incrementoTiempo = inv.incrementoTiempo;
                    ctx.SaveChangesAsync().Wait();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        public async Task <ActionResult <Investigacion> > PostInvestigacion(Investigacion item)
        {
            _context.Investigacion.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetInvestigacion), new { id = item.id }, item));
        }
Ejemplo n.º 5
0
        public Investigacion Get(int id)
        {
            Investigacion investigacion = blHandler.getInvestigacion(id);

            if (investigacion == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(investigacion);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> PutInvestigacion(int id, Investigacion item)
        {
            if (id != item.id)
            {
                return(BadRequest());
            }
            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 7
0
        public HttpResponseMessage Post(Investigacion investigacion)
        {
            if (ModelState.IsValid)
            {
                int id = blHandler.createInvestigacion(investigacion);

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, id);
                return(response);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
Ejemplo n.º 8
0
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            investigacion       = (Investigacion)this.DataContext;
            investigacion.autor = (int)cmbAutor.SelectedValue;
            List <string> listado = LinksReferencia.GetOptions();
            ArrayList     piezas  = (ArrayList)gvPiezasGuardadas.ItemsSource;

            if (modificar == false)
            {
                investigacion.editor = Settings.user.username;
                investigacion.ingresarPiezas(piezas.ToList <Pieza>());
                foreach (string link in LinksReferencia.GetOptions())
                {
                    if (!link.Equals("Opcion"))
                    {
                        investigacion.ingresarLinks(link);
                    }
                }
                investigacion.fecha = DateTime.Now;
                investigacion.guardar();
            }
            else
            {
                investigacion.ingresarPiezas(piezas.ToList <Pieza>());
                List <LinkInvestigacion> lista = new List <LinkInvestigacion>();
                foreach (string link in LinksReferencia.GetOptions())
                {
                    if (!link.Equals("Opcion"))
                    {
                        lista.Add(new LinkInvestigacion(link));
                    }
                }
                investigacion.ingresarLinks(lista);
                investigacion.modificar();
            }

            if (Connection.Objects.Error.isActivo())
            {
                MessageBox.Show(Connection.Objects.Error.nombreError, Connection.Objects.Error.descripcionError);
            }
            else
            {
                MessageBox.Show("Correcto");
                borde.Child = anterior;
            }
        }
Ejemplo n.º 9
0
        public int createInvestigacion(Investigacion i)
        {
            var inv = new Entities.Investigacion(i.nombre, i.descripcion, i.foto, i.tiempoInicial, i.incrementoTiempo);

            try
            {
                ctx.Investigacion.Add(inv);
                ctx.SaveChanges();

                Entities.Investigacion invs = ctx.Investigacion.ToList().LastOrDefault();

                return(invs.id);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 10
0
 private void btnEliminarInvestigacion_Click(object sender, RoutedEventArgs e)
 {
     if (gvResultados.SelectedItem != null)
     {
         Investigacion invT = new Investigacion();
         invT = (Investigacion)gvResultados.SelectedItem;
         invT.eliminar();
         if (Connection.Objects.Error.isActivo())
         {
             MessageBox.Show(Connection.Objects.Error.descripcionError, Connection.Objects.Error.nombreError);
         }
         else
         {
             MessageBox.Show("Se ha eliminado correctamente", "Correcto");
             cargarInvestigaciones();
         }
     }
     else
     {
         MessageBox.Show("Debe seleccionar una clasificación antes de eliminar", "Advertencia");
     }
 }
Ejemplo n.º 11
0
        public HttpResponseMessage Put(int id, Investigacion investigacion)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (id != investigacion.id)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            try
            {
                blHandler.updateInvestigacion(investigacion);
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Ejemplo n.º 12
0
 public void updateInvestigacion(Investigacion investigacion)
 {
     builder.getInvestigacionHandler().updateInvestigacion(investigacion);
 }
Ejemplo n.º 13
0
 public int createInvestigacion(Investigacion investigacion)
 {
     return(builder.getInvestigacionHandler().createInvestigacion(investigacion));
 }