/// <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);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Consultar proximo pago que recibirá el medico
        /// </summary>
        public void consultarProximoPago()
        {
            DataSet ds = new DataSet();
            DataSet dsConcepto = new DataSet();
            PagoDAO ud = new PagoDAO();

            //Monto Liberado
            ds = ud.ProximoPagoMontoLiberado(medico);

            //En esta nómina no se liberaron honorarios para este médico
            if (ds.Tables[0].Rows.Count == 0) { sinpago = true; return; }
            else
            {
                if (ds.Tables[0].Rows[0].ItemArray.ElementAt(0) == DBNull.Value)
                {
                    sinpago = true;
                    return;
                }
                else
                {
                    montoLiberado = decimal.Parse(ds.Tables[0].Rows[0].ItemArray.ElementAt(0).ToString());
                    montoNeto = montoLiberado;

                    //Deducciones
                    ud = new PagoDAO();
                    ds = ud.ProximoPagoDeducciones(medico);

                    Deduccion deduccion;
                    String concepto = "";
                    decimal monto = 0;

                    if (ds.Tables[0].Rows.Count == 0) { Deducciones = null; }
                    else
                    {
                        Deducciones = new ArrayList();
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            deduccion = new Deduccion();
                            //Concepto deduccion
                            if (dr.ItemArray.ElementAt(0) != DBNull.Value)
                            {
                                concepto = dr.ItemArray.ElementAt(0).ToString();
                                ud = new PagoDAO();
                                dsConcepto = ud.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 = decimal.Parse(dr.ItemArray.ElementAt(1).ToString());
                                deduccion.Monto = monto;
                                montoNeto -= monto;
                            }

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

                    //Fecha de pago
                    DateTime hoy = DateTime.Today;
                    DateTime ayer = hoy.AddDays(-1);
                    FechaPago = ayer.ToString();
                }
            }
        }