Exemple #1
0
        protected void Grid_Medicamento_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            LlenarGridMedicamento();

            Grid_Medicamento.PageIndex = e.NewPageIndex;
            Grid_Medicamento.DataBind();
        }
Exemple #2
0
        public void LlenarGridMedicamento()
        {
            string conexion = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;

            SqlConnection cnn;

            cnn = new SqlConnection(conexion);

            cnn.Open();

            SqlCommand comando = new SqlCommand("SP_Catalogo_Clientes", cnn);

            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@Opcion", "LISTADO");
            if (!(txtBuscar_Medicamento.Text == ""))
            {
                string   s        = txtBuscar_Medicamento.Text;
                string[] palabras = s.Split(' ');
                int      i        = 0;
                foreach (string palabra in palabras)
                {
                    if (i <= 4)
                    {
                        string NDescripcion = "@Nombre" + i;
                        comando.Parameters.AddWithValue(NDescripcion, palabra);
                        i++;
                        Console.WriteLine(palabra);
                    }
                }
            }
            else
            {
                comando.Parameters.AddWithValue("@Nombre", "");
            }

            /*
             *  0  Id_Empresa
             *  1  Nombre_Empresa
             */

            SqlDataAdapter da = new SqlDataAdapter(comando);
            DataTable      ds = new DataTable();

            da.Fill(ds);
            Grid_Medicamento.Visible            = true;
            Grid_Medicamento.DataSource         = ds;
            Grid_Medicamento.Columns[0].Visible = true;
            Grid_Medicamento.Columns[1].Visible = true;
            Grid_Medicamento.Columns[2].Visible = true;
            Grid_Medicamento.Columns[3].Visible = true;
            Grid_Medicamento.Columns[4].Visible = true;
            Grid_Medicamento.DataBind();
            ds.Dispose();
            da.Dispose();
            txtBuscar_Medicamento.Focus();
        }