public ActionResult MeusAnimais() { AnimalBLL bll = new AnimalBLL(); List <Animal> animais = bll.LerAnimaisUsuariologado(int.Parse(Cookie.Get())); return(View(animais)); }
private void salvar(Consultas consultas) { try { if (txtRelato.Text.Trim() == string.Empty || cbCliente.SelectedValue == null || data_consulta.Text.Trim() == string.Empty || hora_consulta.Text.Trim() == string.Empty) { MessageBox.Show("Informações obrigatórias não preenchidas", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ConsultaBLL consultaBLL = new ConsultaBLL(); AnimalBLL animal = new AnimalBLL(); consultas.CodCliente = cbCliente.SelectedValue.ToString(); consultas.relatoConsulta = txtRelato.Text; consultas.dataConsulta = Convert.ToDateTime(data_consulta.Text); consultas.horaConsulta = Convert.ToDateTime(hora_consulta.Text); consultaBLL.salvar(consultas); MessageBox.Show("Consulta CADASTRADA com sucesso !", "Resultado", MessageBoxButtons.OK, MessageBoxIcon.Information); limparCampos(); listarConsultas(); } } catch (Exception erro) { MessageBox.Show("OPS..ERRO, VERIFIQUE SE OS CAMPOS ESTÃO CORRETOS " + erro.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//salvar private void salvar(Animais animais) { try { if (txtRaca.Text.Trim() == string.Empty || /*txtNome.Text.Trim() == string.Empty ||*/ cbSexo.Text.Trim() == string.Empty) { MessageBox.Show("Informações obrigatórias não preenchidas", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { AnimalBLL animaisBll = new AnimalBLL(); animais.descricaoAnimal = txtRaca.Text; //animais.nomeAnimal = txtNome.Text; animais.sexoAnimal = cbSexo.Text; animaisBll.salvar(animais); MessageBox.Show("Animal CADASTRADO com sucesso!", "Resultado", MessageBoxButtons.OK, MessageBoxIcon.Information); listarAnimais(); limparCampos(); } } catch (Exception erro) { throw erro; } }
public ActionResult Lista() { AnimalBLL bll = new AnimalBLL(); List <Animal> ultimos5Cadastrados = bll.Listar(); return(View(ultimos5Cadastrados)); }
//editar private void editar(Animais animais) { try { if (txtRaca.Text.Trim() == string.Empty || /*txtNome.Text.Trim() == string.Empty ||*/ cbSexo.Text.Trim() == string.Empty) { MessageBox.Show("Informações obrigatórias não preenchidas", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { AnimalBLL animaisBll = new AnimalBLL(); animais.codAnimal = Convert.ToInt32(txtCodAnimal.Text); animais.descricaoAnimal = txtRaca.Text; // animais.nomeAnimal = txtNome.Text; animais.sexoAnimal = cbSexo.Text; animaisBll.editar(animais); MessageBox.Show("Animal ALTERADO com sucesso!", "Resultado", MessageBoxButtons.OK, MessageBoxIcon.Information); limparCampos(); listarAnimais(); btn_editar.Visible = false; btn_deletar.Visible = false; btn_salvar_medico.Visible = true; } } catch (Exception erro) { throw erro; } }
private void textBox1_TextChanged(object sender, EventArgs e) { if (textBox1.Text == "") { AnimalBLL animalBLL = new AnimalBLL(); dtAnimal.DataSource = animalBLL.listarAnimais(); } else { Animais animais = new Animais(); pesquisar(animais); } }
private void pesquisar(Animais animais) { try { animais.descricaoAnimal = textBox1.Text.Trim(); AnimalBLL animaisBll = new AnimalBLL(); dtAnimal.DataSource = animaisBll.pesquisar(animais); } catch (Exception erro) { throw erro; } }
//------CONFIG DE EXIBIÇÃO DO DGV ------// private void btnPesquisar_Click(object sender, EventArgs e) { if (cbFiltrarAnimal.Text == "Pesquisar por Nome do Animal") { ConexaoDAL conexao = new ConexaoDAL(DadosConexaoDAL.StringDeConexão); AnimalBLL bll = new AnimalBLL(conexao); dgv_ani.DataSource = bll.PesquisarNomeAnimal(txtValor.Text); } if (cbFiltrarAnimal.Text == "Pesquisar Todos Animais") { ConexaoDAL conexao = new ConexaoDAL(DadosConexaoDAL.StringDeConexão); AnimalBLL bll = new AnimalBLL(conexao); dgv_ani.DataSource = bll.PesquisarTodosAnimal(); } }
private void form_ConsAnimal_Load(object sender, EventArgs e) { ConexaoDAL conexao = new ConexaoDAL(DadosConexaoDAL.StringDeConexão); AnimalBLL bll = new AnimalBLL(conexao); dgv_ani.DataSource = bll.PesquisarTodosAnimal(); //------CONFIG DO PESQUISAR ------// btnPesquisar_Click(sender, e); //------ DEFINE DGV COR TEXTO E FUNDO----- // this.dgv_ani.DefaultCellStyle.Font = new Font("Verdana", 10); this.dgv_ani.DefaultCellStyle.ForeColor = Color.Black; this.dgv_ani.DefaultCellStyle.BackColor = Color.White; //------ DEFINE DGV CABEÇALHO----- // //Altera o cabeçalho da coluna dgv_ani.Columns[0].HeaderText = "ID"; //Altera a largura da coluna // dgv_ani.Columns[0].Width = 50; //Altera o cabeçalho da coluna dgv_ani.Columns[1].HeaderText = "Cliente"; //Altera a largura da coluna // dgv_ani.Columns[1].Width = 50; //Altera o cabeçalho da coluna dgv_ani.Columns[2].HeaderText = "Animal"; //Altera a largura da coluna // dgv_ani.Columns[2].Width = 70; //Altera o cabeçalho da coluna dgv_ani.Columns[3].HeaderText = "Sexo"; //Altera a largura da coluna // dgv_ani.Columns[3].Width = 50; //Altera o cabeçalho da coluna dgv_ani.Columns[4].HeaderText = "Espécie"; //Altera a largura da coluna // dgv_ani.Columns[4].Width = 50; //Altera o cabeçalho da coluna dgv_ani.Columns[5].HeaderText = "Raça"; //Altera a largura da coluna // dgv_ani.Columns[5].Width = 20; }
//---------- CONFIG BOTOES - SALVAR ---------------- // private void btnSalvar_Click(object sender, EventArgs e) { try { //leitura dos dados AnimalDTO ani = new AnimalDTO(); ani.Ani_nome = ani_nomeTextBox.Text; ani.Ani_sexo = Convert.ToInt32(ani_sexoComboBox.SelectedValue); ani.Ani_especie = Convert.ToInt32(ani_especieComboBox.SelectedValue); ani.Ani_raça = Convert.ToInt32(ani_raçaComboBox.SelectedValue); ani.Ani_peso = ani_pesoTextBox.Text; ani.Ani_idade = ani_idadeTextBox.Text; ani.Ani_cliente = Convert.ToInt32(ani_clienteTextBox.Text); ani.Ani_cadastro = ani_cadastroDateTimePicker.Value.Date; ani.Ani_status = Convert.ToInt32(ani_statusComboBox.SelectedValue); //obj para gravar dados no bd ConexaoDAL conexao = new ConexaoDAL(DadosConexaoDAL.StringDeConexão); AnimalBLL bll = new AnimalBLL(conexao); if (this.operacao == "inserir") /// alterar salvar para inserir { bll.Incluir(ani); MessageBox.Show("Cadastrado com Sucesso: Código: " + ani.Ani_id.ToString()); } else { ani.Ani_id = Convert.ToInt32(ani_idTextBox.Text); bll.Alterar(ani); MessageBox.Show("Cadastrado Alterado com Sucesso: Código: " + ani.Ani_id.ToString()); } this.LimpaTela(); this.alterarBotoes(1); } //try catch (Exception erro) { MessageBox.Show(erro.Message); } }
//---------- CONFIG BOTOES - EXCLUIR ---------------- // 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); AnimalBLL bll = new AnimalBLL(conexao); bll.Excluir(Convert.ToInt32(ani_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); } }
//excluir private void excluir(Animais animais) { try { AnimalBLL animaisBll = new AnimalBLL(); animais.codAnimal = Convert.ToInt32(txtCodAnimal.Text); animaisBll.excluir(animais); //ou Excluir com maiusculo MessageBox.Show("Animal EXCLUÍDO com sucesso!", "Resultado", MessageBoxButtons.OK, MessageBoxIcon.Information); limparCampos(); btn_editar.Visible = false; btn_deletar.Visible = false; btn_salvar_medico.Visible = true; listarAnimais(); } catch (Exception erro) { MessageBox.Show("Você não tem permissão para deletar" + erro.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnPesquisar_Click(object sender, EventArgs e) { // abre o form dentro do form form_ConsAnimal Form_Cad = new form_ConsAnimal(); 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); AnimalBLL bll = new AnimalBLL(conexao); AnimalDTO ani = bll.CarregaAnimalDTO(Form_Cad.codigo); ani_idTextBox.Text = ani.Ani_id.ToString(); // é isso mesmo aula 16 ani_nomeTextBox.Text = ani.Ani_nome; ani_sexoComboBox.SelectedValue = ani.Ani_sexo; ani_especieComboBox.SelectedValue = ani.Ani_especie; ani_raçaComboBox.SelectedValue = ani.Ani_raça; ani_pesoTextBox.Text = ani.Ani_peso; ani_idadeTextBox.Text = ani.Ani_idade; ani_clienteTextBox.Text = ani.Ani_cliente.ToString(); ani_cadastroDateTimePicker.Value = ani.Ani_cadastro; alterarBotoes(3); } else { this.LimpaTela(); this.alterarBotoes(1); } //encerra form Form_Cad.Dispose(); }
private void Form_CadAtendimento_Load(object sender, EventArgs e) { pnInfo.Hide(); pnExame.Hide(); pnProtocolo.Hide(); pnPrescriçaoMedica.Hide(); pnSuspeitaClinica.Hide(); pnVacina.Hide(); pnDocumento.Hide(); // ate_data = DateTime.Now; // datalb.Text = "Data: " + ate_data.ToShortDateString(); // ate_hora = DateTime.Now; // lbhora.Text = "Hora: " + ate_hora.ToShortTimeString(); //----------INICIA CONFIG BOTOES ---------------- // this.AlterarBotoes(1); // ----------COMBOBOX's -----------------------------// ConexaoDAL conexao = new ConexaoDAL(DadosConexaoDAL.StringDeConexão); // cb medico MedicoBLL medbll = new MedicoBLL(conexao); ate_medicoComboBox.DataSource = medbll.Pesquisar(""); ate_medicoComboBox.DisplayMember = "med_nome"; ate_medicoComboBox.ValueMember = "med_id"; // cb tipo atendimento TipoAtendimentoBLL tipbll = new TipoAtendimentoBLL(conexao); ate_tipoComboBox.DataSource = tipbll.Pesquisar(""); ate_tipoComboBox.DisplayMember = "tpa_atendimento"; ate_tipoComboBox.ValueMember = "tpa_id"; // cb animal AnimalBLL anibll = new AnimalBLL(conexao); ate_animalComboBox.DataSource = anibll.PesquisarNomeAnimal(""); ate_animalComboBox.DisplayMember = "ani_nome"; ate_animalComboBox.ValueMember = "ani_id"; // ----------COMBOBOX's Exame-----------------------------// // cb tipo exame TipoExameBLL exabll = new TipoExameBLL(conexao); exame_tipoComboBox.DataSource = exabll.Pesquisar(""); exame_tipoComboBox.DisplayMember = "tpe_descriçao"; exame_tipoComboBox.ValueMember = "tpe_id"; // ----------COMBOBOX's Protocolo-----------------------------// // cb aplicação AplicaçaoBLL aplibll = new AplicaçaoBLL(conexao); prot_aplicaçaoComboBox.DataSource = aplibll.Pesquisar(""); prot_aplicaçaoComboBox.DisplayMember = "apl_descriçao"; prot_aplicaçaoComboBox.ValueMember = "apl_id"; // cb tipo protocolo TipoProtocoloBLL protbll = new TipoProtocoloBLL(conexao); prot_tipoComboBox.DataSource = protbll.Pesquisar(""); prot_tipoComboBox.DisplayMember = "tpp_descriçao"; prot_tipoComboBox.ValueMember = "tpp_id"; // ----------COMBOBOX's Vacina-----------------------------// // cb tipo vacina TipoVacinaBLL vaccbll = new TipoVacinaBLL(conexao); vac_tipoComboBox.DataSource = vaccbll.Pesquisar(""); vac_tipoComboBox.DisplayMember = "tpv_descriçao"; vac_tipoComboBox.ValueMember = "tpv_id"; // cb tipo protocolo AplicaçaoBLL aplivbll = new AplicaçaoBLL(conexao); vac_aplicaçaoComboBox.DataSource = aplivbll.Pesquisar(""); vac_aplicaçaoComboBox.DisplayMember = "apl_descriçao"; vac_aplicaçaoComboBox.ValueMember = "apl_id"; this.LimpaTela(); }
//listar private void listarAnimais() { AnimalBLL animalBLL = new AnimalBLL(); dtAnimal.DataSource = animalBLL.listarAnimais(); }