Beispiel #1
0
        private void btnPesquisar_Click(object sender, EventArgs e)
        {
            // abre o form dentro do form
            form_ConsVacina Form_Cad = new form_ConsVacina();

            Form_Cad.ShowInTaskbar = false;
            Form_Cad.StartPosition = FormStartPosition.CenterParent;
            Form_Cad.ShowDialog(ActiveForm);

            if (Form_Cad.codigo != 0)
            {
                ConexaoDAL conexao = new ConexaoDAL(DadosConexaoDAL.StringDeConexão);
                VacinaBLL  bll     = new VacinaBLL(conexao);
                VacinaDTO  vac     = bll.CarregaVacinaDTO(Form_Cad.codigo);
                vac_idTextBox.Text = vac.Vac_id.ToString();
                //   vac_vacinaTextBox.Text = vac.Vac_;

                alterarBotoes(3);
            }
            else
            {
                this.LimpaTela();
                this.alterarBotoes(1);
            }

            //encerra form
            Form_Cad.Dispose();
        }
Beispiel #2
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                //leitura dos dados
                VacinaDTO vac = new VacinaDTO();

                //   vac.Vac_vacina = vac_vacinaTextBox.Text;


                //obj para gravar dados no bd
                ConexaoDAL conexao = new ConexaoDAL(DadosConexaoDAL.StringDeConexão);
                VacinaBLL  bll     = new VacinaBLL(conexao);

                if (this.operacao == "inserir")
                {
                    bll.Incluir(vac);

                    MessageBox.Show("Cadastrado com Sucesso: Código: " + vac.Vac_id.ToString());
                    // this.LimpaTela();
                }
                else // alterar
                {
                    vac.Vac_id = Convert.ToInt32(vac_idTextBox.Text);
                    bll.Alterar(vac);
                    MessageBox.Show("Cadastrado Alterado com Sucesso: Código: " + vac.Vac_id.ToString());
                }
                this.LimpaTela();
                this.alterarBotoes(1);
            }//try
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
Beispiel #3
0
        private void btnPesquisar_Click(object sender, EventArgs e)
        {
            ConexaoDAL conexao = new ConexaoDAL(DadosConexaoDAL.StringDeConexão);
            VacinaBLL  bll     = new VacinaBLL(conexao);

            dgv_vac.DataSource = bll.Pesquisar(txtValor.Text);
        }
Beispiel #4
0
        private void form_ConsVacina_Load(object sender, EventArgs e)
        {
            ConexaoDAL conexao = new ConexaoDAL(DadosConexaoDAL.StringDeConexão);
            VacinaBLL  bll     = new VacinaBLL(conexao);

            dgv_vac.DataSource = bll.Pesquisar(txtValor.Text);

            //------CONFIG DO PESQUISAR ------//
            btnPesquisar_Click(sender, e);

            //------  DEFINE DGV COR TEXTO E FUNDO----- //
            this.dgv_vac.DefaultCellStyle.Font      = new Font("Verdana", 11);
            this.dgv_vac.DefaultCellStyle.ForeColor = Color.Black;
            this.dgv_vac.DefaultCellStyle.BackColor = Color.White;
        }
Beispiel #5
0
        private void BtnSalvarVA_Click(object sender, EventArgs e)
        {
            try
            {
                //leitura dos dados
                VacinaDTO vac = new VacinaDTO()
                {
                    Vac_atendimento = vac_atendimentoTextBox.Text,
                    Vac_tipo        = Convert.ToInt32(vac_tipoComboBox.Text),
                    Vac_aplicaçao   = Convert.ToInt32(vac_aplicaçaoComboBox.Text),
                    Vac_data        = vac_dataTextBox.Text,
                    Vac_intervalo   = vac_intervaloTextBox.Text
                };

                //obj para gravar dados no bd
                ConexaoDAL conexao = new ConexaoDAL(DadosConexaoDAL.StringDeConexão);
                VacinaBLL  bll     = new VacinaBLL(conexao);

                if (this.operacao == "inserir") /// alterar salvar para inserir
                {
                    bll.Incluir(vac);

                    MessageBox.Show("Cadastrado com Sucesso: Código: " + vac.Vac_id.ToString());

                    pnInfo.Show();
                }
                else
                {
                    vac.Vac_id = Convert.ToInt32(pre_idTextBox.Text);
                    bll.Alterar(vac);
                    MessageBox.Show("Cadastrado Alterado com Sucesso: Código: " + vac.Vac_id.ToString());
                }
                this.LimpaTelaVA();
                this.AlterarBotoesVA(1);
            } //try

            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
Beispiel #6
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo);
                if (d.ToString() == "Yes")
                {
                    //obj para gravar dados no bd
                    ConexaoDAL conexao = new ConexaoDAL(DadosConexaoDAL.StringDeConexão);
                    VacinaBLL  bll     = new VacinaBLL(conexao);

                    bll.Excluir(Convert.ToInt32(vac_idTextBox.Text));
                    this.LimpaTela();
                    this.alterarBotoes(1);
                }
            }//try
            catch
            {
                MessageBox.Show("Impossível excluir o registro.\n O registro está sendo utilizado em outro local.");
                this.alterarBotoes(3);
            }
        }