private void CarregarTela(string SortExpression) { if (IsPostBack) { ExtratoComponenteBLL CredReeBLL = new ExtratoComponenteBLL(); int iRepresentante = 0; int.TryParse(ddlRepresentante.SelectedValue, out iRepresentante); //var dadosGrid = CredReeBLL.Listar(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), iRepresentante, " ", DateTime.Parse(txtDtIni.Text), DateTime.Parse(txtDtFim.Text)); var dadosGrid = CredReeBLL.Listar(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), iRepresentante, "00", short.Parse(ddlSemestre.SelectedValue), int.Parse(ddlNumAno.SelectedValue.ToString())); DataTable dt1 = dadosGrid; DataTable tblOrdered = new DataTable(); DataView view = new DataView(); var vsSort = ViewState["SortDirection"]; if (String.IsNullOrEmpty(SortExpression)) { grdExtratoUtilizacao.DataSource = dt1; grdExtratoUtilizacao.DataBind(); return; } if (dt1.Rows.Count > 0) { if (vsSort == null) { ViewState["SortDirection"] = System.Web.UI.WebControls.SortDirection.Descending; } System.Web.UI.WebControls.SortDirection lastDirection = (System.Web.UI.WebControls.SortDirection)ViewState["SortDirection"]; if (lastDirection != System.Web.UI.WebControls.SortDirection.Ascending) { EnumerableRowCollection <DataRow> query = from row in dt1.AsEnumerable() orderby DateTime.Parse(row.Field <string>(SortExpression)) descending select row; tblOrdered = query.AsDataView().ToTable(); ViewState["SortDirection"] = System.Web.UI.WebControls.SortDirection.Ascending; } else { EnumerableRowCollection <DataRow> query = from row in dt1.AsEnumerable() orderby DateTime.Parse(row.Field <string>(SortExpression)) ascending select row; tblOrdered = query.AsDataView().ToTable(); ViewState["SortDirection"] = System.Web.UI.WebControls.SortDirection.Descending; } grdExtratoUtilizacao.DataSource = tblOrdered; grdExtratoUtilizacao.DataBind(); } } }
protected void btnPesquisar_Click(object sender, EventArgs e) { if (ValidarCampos()) { ExtratoComponenteBLL CredReeBLL = new ExtratoComponenteBLL(); int iRepresentante = 0; int.TryParse(ddlRepresentante.SelectedValue, out iRepresentante); grdExtratoUtilizacao.DataSource = CredReeBLL.Listar(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), iRepresentante, "00", short.Parse(ddlSemestre.SelectedValue), int.Parse(ddlNumAno.SelectedValue.ToString())); grdExtratoUtilizacao.DataBind(); grdExtratoUtilizacao.Visible = true; txtEMail.Enabled = true; btnEmail.Enabled = true; } }
protected void Page_Load(object sender, EventArgs e) { CarregarDropdownSemestre(); string detalhado = Request.QueryString["hidDetalhado"] ?? "false"; string visualizar = Request.QueryString["hidVisualizar"] ?? "false"; 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) { if (!String.IsNullOrEmpty(COD_EMPRS) && !String.IsNullOrEmpty(NUM_RGTRO_EMPRG)) { //ReportCrystal.Visible = false; txtCodEmpresa.Text = COD_EMPRS; txtCodMatricula.Text = NUM_RGTRO_EMPRG; if (!String.IsNullOrEmpty(PARTICIPANTEEMAIL) && PARTICIPANTEEMAIL != "undefined") { txtEMail.Text = PARTICIPANTEEMAIL; } ddlNumAno.SelectedValue = DateTime.Now.Year.ToString(); CarregarDropDown(); ExtratoComponenteBLL CredReeBLL = new ExtratoComponenteBLL(); int iRepresentante = 0; int.TryParse(ddlRepresentante.SelectedValue, out iRepresentante); grdExtratoUtilizacao.DataSource = CredReeBLL.Listar(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), iRepresentante, "00", short.Parse(ddlSemestre.SelectedValue), int.Parse(ddlNumAno.SelectedValue.ToString())); grdExtratoUtilizacao.DataBind(); grdExtratoUtilizacao.Visible = true; txtEMail.Enabled = true; btnEmail.Enabled = true; //} } } }
private void CarregarDropDown() { int CodEmpresa, CodMatricula, CodRepresentante; if (int.TryParse(txtCodEmpresa.Text, out CodEmpresa) && int.TryParse(txtCodMatricula.Text, out CodMatricula)) { ExtratoComponenteBLL CredReeBLL = new ExtratoComponenteBLL(); if (ddlRepresentante.Items.Count == 0) { List <UsuarioPortal> lstRepresentantes = CredReeBLL.ConsultarRepresentantes(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), NUM_IDNTF_RPTANT ?? 0); if (lstRepresentantes.Count == 0) { lstRepresentantes = CredReeBLL.ConsultarRepresentantes(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), null); } if (lstRepresentantes.Count > 0) { CarregaDropDowList(ddlRepresentante, lstRepresentantes.ToList <object>(), "NomeCompleto", "NUM_IDNTF_RPTANT"); ddlRepresentante.Items.RemoveAt(0); if (lstRepresentantes.Count < 2) { ddlRepresentante.SelectedIndex = 0; } } else { DataTable dt = CredReeBLL.ListarUsuarios(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), 0); if (dt.Rows.Count > 0) { CarregaDropDowDT(dt, ddlRepresentante); ddlRepresentante.Items.RemoveAt(0); for (int i = 0; i < ddlRepresentante.Items.Count; i++) { ddlRepresentante.Items[i].Value = "0"; } ddlRepresentante.SelectedIndex = 0; } } } } }
private bool InicializaDadosEMail(string CodEmpresa, string CodMatricula, string NumIdntfRptant, string NumSubMatric, string Semestre, string DatEmissao, string DatIni = " ") { 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); } ExtratoComponenteBLL ExtUtilBLL = new ExtratoComponenteBLL(); int iRepresentante = 0; int.TryParse(ddlRepresentante.SelectedValue, out iRepresentante); epDados = ExtUtilBLL.Consultar(int.Parse(CodEmpresa), int.Parse(CodMatricula), iRepresentante, 1, 2016); epDados.usuario = ddlRepresentante.SelectedItem.Text; if (String.IsNullOrEmpty(epDados.empresa) && String.IsNullOrEmpty(epDados.registro)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nDados não localizados para a matrícula " + CodMatricula); return(false); } ArquivoDownload newAd = new ArquivoDownload(); // newAd.nome_arquivo = nome_anexo + DatEmissao.Replace("/", "_") + ".pdf"; newAd.nome_arquivo = nome_anexo + ".pdf"; newAd.dados = ReportCrystal.ExportarRelatorioPdf(); lstAdPdf.Add(newAd); return(true); }
private bool ValidarCampos(bool BuscarDados = true) { int CodEmpresa, CodMatricula; int Semestre, NumAno; if (String.IsNullOrEmpty(txtCodEmpresa.Text) || String.IsNullOrEmpty(txtCodMatricula.Text)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nOs campos Empresa e Matrícula são obrigatórios"); ddlRepresentante.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"); ddlRepresentante.Items.Clear(); return(false); } if (String.IsNullOrEmpty(ddlSemestre.SelectedValue)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nO Semestre é obrigatório"); return(false); } else if (!int.TryParse(ddlSemestre.SelectedValue, out Semestre)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nSemestre inválido"); return(false); } if (String.IsNullOrEmpty(ddlNumAno.SelectedValue.ToString())) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nO Ano é obrigatório"); return(false); } else if (!int.TryParse(ddlNumAno.SelectedValue.ToString(), out NumAno)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nAno inválido"); return(false); } if (!BuscarDados) { return(true); } ExtratoComponenteBLL ExtUtilBLL = new ExtratoComponenteBLL(); int iRepresentante = 0; int.TryParse(ddlRepresentante.SelectedValue, out iRepresentante); epDados = ExtUtilBLL.Consultar(CodEmpresa, CodMatricula, iRepresentante, 1, 2016); if (String.IsNullOrEmpty(epDados.empresa) && String.IsNullOrEmpty(epDados.registro)) { MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nExtrato de Utilização não localizado para a matrícula " + txtCodMatricula.Text); ReportCrystal.Visible = false; grdExtratoUtilizacao.Visible = false; return(false); } return(true); }