Esempio n. 1
0
        public ClassResultV Usp_Categoria_GetAll(TipoCons tip)
        {
            ClassResultV cr = new ClassResultV();
            var          pr = new SqlParameter[1];

            try
            {
                pr[0]       = new SqlParameter("@TipoCons", SqlDbType.Int);
                pr[0].Value = (Int32)tip;

                SqlDataReader reader = SqlHelper.ExecuteReader(objCn, CommandType.StoredProcedure, "Usp_Categoria_GetAll", pr);
                cr.List = new List <DtoB>();
                while (reader.Read())
                {
                    DtoCategoria dtoC = new DtoCategoria();
                    dtoC.codCategoria = getValue("codCategoria", reader).Value_String;
                    dtoC.nombre       = getValue("nombre", reader).Value_String;
                    dtoC.IB_Mostrar   = getValue("IB_Mostrar", reader).Value_Bool;
                    cr.List.Add(dtoC);
                }
            }
            catch (Exception ex)
            {
                cr.DT         = null;
                cr.LugarError = ex.StackTrace;
                cr.ErrorEx    = ex.Message;
                cr.ErrorMsj   = "Error al consultar Categorias";
            }
            objCn.Close();
            return(cr);
        }
Esempio n. 2
0
        public bool RegistrarCategoria(DtoCategoria dto)
        {
            bool msg;

            using (AliyavaEntities context = new AliyavaEntities())
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    try
                    {
                        Categoria Cat = new Categoria();
                        Cat.Nombre = dto.Nombre;

                        context.Categoria.Add(Cat);
                        context.SaveChanges();

                        scope.Complete();
                    }
                    catch (Exception ex)
                    {
                        scope.Dispose();
                        return(msg = false);
                    }

                    return(msg = true);
                }
            }
        }
Esempio n. 3
0
        public ClassResultV Usp_Categoria_Update(DtoCategoria dtoBase)
        {
            var cr  = new ClassResultV();
            var dto = (DtoCategoria)dtoBase;
            var pr  = new SqlParameter[4];

            try
            {
                pr[0]           = new SqlParameter("@nombre", SqlDbType.VarChar, 100);
                pr[0].Value     = dto.nombre;
                pr[1]           = new SqlParameter("@IB_Mostrar", SqlDbType.Bit);
                pr[1].Value     = dto.IB_Mostrar;
                pr[2]           = new SqlParameter("@codCategoria", SqlDbType.VarChar, 4);
                pr[2].Value     = dto.codCategoria;
                pr[3]           = new SqlParameter("@msj", SqlDbType.VarChar, 100);
                pr[3].Direction = ParameterDirection.Output;

                SqlHelper.ExecuteNonQuery(objCn, CommandType.StoredProcedure, "Usp_Categoria_Update", pr);
                if (Convert.ToString(pr[3].Value) != "")
                {
                    cr.LugarError = ToString("Usp_Categoria_Update");
                    cr.ErrorMsj   = Convert.ToString(pr[3].Value);
                }
            }
            catch (Exception ex)
            {
                cr.LugarError = ex.StackTrace;
                cr.ErrorEx    = ex.Message;
                cr.ErrorMsj   = "Error al actualizar la categoria.";
                objCn.Close();
            }
            return(dto);
        }
Esempio n. 4
0
        public void ObtenerParticipante(DtoUsuario objUsuario, DtoCategoria objcat)
        {
            SqlCommand command = new SqlCommand("SP_ObtenerParticipante_I", conexion);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@dni", objUsuario.PK_IU_DNI);
            DataSet ds = new DataSet();

            conexion.Open();
            SqlDataAdapter moldura = new SqlDataAdapter(command);

            moldura.Fill(ds);
            moldura.Dispose();

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                objUsuario.nombres      = reader[0].ToString();
                objcat.PK_ICA_CodCat    = Convert.ToInt32(reader[1].ToString());
                objcat.VCA_NomCategoria = reader[2].ToString();
                objUsuario.VU_Sexo      = reader[3].ToString();
            }
            conexion.Close();
            conexion.Dispose();
        }
