Пример #1
0
        public List <Veterinario> GetAllVeterinariosByPetTipo(int pet_tipo_id)
        {
            List <Veterinario> veterinarios_list = new List <Veterinario>();

            FuncionarioBusiness        funcionario_business          = new FuncionarioBusiness();
            VeterinarioPetTipoBusiness veterinario_pet_tipo_business = new VeterinarioPetTipoBusiness();

            try
            {
                this.connection.Open();

                this.command.CommandText = string.Format(@"SELECT 
                                                v.id,
                                                v.id_funcionario,
                                                v.nome,
                                                v.cpf,
                                                v.identidade,
                                                v.registro,
                                                v.ultima_alteracao,
                                                v.responsavel 
                                             FROM veterinario v
                                                inner join veterinario_pet_tipo vpt on vpt.id_veterinario = v.id    
                                             WHERE
                                                vpt.id_pet_tipo = '{0}'
                                             ORDER BY v.nome", pet_tipo_id);
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())//Enquanto existir dados no select
                {
                    Veterinario veterinario = new Veterinario();

                    veterinario.id               = (reader["id"].ToString() != null && reader["id"].ToString() != string.Empty) ? Int32.Parse(reader["id"].ToString()) : 0;
                    veterinario.id_funcionario   = (reader["id_funcionario"].ToString() != null && reader["id_funcionario"].ToString() != string.Empty) ? Int32.Parse(reader["id_funcionario"].ToString()) : 0;
                    veterinario.nome             = (reader["nome"].ToString() != null && reader["nome"].ToString() != string.Empty) ? reader["nome"].ToString() : "";
                    veterinario.cpf              = (reader["cpf"].ToString() != null && reader["cpf"].ToString() != string.Empty) ? reader["cpf"].ToString() : "";
                    veterinario.identidade       = (reader["identidade"].ToString() != null && reader["identidade"].ToString() != string.Empty) ? reader["identidade"].ToString() : "";
                    veterinario.registro         = (reader["registro"].ToString() != null && reader["registro"].ToString() != string.Empty) ? reader["registro"].ToString() : "";
                    veterinario.ultima_alteracao = (reader["ultima_alteracao"].ToString() != null && reader["ultima_alteracao"].ToString() != string.Empty) ? DateTime.Parse(reader["ultima_alteracao"].ToString()) : new DateTime();
                    veterinario.responsavel      = (reader["responsavel"].ToString() != null && reader["responsavel"].ToString() != string.Empty) ? reader["responsavel"].ToString() : "";

                    veterinario.veterinario_pet_tipo_list = veterinario_pet_tipo_business.GetVeterinarioPetTipo(veterinario.id);
                    veterinario.funcionario = funcionario_business.GetFuncionario(veterinario.id_funcionario);

                    veterinarios_list.Add(veterinario);
                }


                this.connection.Close();
            }
            catch (Exception ex)
            {
                if (this.connection.State == System.Data.ConnectionState.Open)
                {
                    this.connection.Close();
                }
            }

            return(veterinarios_list);
        }
Пример #2
0
        public Servico GetServico(int servico_id)
        {
            Servico servico = new Servico();

            FuncionarioBusiness    funcionario_business     = new FuncionarioBusiness();
            ServicoProdutoBusiness servico_produto_business = new ServicoProdutoBusiness();

            try
            {
                this.connection.Open();

                this.command.CommandText = string.Format(@"SELECT 
                                            id,
                                            tipo_executante,
                                            nome,
                                            descricao,
                                            valor_atual,
                                            tempo,
                                            pataz_bonus,
                                            pataz_custo,
                                            ultima_alteracao,
                                            responsavel
                                           FROM servico
                                           WHERE
                                           id = '{0}'", servico_id);
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())//Enquanto existir dados no select
                {
                    servico.id = (reader["id"].ToString() != null && reader["id"].ToString() != string.Empty) ? Int32.Parse(reader["id"].ToString()) : 0;
                    servico.tipo_executante  = (reader["tipo_executante"].ToString() != null && reader["tipo_executante"].ToString() != string.Empty) ? Int32.Parse(reader["tipo_executante"].ToString()) : 0;
                    servico.nome             = (reader["nome"].ToString() != null && reader["nome"].ToString() != string.Empty) ? reader["nome"].ToString() : "";
                    servico.descricao        = (reader["descricao"].ToString() != null && reader["descricao"].ToString() != string.Empty) ? reader["descricao"].ToString() : "";
                    servico.valor_atual      = (reader["valor_atual"].ToString() != null && reader["valor_atual"].ToString() != string.Empty) ? Decimal.Parse(reader["valor_atual"].ToString()) : 0;
                    servico.tempo            = (reader["tempo"].ToString() != null && reader["tempo"].ToString() != string.Empty) ? Int32.Parse(reader["tempo"].ToString()) : 0;
                    servico.pataz_bonus      = (reader["pataz_bonus"].ToString() != null && reader["pataz_bonus"].ToString() != string.Empty) ? Int32.Parse(reader["pataz_bonus"].ToString()) : 0;
                    servico.pataz_custo      = (reader["pataz_custo"].ToString() != null && reader["pataz_custo"].ToString() != string.Empty) ? Int32.Parse(reader["pataz_custo"].ToString()) : 0;
                    servico.ultima_alteracao = (reader["ultima_alteracao"].ToString() != null && reader["ultima_alteracao"].ToString() != string.Empty) ? DateTime.Parse(reader["ultima_alteracao"].ToString()) : new DateTime();
                    servico.responsavel      = (reader["responsavel"].ToString() != null && reader["responsavel"].ToString() != string.Empty) ? reader["responsavel"].ToString() : "";

                    servico.servico_produto_list = servico_produto_business.GetServicoProduto(servico.id);
                }


                this.connection.Close();
            }
            catch (Exception ex)
            {
                if (this.connection.State == System.Data.ConnectionState.Open)
                {
                    this.connection.Close();
                }
            }

            return(servico);
        }
