Beispiel #1
0
        private void Apagar()
        {
            if (dataGridView1.CurrentRow == null)
            {
                MessageBox.Show("Selecione algo neste grid");
                return;
            }

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

            dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
            CadastroYoutuberRepository repositorio = new CadastroYoutuberRepository();

            repositorio.Apagar(codigo);
            MessageBox.Show(codigo + " apagado com sucesso.");
        }
Beispiel #2
0
        private void AtualizarListaYoutubers()
        {
            CadastroYoutuberRepository obtem = new CadastroYoutuberRepository();

            dataGridView1.Rows.Clear();

            foreach (Model dgv in obtem.ObterTeens())
            {
                dataGridView1.Rows.Add(new Object[]
                {
                    dgv.GetCodigo(),
                    dgv.GetNome(),
                    dgv.GetQuantosStrikes(),
                    dgv.GetQuantidadeVisualizacoes(),
                    dgv.GetQuantidadeInscritos(),
                    dgv.GetApelido()
                });
            }
        }
Beispiel #3
0
        public CadastroYoutuber(string linhaSelecionada)
        {
            InitializeComponent();
            this.CodigoSelecionado = CodigoSelecionado;
            CadastroYoutuberRepository repositorio = new CadastroYoutuberRepository();

            int quantidade = 0;

            for (int i = 0; i < repositorio.ObterTeens().Count(); i++)
            {
                Model youtubersTeen = repositorio.ObterTeens()[i];
                if (youtubersTeen.GetCodigo() == CodigoSelecionado)
                {
                    txtNome.Text            = youtubersTeen.GetNome();
                    txtSobrenome.Text       = youtubersTeen.GetSobrenome();
                    txtApelido.Text         = youtubersTeen.GetApelido();
                    txtNomeCanal.Text       = youtubersTeen.GetNomeCanal();
                    txtLikes.Text           = youtubersTeen.GetQuantidaDeLikes().ToString();
                    txtInscritos.Text       = youtubersTeen.GetQuantidadeInscritos().ToString();
                    txtVizualizacao.Text    = youtubersTeen.GetQuantidadeVisualizacoes().ToString();
                    nudVideos.Value         = youtubersTeen.GetQuantidadeVideos();
                    txtNacionalidade.Text   = youtubersTeen.GetNacionalidade();
                    chkPatrocinador.Checked = youtubersTeen.GetPatrocinador();
                    chkAnuncio.Checked      = youtubersTeen.GetAnuncios();
                    chkStreamer.Checked     = youtubersTeen.GetStreamer();
                    txtDescricao.Text       = youtubersTeen.GetDescricao();
                    txtRenda.Text           = youtubersTeen.GetRenda().ToString();
                    txtLink.Text            = youtubersTeen.GetLinkDoCanal();
                    nudStrikes.Value        = youtubersTeen.GetQuantosStrikes();
                    cbPlataforma.Text       = youtubersTeen.GetPlataforma();
                    cbCategoria.Text        = youtubersTeen.GetCategoria();
                    return;
                }
                quantidade++;
            }
        }
Beispiel #4
0
        private void SalvarCadastro()
        {
            salvar = new Model();

            try
            {
                salvar.SetNome(txtNome.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor preencha nome");
                txtNome.Focus();
                return;
            }
            try
            {
                salvar.SetSobrenome(txtSobrenome.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor preencha sobrenome");
                txtSobrenome.Focus();
                return;
            }

            try
            {
                salvar.SetApelido(txtApelido.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor preencha apelido");
                txtApelido.Focus();
                return;
            }

            try
            {
                salvar.SetQuantidaDeLikes(Convert.ToInt64(txtLikes.Text));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor preencha quantidade de likes");
                txtLikes.Focus();
                return;
            }
            try
            {
                salvar.SetQuantidadeInscritos(Convert.ToInt32(txtInscritos.Text));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor preencha quantidade de inscritos");
                txtInscritos.Focus();
                return;
            }
            try
            {
                salvar.SetQuantidadeVisualizacoes(Convert.ToInt64(txtVizualizacao.Text));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor preencha quantidade de vizualições");
                txtVizualizacao.Focus();
                return;
            }
            try
            {
                salvar.SetQuantidadeVideos(Convert.ToInt32(nudVideos.Value));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor preencha quantidade de videos");
                nudVideos.Focus();
                return;
            }
            try
            {
                salvar.SetNacionalidade(txtNacionalidade.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor preencha o campo nacionalidade");
                txtNacionalidade.Focus();
                return;
            }
            if (chkPatrocinador.Checked)
            {
                salvar.SetPatrocinador(true);
            }
            else
            {
                salvar.SetPatrocinador(false);
            }



            if (chkStreamer.Checked)
            {
                salvar.SetStreamer(true);
            }
            else
            {
                salvar.SetStreamer(false);
            }


            if (chkAnuncio.Checked)
            {
                salvar.SetAnuncios(true);
            }
            else
            {
                salvar.SetAnuncios(false);
            }

            try
            {
                salvar.SetDescricao(txtDescricao.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor preencha descrição");
                txtDescricao.Focus();
                return;
            }

            try
            {
                salvar.SetRenda(Convert.ToDouble(txtRenda.Text));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor preencha o campo renda");
                txtRenda.Focus();
                return;
            }
            try
            {
                salvar.SetCodigo(Convert.ToInt32(txtCodigo.Text));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor preencha o campo codigo");
                txtCodigo.Focus();
                return;
            }


            try
            {
                salvar.SetLinkDoCanal(txtLink.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor preencha link do canal");
                txtLink.Focus();
                return;
            }


            try
            {
                salvar.SetQuantosStrikes(Convert.ToInt32(nudStrikes.Value));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                nudStrikes.Focus();
                return;
            }



            if (cbCategoria.SelectedIndex < 0)
            {
                MessageBox.Show("Por favor selecione uma Categoria");
                cbCategoria.DroppedDown = true;
                return;
            }
            try
            {
                salvar.SetCategoria(cbCategoria.SelectedItem.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor selecione uma categoria");
                cbCategoria.DroppedDown = true;
                return;
            }


            if (cbPlataforma.SelectedIndex < 0)
            {
                MessageBox.Show("Por favor selecione uma plataforma");
                cbPlataforma.DroppedDown = true;
                return;
            }
            try
            {
                salvar.SetPlataforma(cbPlataforma.SelectedItem.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show("Por favor selecione uma plataforma");
                cbPlataforma.DroppedDown = true;
                return;
            }

            CadastroYoutuberRepository tudo = new CadastroYoutuberRepository();

            if (CodigoSelecionado == -1)
            {
                tudo.AdicionarYoutuber(salvar);
                MessageBox.Show("Youtuber cadastrado com sucesso");
            }
            else
            {
                tudo.SetCodigo(CodigoSelecionado);
                tudo.EditarYoutuber(salvar, CodigoSelecionado);
                MessageBox.Show("Youtuber alterado com sucesso");
            }



            LimparCampos();
        }