private void carregaCampos(DataView dw) { if (dw == null) { return; } g_tbFiltro.Rows.Clear(); for (int i = 0; i < dw.Count; i++) { HtmlTableRow tr = new HtmlTableRow(); if ((i % 2) <= 0) { tr.Attributes.Add("class", "tr_g_alt_filtro"); } HtmlTableCell td = new HtmlTableCell(); td.Attributes.Add("class", "td_g_filtro"); td.InnerHtml = dw[i]["label"].ToString(); //célulca com os valores.. HtmlTableCell td2 = new HtmlTableCell(); td2.Attributes.Add("class", "td_g_filtro"); string[] st_lista = new String[] {}; if (dw.Table.Columns.Contains("lista") && dw[i]["lista"] != DBNull.Value && dw[i]["lista"].ToString() != String.Empty) { st_lista = new String[] { dw[i]["lista"].ToString() }; } insereCampoFiltro(td2, dw[i]["nome"].ToString(), dw[i]["tipo"].ToString(), String.Empty, st_lista, dw[i]); tr.Cells.Add(td); tr.Cells.Add(td2); g_tbFiltro.Rows.Add(tr); } HtmlTableRow mtr = new HtmlTableRow(); HtmlTableCell mtd = new HtmlTableCell("th"); mtd.InnerHtml = "<label>Ordenar por</label>"; DropDownList cmbOrdem = new DropDownList(); cmbOrdem.ID = "g_glb_cmb_ordem"; string sort_anterior = dw.Sort; dw.Sort = "primaryKey desc, label asc"; carregaCombo(cmbOrdem, dw, "nome", "label", String.Empty); dw.Sort = sort_anterior; HtmlTableCell mtd2 = new HtmlTableCell("th"); mtd2.Controls.Add(cmbOrdem); DropDownList cmbOrdenacao = new DropDownList(); cmbOrdenacao.ID = "g_glb_cmb_ordenacao"; System.Collections.Generic.IList <Entities.SimplesCodigoNome> lst = new System.Collections.Generic.List <Entities.SimplesCodigoNome>(); lst.Add(new Entities.SimplesCodigoNome("ASC", "Ascendente")); lst.Add(new Entities.SimplesCodigoNome("DESC", "Descendente")); carregaCombo(cmbOrdenacao, lst, "Codigo", "Nome", String.Empty); mtd2.Controls.Add(cmbOrdenacao); mtr.Cells.Add(mtd); mtr.Cells.Add(mtd2); g_tbFiltro.Rows.Add(mtr); Control cr_bt = Utilities.Format.localizaControl("btPesquisar", this.Page.Form); if (cr_bt != null) { if (NoClearAction == String.Empty) { this.bt_glob_search.OnClientClick = "document.forms[0].action='" + Request.ServerVariables["URL"].ToString() + "'; " + this.Page.GetPostBackEventReference(cr_bt) + "; return false"; } else { this.bt_glob_search.OnClientClick = this.Page.GetPostBackEventReference(cr_bt) + "; return false"; } } else { this.bt_glob_search.OnClientClick = "document.forms[0].action = 'listar" + PageCadastroBase.SplitCamelCase(this.Tabela) + ".aspx';document.forms[0].__VIEWSTATE.value=''; document.forms[0].submit(); return false"; } Control cr_bt2 = Utilities.Format.localizaControl("btExportar", this.Page.Form); if (cr_bt2 != null) { this.imgExportaExcel.OnClientClick = this.Page.GetPostBackEventReference(cr_bt2) + "; return false"; this.imgExportaExcel.Visible = true; } else { this.imgExportaExcel.Visible = false; } //getRequest(Button1.ID) if (getRequest("__EVENTTARGET") != String.Empty && getRequest("__EVENTTARGET").IndexOf(Button1.ID) > -1 && getRequest("__EVENTTARGET").IndexOf(this.ID) > -1) { Utilities.JavaScript.ExecuteScript(this.Page, "uc_filtro_avancado", "document.getElementById('" + div_filtro_avancado.ClientID + "').style.display='block';", true); } }
public DataView getCampos() { string str_driver = PageCadastroBase.getExcelDriver(); if (str_driver == "") { str_driver = "Microsoft Excel Driver (*.xls)"; } string conexao = "Driver={" + str_driver + "};DriverId=790;DBQ=" + this.CaminhoExcel + ";ReadOnly= true ; "; //conn.ConnectionString = conexao; ConnODBC OdbcConn = null; try { IDbPersist oTmp = FactoryConn.getConn("odbc", conexao, "odbc"); OdbcConn = (ConnODBC)oTmp; //conn.Open(); } catch (Exception exp) { Trace.Write("Erro ao tentar conectar o banco de dados de filtro via ODBC: " + exp.Message + " - Arquivo em formato inválido! - String de Conexão:" + conexao); //Alert("Erro ao tentar conectar o banco de dados de filtro via ODBC: " + // exp.Message + " - Arquivo em formato inválido! "); return(null); } OdbcConnection conn = (OdbcConnection)OdbcConn.getConn(); string[] restrictions = new string[4]; restrictions[3] = "Table"; DataTable userTables = conn.GetSchema("Tables"); string my_tabela = this.Tabela; for (int i = 0; i < userTables.Rows.Count; i++) { string tab_col = userTables.Rows[i][2].ToString(); if (userTables.Rows[i][3].ToString().IndexOf("TABLE") > -1 && tab_col == this.Tabela + "$") { my_tabela = userTables.Rows[i][2].ToString(); break; } } DataTable dt_campos = ConnAccess.fetchData(OdbcConn, "select * from [" + my_tabela + "] where visivel = 'True' order by tipo desc, ordem asc, label asc "); //primaryKey desc, label, conn.Close(); conn.Dispose(); string add_filtro = string.Empty; if (dt_campos.Columns.Contains("filtro")) { add_filtro += " and filtro = '1' "; } DataView dw = dt_campos.DefaultView; return(dw); }