コード例 #1
0
        public OrdenDePago ObtenerById(int id)
        {
            var ordenPago = new OrdenDePago();
            var sucursalRepository = new SucursalRepository();

            try
            {
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["EntidadBancariaConnection"].ToString()))
                {
                    con.Open();

                    var query = new SqlCommand("SELECT * FROM OrdenDePago WHERE Id = @id", con);
                    query.Parameters.AddWithValue("@id", id);

                    using (var dr = query.ExecuteReader())
                    {
                        dr.Read();
                        if (dr.HasRows)
                        {
                            ordenPago.Id = Convert.ToInt32(dr["Id"]);
                            ordenPago.Monto = Convert.ToDecimal(dr["Monto"]);
                            ordenPago.Moneda = (MonedaEnum)Convert.ToByte(dr["Moneda"]);
                            ordenPago.Estado = (EstadoOrdenPagoEnum)Convert.ToByte(dr["Estado"]);
                            ordenPago.FechaDePago = Convert.ToDateTime(dr["FechaDePago"]);
                            ordenPago.IdSucursal = Convert.ToInt32(dr["IdSucursal"]);
                            ordenPago.Sucursal = sucursalRepository.ObtenerById(Convert.ToInt32(dr["IdSucursal"]));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return ordenPago;
        }
コード例 #2
0
 public List<OrdenDePago> Listar(int idSucursal)
 {
     var ordenes = new List<OrdenDePago>();
     var sucursalRepository = new SucursalRepository();
     try
     {
         using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["EntidadBancariaConnection"].ToString()))
         {
             con.Open();
             var query = new SqlCommand("SELECT * FROM OrdenDePago where IdSucursal=@id", con);
             query.Parameters.AddWithValue("@id", idSucursal);
             using (var dr = query.ExecuteReader())
             {
                 while (dr.Read())
                 {
                     var ordenPago = new OrdenDePago
                     {
                         Id = Convert.ToInt32(dr["Id"]),
                         Monto = Convert.ToDecimal(dr["Monto"]),
                         Moneda = (MonedaEnum)Convert.ToByte(dr["Moneda"]),
                         Estado = (EstadoOrdenPagoEnum)Convert.ToByte(dr["Estado"]),
                         FechaDePago = Convert.ToDateTime(dr["FechaDePago"]),
                         IdSucursal = Convert.ToInt32(dr["IdSucursal"]),
                         Sucursal = sucursalRepository.ObtenerById(Convert.ToInt32(dr["IdSucursal"]))
                     };
                     ordenes.Add(ordenPago);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw;
     }
     return ordenes;
 }