Пример #1
0
        public Usuario LoginRemoto(string login, string senha, string path)
        {
            Usuario   usuario   = null;
            DataTable resultado = new DataTable();

            using (OleDbConnection oConn = new OleDbConnection(ConexaoSingle.conexaoRemota(path)))
            {
                oConn.Open();

                using (OleDbCommand cmd = new OleDbCommand(" SELECT * FROM USUARIO.DBF WHERE [LOGIN] = '" + login + "' AND [SENHA] = '" + senha + "';"))//this works and creates an empty .dbf file
                {
                    cmd.Connection = oConn;
                    OleDbDataAdapter DA = new OleDbDataAdapter(cmd);

                    DA.Fill(resultado);
                    if (resultado.Rows.Count > 0)
                    {
                        usuario        = new Usuario();
                        usuario.Codigo = int.Parse(resultado.Rows[0]["ID"].ToString());
                        usuario.Nome   = resultado.Rows[0]["NOME"].ToString();
                        usuario.Login  = resultado.Rows[0]["LOGIN"].ToString();
                        usuario.Perfil = int.Parse(resultado.Rows[0]["CO_PERFIL"].ToString());
                    }
                }
            }
            return(usuario);
        }
Пример #2
0
        public List <Palestrante> ListarPalestrantesEvento(string pathDB)
        {
            List <Palestrante> palestrantes = new List <Palestrante>();
            //Sala usuario = null;
            DataTable resultado = new DataTable();

            using (OleDbConnection oConn = new OleDbConnection(ConexaoSingle.conexaoRemota(pathDB)))
            {
                oConn.Open();

                using (OleDbCommand cmd = new OleDbCommand(" SELECT DISTINCT ID_PALESTR FROM SALA_PAL.DBF"))
                {
                    cmd.Connection = oConn;
                    OleDbDataAdapter DA = new OleDbDataAdapter(cmd);

                    DA.Fill(resultado);
                    if (resultado.Rows.Count > 0)
                    {
                        for (int i = 0; i < resultado.Rows.Count; i++)
                        {
                            Palestrante palestrante = new PalestranteDAO().BuscarPorCodigo(int.Parse(resultado.Rows[i]["ID_PALESTR"].ToString()), pathDB);
                            palestrantes.Add(palestrante);
                        }
                    }
                }
            }
            return(palestrantes.OrderBy(P => P.Nome).ToList());
        }
Пример #3
0
        public Evento VerificaExistenciaEvento(String path)
        {
            Evento evento = null;
            using (OleDbConnection oConn = new OleDbConnection(String.IsNullOrEmpty(path) ? ConexaoSingle.conexao : ConexaoSingle.conexaoRemota(path)))
            {
                oConn.Open();
                DataTable resultado = new DataTable();
                using (OleDbCommand cmd = new OleDbCommand(@" SELECT * FROM EVENTO.DBF"))//this works and creates an empty .dbf file
                {
                    cmd.Connection = oConn;
                    OleDbDataAdapter DA = new OleDbDataAdapter(cmd);

                    DA.Fill(resultado);
                    if (resultado.Rows.Count > 0)
                    {
                        evento = new Evento();
                        evento.Codigo = int.Parse(resultado.Rows[0]["ID"].ToString());
                        evento.Nome = resultado.Rows[0]["NOME"].ToString();
                        evento.Arquivo = resultado.Rows[0]["FILE_NAME"].ToString();
                        evento.Datas = this.DatasEvento(path);
                        return evento;
                    }
                }
                return evento;
            }
        }
Пример #4
0
        public List<DateTime> DatasEvento(string path)
        {
            List<DateTime> datas = new List<DateTime>();
            using (OleDbConnection oConn = new OleDbConnection(String.IsNullOrEmpty(path) ? ConexaoSingle.conexao : ConexaoSingle.conexaoRemota(path)))
            {
                oConn.Open();
                DataTable resultado = new DataTable();
                using (OleDbCommand cmd = new OleDbCommand(@" SELECT * FROM DATAS.DBF ORDER BY DATA_EVENT"))//this works and creates an empty .dbf file
                {
                    cmd.Connection = oConn;
                    OleDbDataAdapter DA = new OleDbDataAdapter(cmd);

                    DA.Fill(resultado);
                    if (resultado.Rows.Count > 0)
                        for (int i = 0; i < resultado.Rows.Count; i++)
                            datas.Add(DateTime.Parse(resultado.Rows[i][0].ToString()));
                }
                return datas;
            }
        }
Пример #5
0
        public Palestrante BuscarPorNome(string pNome, string path)
        {
            Palestrante palestrante = null;
            //Sala usuario = null;
            DataTable resultado = new DataTable();

            using (OleDbConnection oConn = new OleDbConnection(String.IsNullOrEmpty(path) ? ConexaoSingle.conexao : ConexaoSingle.conexaoRemota(path)))
            {
                oConn.Open();

                using (OleDbCommand cmd = new OleDbCommand(" SELECT * FROM PALESTRA.DBF where NOME = '" + pNome.ToUpper() + "'"))
                {
                    cmd.Connection = oConn;
                    OleDbDataAdapter DA = new OleDbDataAdapter(cmd);

                    DA.Fill(resultado);
                    if (resultado.Rows.Count > 0)
                    {
                        palestrante        = new Palestrante();
                        palestrante.Codigo = int.Parse(resultado.Rows[0]["ID"].ToString());
                        palestrante.Nome   = resultado.Rows[0]["NOME"].ToString();
                    }
                }
            }
            return(palestrante);
        }
