private void preencherGrid(int idCategoria, string nomeAplicativo)
        {
            AplicativoDTO dto = new AplicativoDTO();

            if (!String.IsNullOrEmpty(cmbCategorias.SelectedValue))
            {
                dto.idCategoria = int.Parse(cmbCategorias.SelectedValue.ToString());
            }

            if (!String.IsNullOrEmpty(nomeAplicativo))
            {
                dto.nomeAplicativo = nomeAplicativo;
            }

            AplicativoBRL brl = new AplicativoBRL();
            DataTable     dt  = brl.searchAplicativo(dto);

            //grid só o ícone
            this.gridAppsList.DataSource = dt;
            this.gridAppsList.DataBind();

            //grid com detalhes
            //this.gridAplicativos.DataSource = dt;
            //this.gridAplicativos.DataBind();

            lblQuantidadeApps.Text = dt.Rows.Count.ToString() + " publicados.";
        }
示例#2
0
        private void preencherDataListQuantidade()
        {
            AplicativoBRL _aplicativoBRL = new AplicativoBRL();

            this.dtListViewQuantidadeApps.DataSource = _aplicativoBRL.searchAplicativoByCategoria();
            this.dtListViewQuantidadeApps.DataBind();
        }
示例#3
0
        private void preencherGridView(AplicativoDTO dto)
        {
            //HttpCookie Session = Request.Cookies["BEPiDUCB.Site"];

            //if (Session["S"] != null)
            //{
            //AplicativoDTO dto = new AplicativoDTO();

            //verifica se é professor, se for pega todos os apps.
            //if (Session["S"].Equals("A")) //diferente de P
            //dto.idAluno = int.Parse(Session["I"].ToString());

            AplicativoBRL brl = new AplicativoBRL();
            DataTable     dt  = brl.searchAplicativo(dto);

            this.gridAplicativos.DataSource = dt;
            this.gridAplicativos.DataBind();

            lblContador.Text = "Total de aplicativos: " + dt.Rows.Count.ToString();
            //}
            //else
            //{
            //Response.Redirect("Login");
            //}
        }
示例#4
0
        private void preencherGrid(int idCategoria)
        {
            AplicativoDTO dto = new AplicativoDTO();

            if (idCategoria != 0)
            {
                dto.idCategoria = idCategoria;
            }

            AplicativoBRL brl = new AplicativoBRL();
            DataTable     dt  = brl.searchAplicativo(dto);

            this.dtAplicativos.DataSource = dt;
            this.dtAplicativos.DataBind();
        }
