private void CargarInforme() { try { if (TB_CodResponsable2.Text == "") { throw new Exception("Se debe elegir el responsable"); } if (TB_Mes.Text == "") { throw new Exception("Se debe ingresar el mes"); } if (TB_Año.Text == "") { throw new Exception("Se debe ingresar el año"); } if (CB_Ordenamiento.Text == "") { throw new Exception("Se debe elegir un ordenamiento"); } int Año = 0; int.TryParse(TB_Año.Text, out Año); if (Año == 0) { throw new Exception("Se debe ingresar un año valido"); } MesIngresado = 0; int.TryParse(TB_Mes.Text, out MesIngresado); if ((MesIngresado == 0) || (MesIngresado > 12)) { throw new Exception("Se debe ingresar un mes valido"); } //Consulto los cronogramas PENDIENTES dtCronograma = Cro.CronogramaPendiente(Año); dtInforme.Rows.Clear(); foreach (DataRow filaCrono in dtCronograma.Rows) { int Lega = int.Parse(filaCrono[2].ToString()); //BUSCO LOS RESPONSABLES POR EL PERFIL DE CADA LEGAJO dtResponsables = L.LegajoPerfilResponsable(Lega); foreach (DataRow filaResp in dtResponsables.Rows) { //CONSULTO SI LOS RESPONSABLES DEVUELTOS SON IGUAL A EL RESPONSABLE INGRESADO if ((filaResp[1].ToString() == TB_CodResponsable2.Text) || (filaResp[2].ToString() == TB_CodResponsable2.Text)) { int Curs = int.Parse(filaCrono[3].ToString()); dtCronogramaII = CroII.ListarPorCurso(Año, Curs); //RECORRO LOS MESES foreach (DataRow filaCroII in dtCronogramaII.Rows) { if (filaCroII[11].ToString() == "x") { MesDevuelto = 12; } if (filaCroII[10].ToString() == "x") { MesDevuelto = 11; } if (filaCroII[9].ToString() == "x") { MesDevuelto = 10; } if (filaCroII[8].ToString() == "x") { MesDevuelto = 9; } if (filaCroII[7].ToString() == "x") { MesDevuelto = 8; } if (filaCroII[6].ToString() == "x") { MesDevuelto = 7; } if (filaCroII[5].ToString() == "x") { MesDevuelto = 6; } if (filaCroII[4].ToString() == "x") { MesDevuelto = 5; } if (filaCroII[3].ToString() == "x") { MesDevuelto = 4; } if (filaCroII[2].ToString() == "x") { MesDevuelto = 3; } if (filaCroII[1].ToString() == "x") { MesDevuelto = 2; } if (filaCroII[0].ToString() == "x") { MesDevuelto = 1; } } if (MesIngresado >= MesDevuelto) { DataRow filaInforme = dtInforme.NewRow(); filaInforme[0] = TB_CodResponsable2.Text; filaInforme[1] = TB_Responsable2.Text; filaInforme[2] = filaCrono[2].ToString(); filaInforme[3] = filaResp[3].ToString(); filaInforme[4] = filaCrono[3].ToString(); filaInforme[5] = filaCrono[4].ToString(); dtInforme.Rows.Add(filaInforme); } } } } } catch (Exception err) { MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }