仓库管理系统24--统计报表

news2024/10/7 5:29:34

原创不易,打字不易,截图不易,多多点赞,送人玫瑰,留有余香,财务自由明日实现 

1、引用LiveCharts

2、创建LiveChartViewModel

using GalaSoft.MvvmLight;
using LiveCharts.Wpf;
using LiveCharts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GalaSoft.MvvmLight.Command;
using West.StoreMgr.Service;

namespace West.StoreMgr.ViewModel
{
    /// <summary>
    /// 柱状图viewmodel
    /// </summary>
    public class LiveChartViewModel : ViewModelBase
    {
        //物资库存柱状
        private IChartValues goodsChartValues = new ChartValues<double>();
        public IChartValues GoodsChartValues
        {
            get { return goodsChartValues; }
            set { goodsChartValues = value; RaisePropertyChanged(); }
        }

        private List<string> goodsLabes = new List<string>();
        /// <summary>
        /// 物资标签
        /// </summary>
        public List<string> GoodsLabes
        {
            get { return goodsLabes; }
            set { goodsLabes = value; RaisePropertyChanged(); }
        }

        //物资入库流水折线
        public SeriesCollection GoodsInStoreSeries { get; set; } = new SeriesCollection();
        public AxesCollection GoodsInStoreAxis { get; set; } = new AxesCollection();

        //物资出库流水折线
        public SeriesCollection GoodsOutStoreSeries { get; set; } = new SeriesCollection();
        public AxesCollection GoodsOutStoreAxis { get; set; } = new AxesCollection();

        //客户出库饼图
        public SeriesCollection CustomerPieSeries { get; set; } = new SeriesCollection();
        /// <summary>
        /// 加载命令
        /// </summary>
        public RelayCommand LoadCommand
        {
            get
            {
                return new RelayCommand(() =>
                { 
                    GoodsChartValues.Clear();
                    GoodsLabes.Clear();
                    var goodsList = new GoodsService().Select();
                    var instoreList = new InStoreService().Select();
                    var outstoreList = new OutStoreService().Select();
                    var customers = new CustomerService().Select();
                    goodsList.ForEach(goods =>
                    {
                        //物资库存柱状
                        GoodsChartValues.Add(goods.Quant);
                        GoodsLabes.Add(goods.Name);

                        //物资入库流水折线
                        var instores = instoreList.FindAll(item => item.GoodsSerial == goods.Serial);
                        var inserise = new LineSeries() { Title = goods.Name, Values = new ChartValues<double>() };
                        instores.ForEach(item =>
                        {
                            inserise.Values.Add(item.Number);
                        });
                        GoodsInStoreSeries.Add(inserise);

                        //物资出库流水折线
                        var outstores = outstoreList.FindAll(item => item.GoodsSerial == goods.Serial);
                        var outserise = new LineSeries() { Title = goods.Name, Values = new ChartValues<double>() };
                        outstores.ForEach(item =>
                        {
                            outserise.Values.Add(item.Number);
                        });
                        GoodsOutStoreSeries.Add(outserise);
                    });

                    CustomerPieSeries.Clear();
                    customers.ForEach(item =>
                    {
                        var list = outstoreList.FindAll(outstore => outstore.CustomerId == item.Id);
                        var sum = list.Sum(t => t.Number);
                        var pieSeries = new PieSeries
                        {
                            Title = item.Name,
                            Values = new ChartValues<double>() { sum }
                        };
                        CustomerPieSeries.Add(pieSeries);
                    }); 
                });
            }
        }
    }
}

3、创建LiveChartView用户控件