示例#5
0
        private void preencherGrid(int idCategoria)
        {
            AplicativoDTO dto = new AplicativoDTO();

            if (idCategoria != 0)
            {
                dto.idCategoria = idCategoria;
            }

            AplicativoBRL brl = new AplicativoBRL();
            DataTable     dt  = brl.searchAplicativo(dto);

            this.gridAplicativos.DataSource = dt;
            this.gridAplicativos.DataBind();

            lblQuantidadeApps.Text = dt.Rows.Count.ToString() + " publicados.";
        }
        protected void gridAplicativos_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Deletar")
            {
                int    _index = int.Parse((string)e.CommandArgument);
                string chave  = gridAplicativos.DataKeys[_index]["IdAplicativo"].ToString();

                AplicativoDTO dto = new AplicativoDTO();
                dto.idAplicativo = int.Parse(chave);

                AplicativoBRL brl = new AplicativoBRL();
                if (brl.deleteAplicativo(dto))
                {
                    Response.Redirect("AddAplicativo.aspx?id=deletado");
                }
            }
        }
        private void preencherGridView()
        {
            //HttpCookie Session = Request.Cookies["BEPiDUCB.Site"];
            AplicativoDTO dto = new AplicativoDTO();

            if (Session["SAluno"] != null)
            {
                //verifica se é professor, se for pega todos os apps.
                if (Session["SAluno"].Equals("A")) //diferente de P
                {
                    dto.idAluno = int.Parse(Session["IAluno"].ToString());
                }

                AplicativoBRL brl = new AplicativoBRL();
                this.gridAplicativos.DataSource = brl.searchAplicativo(dto);
                this.gridAplicativos.DataBind();
            }
            else
            {
                Response.Redirect("../Login");
            }
        }
        protected void cmdCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    //atualizar o banco de dados.
                    //HttpCookie Session = Request.Cookies["BEPiDUCB.Site"];

                    AplicativoDTO _aplicativoDTO = new AplicativoDTO();
                    _aplicativoDTO.idCategoria         = int.Parse(cmbCategoria.SelectedValue.ToString());
                    _aplicativoDTO.linkAplicativo      = txtLink.Text;
                    _aplicativoDTO.nomeAplicativo      = txtNome.Text;
                    _aplicativoDTO.situacao            = "P";
                    _aplicativoDTO.nomeGrupoAplicativo = txtGrupo.Text;
                    _aplicativoDTO.idAluno             = int.Parse(Session["I"].ToString());

                    //imagem
                    int tamanho = flImagem.PostedFile.ContentLength;

                    if (tamanho == 0)
                    {
                        lblResultado.Text = "Por favor envie a logomarca do aplicativo";
                        return;
                    }

                    if (tamanho <= 4000000)
                    {
                        string filename = System.IO.Path.GetFileName(flImagem.PostedFile.FileName);
                        filename = Guid.NewGuid() + filename;


                        TransferUtility fileTransferUtility = new
                                                              TransferUtility(System.Configuration.ConfigurationManager.AppSettings["AccessKey"].ToString(),
                                                                              System.Configuration.ConfigurationManager.AppSettings["SecretKey"].ToString());

                        var uploadRequest = new Amazon.S3.Transfer.TransferUtilityUploadRequest();
                        uploadRequest.InputStream  = flImagem.PostedFile.InputStream;
                        uploadRequest.BucketName   = "BEPiD";
                        uploadRequest.Key          = filename;
                        uploadRequest.StorageClass = S3StorageClass.ReducedRedundancy;
                        uploadRequest.CannedACL    = S3CannedACL.PublicRead;


                        fileTransferUtility.Upload(uploadRequest);

                        //lblImagem.Text = "<img src='http://s3.amazonaws.com/BEPiD/" + filename.ToString() + "' style='border-radius:30px;'/>";

                        string          urlImagem      = "http://s3.amazonaws.com/BEPiD/" + filename.ToString();
                        HttpWebRequest  httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(urlImagem);
                        HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
                        Stream          stream         = httpWebReponse.GetResponseStream();

                        System.Drawing.Image objImage = System.Drawing.Image.FromStream(stream);
                        int w = objImage.Width;
                        int h = objImage.Height;

                        if (w <= 120 && h <= 120)
                        {
                            _aplicativoDTO.imagemAplicativo = filename.ToString();
                        }
                    }
                    else
                    {
                        lblResultado.Text = "A imagem deve respeitar o tamanho informado. Dimensões: 120 x 120.";
                    }

                    AplicativoBRL _aplicativoBRL = new AplicativoBRL();
                    if (_aplicativoBRL.insertAplicativo(_aplicativoDTO))
                    {
                        Response.Redirect("AddAplicativo?id=sucesso");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void cmdCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    //atualizar o banco de dados.
                    //HttpCookie Session = Request.Cookies["BEPiDUCB.Site"];

                    AplicativoDTO _aplicativoDTO = new AplicativoDTO();
                    _aplicativoDTO.idCategoria         = int.Parse(cmbCategoria.SelectedValue.ToString());
                    _aplicativoDTO.linkAplicativo      = txtLink.Text;
                    _aplicativoDTO.nomeAplicativo      = txtNome.Text;
                    _aplicativoDTO.situacao            = "P";
                    _aplicativoDTO.nomeGrupoAplicativo = txtGrupo.Text;
                    _aplicativoDTO.idAluno             = int.Parse(Session["IAluno"].ToString());
                    _aplicativoDTO.ano                      = txtAno.Text;
                    _aplicativoDTO.challenge                = cmbChallenge.SelectedValue.ToString();
                    _aplicativoDTO.descricaoAplicativo      = txtDescricao.Text;
                    _aplicativoDTO.dataPublicacaoAplicativo = Convert.ToDateTime(txtDataPublicacao.Text);

                    //imagem
                    int tamanho = flImagem.PostedFile.ContentLength;

                    if (tamanho == 0)
                    {
                        lblResultado.Text = "Por favor envie a logomarca do aplicativo";
                        return;
                    }

                    if (tamanho <= 4000000)
                    {
                        //icone
                        string filename = System.IO.Path.GetFileName(flImagem.PostedFile.FileName);
                        filename = Guid.NewGuid() + filename;
                        string icone = uploadImagem(filename, flImagem.PostedFile.InputStream);

                        HttpWebRequest  httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(icone);
                        HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
                        Stream          stream         = httpWebReponse.GetResponseStream();

                        System.Drawing.Image objImage = System.Drawing.Image.FromStream(stream);
                        int w = objImage.Width;
                        int h = objImage.Height;

                        if (w <= 120 && h <= 120)
                        {
                            //imagem1
                            string filename1 = System.IO.Path.GetFileName(flImagem1.PostedFile.FileName);
                            filename1 = Guid.NewGuid() + filename1;
                            string imagem1 = uploadImagem(filename1, flImagem1.PostedFile.InputStream);

                            httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(imagem1);
                            httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
                            stream         = httpWebReponse.GetResponseStream();

                            objImage = System.Drawing.Image.FromStream(stream);
                            w        = objImage.Width;
                            h        = objImage.Height;



                            //imagem2
                            string filename2 = System.IO.Path.GetFileName(flImagem2.PostedFile.FileName);
                            filename2 = Guid.NewGuid() + filename2;
                            string imagem2 = uploadImagem(filename2, flImagem2.PostedFile.InputStream);

                            httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(imagem2);
                            httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
                            stream         = httpWebReponse.GetResponseStream();

                            objImage = System.Drawing.Image.FromStream(stream);
                            w        = objImage.Width;
                            h        = objImage.Height;

                            if ((w == 392 && h == 696) || (w == 512 && h == 384))
                            {
                                //imagem3
                                string filename3 = System.IO.Path.GetFileName(flImagem3.PostedFile.FileName);
                                filename3 = Guid.NewGuid() + filename3;
                                string imagem3 = uploadImagem(filename3, flImagem3.PostedFile.InputStream);


                                _aplicativoDTO.imagemAplicativo  = filename.ToString();
                                _aplicativoDTO.imagemAplicativo1 = filename1.ToString();
                                _aplicativoDTO.imagemAplicativo2 = filename2.ToString();
                                _aplicativoDTO.imagemAplicativo3 = filename3.ToString();

                                //insere no banco de dados
                                AplicativoBRL _aplicativoBRL = new AplicativoBRL();
                                if (_aplicativoBRL.insertAplicativo(_aplicativoDTO))
                                {
                                    Response.Redirect("AddAplicativo?id=sucesso");
                                }//teste
                            }
                            else
                            {
                                lblResultado.Text = "A imagem deve respeitar o tamanho informado. Dimensões: 392 x 696.";
                                return;
                            }
                        }
                        else
                        {
                            lblResultado.Text = "A imagem deve respeitar o tamanho informado. Dimensões: 120 x 120.";
                            return;
                        }
                    }
                    else
                    {
                        lblResultado.Text = "A imagem deve respeitar o tamanho informado. Dimensões: 120 x 120.";
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }