protected void Button1_Click(object sender, EventArgs e) { DataTable dt = Session["DescarteDetalle"] as DataTable; descarte = new DescarteAD(); string fecha = txtFecha.Text; int idBodegaOrigen = Convert.ToInt32(ddlBodegaOrigen.SelectedValue); int id = descarte.InsertDescarte(fecha, idBodegaOrigen); if (id > 0) { for (int i = 1; i < dt.Rows.Count; i++) { int idMedicamento = Convert.ToInt32(dt.Rows[i]["Medicamento"]); int idLote = Convert.ToInt32(dt.Rows[i]["Lote"]); int cantidad = Convert.ToInt32(dt.Rows[i]["Cantidad"]); string motivo = (string)dt.Rows[i]["Motivo"]; if (!descarte.InsertDescarteDetalle(id, idMedicamento, idLote, cantidad, motivo)) { Response.Write("<script>window.alert('Descarte Detalle Fallido')</script>"); } } Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri); } else { Response.Write("<script>window.alert('Descarte Fallido')</script>"); } }
protected void Page_Load(object sender, EventArgs e) { descarte = new DescarteAD(); if (!IsPostBack) { GridLoad(); descarte.DropBodega(ddlBodegaOrigen); descarte.DropMedicamento((DropDownList)grdDescarteDetalle.FooterRow.FindControl("ddlInsertMedicamento")); descarte.DropLote((DropDownList)grdDescarteDetalle.FooterRow.FindControl("ddlInsertLote")); } }