Пример #1
0
        /// <summary>
        /// Obtiene un listado de pagos registrados en la base de datos
        /// </summary>
        /// <returns></returns>
        public List <Pago> GetList()
        {
            using (SqlConnection _SqlConnection = new SqlConnection(ConnectionString.DbMPYOpera))
            {
                List <Pago> lista       = new List <Pago>();
                SqlCommand  _SqlCommand = new SqlCommand("MDOSPS_OBTENER_PAGOS", _SqlConnection)
                {
                    CommandType = CommandType.StoredProcedure
                };

                try
                {
                    _SqlConnection.Open();
                    SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader();
                    if (_SqlDataReader.HasRows)
                    {
                        while (_SqlDataReader.Read())
                        {
                            Pago item = new Pago()
                            {
                                iIdPago       = int.Parse(_SqlDataReader["IdPago"].ToString()),
                                dtFecha       = DateTime.Parse(_SqlDataReader["FechaPago"].ToString()),
                                sNoFactura    = _SqlDataReader["NoFactura"].ToString(),
                                sNoSocio      = _SqlDataReader["NoSocio"].ToString(),
                                sNombre       = _SqlDataReader["Nombre"].ToString(),
                                sNoOperacion  = _SqlDataReader["NoOperacion"].ToString(),
                                sConcepto     = _SqlDataReader["Concepto"].ToString(),
                                sBanco        = _SqlDataReader["Banco"].ToString(),
                                dMonto        = Decimal.Parse(_SqlDataReader["Monto"].ToString()),
                                sReferencia   = _SqlDataReader["Referencia"].ToString(),
                                dCostoFiscal  = decimal.Parse(_SqlDataReader["CostoFiscal"].ToString()),
                                dGanancia     = decimal.Parse(_SqlDataReader["Ganancia"].ToString()),
                                dComisionNeta = decimal.Parse(_SqlDataReader["ComisionNeta"].ToString())
                            };

                            List <Concepto> GetConcepts = new Concepto().GetConcepto(item.iIdPago);
                            for (int i = 0; i < GetConcepts.Count; i++)
                            {
                                Concepto itemConcepto = new Concepto(GetConcepts[i].iIdConcepto, GetConcepts[i].sConcepto, GetConcepts[i].dImporte);
                                item.lConceptos.Add(itemConcepto);
                            }
                            lista.Add(item);
                        }
                    }
                }
                catch (Exception)
                {
                    lista = null;
                }
                return(lista);
            }
        }
Пример #2
0
        public List <Concepto> GetConcepto(int iIdPago)
        {
            using (SqlConnection _SqlConnection = new SqlConnection(ConnectionString.DbMPYOpera))
            {
                List <Concepto> conceptos   = new List <Concepto>();
                SqlCommand      _SqlCommand = new SqlCommand("MDOSPS_OBTENER_CONCEPTOS", _SqlConnection)
                {
                    CommandType = CommandType.StoredProcedure
                };
                _SqlCommand.Parameters.AddWithValue("@IdPago", iIdPago);

                try
                {
                    _SqlConnection.Open();
                    SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader();
                    if (_SqlDataReader.HasRows)
                    {
                        while (_SqlDataReader.Read())
                        {
                            Concepto item = new Concepto()
                            {
                                iIdConcepto = int.Parse(_SqlDataReader["IdTipoConcepto"].ToString()),
                                sConcepto   = _SqlDataReader["Descripcion"].ToString(),
                                dImporte    = decimal.Parse(_SqlDataReader["Precio"].ToString())
                            };
                            conceptos.Add(item);
                        }
                    }
                }
                catch (Exception)
                {
                    conceptos = null;
                }
                return(conceptos);
            }
        }