Пример #1
0
 public CadastroDeYoutubers(int codigo)
 {
     InitializeComponent();
     this.codigo = codigo;
     for (int i = 0; i < Program.youtuber.Count(); i++)
     {
         Youtubers youtuber = Program.youtuber[i];
         if (youtuber.GetCodigo() == codigo)
         {
             txtNome.Text                = youtuber.GetNome();
             txtSobrenome.Text           = youtuber.GetSobrenome();
             txtApelido.Text             = youtuber.GetApelido();
             txtNomeCanal.Text           = youtuber.GetNomeCanal();
             txtQuantidadeInscritos.Text = Convert.ToString(youtuber.GetQuantidadeInscritos());
             txtVisualizacoes.Text       = Convert.ToString(youtuber.GetVizualizacoes());
             txtQuantidadeLikes.Text     = Convert.ToString(youtuber.GetQuantidadeLikes());
             txtDescricao.Text           = youtuber.GetDescricao();
             txtRenda.Text               = Convert.ToString(youtuber.GetRenda());
             txtLinkCanal.Text           = youtuber.GetLink();
             txtQuantidadeVideos.Text    = Convert.ToString(youtuber.GetQuantidadeVideos());
             txtNacionalidade.Text       = youtuber.GetNascionalidade();
             txtCategoria.Text           = youtuber.GetCategoria();
             txtStrikes.Text             = Convert.ToString(youtuber.GetStrike());
             txtPlataforma.Text          = youtuber.GetPlataforma();
             this.youtuber               = youtuber;
         }
     }
 }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                bool novoYoutuber = youtuber == null;
                if (youtuber == null)
                {
                    youtuber = new Youtubers();
                }


                youtuber.SetNome(txtNome.Text);
                youtuber.SetSobrenome(txtSobrenome.Text);
                youtuber.SetApelido(txtApelido.Text);
                youtuber.SetNomeCanal(txtNomeCanal.Text);
                youtuber.SetQuantidadeInscritos(Convert.ToInt32(txtQuantidadeInscritos.Text));
                youtuber.SetVizualizacoes(Convert.ToInt32(txtVisualizacoes.Text));
                youtuber.SetQuantidadeLikes(Convert.ToInt32(txtQuantidadeLikes.Text));
                youtuber.SetDescricao(txtDescricao.Text);
                youtuber.SetRenda(Convert.ToDouble(txtRenda.Text));
                youtuber.SetLink(txtLinkCanal.Text);
                youtuber.SetQuantidadeVideos(Convert.ToInt32(txtQuantidadeVideos.Text));
                youtuber.SetNascionalidade(txtNacionalidade.Text);
                youtuber.SetCategoria(txtCategoria.Text);
                youtuber.SetStrike(Convert.ToInt32(txtStrikes.Text));
                youtuber.SetPlataforma(txtPlataforma.Text);

                if (novoYoutuber)
                {
                    Program.youtuber.Add(youtuber);
                    MessageBox.Show("Cadastro de youtuber realizado com sucesso! Bem-vindo ao Youtube!");
                }

                else
                {
                    for (int i = 0; i < Program.youtuber.Count(); i++)
                    {
                        Youtubers youtubers = Program.youtuber[i];
                        if (youtuber.GetCodigo() == youtubers.GetCodigo())
                        {
                            Program.youtuber[i] = youtuber;
                            MessageBox.Show("Youtuber alterado com sucesso");
                            return;
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
 private void NavigateToMainPage()
 {
     if (ChoiceCategorie != null && ChoiceLogo != null && ChoiceNickname != null)
     {
         Youtubers.Add(NewYoutuber);
         var parameter = new NavigationParameters();
         parameter.Add("youtuber", Youtubers);
         parameter.Add("new", NewYoutuber);
         _navigationService.NavigateAsync(nameof(MainPage), parameter);
     }
     else
     {
         IsFieldEmpty = true;
     }
 }
Пример #4
0
 private void ListagemYoutubers()
 {
     dataGridView1.Rows.Clear();
     for (int i = 0; i < Program.youtuber.Count(); i++)
     {
         Youtubers youtuber = Program.youtuber[i];
         dataGridView1.Rows.Add(new Object[] {
             youtuber.GetCodigo(),
             youtuber.GetNome(),
             youtuber.GetNomeCanal(),
             youtuber.GetApelido(),
             youtuber.GetQuantidadeInscritos(),
             youtuber.GetVizualizacoes()
         });
     }
 }
Пример #5
0
        private void btnApagarAluno_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow == null)
            {
                MessageBox.Show("Selecione um dos registros para que seja possível apagar");
                return;
            }

            int codigo = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString());

            for (int i = 0; i < Program.youtuber.Count(); i++)
            {
                Youtubers youtuber = Program.youtuber[i];
                if (youtuber.GetCodigo() == codigo)
                {
                    Program.youtuber.Remove(youtuber);
                    ListagemYoutubers();
                    MessageBox.Show(youtuber.GetNome() + " apagado com sucesso");
                    return;
                }
            }
        }