Пример #6
0
        public Sala BuscarPorNome(string pNome, string pPath)
        {
            Sala sala = null;
            //Sala usuario = null;
            DataTable resultado = new DataTable();

            using (OleDbConnection oConn = new OleDbConnection(String.IsNullOrEmpty(pPath) ? ConexaoSingle.conexao : ConexaoSingle.conexaoRemota(pPath)))
            {
                oConn.Open();

                using (OleDbCommand cmd = new OleDbCommand(" SELECT * FROM SALAS.DBF where NOME = '" + pNome + "'"))
                {
                    cmd.Connection = oConn;
                    OleDbDataAdapter DA = new OleDbDataAdapter(cmd);

                    DA.Fill(resultado);
                    if (resultado.Rows.Count > 0)
                    {
                        sala        = new Sala();
                        sala.Codigo = int.Parse(resultado.Rows[0]["ID"].ToString());
                        sala.Nome   = resultado.Rows[0]["NOME"].ToString();
                        sala.IP     = resultado.Rows[0]["IP"].ToString();
                    }
                }
            }
            return(sala);
        }
Пример #7
0
        public List <Sala> ListarTodos(string pPath)
        {
            List <Sala> salas = new List <Sala>();
            //Sala usuario = null;
            DataTable resultado = new DataTable();

            using (OleDbConnection oConn = new OleDbConnection(String.IsNullOrEmpty(pPath) ? ConexaoSingle.conexao : ConexaoSingle.conexaoRemota(pPath)))
            {
                oConn.Open();

                using (OleDbCommand cmd = new OleDbCommand(" SELECT * FROM SALAS.DBF ORDER BY NOME"))
                {
                    cmd.Connection = oConn;
                    OleDbDataAdapter DA = new OleDbDataAdapter(cmd);

                    DA.Fill(resultado);
                    if (resultado.Rows.Count > 0)
                    {
                        for (int i = 0; i < resultado.Rows.Count; i++)
                        {
                            Sala sala = new Sala();
                            sala.Codigo = int.Parse(resultado.Rows[i]["ID"].ToString());
                            sala.Nome   = resultado.Rows[i]["NOME"].ToString();
                            sala.IP     = resultado.Rows[i]["IP"].ToString();
                            salas.Add(sala);
                        }
                    }
                }
            }
            return(salas);
        }
Пример #8
0
        public void AtualizarArquivoPalestra(int pIDPalestra, string pFileName, string pathDB)
        {
            using (OleDbConnection oConn = new OleDbConnection(String.IsNullOrEmpty(pathDB) ? ConexaoSingle.conexao : ConexaoSingle.conexaoRemota(pathDB)))
            {
                oConn.Open();

                using (OleDbCommand cmd = new OleDbCommand(@" UPDATE SALA_PAL.DBF SET FILENAME = '" + pFileName + "' WHERE [ID] = " + pIDPalestra))
                {
                    cmd.Connection = oConn;
                    cmd.ExecuteNonQuery();
                }
            }
        }
Пример #9
0
        public List <AgendaEvento> ListarTodos(int?pCodigoPalestrante, int?pCodigoSala, DateTime?data, string pPath)
        {
            List <AgendaEvento> agendas = new List <AgendaEvento>();
            //Sala usuario = null;
            DataTable resultado = new DataTable();

            using (OleDbConnection oConn = new OleDbConnection(String.IsNullOrEmpty(pPath) ? ConexaoSingle.conexao : ConexaoSingle.conexaoRemota(pPath)))
            {
                oConn.Open();

                using (OleDbCommand cmd = new OleDbCommand(" SELECT * FROM SALA_PAL.DBF "))
                {
                    cmd.CommandText += " where 1=1";

                    if (pCodigoPalestrante.HasValue)
                    {
                        cmd.CommandText += " AND ID_PALESTR = @PALEST";
                        cmd.Parameters.Add("@PALEST", OleDbType.Numeric).Value = pCodigoPalestrante;
                    }

                    if (pCodigoSala.HasValue)
                    {
                        cmd.CommandText += " AND ID_SALA = @SALA";
                        cmd.Parameters.Add("@SALA", OleDbType.Numeric).Value = pCodigoSala;
                    }

                    if (data.HasValue)
                    {
                        cmd.CommandText += " AND DATA = @DATA";
                        cmd.Parameters.Add("@DATA", OleDbType.Date).Value = data;
                    }

                    cmd.CommandText += " ORDER BY DATA, HORA";
                    cmd.Connection   = oConn;
                    OleDbDataAdapter DA = new OleDbDataAdapter(cmd);

                    DA.Fill(resultado);
                    if (resultado.Rows.Count > 0)
                    {
                        for (int i = 0; i < resultado.Rows.Count; i++)
                        {
                            AgendaEvento agendaEvento = new AgendaEvento();
                            agendaEvento.Palestrante     = new PalestranteDAO().BuscarPorCodigo(int.Parse(resultado.Rows[i]["ID_PALESTR"].ToString()), pPath);
                            agendaEvento.Codigo          = int.Parse(resultado.Rows[i]["ID"].ToString());
                            agendaEvento.Sala            = new SalaDAO().BuscarPorCodigo(int.Parse(resultado.Rows[i]["ID_SALA"].ToString()), pPath);
                            agendaEvento.Data            = DateTime.Parse(resultado.Rows[i]["DATA"].ToString());
                            agendaEvento.Hora            = resultado.Rows[i]["HORA"].ToString();
                            agendaEvento.Tema            = resultado.Rows[i]["TEMA"].ToString();
                            agendaEvento.ArquivoPalestra = resultado.Rows[i]["FILENAME"].ToString();
                            agendas.Add(agendaEvento);
                        }
                    }
                }
            }
            return(agendas);
        }
