protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { LayerBussines.LayerBussinesReserva oLb = new LayerBussines.LayerBussinesReserva(); Int64 ID = Convert.ToInt64(GridView1.DataKeys[e.RowIndex].Value.ToString()); try { oLb.EliminarReserva(ID); LblMsg.Text = "Reserva Eliminada"; LlenarDatos(); } catch (Exception exc) { LblMsg.Text = exc.Message.ToString(); } finally { oLb = null; } }
protected void BtnGuardar_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } else { try { oLB.InsertarReserva(Convert.ToInt64(TxtId.Text), TxtNombreSolicitante.Text, TxtElementoAPrestar.Text, Convert.ToDateTime(TxtFechaPrestao.Text), TxtObservaciones.Text, Convert.ToDateTime(Txtfechadevolucion.Text)); LblMsg.Text = "Reserva Generada"; } catch (Exception exc) { LblMsg.Text = exc.Message.ToString(); } finally { oLB = null; } } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { LayerBussines.LayerBussinesReserva olB = new LayerBussines.LayerBussinesReserva(); Int64 ID = Convert.ToInt64(GridView1.DataKeys[e.RowIndex].Value.ToString()); int result = 0; GridViewRow row = GridView1.Rows[e.RowIndex]; TextBox NS = (TextBox)row.FindControl("TxtNombreSolicitante"); TextBox EP = (TextBox)row.FindControl("TxtElementoAPrestar"); TextBox FP = (TextBox)row.FindControl("TxtFechaPrestao"); TextBox OB = (TextBox)row.FindControl("TxtObservaciones"); TextBox FD = (TextBox)row.FindControl("Txtfechadevolucion"); try { result = olB.EditarReserva(ID, NS.Text, EP.Text, Convert.ToDateTime(FP.Text), OB.Text, Convert.ToDateTime(FD.Text)); if (result > 0) { LblMsg.Text = "Reserva Editada"; } else { LblMsg.Text = "Reserva no editada"; } } catch (Exception exc) { LblMsg.Text = exc.Message.ToString(); } finally { olB = null; } GridView1.EditIndex = -1; LlenarDatos(); }
public void LlenarDatos() { LayerBussines.LayerBussinesReserva oLb = new LayerBussines.LayerBussinesReserva(); GridView1.DataSource = oLb.MostarReserva(); GridView1.DataBind(); }