Пример #6
0
 public CadastroDeYoutubers()
 {
     InitializeComponent();
     this.youtuber = youtuber;
 }
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            Youtubers youtubers = new Youtubers();

            try
            {
                youtubers.SetNomePessoal(txtNomePessoal.Text);
                txtNomePessoal.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                youtubers.SetNomeCanal(txtNomeCanal.Text);
                txtNomeCanal.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                youtubers.SetInscritos(Convert.ToDouble(txtQuantidadeInscritos.Text));
                txtQuantidadeInscritos.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                youtubers.SetVisualizacao(Convert.ToDouble(txtVisualizacao.Text));
                txtVisualizacao.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                youtubers.SetQuantidadeDeVideos(Convert.ToInt32(txtQuantidadeVideos.Text));
                txtQuantidadeVideos.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            youtubers.SetAnuncio(cbAnuncio.SelectedItem.ToString());

            try
            {
                youtubers.SetLikes(Convert.ToDouble(txtQuantidadeLikes.Text));
                txtQuantidadeLikes.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                youtubers.SetDescricao(txtDescricao.Text);
                txtDescricao.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                youtubers.SetNacionalidade(txtNacionalidade.Text);
                txtNacionalidade.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                youtubers.SetDescricao(txtDescricao.Text);
                txtDescricao.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            youtubers.SetPatrocinador(cbPatrocinador.SelectedItem.ToString());

            try
            {
                youtubers.SetStrikes(Convert.ToInt32(txtQuantidadesStrikes.Text));
                txtQuantidadesStrikes.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            youtubers.SetPlataforma(cbPlataforma.SelectedItem.ToString());

            youtubers.SetStreamer(cbStreamers.SelectedItem.ToString());

            try
            {
                youtubers.SetApelido(txtApelido.Text);
                txtApelido.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                youtubers.SetRenda(Convert.ToDouble(txtRenda.Text));
                txtRenda.Focus();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }


            YoutuberRepository tudo = new YoutuberRepository();

            if (posicao == -1)
            {
                tudo.AdicionarYoutubers(youtubers);
                MessageBox.Show("Youtuber cadastrado com sucesso");
            }

            else
            {
                tudo.EditarYoutubers(youtubers, posicao);
                MessageBox.Show("Youtuber editado com sucesso");
            }
            AtualizarListaYoutubers();
            LimparCampos();
        }
 internal void EditarYoutubers(Youtubers youtuber, int posicao)
 {
     youtubers[posicao] = youtuber;
     EscreverNoArquivoDosYoutubers();
 }
        public void AdicionarYoutubers(Youtubers youtuber)
        {
            youtubers.Add(youtuber);

            EscreverNoArquivoDosYoutubers();
        }