<UserControl x:Class="West.StoreMgr.View.LiveChartView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:West.StoreMgr.View"
                         xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
             xmlns:wpf="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
             mc:Ignorable="d" 
             DataContext="{Binding Source={StaticResource Locator},Path=LiveChart}"
             d:DesignHeight="450" d:DesignWidth="800">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <i:InvokeCommandAction Command="{Binding LoadCommand}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition Height="auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <!--标题-->
        <StackPanel Background="#EDF0F6" Orientation="Horizontal">
            <TextBlock Margin="10 0 0 0" Text="&#xf015;" FontSize="20" FontFamily="/Fonts/#FontAwesome" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="#797672"/>
            <TextBlock Margin="10 0 0 0" Text="首页 > 报表统计" FontSize="20" FontFamily="/Fonts/#FontAwesome" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="#797672"/>
        </StackPanel>

        <!--增加-->
        <Grid Grid.Row="1" Margin="10">

        </Grid>

        <!--报表-->
        <Grid Grid.Row="2" Margin="10 0 10 10" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            
            <!--物资库存柱状图-->
            <TextBlock Text="物资库存柱状图" Grid.Row="0" Grid.Column="0" Margin="150 -20 0 0" FontSize="15" FontFamily="微软雅黑" ></TextBlock>
            <Border Grid.Row="0" Grid.Column="0" BorderBrush="BurlyWood"  BorderThickness="0.5">
                <wpf:CartesianChart  Margin="10">
                    <wpf:CartesianChart.Series>
                        <wpf:ColumnSeries Values="{Binding GoodsChartValues}"/>
                    </wpf:CartesianChart.Series>
                    <wpf:CartesianChart.AxisX>
                        <wpf:Axis ShowLabels="True" Labels="{Binding GoodsLabes}">
                            <wpf:Axis.Separator>
                                <wpf:Separator Step="1" IsEnabled="False"/>
                            </wpf:Axis.Separator>
                        </wpf:Axis>
                    </wpf:CartesianChart.AxisX>
                </wpf:CartesianChart>
            </Border>
           
            <!--客户出库统计饼图-->
            <TextBlock Text="客户出库统计饼图" Grid.Row="0" Grid.Column="1" Margin="150 -20 0 0" FontSize="15" FontFamily="微软雅黑"></TextBlock>
            <Border Grid.Row="0" Grid.Column="1"  BorderBrush="BurlyWood"  BorderThickness="0.5">
                <wpf:PieChart LegendLocation="Right" Hoverable="True" InnerRadius="30" Series="{Binding CustomerPieSeries}">
                    <wpf:PieChart.ChartLegend>
                        <wpf:DefaultLegend Foreground="Green"/>
                    </wpf:PieChart.ChartLegend>
                </wpf:PieChart> 
            </Border> 
            
            <!--物资入库流水记录-->
            <TextBlock  Text="物资入库流水记录" Grid.Row="1" Grid.Column="0"  Margin="150 0 0 0" FontSize="15" FontFamily="微软雅黑"></TextBlock>
            <Border Grid.Row="1" Grid.Column="0" BorderBrush="BurlyWood"  BorderThickness="0.5"> 
                <wpf:CartesianChart  Series="{Binding GoodsInStoreSeries}" AxisX="{Binding GoodsInStoreAxis}"/>
            </Border>

            <!--物资出库流水记录-->
            <TextBlock Text="物资出库流水记录" Grid.Row="1" Grid.Column="1" Margin="150 0 0 0" FontSize="15" FontFamily="微软雅黑" ></TextBlock>
            <Border Grid.Row="1" Grid.Column="1"  BorderBrush="BurlyWood"  BorderThickness="0.5"> 
            <wpf:CartesianChart Margin="10" Series="{Binding GoodsOutStoreSeries}" AxisX="{Binding GoodsOutStoreAxis}"/>
            </Border>
        </Grid>
    </Grid>
</UserControl>

4、运行效果

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1883422.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

mybatis实现多表查询

mybatis高级查询【掌握】 1、准备工作 【1】包结构 创建java项目&#xff0c;导入jar包和log4j日志配置文件以及连接数据库的配置文件&#xff1b; 【2】导入SQL脚本 运行资料中的sql脚本&#xff1a;mybatis.sql 【3】创建实体来包&#xff0c;导入资料中的pojo 【4】User…

