protected void btnCerrar_Click(object sender, ImageClickEventArgs e) { string cleanMessage; int cantidad = 0; int cantPendienteCal = 0; int cantProcesado = 0; int cantPendienteHES = 0; if (GridView1.Rows.Count > 0) { string Reqs_Correlativo; string Requ_Numero; string Reqd_CodLinea; string ide_valor, Proy_Codigo, FLG_FASES, D_Prov_RUC; foreach (GridViewRow row in GridView1.Rows) { Requ_Numero = GridView1.DataKeys[row.RowIndex].Values[0].ToString(); // extrae key Reqd_CodLinea = GridView1.DataKeys[row.RowIndex].Values[1].ToString(); // extrae key Reqs_Correlativo = GridView1.DataKeys[row.RowIndex].Values[2].ToString(); // extrae key ide_valor = GridView1.DataKeys[row.RowIndex].Values[3].ToString(); // extrae key Proy_Codigo = GridView1.DataKeys[row.RowIndex].Values[4].ToString(); // extrae key D_Prov_RUC = GridView1.DataKeys[row.RowIndex].Values[5].ToString(); // extrae key FLG_FASES = GridView1.DataKeys[row.RowIndex].Values[6].ToString(); // extrae key //0 pendiente de calculado //1 pendiente HES //2 PENDIENTE CIERRE //3 CERRADO if (FLG_FASES == "0") { //0 pendiente de calculado cantPendienteCal++; } else if (FLG_FASES == "1") { //1 pendiente HES cantPendienteHES++; } else if (FLG_FASES == "2") { BL_TBL_RequerimientoSubDetalle obj = new BL_TBL_RequerimientoSubDetalle(); DataTable dtResultado = new DataTable(); dtResultado = obj.Ins_valorizar_equipoMenor_cierre( Convert.ToInt32(ddlanio.SelectedValue.ToString()), Convert.ToInt32(ddlMes.SelectedValue.ToString()), Requ_Numero, Reqd_CodLinea, Reqs_Correlativo, Convert.ToInt32(ide_valor) ); if (dtResultado.Rows.Count > 0) { cantidad++; } } else if (FLG_FASES == "3") { //1 pendiente HES cantProcesado++; } } if (cantidad > 0) { cleanMessage = "Se migraron " + cantidad.ToString() + " registro(s)"; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true); Listar("", "", ""); } else { if (cantPendienteCal > 0) { cleanMessage = "Pendiente cálculo " + cantPendienteCal.ToString(); ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true); } else if (cantPendienteHES > 0) { cleanMessage = "Pendiente registro HES " + cantPendienteCal.ToString(); ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true); } else { cleanMessage = "No existen registros a procesar"; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true); } } } else { cleanMessage = "No existen registros"; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true); } ScriptManager.RegisterStartupScript(this, typeof(Page), "myScript", "gridviewScroll();", true); }