private void CarregaTela() { switch (optTipo.SelectedValue) { case "1": case "3": if (InicializaRelatorio(txtCodEmpresa.Text, txtCodMatricula.Text, "01/01/2015")) { ReportCrystal.VisualizaRelatorio(); grdExtratoPrevidenciario.Visible = false; ifExtratoPrevSysDocs.Visible = false; ReportCrystal.Visible = true; } ; break; case "2": extratoPrevidenciarioBLL CredReeBLL = new extratoPrevidenciarioBLL(); grdExtratoPrevidenciario.DataSource = CredReeBLL.ListaPeriodos(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), DateTime.Parse(txtDtIni.Text), DateTime.Parse(txtDtFim.Text)); grdExtratoPrevidenciario.DataBind(); grdExtratoPrevidenciario.Visible = true; ifExtratoPrevSysDocs.Visible = false; ReportCrystal.Visible = false; break; default: CarregarExtratoPrevSysDocs(); grdExtratoPrevidenciario.Visible = false; ifExtratoPrevSysDocs.Visible = true; break; } }
private void CarregarDropDown() { int CodEmpresa, CodMatricula; if (int.TryParse(txtCodEmpresa.Text, out CodEmpresa) && int.TryParse(txtCodMatricula.Text, out CodMatricula)) { extratoPrevidenciarioBLL extPrevBLL = new extratoPrevidenciarioBLL(); CarregaDropDowDT(extPrevBLL.ListaPeriodos(CodEmpresa, CodMatricula), ddlPeriodo); } }
protected void Page_Load(object sender, EventArgs e) { string detalhado = Request.QueryString["hidDetalhado"] ?? "false"; string visualizar = Request.QueryString["hidVisualizar"] ?? "true"; string COD_EMPRS = Request.QueryString["nempr"]; string NUM_RGTRO_EMPRG = Request.QueryString["nreg"]; string PARTICIPANTEEMAIL = Request.QueryString["ParticipanteEmail"]; NUM_IDNTF_RPTANT = Util.String2Int32(Request.QueryString["nrepr"]); ScriptManager.RegisterStartupScript(UpdatePanel, UpdatePanel.GetType(), "script", "_client_side_script()", true); Page.Form.DefaultButton = btnPesquisar.UniqueID; if (!IsPostBack) { //for (int Ano = 2002; Ano <= DateTime.Now.Year; Ano++) //{ // ddlAnoDe.Items.Add(new ListItem(Ano.ToString(), Ano.ToString())); // ddlAnoAte.Items.Add(new ListItem(Ano.ToString(), Ano.ToString())); //} if (!String.IsNullOrEmpty(COD_EMPRS) && !String.IsNullOrEmpty(NUM_RGTRO_EMPRG)) { txtCodEmpresa.Text = COD_EMPRS; txtCodMatricula.Text = NUM_RGTRO_EMPRG; if (!String.IsNullOrEmpty(PARTICIPANTEEMAIL) && PARTICIPANTEEMAIL != "undefined") { txtEMail.Text = PARTICIPANTEEMAIL; } CarregarDropDown(); if (NUM_IDNTF_RPTANT == null || NUM_IDNTF_RPTANT == 0) { extratoPrevidenciarioBLL CredReeBLL = new extratoPrevidenciarioBLL(); grdExtratoPrevidenciario.DataSource = CredReeBLL.ListaPeriodos(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), Util.PrimeiroDiaMes(DateTime.Now.AddMonths(-6)), Util.UltimoDiaMes(DateTime.Now)); grdExtratoPrevidenciario.DataBind(); grdExtratoPrevidenciario.Visible = true; ifExtratoPrevSysDocs.Visible = false; //ReportCrystal.Visible = false; } } } else { RegraTela(); } }
private bool InicializaDadosEMail(string CodEmpresa, string CodMatricula, string DataBase) { txtEMail.Text = txtEMail.Text.Trim(); if (String.IsNullOrEmpty(txtEMail.Text)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nE-Mail obrigatório"); return(false); } else if (!Util.ValidaEmail(txtEMail.Text)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nE-Mail inválido"); return(false); } if (epDados == null) { extratoPrevidenciarioBLL extPrevBLL = new extratoPrevidenciarioBLL(); epDados = extPrevBLL.Consultar(int.Parse(CodEmpresa), int.Parse(CodMatricula)); } ArquivoDownload newAd = new ArquivoDownload(); switch (optTipo.SelectedValue) { case "1": newAd.nome_arquivo = nome_anexo_extrato + DateTime.Today.ToString("yyyy_MM_dd") + ".pdf"; break; case "2": newAd.nome_arquivo = nome_anexo_extrato + DateTime.Parse(DataBase).ToString("yyyy_MM_dd") + ".pdf"; break; case "3": newAd.nome_arquivo = nome_anexo_ficha + DateTime.Today.ToString("yyyy_MM_dd") + ".pdf"; break; case "4": MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nOpção inválida"); ReportCrystal.Visible = false; return(false); } newAd.dados = ReportCrystal.ExportarRelatorioPdf(); lstAdPdf.Add(newAd); return(true); }
private bool ValidarCampos() { int CodEmpresa, CodMatricula; DateTime DtIni, DtFim; bool detalhado = (optTipo.SelectedValue == "2"); //(TabContainer.ActiveTabIndex > 0); bool periodo_anterior = (optTipo.SelectedValue == "4"); //(TabContainer.ActiveTabIndex > 0); ReportCrystal.Visible = false; ifExtratoPrevSysDocs.Visible = false; if (String.IsNullOrEmpty(txtCodEmpresa.Text) || String.IsNullOrEmpty(txtCodMatricula.Text)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nOs campos Nº Empresa e Nº Matrícula são obrigatórios"); ddlPeriodo.Items.Clear(); return(false); } else if (!int.TryParse(txtCodEmpresa.Text, out CodEmpresa) || !int.TryParse(txtCodMatricula.Text, out CodMatricula)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nCampo Empresa ou Matrícula inválido"); ddlPeriodo.Items.Clear(); return(false); } if (NUM_IDNTF_RPTANT != null && NUM_IDNTF_RPTANT > 0) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nConsulta não permitida para Representante, Dependente ou Designado Responsável"); ddlPeriodo.Items.Clear(); return(false); } if (detalhado || periodo_anterior) { if (String.IsNullOrEmpty(txtDtIni.Text) || String.IsNullOrEmpty(txtDtFim.Text)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nOs campos do Período são obrigatórios"); return(false); } else if (!DateTime.TryParse(txtDtIni.Text, out DtIni) || !DateTime.TryParse(txtDtFim.Text, out DtFim)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nPeríodo de emissão inválido"); return(false); } txtDtIni.Text = Util.PrimeiroDiaMes(DtIni).ToString("dd/MM/yyyy"); txtDtFim.Text = Util.UltimoDiaMes(DtFim).ToString("dd/MM/yyyy"); } if (ddlPeriodo.Items.Count == 0) { CarregarDropDown(); } extratoPrevidenciarioBLL extPrevBLL = new extratoPrevidenciarioBLL(); epDados = extPrevBLL.Consultar(CodEmpresa, CodMatricula); if (String.IsNullOrEmpty(epDados.empresa) && String.IsNullOrEmpty(epDados.registro)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nExtrato Previdenciário não localizado para a matrícula " + txtCodMatricula.Text); ddlPeriodo.Items.Clear(); return(false); } //if ((string.IsNullOrEmpty(ddlPeriodo.SelectedValue) || ddlPeriodo.SelectedValue == "0") && detalhado) //{ // MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nO campo período é obrigatório para o extrato detalhado"); // return false; //} //if (ddlAnoDe.SelectedValue == "0" && // ddlAnoAte.SelectedValue == "0" && // ddlTrimestreDe.SelectedValue == "0" && // ddlTrimestreAte.SelectedValue == "0" && periodo_anterior) //{ // MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nOs campos período (de/até) são obrigatórios para a pesquisa"); // return false; //} return(true); }
//protected void btnVisualizar_Click(object sender, EventArgs e) //{ // if (ValidarCampos()) // { // switch (optTipo.SelectedValue) // { // case "1": // case "2": // case "3": // if (InicializaRelatorio(txtCodEmpresa.Text, txtCodMatricula.Text, "01/01/2015")) // { // ReportCrystal.VisualizaRelatorio(); // ifExtratoPrevSysDocs.Visible = false; // ReportCrystal.Visible = true; // }; // break; // default: // CarregarExtratoPrevSysDocs(); // ifExtratoPrevSysDocs.Visible = true; // break; // } // } //} private void CarregarExtratoPrevSysDocs() { if (!ValidarCampos()) { return; } extratoPrevidenciarioBLL CredReeBLL = new extratoPrevidenciarioBLL(); List <UsuarioPortal> usPortal = CredReeBLL.ConsultarRepresentantes(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), NUM_IDNTF_RPTANT); DateTime DtIni, DtFim; string fullUrl = ""; if (usPortal.Count > 0) { UsuarioPortal userPortal = usPortal[0]; DateTime.TryParse(txtDtIni.Text, out DtIni); DateTime.TryParse(txtDtFim.Text, out DtFim); string cp01 = userPortal.COD_EMPRS.ToString().PadLeft(3, '0'); //empresaFormat.format(dcVo.getEmpresa()); string cp02 = userPortal.NUM_RGTRO_EMPRG.ToString().PadLeft(10, '0'); //matriculaFormat.format(dcVo.getMatricula()); string cp03 = userPortal.NUM_DIGVR_EMPRG.ToString(); //string cp04 = ddlAnoDe.SelectedValue; //anoInicio; //string cp05 = ddlAnoAte.SelectedValue; //anoFim; //string cp06 = ddlTrimestreDe.SelectedValue; //mesInicio; //string cp07 = ddlTrimestreAte.SelectedValue; //mesFim; string cp04 = DtIni.Year.ToString(); //anoInicio; string cp05 = DtFim.Year.ToString(); //anoFim; string cp06 = DtIni.Month.ToString(); //mesInicio; string cp07 = DtFim.Month.ToString(); //mesFim; string cp08 = userPortal.NomeCompleto.ToString().Replace(' ', '_'); //"0"; //dcVo.getNome().replace(' ', '_'); string cp09 = userPortal.CPF.ToString(); //0; //dcVo.getCpf(); string strUrl = String.Format("https://docs.prevcesp.com.br/ged/idocs_portal_ticket.php?BdTypeName={0}&CP01={1}&CP02={2}&CP03={3}&CP04={4}&CP05={5}&CP06={6}&CP07={7}&CP08={8}&CP09={9}", 2, //tp_contrib.php cp01, cp02, cp03, cp04, cp05, cp06, cp07, cp08, cp09); try { WebRequest request = WebRequest.Create(strUrl); request.Credentials = CredentialCache.DefaultCredentials; WebResponse response = request.GetResponse(); Console.WriteLine(((HttpWebResponse)response).StatusDescription); Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string responseFromServer = reader.ReadToEnd(); Console.WriteLine(responseFromServer); if (responseFromServer.Split('|').Length > 1) { string token = responseFromServer.Split('|')[1]; fullUrl = "https://docs.prevcesp.com.br/ged/idocs_portal_procrel.php?ticket=" + token; ifExtratoPrevSysDocs.Src = fullUrl; //AdicionarAcesso(fullUrl); //AbrirNovaAba(UpdatePanel, fullUrl, "Sysdocs"); } reader.Close(); response.Close(); } catch (Exception ex) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nErro ao consultar o Sysdocs.\\nMotivo:\\n" + ex.Message); return; } } else { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nSysDoc não disponível para esta Empresa e Matrícula"); } }