Exemplo n.º 1
0
 public ActionResult Index()
 {
     using (var connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["SQLServer"].ConnectionString))
     {
         string query = @"SELECT [dbo].[Apuntes].[ApunteId], [dbo].[Apuntes].[Title], [dbo].[Apuntes].[Description], [dbo].[Apuntes].[Precio], [dbo].[Universidades].[UniversidadName], [dbo].[Facultades].[FacultadName], [dbo].[Materias].[MateriaName], [dbo].[Apuntes].[OwnerId], [dbo].[Apuntes].[Foto] FROM [dbo].[Apuntes] LEFT OUTER JOIN [dbo].[Universidades] ON [dbo].[Apuntes].[UniversidadId]=[dbo].[Universidades].[UniversidadId] LEFT OUTER JOIN [dbo].[Materias] ON [dbo].[Apuntes].[MateriaId] = [dbo].[Materias].[MateriaId] LEFT OUTER JOIN [dbo].[Facultades] ON [dbo].[Apuntes].[FacultadId]=[dbo].[Facultades].[FacultadId]";
         var    cmd   = new SqlCommand(query, connection);
         connection.Open();
         var           reader      = cmd.ExecuteReader();
         List <Apunte> listApuntes = new List <Apunte>();
         while (reader.Read())
         {
             var apunteDetails = new Apunte();
             apunteDetails.Id          = reader.GetInt32(reader.GetOrdinal("ApunteId"));
             apunteDetails.Title       = reader["Title"].ToString();
             apunteDetails.Description = reader["Description"].ToString();
             apunteDetails.Precio      = reader.GetInt32(reader.GetOrdinal("Precio"));
             apunteDetails.Universidad = reader["UniversidadName"].ToString();
             apunteDetails.Facultad    = "-";
             if (!reader.IsDBNull(reader.GetOrdinal("FacultadName")))
             {
                 apunteDetails.Facultad = reader["FacultadName"].ToString();
             }
             apunteDetails.Materia = "-";
             if (!reader.IsDBNull(reader.GetOrdinal("MateriaName")))
             {
                 apunteDetails.Materia = reader["MateriaName"].ToString();
             }
             apunteDetails.OwnerId  = reader.GetInt32(reader.GetOrdinal("OwnerId"));
             apunteDetails.FotoPath = reader["Foto"].ToString();
             listApuntes.Add(apunteDetails);
         }
         return(View(listApuntes));
     }
 }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("ApunteID,Descripcion,Importe,Fecha,Estatus,TipoApunteID,EmpresaID,SlotID,CategoriaID")] Apunte apunte)
        {
            if (id != apunte.ApunteID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(apunte);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ApunteExists(apunte.ApunteID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TipoApunteID"] = new SelectList(_context.TipoApunte, "TipoApunteID", "Descripcion");
            ViewData["EmpresaID"]    = new SelectList(_context.Empresa, "EmpresaID", "Descripcion");
            ViewData["SlotID"]       = new SelectList(_context.Slot, "SlotID", "Descripcion");
            ViewData["CategoriaID"]  = new SelectList(_context.Categoria, "CategoriaID", "Descripcion");

            return(View(apunte));
        }
Exemplo n.º 3
0
 public ApunteParaVistaMayor(Apunte apunte, decimal saldoEnCuenta)
     : base(apunte.Id, apunte.IdOwnerComunidad, apunte.Asiento, apunte.Factura, apunte.OrdenEnAsiento, apunte.DebeHaber, apunte.Importe,
            apunte.Concepto, apunte.Cuenta, apunte.Punteo)
 {
     this.Fecha         = apunte.Asiento.Fecha;
     this.SaldoEnCuenta = saldoEnCuenta;
     this.NAsiento      = apunte.Asiento.Codigo.CurrentCodigo;
 }
        private void rellenarCampos()
        {
            WebService     webService = new WebService();
            ApunteResponse response   = webService.getApunte(this.idApunte);

            if (response.estado == 1)
            {
                Apunte apunte = response.apuntes.ElementAt(0);
                txtNombreApuntes.Text      = apunte.nombre;
                cbTipoApuntes.Text         = apunte.tipo;
                txtNombreAsignatura.Text   = this.asignatura.nombre;
                txtEnlaceApuntes.Text      = apunte.enlace;
                txtDescripcionAputnes.Text = apunte.descripcion;
            }
        }
 private void apuntesDGClick(object sender, MouseButtonEventArgs e)
 {
     if (!ventanaAbierta())
     {
         if (dgApuntesMainClases.SelectedItem != null)
         {
             Apunte        apunte = dgApuntesMainClases.SelectedItem as Apunte;
             int           numAsignaturaSeleccionada = cbAsignaturasClases.SelectedIndex;
             Asignatura    asignaturaSeleccionada    = listaAsignaturas.ElementAt(numAsignaturaSeleccionada);
             ApuntesWindow apuntesFicha = new ApuntesWindow(asignaturaSeleccionada, apunte.id);
             apuntesFicha.Show();
             apuntesFicha.Owner = this;
         }
     }
 }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("ApunteID,Descripcion,Importe,Fecha,Estatus,TipoApunteID,EmpresaID,SlotID,CategoriaID")] Apunte apunte)
        {
            if (ModelState.IsValid)
            {
                _context.Add(apunte);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TipoApunteID"] = new SelectList(_context.TipoApunte, "TipoApunteID", "Descripcion");
            ViewData["EmpresaID"]    = new SelectList(_context.Empresa, "EmpresaID", "Descripcion");
            ViewData["SlotID"]       = new SelectList(_context.Slot, "SlotID", "Descripcion");
            ViewData["CategoriaID"]  = new SelectList(_context.Categoria, "CategoriaID", "Descripcion");

            return(View(apunte));
        }
Exemplo n.º 7
0
 // GET: Apunte
 public ActionResult Index(int Id)
 {
     using (var connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["SQLServer"].ConnectionString))
     {
         string query = @"SELECT [dbo].[Apuntes].[ApunteId], [dbo].[Apuntes].[Title], [dbo].[Apuntes].[Description], [dbo].[Apuntes].[Precio], [dbo].[Universidades].[UniversidadName], [dbo].[Facultades].[FacultadName], [dbo].[Materias].[MateriaName], [dbo].[Apuntes].[OwnerId], [dbo].[Apuntes].[Foto] FROM [dbo].[Apuntes] LEFT OUTER JOIN [dbo].[Universidades] ON [dbo].[Apuntes].[UniversidadId]=[dbo].[Universidades].[UniversidadId] LEFT OUTER JOIN [dbo].[Materias] ON [dbo].[Apuntes].[MateriaId] = [dbo].[Materias].[MateriaId] LEFT OUTER JOIN [dbo].[Facultades] ON [dbo].[Apuntes].[FacultadId]=[dbo].[Facultades].[FacultadId] WHERE [dbo].[Apuntes].[ApunteId] = @id";
         var    cmd   = new SqlCommand(query, connection);
         cmd.Parameters
         .Add(new SqlParameter("@id", SqlDbType.NVarChar))
         .Value = Id;
         connection.Open();
         var reader = cmd.ExecuteReader();
         if (reader.HasRows)
         {
             while (reader.Read())
             {
                 var apunteDetails = new Apunte();
                 apunteDetails.Id          = reader.GetInt32(reader.GetOrdinal("ApunteId"));
                 apunteDetails.Title       = reader["Title"].ToString();
                 apunteDetails.Description = reader["Description"].ToString();
                 apunteDetails.Precio      = reader.GetInt32(reader.GetOrdinal("Precio"));
                 apunteDetails.Universidad = reader["UniversidadName"].ToString();
                 apunteDetails.Facultad    = "-";
                 if (!reader.IsDBNull(reader.GetOrdinal("FacultadName")))
                 {
                     apunteDetails.Facultad = reader["FacultadName"].ToString();
                 }
                 apunteDetails.Materia = "-";
                 if (!reader.IsDBNull(reader.GetOrdinal("MateriaName")))
                 {
                     apunteDetails.Materia = reader["MateriaName"].ToString();
                 }
                 apunteDetails.OwnerId  = reader.GetInt32(reader.GetOrdinal("OwnerId"));
                 apunteDetails.FotoPath = reader["Foto"].ToString();
                 return(View(apunteDetails));
             }
         }
         return(RedirectToAction("Index", "Error", new { Id = 404 }));
     }
 }