Ejemplo n.º 1
0
        public static bool TesOracleConnection(string DataSource, string Username, string Password, out string pesan)
        {
            string errMsg = string.Empty;

            pesan = string.Empty;
            bool isConnect = false;

            try
            {
                POProject.CommandAdapter.OracleCmdBuilder cmd = new POProject.CommandAdapter.OracleCmdBuilder(DataSource, Username, Password);
                if (cmd.TestConnection(out errMsg))
                {
                    pesan     = "Koneksi Berhasil";
                    isConnect = true;
                }
                else
                {
                    pesan = "Koneksi Gagal : " + errMsg;
                }
            }
            catch (Exception ex)
            {
                pesan = "Koneksi Gagal : " + ex.Message;
            }

            return(isConnect);
        }
Ejemplo n.º 2
0
        public static void OracleDataParser(DataTable dtSource, string queryPajak, string queryLampiran, DateTime LastErrDate, DateTime Serverdate, out DataTable dtPajak, out DataTable dtLampiran)
        {
            string oracleDatasource = dtSource.Select("NAME='tbOracleDataSource'").FirstOrDefault().Field <string>("VALUE");
            string oracleUserId     = dtSource.Select("NAME='tbOracleUsername'").FirstOrDefault().Field <string>("VALUE");
            string oraclePassword   = dtSource.Select("NAME='tbOraclePassword'").FirstOrDefault().Field <string>("VALUE");

            //query get pajak
            POProject.CommandAdapter.OracleCmdBuilder cmdOra = new POProject.CommandAdapter.OracleCmdBuilder(oracleDatasource, oracleUserId, oraclePassword);
            //cmdOra.Query = "SELECT * FROM (" + queryPajak + ") WHERE TRUNC(TGL_TRANSAKSI) BETWEEN :tglAwal AND :tglAkhir";
            cmdOra.Query = queryPajak;

            cmdOra.AddParameter("tglAwal", POProject.CommandAdapter.OracleCmdParameterDirection.Input, LastErrDate.ToString("dd-MMM-yyyy", new CultureInfo("en-US")));
            cmdOra.AddParameter("tglAkhir", POProject.CommandAdapter.OracleCmdParameterDirection.Input, Serverdate.ToString("dd-MMM-yyyy", new CultureInfo("en-US")));

            dtPajak = cmdOra.GetTable();
            //query get detail
            cmdOra       = new POProject.CommandAdapter.OracleCmdBuilder(oracleDatasource, oracleUserId, oraclePassword);
            cmdOra.Query = queryLampiran;

            cmdOra.AddParameter("tglAwal", POProject.CommandAdapter.OracleCmdParameterDirection.Input, LastErrDate.ToString("dd-MMM-yyyy", new CultureInfo("en-US")));
            cmdOra.AddParameter("tglAkhir", POProject.CommandAdapter.OracleCmdParameterDirection.Input, Serverdate.ToString("dd-MMM-yyyy", new CultureInfo("en-US")));

            dtLampiran = cmdOra.GetTable();
        }
Ejemplo n.º 3
0
        public static void CekValidQuery(string query, string DBConnector, Dictionary <string, string> dictDbConnector, out DataTable dt)
        {
            dt = new DataTable();
            switch (DBConnector)
            {
            case "ORACLE":
                POProject.CommandAdapter.OracleCmdBuilder cmdOra = new POProject.CommandAdapter.OracleCmdBuilder(dictDbConnector["tbOracleDataSource"].ToString(),
                                                                                                                 dictDbConnector["tbOracleUsername"].ToString(), dictDbConnector["tbOraclePassword"].ToString());

                cmdOra.Query = query;

                if (query.Contains("tglAwal") && query.Contains("tglAkhir"))
                {
                    cmdOra.AddParameter("tglAwal", POProject.CommandAdapter.OracleCmdParameterDirection.Input, DateTime.Now.ToString("dd-MMM-yyyy", new CultureInfo("en-US")));
                    cmdOra.AddParameter("tglAkhir", POProject.CommandAdapter.OracleCmdParameterDirection.Input, DateTime.Now.ToString("dd-MMM-yyyy", new CultureInfo("en-US")));
                }

                dt = cmdOra.GetTable();
                break;

            case "SQL":
                POProject.CommandAdapter.SqlCmdBuilder cmdSql = new POProject.CommandAdapter.SqlCmdBuilder(dictDbConnector["tbSqlServer"].ToString(), dictDbConnector["tbSqlDatabase"].ToString(),
                                                                                                           dictDbConnector["tbSqlUsername"].ToString(), dictDbConnector["tbSqlPassword"].ToString());
                cmdSql.Query = query;

                if (query.Contains("tglAwal") && query.Contains("tglAkhir"))
                {
                    cmdSql.AddParameter("tglAwal", ParameterDirection.Input, DateTime.Now.ToString("yyyy-MM-dd"));
                    cmdSql.AddParameter("tglAkhir", ParameterDirection.Input, DateTime.Now.ToString("yyyy-MM-dd"));
                }

                dt = cmdSql.GetTable();
                break;

            case "MYSQL":
                POProject.CommandAdapter.MySqlCmdBuilder cmdMySql = new POProject.CommandAdapter.MySqlCmdBuilder(dictDbConnector["tbMySqlServer"].ToString(), dictDbConnector["tbMySqlDatabase"].ToString(),
                                                                                                                 dictDbConnector["tbMySqlUsername"].ToString(), dictDbConnector["tbMySqlPassword"].ToString());
                cmdMySql.Query = query;

                if (query.Contains("tglAwal") && query.Contains("tglAkhir"))
                {
                    cmdMySql.AddParameter("tglAwal", ParameterDirection.Input, DateTime.Now.ToString("yyyy-MM-dd"));
                    cmdMySql.AddParameter("tglAkhir", ParameterDirection.Input, DateTime.Now.ToString("yyyy-MM-dd"));
                }

                dt = cmdMySql.GetTable();
                break;

            case "ACCESS":
                POProject.CommandAdapter.MsAccessCmdBuilder cmdAccess = new POProject.CommandAdapter.MsAccessCmdBuilder(dictDbConnector["tbAccessPath"].ToString(), dictDbConnector["tbAccessPassword"].ToString());
                cmdAccess.Query = query;

                if (query.Contains("tglAwal") && query.Contains("tglAkhir"))
                {
                    cmdAccess.AddParameter("@tglAwal", ParameterDirection.Input, DateTime.Now.ToString("yyyy-MM-dd"));
                    cmdAccess.AddParameter("@tglAkhir", ParameterDirection.Input, DateTime.Now.ToString("yyyy-MM-dd"));
                }

                dt = cmdAccess.GetTable();
                break;

            default:
                break;
            }
        }