Пример #10
0
        public List <AgendaEvento> BuscaAgendaPorPalestrante(int pPalestrante, string path)
        {
            List <AgendaEvento> agendas = new List <AgendaEvento>();
            //Sala usuario = null;
            DataTable resultado = new DataTable();

            using (OleDbConnection oConn = new OleDbConnection(string.IsNullOrEmpty(path) ? ConexaoSingle.conexao : ConexaoSingle.conexaoRemota(path)))
            {
                oConn.Open();

                using (OleDbCommand cmd = new OleDbCommand(" SELECT * FROM SALA_PAL.DBF "))
                {
                    cmd.CommandText += " where ID_PALESTR = @ID_PALESTR";
                    cmd.Parameters.Add("@ID_PALESTR", OleDbType.Numeric).Value = pPalestrante;
                    cmd.Connection = oConn;
                    OleDbDataAdapter DA = new OleDbDataAdapter(cmd);

                    DA.Fill(resultado);
                    if (resultado.Rows.Count > 0)
                    {
                        for (int i = 0; i < resultado.Rows.Count; i++)
                        {
                            AgendaEvento agendaEvento = new AgendaEvento();
                            agendaEvento.Palestrante     = new PalestranteDAO().BuscarPorCodigo(int.Parse(resultado.Rows[i]["ID_PALESTR"].ToString()), path);
                            agendaEvento.Codigo          = int.Parse(resultado.Rows[i]["ID"].ToString());
                            agendaEvento.Sala            = new SalaDAO().BuscarPorCodigo(int.Parse(resultado.Rows[i]["ID_SALA"].ToString()), path);
                            agendaEvento.Data            = DateTime.Parse(resultado.Rows[i]["DATA"].ToString());
                            agendaEvento.Hora            = resultado.Rows[i]["HORA"].ToString();
                            agendaEvento.Tema            = resultado.Rows[i]["TEMA"].ToString();
                            agendaEvento.ArquivoPalestra = resultado.Rows[i]["FILENAME"].ToString();
                            agendas.Add(agendaEvento);
                        }
                    }
                }
            }
            return(agendas);
        }
Пример #11
0
        public AgendaEvento BuscarPorCodigo(int pCodigo, string pPath)
        {
            AgendaEvento agendaEvento = null;

            using (OleDbConnection oConn = new OleDbConnection(String.IsNullOrEmpty(pPath) ? ConexaoSingle.conexao : ConexaoSingle.conexaoRemota(pPath)))
            {
                oConn.Open();
                DataTable resultado = new DataTable();
                using (OleDbCommand cmd = new OleDbCommand(" SELECT * FROM SALA_PAL.DBF WHERE ID = @ID"))//this works and creates an empty .dbf file
                {
                    cmd.Parameters.Add("@ID", OleDbType.Numeric).Value = pCodigo;
                    cmd.Connection = oConn;
                    OleDbDataAdapter DA = new OleDbDataAdapter(cmd);

                    DA.Fill(resultado);
                    if (resultado.Rows.Count > 0)
                    {
                        agendaEvento                 = new AgendaEvento();
                        agendaEvento.Palestrante     = new PalestranteDAO().BuscarPorCodigo(int.Parse(resultado.Rows[0]["ID_PALESTR"].ToString()), pPath);
                        agendaEvento.Codigo          = int.Parse(resultado.Rows[0]["ID"].ToString());
                        agendaEvento.Sala            = new SalaDAO().BuscarPorCodigo(int.Parse(resultado.Rows[0]["ID_SALA"].ToString()), pPath);
                        agendaEvento.Data            = DateTime.Parse(resultado.Rows[0]["DATA"].ToString());
                        agendaEvento.Hora            = resultado.Rows[0]["HORA"].ToString();
                        agendaEvento.Tema            = resultado.Rows[0]["TEMA"].ToString();
                        agendaEvento.ArquivoPalestra = resultado.Rows[0]["FILENAME"].ToString();
                        //evento.Datas = this.DatasEvento();
                        return(agendaEvento);
                    }
                }
                return(agendaEvento);
            }
        }