示例#1
0
        public string abrirArquivoPDF(int CodAnexo, bool Wait, bool SomenteGerar)
        {
            ClassWebBI.ClassFuncoes clFuncoes = new ClassWebBI.ClassFuncoes();

            SqlCommand sCommand = new SqlCommand();

            System.Data.DataTable tblArq = new System.Data.DataTable();

            SqlParameter pCodigo = new SqlParameter("@COD_ANEXO", System.Data.SqlDbType.Int);

            sCommand.Parameters.Add(pCodigo);
            sCommand.Parameters["@COD_ANEXO"].Value = CodAnexo;
            sCommand.CommandText = "SELECT NOME, ARQUIVO FROM EXCEL_TITULO_ANEXOS WHERE COD_ANEXO = @COD_ANEXO";

            tblArq = clFuncoes.ExecReader(sCommand);
            string nomeArq = "";

            if (tblArq.Rows.Count > 0)
            {
                nomeArq = clFuncoes.GetProperties("fTempDirUsuario").ToString() + tblArq.Rows[0]["NOME"].ToString();
                byte[] arquivo = (byte[])tblArq.Rows[0]["ARQUIVO"];

                clFuncoes.SalvaArquivo(@nomeArq, arquivo);
            }

            if (!SomenteGerar)
            {
                if (File.Exists(@nomeArq))
                {
                    clFuncoes.ExecProcess(@nomeArq, Wait);
                }
            }

            return(@nomeArq);
        }
示例#2
0
        public string salvaArquivoExcel(int CodExcel)
        {
            ClassWebBI.ClassFuncoes clFuncoes = new ClassWebBI.ClassFuncoes();

            SqlCommand sCommand = new SqlCommand();

            System.Data.DataTable tblArq = new System.Data.DataTable();

            SqlParameter pCodigo = new SqlParameter("@COD_EXCEL", System.Data.SqlDbType.Int);

            sCommand.Parameters.Add(pCodigo);
            sCommand.Parameters["@COD_EXCEL"].Value = CodExcel;
            sCommand.CommandText = "SELECT NOME, ARQUIVO FROM EXCEL WHERE COD_EXCEL = @COD_EXCEL";

            tblArq = clFuncoes.ExecReader(sCommand);

            string nomeArq = "";

            if (tblArq.Rows.Count > 0)
            {
                nomeArq = clFuncoes.GetProperties("fTempDirUsuario").ToString() + tblArq.Rows[0]["NOME"].ToString();
                byte[] arquivo = (byte[])tblArq.Rows[0]["ARQUIVO"];

                clFuncoes.SalvaArquivo(@nomeArq, arquivo);
            }

            return(@nomeArq);
        }
示例#3
0
        public bool ValidaLogin(int CodUsuario, DateTime DtMovto)
        {
            bool lRetorno = false;

            ClassWebBI.Dados.ClassParametros clParametros = new Dados.ClassParametros();
            clParametros.getParametro();

            ClassFuncoes clFuncoes = new ClassWebBI.ClassFuncoes();

            DataTable tblUsuarios = new DataTable();

            SqlCommand sCommand = new SqlCommand();

            SqlParameter pUsuario = new SqlParameter("@COD_USUARIO", System.Data.SqlDbType.Int);

            sCommand.Parameters.Add(pUsuario);
            sCommand.Parameters["@COD_USUARIO"].Value = CodUsuario;

            sCommand.CommandText = "SELECT COD_USUARIO, NOME, USUARIO, SENHA, ENDERECO_MAIL, ADMINISTRADOR FROM USUARIOS" +
                                   " WHERE COD_USUARIO = @COD_USUARIO";

            tblUsuarios = clFuncoes.ExecReader(sCommand);

            if (tblUsuarios.Rows.Count > 0)
            {
                lRetorno = true;

                if (DtMovto > clParametros.fdt_limite_atualizacao)
                {
                    DtMovto = clParametros.fdt_limite_atualizacao;
                }

                clFuncoes.SetProperties("fData", DtMovto.ToShortDateString());
                clFuncoes.SetProperties("fCodUsuario", Convert.ToInt32(tblUsuarios.Rows[0]["COD_USUARIO"].ToString()));
                clFuncoes.SetProperties("fNomeUsuario", tblUsuarios.Rows[0]["NOME"].ToString());
                clFuncoes.SetProperties("fAdministrador", Convert.ToBoolean(tblUsuarios.Rows[0]["ADMINISTRADOR"].ToString()));
                clFuncoes.SetProperties("fMail", tblUsuarios.Rows[0]["ENDERECO_MAIL"].ToString());
                clFuncoes.SetProperties("fUsuario", tblUsuarios.Rows[0]["USUARIO"].ToString());
                clFuncoes.SetProperties("fSenha", tblUsuarios.Rows[0]["SENHA"].ToString());

                string sDir = clFuncoes.GetProperties("fTempDir").ToString();
                if (!File.Exists(@sDir))
                {
                    Directory.CreateDirectory(@sDir);
                }

                sDir = clFuncoes.GetProperties("fTempDir").ToString() + "\\" + clFuncoes.GetProperties("fUsuario").ToString();
                if (!File.Exists(@sDir))
                {
                    Directory.CreateDirectory(@sDir);
                }

                sDir = sDir + "\\";
                clFuncoes.SetProperties("fTempDirUsuario", @sDir);
            }

            return(lRetorno);
        }
示例#4
0
        public string gerarPDF(int CodTitulo, bool Armazenar)
        {
            ClassWebBI.ClassFuncoes clFuncoes = new ClassWebBI.ClassFuncoes();

            SqlCommand sCommand = new SqlCommand();

            System.Data.DataTable tblTitulo = new System.Data.DataTable();

            SqlParameter pCodigo = new SqlParameter("@COD_TITULO", System.Data.SqlDbType.Int);

            sCommand.Parameters.Add(pCodigo);
            sCommand.Parameters["@COD_TITULO"].Value = CodTitulo;

            SqlParameter pAtualiza = new SqlParameter("@DT_GERACAO", System.Data.SqlDbType.DateTime);

            sCommand.Parameters.Add(pAtualiza);
            sCommand.Parameters["@DT_GERACAO"].Value = clFuncoes.GetProperties("fData");

            SqlParameter pHrAtualiza = new SqlParameter("@HR_GERACAO", System.Data.SqlDbType.VarChar, 5);

            sCommand.Parameters.Add(pHrAtualiza);
            sCommand.Parameters["@HR_GERACAO"].Value = DateTime.Now.ToString("HH:mm");

            sCommand.CommandText = "SELECT COD_TITULO, NOME, COD_EXCEL, NUM_PLAN_PDF, TIPO_ARMAZENAGEM FROM EXCEL_TITULOS WHERE COD_TITULO = @COD_TITULO";

            tblTitulo = clFuncoes.ExecReader(sCommand);

            if (tblTitulo.Rows.Count <= 0)
            {
                return("");
            }

            string Arquivo = salvaArquivoExcel(Convert.ToInt32(tblTitulo.Rows[0]["COD_EXCEL"].ToString()));

            if (!File.Exists(Arquivo))
            {
                return("");
            }

            Application xlsApp = new Application();

            if (xlsApp == null)
            {
                return("");
            }

            string NomeSimples = tblTitulo.Rows[0]["NOME"].ToString().Replace(" ", "") +
                                 "_" + clFuncoes.GetDataParcial(Convert.ToDateTime(pAtualiza.Value), tblTitulo.Rows[0]["TIPO_ARMAZENAGEM"].ToString());

            string Nome = clFuncoes.GetProperties("fTempDirUsuario").ToString() + NomeSimples + ".pdf";

            Workbook  workbook  = xlsApp.Workbooks.Open(Arquivo);
            Worksheet worksheet = workbook.Sheets[Convert.ToInt32(tblTitulo.Rows[0]["NUM_PLAN_PDF"].ToString())] as Worksheet;

            worksheet.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, @Nome, XlFixedFormatQuality.xlQualityStandard);

            //GC.Collect();
            // GC.WaitForPendingFinalizers();

            workbook.Close(true);
            workbook = null;

            xlsApp.Quit();
            xlsApp = null;

            if (Armazenar)
            {
                sCommand.CommandText = "UPDATE EXCEL_TITULOS" +
                                       " SET DT_GERACAO = @DT_GERACAO" +
                                       ", HR_GERACAO = @HR_GERACAO" +
                                       " WHERE COD_TITULO = @COD_TITULO";

                string sAux = clFuncoes.ExecNonQuery(sCommand);

                sAux = NomeSimples + ".pdf";

                adicionaAnexoBase(Convert.ToInt32(pCodigo.Value),
                                  @Nome,
                                  "PDF",
                                  sAux,
                                  Convert.ToDateTime(pAtualiza.Value),
                                  pHrAtualiza.Value.ToString());
            }

            return(@Nome);
        }