Esempio n. 5
0
        public async Task <IActionResult> Create(DtoCategoria categoria)
        {
            byte[] imagen          = null;
            string extensionImagen = null;

            if (categoria.Imagen?.Length > 0)
            {
                using (var memstream = new MemoryStream())
                {
                    categoria.Imagen.OpenReadStream().CopyTo(memstream);
                    imagen          = memstream.ToArray();
                    extensionImagen = categoria.Imagen.ContentType;
                }
            }

            if (ModelState.IsValid)
            {
                var newDbItem = new Categoria
                {
                    CodCategoria    = categoria.CodCategoria,
                    Descripcion     = categoria.Descripcion,
                    ExtensionImagen = extensionImagen,
                    Imagen          = imagen,
                    Fecha           = categoria.Fecha
                };

                _context.Add(newDbItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoria));
        }
Esempio n. 6
0
        //Vista formulario a modificar.
        public ActionResult ModificarCategoria(int id)
        {
            DtoCategoria cateFB = new DtoCategoria();

            cateFB = HCategoria.getInstace().GetCategoriaM(id);

            return(View(cateFB));
        }
Esempio n. 7
0
        public static Categoria MapToEntity(DtoCategoria dto)
        {
            Categoria entity = new Categoria();

            entity.idCategoria = dto.idCategoria;
            entity.Nombre      = dto.Nombre;

            return(entity);
        }
Esempio n. 8
0
        public static DtoCategoria MapToDto(Categoria entity)
        {
            DtoCategoria dto = new DtoCategoria();

            dto.idCategoria = entity.idCategoria;
            dto.Nombre      = entity.Nombre;

            return(dto);
        }
Esempio n. 9
0
        public void ModificarCategoria(DtoCategoria DtoCat)
        {
            using (AliyavaEntities context = new AliyavaEntities())
            {
                Categoria updatecat = context.Categoria.FirstOrDefault(f => f.idCategoria == DtoCat.idCategoria);
                updatecat.Nombre = DtoCat.Nombre;

                context.SaveChanges();
            }
        }
Esempio n. 10
0
        public DtoCategoria GetCategoriaM(int id)
        {
            DtoCategoria dto = new DtoCategoria();

            using (AliyavaEntities context = new AliyavaEntities())
            {
                Categoria cat = context.Categoria.FirstOrDefault(f => f.idCategoria == id);

                dto = MCategoria.MapToDto(cat);
            }
            return(dto);
        }
Esempio n. 11
0
        public ActionResult AddCategoria(DtoCategoria nuevacategoria)
        {
            bool msg = HCategoria.getInstace().AddCategoria(nuevacategoria);

            if (msg == true)
            {
                TempData["Cat"] = "Categoría añadida satisfactoriamente!";
            }
            else
            {
                TempData["Cat"] = "Revisa el nombre que quieres ingresar!";
            }

            return(RedirectToAction("RegistrarCategoria"));
        }
Esempio n. 12
0
        protected void btnBuscar2_Click(object sender, EventArgs e)
        {
            try
            {
                objDtoUsuario.PK_IU_DNI = txtdni2.Text;
                if (objCtrParticipante.existeUsuario(objDtoUsuario))
                {
                    if (objCtrParticipante.existeUsuarioAca(objDtoUsuario))
                    {
                        string gen = txtGen.Text;
                        if (objCtrParticipante.existeUsuarioGen(objDtoUsuario, gen))
                        {
                            _log.CustomWriteOnLog("inscribir Participante", "entra boton pareja");
                            DtoCategoria objcat = new DtoCategoria();
                            objCtrParticipante.obtenerParticipante(objDtoUsuario, objcat);
                            _log.CustomWriteOnLog("inscribir Participante", "*********************************");
                            _log.CustomWriteOnLog("inscribir Participante", "nombre" + objDtoUsuario.nombres.ToString());
                            _log.CustomWriteOnLog("inscribir Participante", "categoria" + objcat.VCA_NomCategoria.ToString());
                            _log.CustomWriteOnLog("inscribir Participante", "genero" + objDtoUsuario.VU_Sexo.ToString());
                            txtNombre2.Text    = objDtoUsuario.nombres.ToString();
                            txtCategoria2.Text = objcat.VCA_NomCategoria;
                            txtCodCatN.Text    = objcat.PK_ICA_CodCat.ToString();
                            updPanel2.Update();
                        }
                        else
                        {
                            string m = "Usuario no petenece a genero diferente";
                            Utils.AddScriptClientUpdatePanel(upnBotonBuscar2, "showMessage('top','center','" + m + "','danger')");
                        }
                    }
                    else
                    {
                        string m = "Usuario no permitido";
                        Utils.AddScriptClientUpdatePanel(upnBotonBuscar2, "showMessage('top','center','" + m + "','danger')");
                    }
                }
                else
                {
                    string m = "No existe DNI";
                    Utils.AddScriptClientUpdatePanel(upnBotonBuscar2, "showMessage('top','center','" + m + "','danger')");
                }
            }

            catch (Exception ex)
            {
                _log.CustomWriteOnLog("inscribir Participante", "Error : " + ex.Message + "Stac" + ex.StackTrace);
            }
        }
