コード例 #1
0
        public void Adicionar(string item)
        {
            var itemSplit = item.Split(AnaliseVendasRelatorioService.SEPARADOR);
            var tipo      = itemSplit[0];

            switch (tipo)
            {
            case VENDEDOR:
                Vendedores.Add(
                    new VendedorBuilder()
                    .ComCpf(itemSplit[1])
                    .ComNome(itemSplit[2])
                    .ComSalario(itemSplit[3])
                    .Construir());
                break;

            case CLIENTE:
                Clientes.Add(
                    new ClienteBuilder()
                    .ComCnpj(itemSplit[1])
                    .ComNome(itemSplit[2])
                    .ComAreaNegocio(itemSplit[3])
                    .Construir());
                break;

            case VENDAS:
                Vendas.Add(new VendasBuilder()
                           .ComId(itemSplit[1])
                           .ComVendaItens(itemSplit[2])
                           .ComVendedorNome(itemSplit[3])
                           .Construir());
                break;
            }
            ;
        }
コード例 #2
0
        public void CadastraVenda(Vendedor vendedor, Produto produto, int quantidadeVenda)
        {
            var vendasVendedor = Vendas.FirstOrDefault(v => v.Vendedor.Nome == vendedor.Nome);

            if (vendasVendedor != null)
            {
                vendasVendedor.produtosQuantidade.Add(new ProdutoQuantidade()
                {
                    Produto    = produto,
                    Quantidade = quantidadeVenda
                });
            }
            else
            {
                Vendas.Add(new VendaProdutos()
                {
                    Vendedor           = vendedor,
                    produtosQuantidade = new List <ProdutoQuantidade>()
                    {
                        new ProdutoQuantidade()
                        {
                            Produto    = produto,
                            Quantidade = quantidadeVenda
                        }
                    }
                });
            }
        }
コード例 #3
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Vendas.Clear();
                var vendas = await Api.Vendas.GetAsync();

                foreach (var venda in vendas)
                {
                    Vendas.Add(venda);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #4
0
        public void Adicionar()
        {
            Venda v = new Venda();

            v.Data       = DateTime.Now;
            v.VendaItens = new ObservableCollection <VendaItem>();
            Vendas.Add(v);
            Context.Vendas.Add(v);
            VendaSelecionada = v;
        }
コード例 #5
0
        public MainViewModel()
        {
            var rnd = new Random();

            foreach (var c in new string[] { "Bebidas", "Mercearia", "Bazar", "Limpeza", "Perfumaria", "Carnes & Aves", "Frios e Laticinios", "Peixaria", "Padaria" })
            {
                for (int l = HoraInicio + 1; l <= 18; l++)
                {
                    Vendas.Add(new VendaCategoria {
                        Categoria = c, Hora = l, Valor = rnd.NextDouble() * 3000
                    });
                }
            }

            this.Temp = new PlotModel
            {
                PlotAreaBorderColor = OxyColors.Transparent,
                Padding             = new OxyThickness(0, 5, 0, 0)
            };

            this.Temp2 = new PlotModel
            {
                PlotAreaBorderColor = OxyColors.Transparent,
                Padding             = new OxyThickness(0, 10, 0, 5)
            };

            this.Temp.Axes.Add(new LinearAxis
            {
                Position      = AxisPosition.Left,
                IsPanEnabled  = false,
                IsZoomEnabled = false,
                //IsAxisVisible = false,
                MajorGridlineStyle = LineStyle.Dot,
                MajorStep          = 50000,
                LabelFormatter     = (d) => (d / 1000).ToString("0M")
            });

            this.Temp.Axes.Add(new LinearAxis
            {
                Position       = AxisPosition.Bottom,
                IsPanEnabled   = false,
                IsZoomEnabled  = false,
                Selectable     = true,
                MajorStep      = 2,
                LabelFormatter = (d) => d.ToString("00H")
                                 //IsAxisVisible = false
            });

            var colors = new OxyColor[]
            {
                OxyColors.Green,
                OxyColors.Purple,
                OxyColors.Orange,
                OxyColors.Blue,
                OxyColors.Red,
                OxyColors.Brown,
                OxyColors.Goldenrod,
                OxyColors.DarkCyan,
                OxyColors.DarkSeaGreen
            };

            var seriePie = new PieSeries()
            {
            };

            var i = -1;

            foreach (var vendaCat in Vendas.GroupBy(_ => _.Categoria))
            {
                i++;
                var serie = new AreaSeries();
                serie.Color           = colors[i];
                serie.Fill            = colors[i];
                serie.StrokeThickness = 0;
                serie.Points.Add(new DataPoint(this.HoraInicio, 0));
                serie.Points2.Add(new DataPoint(this.HoraInicio, 0));
                var valor = 0D;
                foreach (var venda in vendaCat)
                {
                    valor += venda.Valor;


                    var valorHora = !Temp.Series.Any() ? 0 : Temp.Series.OfType <AreaSeries>().Max(_ => _.Points2.Where(_1 => _1.X == (double)venda.Hora).Max(_1 => _1.Y));
                    serie.Points.Add(new DataPoint(venda.Hora, valorHora));
                    serie.Points2.Add(new DataPoint(venda.Hora, valor + valorHora));
                }

                this.Temp.Series.Add(serie);

                seriePie.Slices.Add(new PieSlice("", vendaCat.Sum(_ => _.Valor))
                {
                    Fill = colors[i],
                });

                this.VendaCategorias.Add(new
                {
                    Categoria = vendaCat.Key,
                    Valor     = vendaCat.Sum(_ => _.Valor),
                    Color     = Color.FromRgb(colors[i].R, colors[i].G, colors[i].B)
                });
            }

            this.Temp2.Series.Add(seriePie);


            var maxHora  = !this.Temp.Series.OfType <AreaSeries>().Any() ? this.HoraInicio : this.Temp.Series.OfType <AreaSeries>().Max(_ => _.Points2.Max(_1 => _1.X));
            var maxValor = !this.Temp.Series.OfType <AreaSeries>().Any() ? 0 : this.Temp.Series.OfType <AreaSeries>().Max(_ => _.Points2.Max(_1 => _1.Y));

            var serieSobra = new AreaSeries();

            serieSobra.Color           = OxyColors.Gray;
            serieSobra.StrokeThickness = 0;

            serieSobra.Points.Add(new DataPoint(maxHora, 0));
            serieSobra.Points2.Add(new DataPoint(maxHora, maxValor));

            serieSobra.Points.Add(new DataPoint(this.HoraFim, 0));
            serieSobra.Points2.Add(new DataPoint(this.HoraFim, this.Meta));

            this.Temp.Series.Add(serieSobra);

            var metaSerie = new LineSeries
            {
                Color = OxyColor.FromRgb(Convert.ToByte(Color.Gray.R), Convert.ToByte(Color.Gray.G), Convert.ToByte(Color.Gray.B))
            };

            metaSerie.Points.Add(new DataPoint(this.HoraInicio, 0));
            metaSerie.Points.Add(new DataPoint(this.HoraFim, this.Meta));
            metaSerie.LineStyle = LineStyle.Dash;
            metaSerie.Color     = OxyColors.LightGray;
            this.Temp.Series.Add(metaSerie);

            this.Realizado = Vendas.Sum(_ => _.Valor);
        }
コード例 #6
0
 public void AdicionarVenda(Venda venda)
 {
     Vendas.Add(venda);
 }