示例#5
0
        public bool ValidaLogin(string usuario, string senha, DateTime DtMovto)
        {
            bool lRetorno = false;

            ClassWebBI.Dados.ClassParametros clParametros = new Dados.ClassParametros();
            clParametros.getParametro();

            ClassFuncoes clFuncoes = new ClassWebBI.ClassFuncoes();

            DataTable tblUsuarios = new DataTable();

            SqlCommand sCommand = new SqlCommand();

            SqlParameter pUsuario = new SqlParameter("@ID_USUARIO", System.Data.SqlDbType.VarChar, 20);

            sCommand.Parameters.Add(pUsuario);
            sCommand.Parameters["@ID_USUARIO"].Value = usuario;

            SqlParameter pSenha = new SqlParameter("@SENHA", System.Data.SqlDbType.VarChar, 20);

            sCommand.Parameters.Add(pSenha);
            sCommand.Parameters["@SENHA"].Value = senha;

            sCommand.CommandText = "SELECT COD_USUARIO, NOME, ID_USUARIO, SENHA, MAIL FROM USUARIOS" +
                                   " WHERE ID_USUARIO = @ID_USUARIO" +
                                   "   AND SENHA   = @SENHA";

            tblUsuarios = clFuncoes.ExecReader(sCommand);

            if (tblUsuarios.Rows.Count > 0)
            {
                lRetorno = true;

                if (DtMovto > clParametros.fdt_limite_atualizacao)
                {
                    DtMovto = clParametros.fdt_limite_atualizacao;
                }

                clFuncoes.SetProperties("fData", DtMovto.ToShortDateString());
                clFuncoes.SetProperties("fCodUsuario", Convert.ToInt32(tblUsuarios.Rows[0]["COD_USUARIO"].ToString()));
                clFuncoes.SetProperties("fNomeUsuario", tblUsuarios.Rows[0]["NOME"].ToString());
                clFuncoes.SetProperties("fMail", tblUsuarios.Rows[0]["MAIL"].ToString());
                clFuncoes.SetProperties("fUsuario", tblUsuarios.Rows[0]["ID_USUARIO"].ToString());
                clFuncoes.SetProperties("fSenha", tblUsuarios.Rows[0]["SENHA"].ToString());

                string sDir = clFuncoes.GetProperties("fTempDir").ToString();
                if (!File.Exists(@sDir))
                {
                    Directory.CreateDirectory(@sDir);
                }

                sDir = clFuncoes.GetProperties("fTempDir").ToString() + "\\" + clFuncoes.GetProperties("fUsuario").ToString();
                if (!File.Exists(@sDir))
                {
                    Directory.CreateDirectory(@sDir);
                }

                sDir = sDir + "\\";
                clFuncoes.SetProperties("fTempDirUsuario", @sDir);
            }

            return(lRetorno);
        }