Пример #3
0
        public Veterinario GetVeterinario(int veterinario_id)
        {
            Veterinario veterinario = new Veterinario();

            FuncionarioBusiness        funcionario_business          = new FuncionarioBusiness();
            VeterinarioPetTipoBusiness veterinario_pet_tipo_business = new VeterinarioPetTipoBusiness();

            try
            {
                this.connection.Open();

                this.command.CommandText = string.Format(@"SELECT 
                                            id,
                                            id_funcionario,
                                            nome,
                                            cpf,
                                            identidade,
                                            registro,
                                            ultima_alteracao,
                                            responsavel
                                           FROM veterinario
                                           WHERE
                                           id = '{0}'", veterinario_id);
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())//Enquanto existir dados no select
                {
                    veterinario.id               = (reader["id"].ToString() != null && reader["id"].ToString() != string.Empty) ? Int32.Parse(reader["id"].ToString()) : 0;
                    veterinario.id_funcionario   = (reader["id_funcionario"].ToString() != null && reader["id_funcionario"].ToString() != string.Empty) ? Int32.Parse(reader["id_funcionario"].ToString()) : 0;
                    veterinario.nome             = (reader["nome"].ToString() != null && reader["nome"].ToString() != string.Empty) ? reader["nome"].ToString() : "";
                    veterinario.cpf              = (reader["cpf"].ToString() != null && reader["cpf"].ToString() != string.Empty) ? reader["cpf"].ToString() : "";
                    veterinario.identidade       = (reader["identidade"].ToString() != null && reader["identidade"].ToString() != string.Empty) ? reader["identidade"].ToString() : "";
                    veterinario.registro         = (reader["endereco"].ToString() != null && reader["endereco"].ToString() != string.Empty) ? reader["endereco"].ToString() : "";
                    veterinario.ultima_alteracao = (reader["ultima_alteracao"].ToString() != null && reader["ultima_alteracao"].ToString() != string.Empty) ? DateTime.Parse(reader["ultima_alteracao"].ToString()) : new DateTime();
                    veterinario.responsavel      = (reader["responsavel"].ToString() != null && reader["responsavel"].ToString() != string.Empty) ? reader["responsavel"].ToString() : "";

                    veterinario.veterinario_pet_tipo_list = veterinario_pet_tipo_business.GetVeterinarioPetTipo(veterinario.id);
                    veterinario.funcionario = funcionario_business.GetFuncionario(veterinario.id_funcionario);
                }


                this.connection.Close();
            }
            catch (Exception ex)
            {
                if (this.connection.State == System.Data.ConnectionState.Open)
                {
                    this.connection.Close();
                }
            }

            return(veterinario);
        }
Пример #4
0
        public List <Atendente> GetAllAtendentes()
        {
            List <Atendente> atendentes_list = new List <Atendente>();

            FuncionarioBusiness funcionario_business = new FuncionarioBusiness();

            try
            {
                this.connection.Open();

                this.command.CommandText = @"SELECT 
                                            id,
                                            id_funcionario,
                                            nome
                                           FROM atendente ORDER BY nome";
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())//Enquanto existir dados no select
                {
                    Atendente atendente = new Atendente();

                    atendente.id             = (reader["id"].ToString() != null && reader["id"].ToString() != string.Empty) ? Int32.Parse(reader["id"].ToString()) : 0;
                    atendente.id_funcionario = (reader["id_funcionario"].ToString() != null && reader["id_funcionario"].ToString() != string.Empty) ? Int32.Parse(reader["id_funcionario"].ToString()) : 0;
                    atendente.nome           = (reader["nome"].ToString() != null && reader["nome"].ToString() != string.Empty) ? reader["nome"].ToString() : "";

                    atendente.funcionario = funcionario_business.GetFuncionario(atendente.id_funcionario);

                    atendentes_list.Add(atendente);
                }


                this.connection.Close();
            }
            catch (Exception ex)
            {
                if (this.connection.State == System.Data.ConnectionState.Open)
                {
                    this.connection.Close();
                }
            }

            return(atendentes_list);
        }
