/// <summary>
        /// Consultar Histórico de Pagos
        /// </summary>
        public void consultarHistoricoPagos()
        {
            DataSet ds = new DataSet();
            DataSet dsDeducciones = new DataSet();
            DataSet dsConcepto = new DataSet();
            HistoricoPagosDAO ud = new HistoricoPagosDAO();
            PagoDAO ud1 = new PagoDAO();

            Pago pago;
            String fechaPago;
            String concepto;
            String monto;
            Deduccion deduccion;

            //Monto Liberado
            ds = ud.HistoricoPagosFechayMontoLiberado(medico, fechaI, fechaF);

            //En esta nómina no se liberaron honorarios para este médico
            if (ds.Tables[0].Rows.Count == 0) { sinpagos = true; return; }
            else
            {
                if (ds.Tables[0].Rows.Count > 50) { excede = true; return; }
                else
                {
                    pagos = new ArrayList();
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        pago = new Pago(medico);
                        DataRow row = ds.Tables[0].Rows[i];

                        //Fecha de Pago
                        if (row.ItemArray.ElementAt(0) != DBNull.Value)
                        {
                            fechaPago = row.ItemArray.ElementAt(0).ToString();
                            pago.FechaPago = fechaPago;

                            //Deducciones
                            ud = new HistoricoPagosDAO();
                            dsDeducciones = new DataSet();
                            dsDeducciones = ud.HistoricoPagosDeducciones(medico, fechaPago);

                            if (dsDeducciones.Tables[0].Rows.Count == 0) { pago.Deducciones = null; }
                            else
                            {
                                pago.Deducciones = new ArrayList();
                                foreach (DataRow dr in dsDeducciones.Tables[0].Rows)
                                {
                                    deduccion = new Deduccion();
                                    //Concepto deduccion
                                    if (dr.ItemArray.ElementAt(0) != DBNull.Value)
                                    {
                                        concepto = dr.ItemArray.ElementAt(0).ToString();
                                        ud1 = new PagoDAO();
                                        dsConcepto = ud1.NombreConcepto(concepto);
                                        if (dsConcepto.Tables[0].Rows.Count != 0)
                                        {
                                            if (dsConcepto.Tables[0].Rows[0].ItemArray.ElementAt(0) != DBNull.Value)
                                            {
                                                concepto = dsConcepto.Tables[0].Rows[0].ItemArray.ElementAt(0).ToString();
                                                deduccion.Concepto = concepto;
                                            }
                                        }
                                    }

                                    //Monto
                                    if (dr.ItemArray.ElementAt(1) != DBNull.Value)
                                    {
                                        monto = dr.ItemArray.ElementAt(1).ToString();
                                        deduccion.Monto = decimal.Parse(monto);
                                        pago.MontoNeto -= decimal.Parse(monto);
                                    }

                                    //Agregamos la deduccion al ArrayList
                                    pago.Deducciones.Add(deduccion);
                                }
                            }
                        }

                        //Monto Liberado
                        if (row.ItemArray.ElementAt(1) != DBNull.Value)
                        {
                            pago.MontoLiberado = decimal.Parse(row.ItemArray.ElementAt(1).ToString());
                            pago.MontoNeto += pago.MontoLiberado;
                        }

                        pagos.Add(pago);
                    }
                }
            }
        }
        public String ConsultarProximoPago(string medico_tb)
        {
            ManejadorXML manej = new ManejadorXML();

            medico_tb = medico_tb.Trim();

            System.Diagnostics.Debug.WriteLine("En proximo pago ESTE es el SessionID " + Session.SessionID);

            if (Context.Session != null)
            {
                //check the IsNewSession value, this will tell us if the session has been reset
                if (Session.IsNewSession)
                {
                    //now we know it's a new session, so we check to see if a cookie is present
                    string cookie = HttpContext.Current.Request.Headers["Cookie"];
                    //now we determine if there is a cookie does it contains what we're looking for
                    if ((null != cookie) && (cookie.IndexOf("ASP.NET_SessionId") >= 0))
                    {
                        //since it's a new session but a ASP.Net cookie exist we know
                        //the session has expired so we need to redirect them
                        return manej.codificarXmlAEnviar(manej.envioMensajeError("505"));
                    }
                    else
                    {
                        return manej.codificarXmlAEnviar(manej.envioMensajeError("13"));
                    }
                }
                else
                {
                    if (Session["Loggedin"] != null)
                    {
                        if (Session["Loggedin"].Equals("yes"))
                        {
                            if (CodValido(medico_tb))
                            {
                                DateTime x = DateTime.Now;
                                DateTime y = (DateTime)Session["UltimaConsulta"];
                                TimeSpan z = x.Subtract(y);

                                System.Diagnostics.Debug.WriteLine(x.ToString("yyyyMMdd HH:mm:ss"));
                                System.Diagnostics.Debug.WriteLine(y.ToString("yyyyMMdd HH:mm:ss"));
                                System.Diagnostics.Debug.WriteLine("Diferencia " + z.TotalMinutes);

                                if (z.TotalMinutes < 10)
                                {
                                    Session["UltimaConsulta"] = x;
                                    //Creamos una instancia de EstadoDeCuenta con los datos de entrada (medico_tb)
                                    Pago pago = new Pago(medico_tb);

                                    //Verificamos si la base de datos está disponible
                                    bool disponible = pago.DisponibleBD();
                                    if (disponible == false)
                                        return manej.codificarXmlAEnviar(manej.envioMensajeError("600"));
                                    else
                                    {
                                        //Consultamos el estado de cuenta por antiguedad de saldo
                                        pago.consultarProximoPago();
                                        if (pago.sinPago == true)
                                            return manej.codificarXmlAEnviar(manej.envioMensajeError("0"));
                                        else
                                            return manej.codificarXmlAEnviar(manej.creacionRespuestaProximoPago(pago));
                                    }
                                }
                                else
                                {
                                    return manej.codificarXmlAEnviar(manej.envioMensajeError("500"));
                                }
                            }
                            else return manej.codificarXmlAEnviar(manej.envioMensajeError("14"));
                        }
                        else
                            return manej.codificarXmlAEnviar(manej.envioMensajeError("13"));
                    }
                    else
                        return manej.codificarXmlAEnviar(manej.envioMensajeError("13"));
                }
            }
            else
                return manej.codificarXmlAEnviar(manej.envioMensajeError("13"));
        }