protected void Rale1_SelectedIndexChanged(object sender, EventArgs e) { LabelMensaje.Visible = false; RadioButtonList1.Enabled = false; RadioButtonList1.ClearSelection(); RadioButtonList2.Enabled = false; RadioButtonList2.ClearSelection(); fecha1.Items.Clear(); fecha1.Items.Add(new ListItem("-- Seleccione el Periodo Inicial --", "")); fecha1.Enabled = false; fecha2.Items.Clear(); fecha2.Items.Add(new ListItem("-- Seleccione el Periodo Final --", "")); fecha2.Enabled = false; Rale2.Items.Clear(); Rale2.Items.Add(new ListItem("-- Selecciona Rale a Comparar --", "")); Rale2.AppendDataBoundItems = true; String strConnString = ConfigurationManager.ConnectionStrings["SupervisionConnectionString"].ConnectionString; String strQuery = "SELECT CONVERT(NVARCHAR, [fecha_rale], 105) AS MOSTRAR,CONVERT(NVARCHAR, [fecha_rale], 105) AS VALUE,CONVERT (NVARCHAR, fecha_rale, 112) AS VALUE1 FROM [Supervision].[dbo].[Rales_Combo] WHERE [tipo_rale]= @TIPO AND [fecha_rale] > @FEC ORDER BY VALUE1 ASC"; SqlConnection con = new SqlConnection(strConnString); SqlCommand cmd = new SqlCommand(); cmd.Parameters.AddWithValue("@TIPO", Tipo_Rale.SelectedItem.Value); cmd.Parameters.AddWithValue("@FEC", Rale1.SelectedItem.Value); cmd.CommandType = CommandType.Text; cmd.CommandText = strQuery; cmd.Connection = con; try { con.Open(); Rale2.DataSource = cmd.ExecuteReader(); Rale2.DataTextField = "MOSTRAR"; Rale2.DataValueField = "VALUE"; Rale2.DataBind(); if (Rale2.Items.Count > 1) { Rale2.Enabled = true; } else { Rale2.Enabled = false; } } catch (Exception ex) { throw ex; } finally { con.Close(); con.Dispose(); } }
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { if (RadioButtonList1.SelectedValue == "1") { Literal5.Text = ""; Panel3.Visible = false; Panel2.Visible = true; GridView1.Visible = false; GridView2.Visible = false; Rale1.Items.Clear(); Rale1.Items.Add(new ListItem("-- Selecciona Rale --", "")); Rale1.Enabled = false; TIPO.Items.Clear(); TIPO.Items.Add(new ListItem("-- Selecione la Subdelegación --", "")); TIPO.Enabled = false; incidencia.Items.Clear(); incidencia.Items.Add(new ListItem("-- Seleccione Incidencia --", "")); incidencia.Enabled = false; Tipo_Rale.Items.Clear(); Tipo_Rale.Items.Add(new ListItem("-- Selecciona Tipo de Rale --", "")); Tipo_Rale.Enabled = true; Tipo_Rale.AppendDataBoundItems = true; String strQuery = "SELECT DISTINCT [tipo_rale] as id,[tipo_rale] as des FROM [Supervision].[dbo].[Rales_Combo]"; SqlConnection con = new SqlConnection(strConnString); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = strQuery; cmd.Connection = con; try { con.Open(); Tipo_Rale.DataSource = cmd.ExecuteReader(); Tipo_Rale.DataTextField = "des"; Tipo_Rale.DataValueField = "id"; Tipo_Rale.DataBind(); } catch (Exception ex) { throw ex; } finally { con.Close(); con.Dispose(); } } else { if (RadioButtonList1.SelectedValue == "2") { Literal5.Text = ""; Encabezado.Visible = false; EncabezadoSegundaTabla.Visible = false; GridView3.Visible = false; Panel2.Visible = false; Panel3.Visible = true; GridView1.Visible = false; Rale2.Items.Clear(); Reg_Pat.Text = null; Rale2.Items.Add(new ListItem("-- Selecciona Rale --", "")); Rale2.AppendDataBoundItems = true; String strQuery = "SELECT CONVERT(NVARCHAR, fecha_rale, 105) AS MOSTRAR, CONVERT (NVARCHAR, fecha_rale, 105) AS VALUE, CONVERT (NVARCHAR, fecha_rale, 102) AS VALUE1 FROM Rales_Combo WHERE (tipo_rale = 'COP' ) ORDER BY VALUE1 ASC"; SqlConnection con = new SqlConnection(strConnString); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = strQuery; cmd.Connection = con; try { con.Open(); Rale2.DataSource = cmd.ExecuteReader(); Rale2.DataTextField = "MOSTRAR"; Rale2.DataValueField = "VALUE"; Rale2.DataBind(); if (Rale2.Items.Count > 1) { Rale2.Enabled = true; } else { Rale2.Enabled = false; } } catch (Exception ex) { throw ex; } finally { con.Close(); con.Dispose(); } } } }