예제 #1
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (!InputValid())
                {
                    return;
                }

                Animador esc = (Animador)dataGridView1.SelectedRows[0].DataBoundItem;


                var animador = (from _animador in modelContainer.Animadores
                                where _animador.IdPessoa == esc.IdPessoa
                                select _animador).FirstOrDefault();

                animador.Nome          = tbNome.Text;
                animador.Morada        = tbMorada.Text;
                animador.Telefone      = tbTelefone.Text;
                animador.Telemovel     = tbTelemovel.Text;
                animador.Mail          = tbMail.Text;
                animador.CodPostal     = tbCodPostal.Text;
                animador.Localidade    = tbLocalidade.Text;
                animador.Especialidade = tbEspecialidade.Text;

                modelContainer.SaveChanges();
                carregarAnimadores();

                clearTextBoxes();
            }
            catch (Exception)
            {
            }
        }
예제 #2
0
        private void BtnAdicionar_Click(object sender, EventArgs e)
        {
            if (!InputValid())
            {
                return;
            }

            Animador animador = new Animador
            {
                Nome          = tbNome.Text,
                Morada        = tbMorada.Text,
                Telefone      = tbTelefone.Text,
                Telemovel     = tbTelemovel.Text,
                Mail          = tbMail.Text,
                CodPostal     = tbCodPostal.Text,
                Localidade    = tbLocalidade.Text,
                Especialidade = tbEspecialidade.Text
            };

            modelContainer.Animadores.Add(animador);
            modelContainer.SaveChanges();
            carregarAnimadores();

            clearTextBoxes();
        }
예제 #3
0
        private void BtnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                Animador escola = (Animador)dataGridView1.SelectedRows[0].DataBoundItem;

                modelContainer.Animadores.Remove(escola);
                modelContainer.SaveChanges();
                carregarAnimadores();

                clearTextBoxes();
            }
            catch (Exception)
            {
            }
        }
예제 #4
0
        private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                dataGridView1.CurrentRow.Selected = true;

                Animador animador = (Animador)dataGridView1.SelectedRows[0].DataBoundItem;

                tbNome.Text          = animador.Nome;
                tbMorada.Text        = animador.Morada;
                tbTelefone.Text      = animador.Telefone;
                tbTelemovel.Text     = animador.Telemovel;
                tbMail.Text          = animador.Mail;
                tbCodPostal.Text     = animador.CodPostal;
                tbLocalidade.Text    = animador.Localidade;
                tbEspecialidade.Text = animador.Especialidade;

                isEditing = true;
                updateLayout();
            }
        }