Esempio n. 13
0
        public List <DtoCategoria> GetCategoria()
        {
            List <DtoCategoria> coldtoCat = new List <DtoCategoria>();

            using (AliyavaEntities context = new AliyavaEntities())
            {
                List <Categoria> colCategoria = context.Categoria.Select(s => s).ToList();

                foreach (Categoria cat in colCategoria)
                {
                    DtoCategoria dto = MCategoria.MapToDto(cat);
                    coldtoCat.Add(dto);
                }
            }
            return(coldtoCat);
        }
Esempio n. 14
0
        public List <DtoCategoria> getCat(string familia)
        {
            List <DtoCategoria> colCatego = new List <DtoCategoria>();

            using (AliyavaEntities context = new AliyavaEntities())
            {
                List <Categoria> colCat = context.Categoria.Where(w => w.Nombre == familia).ToList();

                foreach (Categoria item in colCat)
                {
                    DtoCategoria dto = MCategoria.MapToDto(item);
                    colCatego.Add(dto);
                }
            }

            return(colCatego);
        }
Esempio n. 15
0
        public async Task <IActionResult> Edit(DtoCategoria categoria)
        {
            var categoriaDB = await _context.Categorias.FirstOrDefaultAsync(m => categoria.CodCategoria == m.CodCategoria);

            categoriaDB.CodCategoria = categoria.CodCategoria;
            categoriaDB.Descripcion  = categoria.Descripcion;
            categoriaDB.Fecha        = categoria.Fecha;

            if (categoria.Imagen?.Length > 0)
            {
                using (var memstream = new MemoryStream())
                {
                    categoria.Imagen.OpenReadStream().CopyTo(memstream);
                    categoriaDB.Imagen          = memstream.ToArray();
                    categoriaDB.ExtensionImagen = categoria.Imagen.ContentType;
                }
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categoriaDB);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoriaExists(categoriaDB.CodCategoria))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoria));
        }
Esempio n. 16
0
 public void obtenerParticipante(DtoUsuario dtoUsuario, DtoCategoria objcat)
 {
     objdaoParticipante.ObtenerParticipante(dtoUsuario, objcat);
 }
Esempio n. 17
0
 public ActionResult ConfirmarCambios(DtoCategoria dtoCat)
 {
     HCategoria.getInstace().ModificarCategoria(dtoCat);
     return(RedirectToAction("ListarCategoria"));
 }
Esempio n. 18
0
        public void ModificarCategoria(DtoCategoria dto)
        {
            PCategoria pc = new PCategoria();

            pc.ModificarCategoria(dto);
        }
Esempio n. 19
0
 public ClassResultV Usp_Categoria_Update(DtoCategoria dtoBase)
 {
     return(new DaoCategoria().Usp_Categoria_Update(dtoBase));
 }
Esempio n. 20
0
 public ClassResultV Usp_Categoria_Insert(DtoCategoria dtoBase)
 {
     return(new DaoCategoria().Usp_Categoria_Insert(dtoBase));
 }
Esempio n. 21
0
 //nombres concatenados
 public void obtenerNombreAlumno(DtoUsuario dtoUsuario, DtoCategoria objcat)
 {
     objDaoPago.ObtenerDatosAlumno(dtoUsuario, objcat);
 }
Esempio n. 22
0
        public bool AddCategoria(DtoCategoria dto)
        {
            PCategoria pc = new PCategoria();

            return(pc.RegistrarCategoria(dto));
        }