protected void dgtListaColchones_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { this.listaColchones = new List <Colchon>(); this.tabla = new DataTable(); this.tabla.Columns.Add(new DataColumn("NumeroColchon", typeof(int))); this.tabla.Columns.Add(new DataColumn("Estado", typeof(string))); for (int i = 0; i < this.dgtListaColchones.Rows.Count; i++) { if (Convert.ToInt32(dgtListaColchones.DataKeys[e.RowIndex].Value) != int.Parse(this.dgtListaColchones.Rows[i].Cells[0].Text)) { this.colchon = new Colchon(); this.colchon.numeroColchon = int.Parse(this.dgtListaColchones.Rows[i].Cells[0].Text); this.colchon.estado = this.dgtListaColchones.Rows[i].Cells[1].Text; this.listaColchones.Add(this.colchon); } } for (int i = 0; i < this.listaColchones.Count; i++) { DataRow fila = tabla.NewRow(); fila["NumeroColchon"] = this.listaColchones[i].numeroColchon; fila["Estado"] = this.listaColchones[i].estado; this.tabla.Rows.Add(fila); } this.dgtListaColchones.DataSource = this.tabla; this.dgtListaColchones.DataBind(); } catch (Exception ex) { throw ex; } }
private void recargarTabla() { try { this.entidades = new AEUSP(); var colchonSolicitado = this.entidades.SP_CNS_COLCHONPORNUMERO(int.Parse(this.cboxColchones.Text)); if (colchonSolicitado != null) { this.tabla = new DataTable(); this.tabla.Columns.Add(new DataColumn("NumeroColchon", typeof(int))); this.tabla.Columns.Add(new DataColumn("Estado", typeof(string))); this.listaColchones = new List <Colchon>(); //Se almancena el colchon solicitado nuevamente this.colchon = new Colchon(); this.colchon.numeroColchon = colchonSolicitado.Single().numeroColchon; colchonSolicitado = null; colchonSolicitado = this.entidades.SP_CNS_COLCHONPORNUMERO(int.Parse(this.cboxColchones.Text)); this.colchon.estado = colchonSolicitado.Single().Estado; colchonSolicitado = null; colchonSolicitado = this.entidades.SP_CNS_COLCHONPORNUMERO(int.Parse(this.cboxColchones.Text)); this.listaColchones.Add(this.colchon); //Se obtienen los datos almacenados en la tabla for (int i = 0; i < this.dgtListaColchones.Rows.Count; i++) { if (int.Parse(this.dgtListaColchones.Rows[i].Cells[0].Text) == colchonSolicitado.Single().numeroColchon) { this.listaColchones.RemoveAt(0); } this.colchon = new Colchon(); this.colchon.numeroColchon = int.Parse(this.dgtListaColchones.Rows[i].Cells[0].Text); this.colchon.estado = this.dgtListaColchones.Rows[i].Cells[1].Text; this.listaColchones.Add(this.colchon); colchonSolicitado = null; colchonSolicitado = this.entidades.SP_CNS_COLCHONPORNUMERO(int.Parse(this.cboxColchones.Text)); } //Se procede a llenar la tabla for (int i = 0; i < this.listaColchones.Count; i++) { DataRow fila = tabla.NewRow(); fila["NumeroColchon"] = this.listaColchones[i].numeroColchon; fila["Estado"] = this.listaColchones[i].estado; this.tabla.Rows.Add(fila); } this.dgtListaColchones.DataSource = this.tabla; this.dgtListaColchones.DataBind(); } this.btnPrestar.Visible = true; this.btnLimpiar.Visible = true; } catch (Exception ex) { throw ex; } }