using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace acc_pgsql
{
    public enum DBTYPE
    {
        OLEDB = 1,
        SQLDB = 2,
        POSTGRESS = 3
    }
    public static class DBGlobals
    {
        static string ACCESS_CONN = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\dspec\\RPM-97.mdb;User Id=admin;Password=;";
        static string SQL_CONN = "Data Source=RPM-APP.prelub.com;Initial Catalog=access;Persist Security Info=True;User ID=mobilepmuser;Password=data4techs;";
        static string POSTGRESS_CONN = "Server={0};Database=accessdb_v2;Port={1};User Id=mcarman;Password=@ng31F@rm0823262;";


        public static System.Data.DataSet SelectDS(DBTYPE db, string sql)
        {
            System.Data.DataSet obj = new System.Data.DataSet();
            switch (db)
            {
                case DBTYPE.OLEDB:
                    using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(ACCESS_CONN))
                    {
                        conn.Open();
                        System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(sql);
                        cmd.Connection = conn;
                        System.Data.OleDb.OleDbDataAdapter accAdapter = new System.Data.OleDb.OleDbDataAdapter(cmd);
                        accAdapter.Fill(obj);
                        conn.Close();
                        conn.Dispose();
                    }
                    return obj;
                case DBTYPE.SQLDB:
                    using (System.Data.SqlClient.SqlConnection sqlconn = new System.Data.SqlClient.SqlConnection(SQL_CONN))
                    {
                        sqlconn.Open();
                        System.Data.SqlClient.SqlCommand sqlcmd = new System.Data.SqlClient.SqlCommand(sql);
                        sqlcmd.Connection = sqlconn;
                        sqlcmd.CommandType = System.Data.CommandType.Text;
                        System.Data.SqlClient.SqlDataAdapter sqlAdapter = new System.Data.SqlClient.SqlDataAdapter(sqlcmd);
                        sqlAdapter.Fill(obj);
                        sqlconn.Close();
                        sqlconn.Dispose();
                    }
                    return obj;
                default:
                    return obj;
            }
        }
    }
}
