protected void btnPublicar_Click(object sender, EventArgs e) { try { List<LABORATORIO> laboratorios = Session["laboratorios"] as List<LABORATORIO>; Guid idLaboratorio = Guid.Empty; DateTime fechaInicio; IVentas bdd = new BusinessLogic(); CheckBox chkPublicar = null; fechaInicio = (DateTime)Session["fechaInicio"]; bdd.PublicarVentas(fechaInicio); GridCiclos.Rows.ToList().ForEach(row => { chkPublicar = row.FindControl("chkPublicar") as CheckBox; if (chkPublicar.Checked) { idLaboratorio = laboratorios.FirstOrDefault(lab => lab.NOMBRELABORATORIO == row.Cells[1].Text).IDLABORATORIO; //if (fechaFin.Month != DateTime.Now.Month - 1) throw new Exception("Solo se puede publicar las ventas del ciclo actual"); bdd.ActualizarVentas(idLaboratorio, fechaInicio); } }); GridCiclos.DataSource = null; GridCiclos.DataBind(); Response.Redirect("~/ui/VerificarVentas.aspx"); } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } }