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); }
private void Inicializa() { ClassWebBI.ClassFuncoes clFuncoes = new ClassWebBI.ClassFuncoes(); lblVersao.Text = AssemblyVersion; lblData.Text = Convert.ToDateTime(clFuncoes.GetProperties("fData")).ToString("dd/MM/yyyy"); lblUsuario.Text = clFuncoes.GetProperties("fUsuario").ToString() + " - " + clFuncoes.GetProperties("fNomeUsuario").ToString() + " (" + clFuncoes.GetProperties("fMail").ToString() + ")"; if (DateTime.Today.ToString("dd/MM/yyyy") != lblData.Text) { lblData.ForeColor = Color.Red; } }
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); }
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); }
public void LimpaDiretorioUsuarioLogado() { ClassWebBI.ClassFuncoes clFuncoes = new ClassWebBI.ClassFuncoes(); string sDir = clFuncoes.GetProperties("fTempDirUsuario").ToString(); try { Directory.Delete(sDir, true); } catch { } }
private void btnConfirmar_Click(object sender, EventArgs e) { if (edtDe.Text == "") { MessageBox.Show("Configure o usuário de origem !", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cbxPara.Text == "") { MessageBox.Show("Informe o usuário de destino !", "Informações", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (edtAssunto.Text == "") { MessageBox.Show("Informe o assunto !", "Informações", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (edtMensagem.Text == "") { MessageBox.Show("Informe a mensagem !", "Informações", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ClassWebBI.ClassFuncoes clFuncoes = new ClassWebBI.ClassFuncoes(); ClassWebBI.Dados.ClassUsuarios clUsuarios = new ClassWebBI.Dados.ClassUsuarios(); clUsuarios.getUsuario(Convert.ToInt32(clFuncoes.GetProperties("fCodUsuario").ToString())); clFuncoes.EnviaMail(clUsuarios.fservidor_mail, clUsuarios.fporta_mail, clUsuarios.fendereco_mail, cbxPara.Text, edtAssunto.Text, edtMensagem.Text, clUsuarios.fusuario_mail, clUsuarios.fsenha_mail, clUsuarios.fssl, edtAnexo.Text); this.DialogResult = System.Windows.Forms.DialogResult.OK; }
public bool podeEnviarMail() { bool lPode = false; ClassWebBI.ClassFuncoes clFuncoes = new ClassWebBI.ClassFuncoes(); DateTime dData = Convert.ToDateTime(clFuncoes.GetProperties("fData")); if (ftipo_envio == "S") { lPode = testaDiaSemana(dData); } if (ftipo_envio == "M") { lPode = testaDiaMes(dData); } return(lPode); }
public void Inicializa() { DataTable tblAssinaturas = new DataTable(); ClassWebBI.ClassFuncoes clFuncoes = new ClassWebBI.ClassFuncoes(); ClassWebBI.Dados.ClassExcel clExcel = new ClassWebBI.Dados.ClassExcel(); ClassWebBI.Dados.ClassTitulos clTitulos = new ClassWebBI.Dados.ClassTitulos(); ClassWebBI.Dados.ClassParametros clParametros = new ClassWebBI.Dados.ClassParametros(); ClassWebBI.Dados.ClassAssinaturas clAssinaturas = new ClassWebBI.Dados.ClassAssinaturas(); clParametros.getParametro(); clTitulos.getTitulo(iCodTitulo); clExcel.getExcel(clTitulos.fcod_excel); edtDe.Text = clFuncoes.GetProperties("fMail").ToString(); edtAssunto.Text = clParametros.fmail_assunto; edtMensagem.Text = clParametros.fmail_mensagem; if (clExcel.fmail_mensagem != "") { edtMensagem.Text = clExcel.fmail_mensagem; } if (clExcel.fmail_assunto != "") { edtAssunto.Text = clExcel.fmail_assunto; } edtAnexo.Text = clExcel.abrirArquivoPDF(iCodAnexo, false, true); tblAssinaturas = clAssinaturas.getAssinaturas(iCodTitulo, "USUARIOS.MAIL"); for (int i = 0; i <= tblAssinaturas.Rows.Count - 1; i++) { cbxPara.Items.Add(tblAssinaturas.Rows[i]["MAIL"].ToString()); } }
private void btnParametros_Click(object sender, EventArgs e) { if (Convert.ToBoolean(new ClassWebBI.ClassFuncoes().GetProperties("fAdministrador")) == false) { MessageBox.Show("Usuário não tem permissão para realizar esta ação.", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } FormParametros frmParametros = new FormParametros(); frmParametros.ShowDialog(); ClassWebBI.Dados.ClassParametros clParametros = new ClassWebBI.Dados.ClassParametros(); clParametros.getParametro(); ClassWebBI.ClassFuncoes clFuncoes = new ClassWebBI.ClassFuncoes(); if (Convert.ToDateTime(clFuncoes.GetProperties("fData")) > clParametros.fdt_limite_atualizacao) { clFuncoes.SetProperties("fData", clParametros.fdt_limite_atualizacao.ToShortDateString()); Inicializa(); } }
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); }
public void atualizaExcel(int CodExcel) { string Arquivo = salvaArquivoExcel(CodExcel); if (!File.Exists(Arquivo)) { return; } Application xlsApp = new Application(); if (xlsApp == null) { return; } Workbook workbook = xlsApp.Workbooks.Open(Arquivo); workbook.RefreshAll(); workbook.Close(true); workbook = null; xlsApp.Quit(); xlsApp = null; GC.Collect(); GC.WaitForPendingFinalizers(); ClassWebBI.ClassFuncoes clFuncoes = new ClassWebBI.ClassFuncoes(); SqlCommand sCommand = new SqlCommand(); SqlParameter pCodigo = new SqlParameter("@COD_EXCEL", System.Data.SqlDbType.Int); sCommand.Parameters.Add(pCodigo); sCommand.Parameters["@COD_EXCEL"].Value = CodExcel; SqlParameter pAtualiza = new SqlParameter("@DT_ATUALIZA", System.Data.SqlDbType.DateTime); sCommand.Parameters.Add(pAtualiza); sCommand.Parameters["@DT_ATUALIZA"].Value = clFuncoes.GetProperties("fData"); SqlParameter pHrAtualiza = new SqlParameter("@HR_ATUALIZA", System.Data.SqlDbType.VarChar, 5); sCommand.Parameters.Add(pHrAtualiza); sCommand.Parameters["@HR_ATUALIZA"].Value = DateTime.Now.ToString("HH:mm"); byte[] fArquivo = null; fArquivo = clFuncoes.CarregarArquivo(Arquivo); SqlParameter pExcel = new SqlParameter("@ARQUIVO", System.Data.SqlDbType.Image, fArquivo.Length); sCommand.Parameters.Add(pExcel); sCommand.Parameters["@ARQUIVO"].Value = fArquivo; sCommand.CommandText = "UPDATE EXCEL" + " SET DT_ATUALIZA = @DT_ATUALIZA" + ", ARQUIVO = @ARQUIVO" + ", HR_ATUALIZA = @HR_ATUALIZA" + " WHERE COD_EXCEL = @COD_EXCEL"; string sAux = clFuncoes.ExecNonQuery(sCommand); }
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); }