예제 #1
0
        private void btnSalvarAT_Click(object sender, EventArgs e)
        {
            try
            {
                //leitura dos dados
                TipoAtendimentoDTO tip = new TipoAtendimentoDTO()
                {
                    Tpa_atendimento = tpa_descriçaoTextBox.Text
                };

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

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

                    MessageBox.Show("Cadastrado com Sucesso: Código: " + tip.Tpa_id.ToString());
                }
                else // alterar
                {
                    tip.Tpa_id = Convert.ToInt32(tpp_idTextBox.Text);
                    bll.Alterar(tip);
                    MessageBox.Show("Cadastrado Alterado com Sucesso: Código: " + tip.Tpa_id.ToString());
                }
                this.LimpaTelaAT();
                this.alterarBotoesAT(1);
            }//try
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
예제 #2
0
        //public SegmentoDTO GetTipoAtendimento(String id)
        //{
        //    this.CreateTextCommand("select * from Atendimento_tipo where id='" + id+"'");

        //    IDataReader dr = this.ExecuteDataReader();
        //    SegmentoDTO sgmento = new SegmentoDTO();
        //    if (dr.Read()) {

        //        sgmento.Id = dr["id"].ToString();
        //        sgmento.descricao = dr["descricao"].ToString();



        //    }

        //    return sgmento;

        //}


        public TipoAtendimentoDTO BuscarTipo(Int32 id)
        {
            this.CreateTextCommand("SELECT * FROM bobson01.Atendimento_tipo where id=@ID");
            this.AddInParameter("@ID", id, DbType.Int32);

            IDataReader dr = this.ExecuteDataReader();

            TipoAtendimentoDTO tpAtendimento = new TipoAtendimentoDTO();

            try
            {
                if (dr.Read())
                {
                    tpAtendimento.Id        = dr["id"].ToString();
                    tpAtendimento.descricao = dr["descricao"].ToString();
                    tpAtendimento.completo  = dr["completo"].ToString();
                }
            }
            finally
            {
                dr.Close();
                this.CloseConnection();
            }
            return(tpAtendimento);
        }
예제 #3
0
        public void Alterar(TipoAtendimentoDTO tipoaBllCrud)
        {
            if (tipoaBllCrud.Tpa_atendimento.Trim().Length == 0) //verifica se foi informado
            {
                throw new Exception("O tipo de atendimento é obrigatório");
            }

            TipoAtendimentoDAL dalObj = new TipoAtendimentoDAL(conexao);

            dalObj.Alterar(tipoaBllCrud);
        }
예제 #4
0
        }//incluir

        public void Alterar(TipoAtendimentoDTO tipoaDalCrud)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conexao.Conexao;
            cmd.CommandText = "update tbTPATENDIMENTO set tpa_atendimento = @tpa_atendimento where tpa_id = @tpa_id;";

            cmd.Parameters.AddWithValue("@tpa_id", tipoaDalCrud.Tpa_id);
            cmd.Parameters.AddWithValue("@tpa_atendimento", tipoaDalCrud.Tpa_atendimento);
            conexao.Conectar();
            cmd.ExecuteNonQuery(); //não retorna parametro algum
            conexao.Desconectar();
        }//alterar
예제 #5
0
        public void Incluir(TipoAtendimentoDTO tipoaDalCrud)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conexao.Conexao;
            cmd.CommandText = "insert into tbTPATENDIMENTO(tpa_atendimento) values (@tpa_atendimento);select @@identity;";
            cmd.Parameters.AddWithValue("@tpa_atendimento", tipoaDalCrud.Tpa_atendimento);
            conexao.Conectar();

            tipoaDalCrud.Tpa_id = Convert.ToInt32(cmd.ExecuteScalar());

            conexao.Desconectar();
        }//incluir
예제 #6
0
        }//pesquisar

        public TipoAtendimentoDTO CarregaTipoDTO(int tpa_id) //tipo + o campo do banco
        {
            TipoAtendimentoDTO tip = new TipoAtendimentoDTO();
            SqlCommand         cmd = new SqlCommand();

            cmd.Connection  = conexao.Conexao;
            cmd.CommandText = "select * from tbTPATENDIMENTO where tpa_id = @tpa_id;";
            cmd.Parameters.AddWithValue("@tpa_id", tpa_id);
            conexao.Conectar();
            SqlDataReader registro = cmd.ExecuteReader();

            if (registro.HasRows)
            {
                registro.Read();
                tip.Tpa_id          = Convert.ToInt32(registro["tpa_id"]);
                tip.Tpa_atendimento = Convert.ToString(registro["tpa_atendimento"]);
            }
            conexao.Desconectar();
            return(tip);
        } //carrega