Ejemplo n.º 1
0
        public List <DataFactura> ObtenerFactura(string idUsuario, string idTienda)
        {
            try
            {
                if (idUsuario == null)
                {
                    throw new Exception("Debe pasar el identificador de un usuario.");
                }
                chequearTienda(idTienda);
                using (var context = ChebayDBContext.CreateTenant(idTienda))
                {
                    //Obtengo todas las compras realizadas.
                    var qCompras = from cmp in context.compras.Include("producto")
                                   where cmp.UsuarioID == idUsuario
                                   select cmp;
                    List <Compra>      lc  = qCompras.ToList();
                    List <DataFactura> ret = new List <DataFactura>();
                    foreach (Compra c in lc)
                    {
                        DataFactura df = new DataFactura
                        {
                            monto          = c.monto,
                            esCompra       = true,
                            fecha          = c.fecha_compra,
                            nombreProducto = c.producto.nombre,
                            ProductoID     = c.ProductoID
                        };
                        ret.Add(df);
                    }

                    //Obtengo todas las ventas realizadas.
                    var qVentas = from vnt in context.compras.Include("producto")
                                  where vnt.producto.UsuarioID == idUsuario
                                  select vnt;
                    lc = qVentas.ToList();
                    foreach (Compra c in lc)
                    {
                        DataFactura df = new DataFactura
                        {
                            monto          = c.monto,
                            esCompra       = false,
                            fecha          = c.fecha_compra,
                            nombreProducto = c.producto.nombre,
                            ProductoID     = c.ProductoID
                        };
                        ret.Add(df);
                    }
                    return(ret);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
Ejemplo n.º 2
0
        public FacturaController()
        {
            dataservFactura = new DataFactura();

            List <Profile> profilelist = new List <Profile>();

            profilelist.Add(new FacturaProfile());
            profilelist.Add(new MFacturaProfile());
            profilelist.Add(new ServicioProfile());
            profilelist.Add(new MServicioProfile());
            profilelist.Add(new TarjetaProfile());
            profilelist.Add(new MTarjetaProfile());

            objMap = new AutoMapper.MapperConfiguration(i => i.AddProfiles(profilelist));
        }
Ejemplo n.º 3
0
        public IEnumerable <FacturasRFC> GetFacturasRFCs(DataFactura datafactura)
        {
            try
            {
                List <FacturasRFC> lstfacturas = new List <FacturasRFC>();

                using (SqlConnection con = new SqlConnection(connectionString))
                {
                    SqlCommand cmd = new SqlCommand("Facturacion.spu_COMP_ConFacturasClienteRFC", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@sRFC", SqlDbType.Char).Value = datafactura.Opcion.ToString();

                    con.Open();
                    SqlDataReader rdr = cmd.ExecuteReader();

                    while (rdr.Read())
                    {
                        FacturasRFC facturasrfc = new FacturasRFC();

                        facturasrfc.Cliente       = rdr["Cliente"].ToString();
                        facturasrfc.Nombre        = rdr["Nombre"].ToString();
                        facturasrfc.Factura       = rdr["Factura"].ToString();
                        facturasrfc.Division      = rdr["Division"].ToString();
                        facturasrfc.UUID          = rdr["UUID"].ToString();
                        facturasrfc.Total         = Convert.ToDouble(rdr["Total"]);
                        facturasrfc.Moneda        = rdr["Moneda"].ToString();
                        facturasrfc.Fecha_factura = rdr["Fecha Factura"].ToString();
                        facturasrfc.Hora_factura  = rdr["Hora Factura"].ToString();
                        facturasrfc.Folio         = Convert.ToInt32(rdr["Folio"]);

                        lstfacturas.Add(facturasrfc);
                    }
                    con.Close();
                }
                return(lstfacturas);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        public DataPendiente GetPendientes(DataFactura datafactura)
        {
            try
            {
                DataPendiente datos = new DataPendiente();
                //string sRespuesta = "";
                using (SqlConnection con = new SqlConnection(connectionString))
                {
                    SqlCommand cmd = new SqlCommand("Facturacion.spu_COMP_ConAplicacionesPendientesRFC", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@sRFC", datafactura.Opcion.Trim());

                    con.Open();
                    SqlDataReader rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        datos.Opcion = rdr["sRespuesta"].ToString();
                        //if (datos.Opcion != "")
                        //{

                        //}
                        //else
                        //{
                        //    datos.Opcion = null;
                        //}
                    }
                    con.Close();
                }
                return(datos);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public DataPendiente Consultar([FromBody] DataFactura datafactura)
 {
     return(objfacturas.GetPendientes(datafactura));
 }
 public IEnumerable <FacturasRFC> Index([FromBody] DataFactura datafactura)
 {
     return(objfacturas.GetFacturasRFCs(datafactura));
 }