Пример #5
0
        public Atendente GetAtendente(int atendente_id)
        {
            Atendente atendente = new Atendente();

            FuncionarioBusiness funcionario_business = new FuncionarioBusiness();

            try
            {
                this.connection.Open();

                this.command.CommandText = string.Format(@"SELECT 
                                            id,
                                            id_funcionario,
                                            nome
                                           FROM atendente
                                           WHERE
                                           id = '{0}'", atendente_id);
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())//Enquanto existir dados no select
                {
                    atendente.id   = (reader["id"].ToString() != null && reader["id"].ToString() != string.Empty) ? Int32.Parse(reader["id"].ToString()) : 0;
                    atendente.id   = (reader["id_funcionario"].ToString() != null && reader["id_funcionario"].ToString() != string.Empty) ? Int32.Parse(reader["id_funcionario"].ToString()) : 0;
                    atendente.nome = (reader["nome"].ToString() != null && reader["nome"].ToString() != string.Empty) ? reader["nome"].ToString() : "";

                    atendente.funcionario = funcionario_business.GetFuncionario(atendente.id_funcionario);
                }


                this.connection.Close();
            }
            catch (Exception ex)
            {
                if (this.connection.State == System.Data.ConnectionState.Open)
                {
                    this.connection.Close();
                }
            }

            return(atendente);
        }
Пример #6
0
        public List <Agendamento> GetAllAgendamentoss()
        {
            List <Agendamento> agendamentos_list = new List <Agendamento>();

            ClienteBusiness     cliente_business     = new ClienteBusiness();
            PetBusiness         pet_business         = new PetBusiness();
            ServicoBusiness     servico_business     = new ServicoBusiness();
            FuncionarioBusiness funcionario_business = new FuncionarioBusiness();

            try
            {
                this.connection.Open();

                this.command.CommandText = @"SELECT 
                                            id,
                                            id_cliente,
                                            id_pet,
                                            id_servico,
                                            id_funcionario,
                                            data_inicio,
                                            data_termino,
                                            notificacao_enviada,
                                            cancelamento,
                                            ultima_alteracao,
                                            responsavel
                                           FROM agendamento ORDER BY data_inicio DESC";
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())//Enquanto existir dados no select
                {
                    Agendamento agendamento = new Agendamento();

                    agendamento.id                  = (reader["id"].ToString() != null && reader["id"].ToString() != string.Empty) ? Int32.Parse(reader["id"].ToString()) : 0;
                    agendamento.id_cliente          = (reader["id_cliente"].ToString() != null && reader["id_cliente"].ToString() != string.Empty) ? Int32.Parse(reader["id_cliente"].ToString()) : 0;
                    agendamento.id_pet              = (reader["id_pet"].ToString() != null && reader["id_pet"].ToString() != string.Empty) ? Int32.Parse(reader["id_pet"].ToString()) : 0;
                    agendamento.id_servico          = (reader["id_servico"].ToString() != null && reader["id_servico"].ToString() != string.Empty) ? Int32.Parse(reader["id_servico"].ToString()) : 0;
                    agendamento.id_funcionario      = (reader["id_funcionario"].ToString() != null && reader["id_funcionario"].ToString() != string.Empty) ? Int32.Parse(reader["id_funcionario"].ToString()) : 0;
                    agendamento.data_inicio         = (reader["data_inicio"].ToString() != null && reader["data_inicio"].ToString() != string.Empty) ? DateTime.Parse(reader["data_inicio"].ToString()) : new DateTime();
                    agendamento.data_termino        = (reader["data_termino"].ToString() != null && reader["data_termino"].ToString() != string.Empty) ? DateTime.Parse(reader["data_termino"].ToString()) : new DateTime();
                    agendamento.notificacao_enviada = (reader["notificacao_enviada"].ToString() != null && reader["notificacao_enviada"].ToString() != string.Empty) ? Boolean.Parse(reader["notificacao_enviada"].ToString()) : false;
                    agendamento.cancelamento        = (reader["cancelamento"].ToString() != null && reader["cancelamento"].ToString() != string.Empty) ? Boolean.Parse(reader["cancelamento"].ToString()) : false;
                    agendamento.ultima_alteracao    = (reader["ultima_alteracao"].ToString() != null && reader["ultima_alteracao"].ToString() != string.Empty) ? DateTime.Parse(reader["ultima_alteracao"].ToString()) : new DateTime();
                    agendamento.responsavel         = (reader["responsavel"].ToString() != null && reader["responsavel"].ToString() != string.Empty) ? reader["responsavel"].ToString() : "";

                    agendamento.data_inicio_br  = agendamento.data_inicio.ToString();
                    agendamento.data_termino_br = agendamento.data_termino.ToString();

                    agendamento.cliente     = cliente_business.GetCliente(agendamento.id_cliente);
                    agendamento.pet         = pet_business.GetPet(agendamento.id_pet);
                    agendamento.servico     = servico_business.GetServico(agendamento.id_servico);
                    agendamento.funcionario = funcionario_business.GetFuncionario(agendamento.id_funcionario);

                    agendamentos_list.Add(agendamento);
                }


                this.connection.Close();
            }
            catch (Exception ex)
            {
                if (this.connection.State == System.Data.ConnectionState.Open)
                {
                    this.connection.Close();
                }
            }

            return(agendamentos_list);
        }