public static Object[] executaDblink(String servidor, String banco, String usuario, String senha, String tabela, String consulta, String where, String parametro, Boolean insert = false, Boolean log = false) { String vlInsert = ""; Object[] vlRetorno = null; try { if (insert) { vlInsert = String.Format("INSERT INTO {0}({1}) ", tabela, consulta); } String vsql = vlInsert + " SELECT " + consulta + " FROM " + " dblink('host=" + servidor + " user="******" password="******" dbname=" + banco + "'::text," + " 'SELECT " + consulta + " FROM " + tabela + " " + where + "'::text, false)" + tabela + "(" + parametro + ");"; Object[] result = Utilidades.consultar(vsql); if (result != null) { vlRetorno = result; } else if (log) { String msg = String.Format("Erro ao executar Select dblink na tabela {0}. Erro: {1}", tabela, result); Ficheiro.criaArquivo(tabela, "txt", "Logs"); Ficheiro.escreveArquivo(msg, tabela, "txt", "Logs"); Alert.atencao(msg); } } catch (Exception erro) { Alert.erro(String.Format("Erro ao importar dados da tabela {0} \n{1}", tabela, erro.Message)); } return(vlRetorno); }
public static Report loadReport(string irelatorioname) { Report report = new Report(); try { report.Load(String.Format("{0}\\Relatorios\\{1}", Ficheiro.getLocalExecutavel(), irelatorioname)); } catch (Exception ex) { Alert.erro("Erro ao gerar o relatorio \n" + ex.Message); } return(report); }
public static String loadWord(string irelatorioname) { String report = ""; try { report = String.Format("{0}\\Relatorios\\{1}", Ficheiro.getLocalExecutavel(), irelatorioname); } catch (Exception ex) { Alert.erro(String.Format("Erro ao acessar o arquivo do Word {0} \n", irelatorioname, ex.Message)); } return(report); }
public static Image selecionaImagem() { //pictureBox1.Image = Ficheiro.selecionaImagem(); String logo = Ficheiro.selecionaArquivo("Arquivos de Imagem(*.BMP;*.JPG;*.GIF;*.PNG;*.GIF)|*.BMP;*.JPG;*.GIF;*.PNG;*.GIF"); if (!logo.Equals(String.Empty)) { var resultado = new Bitmap(logo); return(resultado); } else { return(null); } }
public static void exportaArquivoGrid(GridControl grid, String dsNome, String dsFormato, String dsDiretorio) { //Utilidades.exportaArquivoGrid(gcGrid, "NomeDoArquivo", "xls", "Relatorios"); Ficheiro.criaArquivo(dsNome, dsFormato, dsDiretorio); string filePath = Ficheiro.getLocalArquivo(dsNome, dsFormato, dsDiretorio); if (dsFormato.Equals("csv")) { grid.ExportToXlsx(filePath); } else if (dsFormato.Equals("html")) { grid.ExportToHtml(filePath); } else if (dsFormato.Equals("mht")) { grid.ExportToMht(filePath); } else if (dsFormato.Equals("pdf")) { grid.ExportToPdf(filePath); } else if (dsFormato.Equals("rtf")) { grid.ExportToRtf(filePath); } else if (dsFormato.Equals("txt")) { grid.ExportToText(filePath); } else if (dsFormato.Equals("xlsx")) { grid.ExportToXlsx(filePath); } else if (dsFormato.Equals("xls")) { grid.ExportToXls(filePath); } System.Diagnostics.Process.Start(@filePath); }