PCL 基于点云RGB颜色的区域生长算法

RGB颜色的区域生长算法 一、概述1.1 算法定义1.2 算法特点1.3 算法实现二、代码示例三、运行结果🙋 结果预览 一、概述 1.1 算法定义 点云RGB区域生长算法: 是一个基于RGB颜色信息的区域生长算法,用于点云分割。该算法利用了点云中相邻点之间的颜色相似性来将点云分割成…

SQLAlchemy(alembic)和Flask-SQLAlchemy入门教程

SQLAlchemy 是 Python 生态中最流行的 ORM 类库&#xff0c;alembic 用来做 OMR 模型与数据库的迁移与映射&#xff0c;Flask-SQLAlchemy 是 Flask 的扩展&#xff0c;可为应用程序添加对 SQLAlchemy 的支持&#xff0c;简化 SQLAlchemy 与 Flask 的使用。 一.SQLAlchemy 和 a…

鸿蒙本地签名不匹配问题

连接鸿蒙手机运行项目报如下错误 这是由于本地签名和鸿蒙设备签名不匹配导致的&#xff0c;需要注释掉如下代码&#xff0c;选择file project 自动签名 勾选auto选项&#xff0c;会在build-profile.json5中生成一个签名&#xff0c;然后运行就ok了~

商汤上海AI实验室联合发布:自动驾驶全栈式高精度标定工具箱(含车、IMU、相机、激光雷达等的标定)

前言 在自动驾驶技术飞速发展的今天&#xff0c;传感器的精确标定对于确保系统性能至关重要。SensorsCalibration&#xff0c;一个专为自动驾驶车辆设计的标定工具箱&#xff0c;提供了一套全面的解决方案&#xff0c;用于校准包括IMU、激光雷达、摄像头和雷达在内的多种传感器…

探索智慧校园人事系统,了解人事合同功能的核心优势

智慧校园人事系统中的人事合同管理功能&#xff0c;是一个高度集成且自动化的模块&#xff0c;专注于优化合同的全生命周期管理&#xff0c;从合同创建、审批、签署到存档及续签提醒&#xff0c;旨在提升人事管理工作的规范性与效率&#xff0c;同时保障学校的法律合规性。 在智…

ARP 原理详解 一

ARP 原理 ARP&#xff08;Address Resolution Protocol&#xff09;地址解析协议&#xff0c;是根据 IP 地址获取物理地址的一个 TCP/IP 协议。 OSI 网络七层模型中&#xff0c;IP 地址在 OSI 模型第三层&#xff0c;MAC 地址在第二层&#xff0c;彼此不直接通信。 在通过以…

HTMLCSS(入门)

HTML <html> <head><title>第一个页面</title></head><body>键盘敲烂&#xff0c;工资过万</body> </html> <!DOCTYPE>文档类型声明&#xff0c;告诉浏览器使用哪种HTML版本显示网页 <!DOCTYPE html>当前页面采取…

汽车零部件材料耐候性测试氙光太阳辐射系统试验箱

概述 汽车零部件等领域的材料耐候性测试是一项关键的质量控制环节&#xff0c;它关乎汽车部件在各种气候条件下的性能表现和寿命。塑料件光照老化实验箱&#xff0c;即氙灯老化试验箱&#xff0c;在其中扮演着至关重要的角色。通过模拟自然环境中的光照、温度、湿度等条件&…

分享一个在 WinForm 桌面程序中使用进度条展示报表处理进度的例子,提升用户体验

前言 在有些比较消耗时间的业务场景中&#xff0c;比如生成报表等&#xff0c;如果没有在操作的过程中向用户反馈操作进度&#xff0c;会让用户以为程序 “死” 掉了&#xff0c;用户体验非常不好。 WinForm 桌面程序项目与 Console 项目不一样&#xff0c;如果 Console 项目…

农村程序员陈随易2024年中总结

今天是 2024年7月1日&#xff0c;时间如白驹过隙&#xff0c;今年已去其一半。 总结一下今年上半年的情况&#xff0c;给大家提供一些参考和建议。 希望大家关注一下公众号 陈随易&#xff0c;有些内容只在公众号发表。 先看看我的年初计划&#xff0c;这个在今年年初的时候&…

【解锁未来:深入了解机器学习的核心技术与实际应用】

解锁未来&#xff1a;深入了解机器学习的核心技术与实际应用 &#x1f48e;1.引言&#x1f48e;1.1 什么是机器学习&#xff1f; &#x1f48e;2 机器学习的分类&#x1f48e;3 常用的机器学习算法&#x1f48e;3.1 线性回归&#xff08;Linear Regression&#xff09;&#x1…

141个图表,完美展示数据分类别关系!

本文介绍使用Python工具seaborn详细实现分类关系图表&#xff0c;包含8类图141个代码模版。 分类关系图表用于展示数字变量和一个或多个分类变量之间的关系&#xff0c;可以进一步分为&#xff1a;箱形图&#xff08;box plot&#xff09;、增强箱形图&#xff08;enhanced bo…

C++进阶 | [4.3] 红黑树

摘要&#xff1a;什么是红黑树&#xff0c;模拟实现红黑树 红黑树 &#xff0c;是一种 二叉搜索树 &#xff0c;但 在每个结点上增加一个存储位表示结点的颜色&#xff0c;可以是 Red 或 Black 。 通过对 任何一条从根到叶子的路径上各个结点着色方式的限制&#xff0c;红黑树…

创建XCOM窗体和跳转连接

Xcom 窗体&#xff1a; (groupBox组合框&#xff0c;comboBox下拉框) xcom代码&#xff1a; namespace _01_作业 {// 1kb 1024B 1200B// 1MB public partial class Form1 : Form{public List<string> botelv new List<string> { "600","1200&…

基于Tools体验NLP编程的魅力

大模型能理解自然语言&#xff0c;从而能解决问题&#xff0c;但是就像人类大脑一样&#xff0c;大脑只能发送指令&#xff0c;实际行动得靠四肢&#xff0c;所以LangChain4j提供的Tools机制就是大模型的四肢。 大模型的不足 大模型在解决问题时&#xff0c;是基于互联网上很…

图像大模型中的注意力和因果掩码

AIM — 图像领域中 LLM 的对应物。尽管 iGPT 已经存在 2 年多了&#xff0c;但自回归尚未得到充分探索。在本文中&#xff0c;作者表明&#xff0c;当使用 AIM 对网络进行预训练时&#xff0c;一组图像数据集上的下游任务的平均准确率会随着数据和参数的增加而线性增加。 要运…

Android 大话binder通信

戳蓝字“牛晓伟”关注我哦&#xff01; 用心坚持输出易读、有趣、有深度、高质量、体系化的技术文章 由于 Android 大话binder通信(上) 和 Android 大话binder通信(下) 分为两篇阅读体验不好&#xff0c;顾合并为一篇。 本文摘要 用故事的方式把binder通信的整个过程都描述…

机械原理介绍

机械原理介绍 1 介绍1.1 概述1.2 资料书籍在线资料 2 [机械原理知识整理](https://tomm.muzing.top/) 【muzing整理编写】1 绪论2 机构的结构分析2-2 机构的组成及分类2-3 机构运动简图2-4 机构具有确定运动的条件及最小阻力定律2-5 2-6 机构自由度的计算2-7 平面机构的组成原理…

【深度学习】图生图img3img论文原理,SD EDIT

https://arxiv.org/abs/2108.01073 摘要 引导图像合成技术使普通用户能够以最小的努力创建和编辑逼真的图像。关键挑战在于平衡对用户输入&#xff08;例如&#xff0c;手绘的彩色笔画&#xff09;的忠实度和合成图像的真实感。现有的基于GAN的方法试图通过使用条件GAN或GAN反…