public void ActualizarEstadoPrestamo() { DataTable dt = new DataTable(); Prestamo pre = new Prestamo(); int UsuarioId = 0; DateTime FechaCortetime; try { if (Convert.ToInt32(Session["UsuarioId"]) > 0) { UsuarioId = Convert.ToInt32(Session["UsuarioId"]); } else if (Convert.ToInt32(Session["UsuarioCoId"]) > 0) { UsuarioId = Utilitario.ObtenerIdUsuarioAdm(Convert.ToInt32(Session["UsuarioCoId"])); } else { Response.Redirect("~/default.aspx"); } dt = Utilitario.Lista(" P.Estado,P.PrestamoId,P.FechaCorte ", " from Usuario as U inner join UsuarioCo as Uc on Uc.UsuarioId = U.UsuarioId inner Join Prestamo as P on P.UsuarioCoId = Uc.UsuarioCoId ", " where P.Estado >= 1 and P.Estado <= 2 and U.UsuarioId =" + UsuarioId); if (Utilitario.ValidarTabla(dt)) { FechaCortetime = Convert.ToDateTime(dt.Rows[0]["FechaCorte"].ToString()); foreach (DataRow dtRow in dt.Rows) { int PrestamoId = Convert.ToInt32(dt.Rows[0]["PrestamoId"].ToString()); if (DateTime.Now > FechaCortetime) { pre.PrestamoId = PrestamoId; pre.Estado = 3; pre.ActualizarEstado(); } else if (Utilitario.AlertarMora(PrestamoId)) { pre.PrestamoId = PrestamoId; pre.Estado = 2; pre.ActualizarEstado(); } } } } catch (Exception e) { throw e; } }