C#WPF實戰出真汁13--【營業查詢】

1、營業查詢介紹

本模塊是最后一個模塊,該板塊需要的功能有:營業數據列表,查詢數據,導出數據,數據統計。

2、UI設計布局

TabControl 是 WPF 中用于創建多頁標簽式界面的控件,常用于組織多個子內容區域。每個子內容通過 TabItem 定義,用戶可以通過點擊標簽頭切換內容,通過修改樣式和模板,可以完全自定義 TabControl 的外觀。可以通過代碼動態管理 TabControl 中的 TabItem,TabControl 支持數據綁定,可以通過 ItemsSource 屬性綁定到一個集合,并使用 ItemTemplate 定義標簽頭的顯示方式,TabControl 提供了多個有用的事件,例如 SelectionChanged,可以在用戶切換標簽頁時執行自定義邏輯:通過設置 TabStripPlacement 屬性,可以改變標簽頭的位置,使其顯示在左側、右側或底部。

<UserControlx:Class="HQ.fResApp.UControls.BusinessInquiry"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:MetroChart="clr-namespace:De.TorstenMandelkow.MetroChart;assembly=De.TorstenMandelkow.MetroChart"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"xmlns:vm="clr-namespace:HQ.fResApp.ViewModel"d:DesignHeight="450"d:DesignWidth="1000"Background="#f6f9ff"mc:Ignorable="d"><UserControl.DataContext><vm:BusinessInquiryListVModel /></UserControl.DataContext><TabControlMargin="20"VerticalAlignment="Stretch"pu:TabControlHelper.HeaderPanelBackground="#fcfcfc"pu:TabControlHelper.ItemHeight="50"pu:TabControlHelper.ItemPadding="20,0"pu:TabControlHelper.ItemsAlignment="LeftOrTop"pu:TabControlHelper.SelectedBackground="#FF009BFF"pu:TabControlHelper.SelectedForeground="#ffffff"pu:TabControlHelper.TabControlStyle="Card"><TabItemBackground="BlanchedAlmond"BorderBrush="AliceBlue"BorderThickness="1"Cursor="Hand"FontFamily="雅黑"FontSize="20"Header="營業訂單數據"><Grid Margin="10"><Grid.ColumnDefinitions><ColumnDefinition Width="56*" /><ColumnDefinition Width="411*" /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition /></Grid.RowDefinitions><Grid Grid.ColumnSpan="2"><Grid.RowDefinitions><RowDefinition Height="80" /><RowDefinition /><RowDefinition Height="60" /></Grid.RowDefinitions><Grid Background="#ffffff"><Grid.ColumnDefinitions><ColumnDefinition /></Grid.ColumnDefinitions><StackPanel Orientation="Horizontal"><TextBoxWidth="280"Height="40"Margin="0,0,20,0"pu:TextBoxHelper.Watermark="輸入訂單號搜索"FontSize="15"Foreground="#909399"Text="{Binding BillHistoryKey}" /><Buttonx:Name="btnSearch"Width="100"Height="40"Margin="0,0,20,0"Padding="-10,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.ClickStyle="Sink"pu:ButtonHelper.CornerRadius="20"pu:ButtonHelper.HoverBrush="#009BFF"pu:ButtonHelper.Icon="/HQ.fResApp;component/Resources/icon/search.png"pu:IconHelper.Width="40"Background="#FF009BFF"BorderBrush="#FF009BFF"Command="{Binding FindCommand}"Content="查詢"Cursor="Hand"FontSize="16"Foreground="#ffffff"IsDefault="true" /><ButtonWidth="100"Height="40"Margin="0,0,20,0"Padding="-10,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.ClickStyle="Sink"pu:ButtonHelper.CornerRadius="20"pu:ButtonHelper.HoverBrush="#009BFF"pu:ButtonHelper.Icon="/HQ.fResApp;component/Resources/icon/Refresh.png"pu:IconHelper.Width="40"Background="LightSlateGray"BorderBrush="#FF009BFF"Command="{Binding ResetCommand}"Content="重置"Cursor="Hand"FontSize="16"Foreground="#ffffff" /><ButtonWidth="140"Height="40"Margin="0,0,20,0"Padding="-10,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.ClickStyle="Sink"pu:ButtonHelper.CornerRadius="20"pu:ButtonHelper.HoverBrush="#65d17f"pu:ButtonHelper.Icon="/HQ.fResApp;component/Resources/icon/openorder.png"pu:IconHelper.Width="35"Background="#ab4321"BorderBrush="#65d17f"Command="{Binding BackUpAllCommand}"Content="導出全部數據"Cursor="Hand"FontSize="16"Foreground="#ffffff" /><ButtonWidth="140"Height="40"Margin="0,0,20,0"Padding="-10,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.ClickStyle="Sink"pu:ButtonHelper.CornerRadius="20"pu:ButtonHelper.HoverBrush="#65d17f"pu:ButtonHelper.Icon="/HQ.fResApp;component/Resources/icon/openorder.png"pu:IconHelper.Width="35"Background="#65d17f"BorderBrush="#65d17f"Command="{Binding BackUpPageCommand}"Content="導出本頁數據"Cursor="Hand"FontSize="16"Foreground="#ffffff" /></StackPanel></Grid><DataGridx:Name="tableList"Grid.Row="1"pu:DataGridHelper.ColumnHorizontalContentAlignment="Center"pu:DataGridHelper.HeaderBackground="#FF009BFF"pu:DataGridHelper.HeaderForeground="#ffffff"pu:DataGridHelper.HeaderMinHeight="50"pu:DataGridHelper.HoverBackground="#FF009BFF"pu:DataGridHelper.ResizeThumbThickness="0.5"pu:DataGridHelper.SelectedBackground="Transparent"pu:DataGridHelper.SelectedForeground="Red"AlternatingRowBackground="#f7faff"AutoGenerateColumns="False"CanUserAddRows="False"CanUserDeleteRows="False"CanUserReorderColumns="False"CanUserResizeRows="False"Cursor="Pen"FontSize="16"ItemsSource="{Binding BillHistoryDataList}"SelectionMode="Extended"SelectionUnit="FullRow"><DataGrid.RowStyle><Style TargetType="DataGridRow"><!--  Event綁定MouseLeftButtonUp表示鼠標點擊事件,Handler表示具體的事件處理程序  --><Setter Property="Height" Value="40" /><!--  樣式觸發器,IsMouseOver表示鼠標滑過時事件  --><Style.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter Property="Background"><Setter.Value><LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"><GradientStop Offset="0.98" Color="#FF73BCE8" /><GradientStop Offset="0" Color="White" /></LinearGradientBrush></Setter.Value></Setter></Trigger></Style.Triggers></Style></DataGrid.RowStyle><DataGrid.Columns><DataGridTextColumnWidth="2*"Binding="{Binding tName}"FontSize="18"Header="餐桌號"IsReadOnly="True" /><DataGridTextColumnWidth="3*"Binding="{Binding obId}"FontSize="18"Header="訂單號"IsReadOnly="True" /><DataGridTextColumnWidth="4*"Binding="{Binding obDate, StringFormat='{}{0:yyyy年MM月dd日 dddd HH時mm分}', ConverterCulture=zh-CN}"FontSize="18"Header="開單時間"IsReadOnly="True" /><DataGridTextColumnWidth="2*"Binding="{Binding obNumber}"FontSize="18"Header="消費人數"IsReadOnly="True" /><DataGridTextColumnWidth="2*"Binding="{Binding opConsumeMoney}"FontSize="18"Header="消費金額"IsReadOnly="True" /><DataGridTextColumnWidth="2*"Binding="{Binding opClientMoney}"FontSize="18"Header="支付金額"IsReadOnly="True" /><DataGridTextColumnWidth="4*"Binding="{Binding obDate, StringFormat='{}{0:yyyy年MM月dd日 dddd HH時mm分}', ConverterCulture=zh-CN}"FontSize="18"Header="創建時間"IsReadOnly="True" /><DataGridTextColumnWidth="3*"Binding="{Binding opRemark}"FontSize="18"Header="備注"IsReadOnly="True" /></DataGrid.Columns></DataGrid><Grid Grid.Row="2"><Grid.ColumnDefinitions><ColumnDefinition /><ColumnDefinition Width="250" /></Grid.ColumnDefinitions><pu:Paginationx:Name="tabPagination"Height="45"Margin="0,0,20,0"HorizontalAlignment="Left"Background="#963F3F3F"CurrentIndex="{Binding BillHistoryCurrentIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"CurrentIndexChanged="tabPageActiveChanged"Cursor="Hand"HoverBrush="#FF009BFF"Spacing="15"TotalIndex="{Binding BillHistoryTotalIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /><StackPanelGrid.Column="1"HorizontalAlignment="Right"Orientation="Horizontal"><ButtonWidth="20"Height="45"Padding="-35,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.HoverBrush="Transparent"pu:IconHelper.Width="35"Background="Transparent"BorderBrush="Transparent"Content="共"FontSize="17"FontWeight="ExtraBold"Foreground="#2F4056" /><Buttonx:Name="txtTotalNum"Height="45"Padding="-35,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.HoverBrush="Transparent"pu:IconHelper.Width="35"Background="Transparent"BorderBrush="Transparent"Content="{Binding BillHistoryTotalNum, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"FontSize="17"FontWeight="ExtraBold"Foreground="#FF009BFF" /><ButtonWidth="100"Height="45"Padding="-35,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.HoverBrush="Transparent"pu:IconHelper.Width="35"Background="Transparent"BorderBrush="Transparent"Content="條數據/每頁"FontSize="17"FontWeight="ExtraBold"Foreground="#2F4056" /><TextBoxx:Name="txtPageSize"Grid.Row="2"Width="50"Height="30"HorizontalAlignment="Center"pu:TextBoxHelper.CornerRadius="0"Text="{Binding BillHistoryPageSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /><ButtonWidth="20"Height="45"Padding="-35,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.HoverBrush="Transparent"pu:IconHelper.Width="35"Background="Transparent"BorderBrush="Transparent"Content="條"FontSize="17"FontWeight="ExtraBold"Foreground="#2F4056" /></StackPanel></Grid></Grid></Grid></TabItem><TabItemBackground="BlanchedAlmond"BorderBrush="AliceBlue"BorderThickness="1"Cursor="Hand"FontFamily="雅黑"FontSize="20"FontWeight="Bold"Header="最近一周"><Grid><Grid.RowDefinitions><RowDefinition Height="1*" /><RowDefinition Height="9*" /></Grid.RowDefinitions><StackPanel HorizontalAlignment="Right" Orientation="Horizontal"><ButtonWidth="100"Height="40"Margin="0,-10,20,0"Padding="-10,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.ClickStyle="Sink"pu:ButtonHelper.CornerRadius="20"pu:ButtonHelper.HoverBrush="#009BFF"pu:ButtonHelper.Icon="/HQ.fResApp;component/Resources/icon/Refresh.png"pu:IconHelper.Width="40"Background="#65d17f"BorderBrush="#65d17f"Content="刷新"Cursor="Hand"FontSize="16"Foreground="#ffffff" /></StackPanel><MetroChart:ClusteredColumnChartGrid.Row="1"Margin="0,-10,20,0"ChartLegendVisibility="Collapsed"ChartSubTitle="額度"ChartTitle="最近一周營業情況統計"ChartTitleVisibility="Visible"IsRowColumnSwitched="True"ToolTipFormat="{Binding Path=ToolTipFormat}"><MetroChart:ClusteredColumnChart.Series><MetroChart:ChartSeriesDisplayMember="Name"ItemsSource="{Binding Path=WeekDatas}"SeriesTitle="日期"ValueMember="Count" /></MetroChart:ClusteredColumnChart.Series></MetroChart:ClusteredColumnChart></Grid></TabItem><TabItemBackground="BlanchedAlmond"BorderBrush="AliceBlue"BorderThickness="1"Cursor="Hand"FontFamily="雅黑"FontSize="20"FontWeight="Bold"Header="最近一個月"><Grid><Grid.RowDefinitions><RowDefinition Height="1*" /><RowDefinition Height="9*" /></Grid.RowDefinitions><StackPanel HorizontalAlignment="Right" Orientation="Horizontal"><ButtonWidth="100"Height="40"Margin="0,-10,20,0"Padding="-10,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.ClickStyle="Sink"pu:ButtonHelper.CornerRadius="20"pu:ButtonHelper.HoverBrush="#009BFF"pu:ButtonHelper.Icon="/HQ.fResApp;component/Resources/icon/Refresh.png"pu:IconHelper.Width="40"Background="#65d17f"BorderBrush="#65d17f"Content="刷新"Cursor="Hand"FontSize="16"Foreground="#ffffff" /></StackPanel><MetroChart:ClusteredColumnChartGrid.Row="1"Margin="0,-10,20,0"ChartLegendVisibility="Collapsed"ChartSubTitle="額度"ChartTitle="最近一個月營業情況統計"ChartTitleVisibility="Visible"IsRowColumnSwitched="True"ToolTipFormat="{Binding Path=ToolTipFormat}"><MetroChart:ClusteredColumnChart.Series><MetroChart:ChartSeriesDisplayMember="Name"ItemsSource="{Binding Path=MonthDatas}"SeriesTitle="日期"ValueMember="Count" /></MetroChart:ClusteredColumnChart.Series></MetroChart:ClusteredColumnChart></Grid></TabItem><TabItemBackground="BlanchedAlmond"BorderBrush="AliceBlue"BorderThickness="1"Cursor="Hand"FontFamily="雅黑"FontSize="20"FontWeight="Bold"Header="按年份統計"><Grid><Grid.RowDefinitions><RowDefinition Height="1*" /><RowDefinition Height="9*" /></Grid.RowDefinitions><StackPanel HorizontalAlignment="Right" Orientation="Horizontal"><ButtonWidth="100"Height="40"Margin="0,-10,20,0"Padding="-10,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.ClickStyle="Sink"pu:ButtonHelper.CornerRadius="20"pu:ButtonHelper.HoverBrush="#009BFF"pu:ButtonHelper.Icon="/HQ.fResApp;component/Resources/icon/Refresh.png"pu:IconHelper.Width="40"Background="#65d17f"BorderBrush="#65d17f"Content="刷新"Cursor="Hand"FontSize="16"Foreground="#ffffff" /></StackPanel><MetroChart:ClusteredColumnChartGrid.Row="1"Margin="0,-10,20,0"ChartLegendVisibility="Collapsed"ChartSubTitle="額度"ChartTitle="各年份營業情況統計"ChartTitleVisibility="Visible"IsRowColumnSwitched="True"ToolTipFormat="{Binding Path=ToolTipFormat}"><MetroChart:ClusteredColumnChart.Series><MetroChart:ChartSeriesDisplayMember="Name"ItemsSource="{Binding Path=YearDatas}"SeriesTitle="年份"ValueMember="Count" /></MetroChart:ClusteredColumnChart.Series></MetroChart:ClusteredColumnChart></Grid></TabItem></TabControl>
</UserControl>

3、viewmodel模型

ViewModel 的主要職責是封裝業務邏輯和狀態,為視圖提供數據綁定和命令綁定的接口。通過數據綁定,ViewModel 能夠將數據從 Model 傳遞到 View,同時處理用戶輸入和界面邏輯,而無需直接操作 UI 元素,viewmodel就是一個類,這個類中包括了變量,屬性,命令,其中屬性和命令是最重要的,屬性是動態通知屬性,當屬性的值發生更改時,自動更新界面元素標簽,反過來也是這樣的,命令來說就是響應事件,如單擊,雙擊,右鍵等。

using HQ.BLL;
using HQ.COMM;
using HQ.COMM.DtoModel;
using HQ.fResApp.BaseModel;
using HQ.fResApp.Utils;
using HQ.fResApp.ViewModel.PageViewModel;
using HQ.MODEL.DBModel;
using Panuon.UI.Silver;
using Panuon.UI.Silver.Core;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;namespace HQ.fResApp.ViewModel
{/// <summary>/// 營業查詢視圖模型/// </summary>public class BusinessInquiryListVModel : ViewModelBase{#region 變量BillHistoryBLL billhistoryBLL = new BillHistoryBLL();public string ToolTipFormat{get { return "當前額度是:{1},在總額中占比為:{3:P2}"; }}#endregionpublic BusinessInquiryListVModel(){BillHistoryDataList = getBillHistoryList();InitUIData();}#region 屬性public ObservableCollection<Population> weekDatas = new ObservableCollection<Population>(); public ObservableCollection<Population> WeekDatas{get { return weekDatas; }set{weekDatas = value;OnPropertyChanged();}}public ObservableCollection<Population> monthDatas = new ObservableCollection<Population>();public ObservableCollection<Population> MonthDatas{get { return monthDatas; }set{monthDatas = value;OnPropertyChanged();}}public ObservableCollection<Population> yearhDatas = new ObservableCollection<Population>(); public ObservableCollection<Population> YearDatas{get { return yearhDatas; }set{yearhDatas = value;OnPropertyChanged();}}ObservableCollection<BillHistory> billHistoryDataList = new ObservableCollection<BillHistory>();/// <summary>///歷史訂單列表/// </summary>public ObservableCollection<BillHistory> BillHistoryDataList{get { return billHistoryDataList; }set{billHistoryDataList = value;OnPropertyChanged();}}private int billHistoryCurrentIndex = 1;/// <summary>/// 當前頁,默認第1頁/// </summary>public int BillHistoryCurrentIndex{get { return billHistoryCurrentIndex; }set{billHistoryCurrentIndex = value;OnPropertyChanged();}}private int billHistoryTotalIndex;/// <summary>/// 總頁數/// </summary>public int BillHistoryTotalIndex{get { return billHistoryTotalIndex; }set{billHistoryTotalIndex = value;OnPropertyChanged();}}private int billHistoryTotalNum;/// <summary>/// 總條數/// </summary>public int BillHistoryTotalNum{get { return billHistoryTotalNum; }set{billHistoryTotalNum = value;OnPropertyChanged();}}private int billHistoryPageSize = 15;/// <summary>/// 每頁條數,默認10條/// </summary>public int BillHistoryPageSize{get { return billHistoryPageSize; }set{billHistoryPageSize = value;OnPropertyChanged();//當改變每頁條數時,觸發以下事件BillHistoryDataList = getBillHistoryList(); //訂單歷史數據集合}}private string billHistoryKey = "";/// <summary>/// 搜索時的關鍵字,默認為空/// </summary>public string BillHistoryKey{get { return billHistoryKey; }set{billHistoryKey = value;OnPropertyChanged();}}#endregion#region 方法private void InitUIData(){//最近一周var _resweek = billhistoryBLL.CountBillHistoryData(new CountModelDto { _where = 7 }).Result;if (_resweek.statusCode == (int)ApiEnum.Status){foreach (var item in _resweek.data){weekDatas.Add(new Population() { Name = item.wDate, Count = item.countCost });}}//最近一月var _resmonth = billhistoryBLL.CountBillHistoryData(new CountModelDto { _where = 30 }).Result;if (_resmonth.statusCode == (int)ApiEnum.Status){foreach (var item in _resmonth.data){monthDatas.Add(new Population() { Name = item.wDate, Count = item.countCost });}}//按年份var _resyear = billhistoryBLL.CountBillHistoryData(new CountModelDto { _where = 365 }).Result;if (_resyear.statusCode == (int)ApiEnum.Status){foreach (var item in _resyear.data){yearhDatas.Add(new Population() { Name = item.wDate, Count = item.countCost });}}}/// <summary>/// 獲取訂單歷史數據/// </summary>/// <returns></returns>public ObservableCollection<BillHistory> getBillHistoryList(){ObservableCollection<BillHistory> TableDataList = new ObservableCollection<BillHistory>();var parms = new PageParm { page = BillHistoryCurrentIndex, limit = BillHistoryPageSize, key = BillHistoryKey.Trim() };var pageRes = billhistoryBLL.GetBillHistoryPages(parms).Result;//分頁查詢結果if (pageRes.statusCode == (int)ApiEnum.Status){var _pageResData = pageRes.data;var tabList = _pageResData.Items;//數據集需要重新處理,將每個數據項加上復選框,用于頁面數據展示if (tabList != null && tabList.Count != 0){foreach (var item in tabList){var curBill = new BillHistory{obGuid = item.obGuid,obId = item.obId,tName = item.tName,obDate = item.obDate,obNumber = item.obNumber,opConsumeMoney = item.opConsumeMoney,opClientMoney = item.opClientMoney,opRemark = item.opRemark,lastUpDate = item.lastUpDate };TableDataList.Add(curBill);}BillHistoryTotalNum = (int)_pageResData.TotalItems;BillHistoryCurrentIndex = (int)_pageResData.CurrentPage;BillHistoryTotalIndex = (int)_pageResData.TotalPages;}else{Notice.Show("沒有獲取到歷史列表數據!", "提示", 3, MessageBoxIcon.Info);Logger.Default.ProcessError((int)ApiEnum.Error, "沒有獲取到歷史列表數據");}}else{Notice.Show("沒有獲取到歷史列表數據!", "提示", 3, MessageBoxIcon.Info);Logger.Default.ProcessError(pageRes.statusCode, "獲取到歷史列表數據異常");}return TableDataList;}/// <summary>/// 導出數據/// </summary>/// <param name="array">列表對象</param>/// <param name="filename">文件名稱</param>/// <exception cref="NotImplementedException"></exception>private void Backup<T>(List<T> array, string name){var t = typeof(T);var properties = t.GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);var contents = new StringBuilder();//標題foreach (var item in properties){//得到第一個自定義屬性的參數的值,即屬性描述var desc = item.CustomAttributes.ToList()[0].ConstructorArguments[0].Value.ToString();contents.Append(desc);contents.Append(",");}contents.Append("\r\n");//換行//內容foreach (var model in array){var row = new StringBuilder();foreach (var property in properties){var val = property.GetValue(model);row.Append(val);row.Append(",");}contents.Append(row.ToString());contents.Append("\r\n");}//finename -> 表格+日期var date = string.Format("{0:yyyyMMddHHmmssffff}", DateTime.Now);var filename = $"{name}{date}.csv";var rootImagPath = Directory.GetCurrentDirectory().Replace(@"\bin\Debug", "") + @"\Resources\proData\" + filename;//保存File.WriteAllText(rootImagPath, contents.ToString(), Encoding.UTF8);//以utf-8的格式保存成csv格式MessageBoxX.Show("數據導出成功!", "提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Success,ButtonBrush = "#F1C825".ToColor().ToBrush(),});}#endregion/// <summary>/// 查詢命令/// </summary>public ICommand FindCommand{get{return new RelayCommand(o =>{BillHistoryDataList = getBillHistoryList();});}}/// <summary>/// 重置命令/// </summary>public ICommand ResetCommand{get{return new RelayCommand(o =>{BillHistoryCurrentIndex = 1;//當前頁為第1頁BillHistoryPageSize = 15;//每頁10條BillHistoryKey = "";//關鍵字清空 BillHistoryDataList = getBillHistoryList();//訂單數據集合 });}}/// <summary>/// 導出本頁/// </summary>public ICommand BackUpPageCommand{get{return new RelayCommand(o =>{Backup(BillHistoryDataList.ToList(), "billspage");});}}/// <summary>/// 導出全部/// </summary>public ICommand BackUpAllCommand{get{return new RelayCommand(o =>{ParmString ps = new ParmString();var objdata = billhistoryBLL.QueryBillHistoryList(ps).Result.data;Backup(objdata, "billslist");});}}}
}

using HQ.BLL;
using HQ.COMM.DtoModel;
using HQ.fResApp.BaseModel;
using HQ.fResApp.Utils;
using HQ.fResApp.ViewModel.PageViewModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace HQ.fResApp.ViewModel
{/// <summary>///  營業查詢視圖模型/// </summary>public class MetroChartVModel : ViewModelBase{BillHistoryBLL openBillsService = new BillHistoryBLL();public string ToolTipFormat{get { return "當前額度是:{1},在總額中占比為:{3:P2}"; }}private readonly ObservableCollection<Population> _weekDatas = new ObservableCollection<Population>();private readonly ObservableCollection<Population> _monthDatas = new ObservableCollection<Population>();private readonly ObservableCollection<Population> _yearhDatas = new ObservableCollection<Population>();public ObservableCollection<Population> WeekDatas { get { return _weekDatas; } }public ObservableCollection<Population> MonthDatas { get { return _monthDatas; } }public ObservableCollection<Population> YearDatas { get { return _yearhDatas; } }public MetroChartVModel(){//最近一周var _resweek = openBillsService.CountBillHistoryData(new CountModelDto { _where = 7 }).Result;if (_resweek.statusCode == (int)ApiEnum.Status){foreach (var item in _resweek.data) { _weekDatas.Add(new Population(){ Name = item.wDate, Count = item.countCost }); }}//最近一月var _resmonth = openBillsService.CountBillHistoryData(new CountModelDto { _where = 30 }).Result;if (_resmonth.statusCode == (int)ApiEnum.Status){foreach (var item in _resmonth.data) { _monthDatas.Add(new Population() { Name = item.wDate, Count = item.countCost }); }}//按年份var _resyear = openBillsService.CountBillHistoryData(new CountModelDto { _where = 365 }).Result;if (_resyear.statusCode == (int)ApiEnum.Status){foreach (var item in _resyear.data) { _yearhDatas.Add(new Population() { Name = item.wDate, Count = item.countCost }); }}}}
}

4、運行測試

原創不易,打字截圖不易,走過路過,不要錯過,歡迎點贊,收藏,轉載,復制,抄襲,留言,灌水,噴火,吐槽,動動你的金手指,早日實現財務自由!

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/94013.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/94013.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/94013.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

基于 Java 和 MySQL 的精品課程網站

基于 Java 和 MySQL 的精品課程網站設計與實現一、 畢業設計&#xff08;論文&#xff09;任務書摘要&#xff1a;近年來&#xff0c;教育信息化發展十分迅猛&#xff0c;人們的教育觀念、教育手段、學習方法、學習渠道等等都發生了重大的變化。知識性人才也已經日益成為了一個…

全球首款 8K 全景無人機影翎 A1 發布解讀:航拍進入“先飛行后取景”時代

全球首款 8K 全景無人機影翎 A1 發布解讀&#xff1a;航拍進入“先飛行后取景”時代 特別說明&#xff1a;本文所有圖片素材來源于影翎官網 影翎官方介紹稱&#xff1a;“全球首款”是指截至 2025 年&#xff0c;A1 是首臺全面整合的全景無人機&#xff1a;無需外掛全景相機配件…

androidstudio內存大小配置

help->Edit Custom Vm option-Xmx8096m或者其他數值 改成-Xmx10240m然后設置里面的內存大小也要修改一下

vue3和elementPlus中的el-dropdown-menu中的背景樣式修改

1. 效果展示2. 代碼展示在el-dropdown-menu下加載類名,class"my-dropdown-menu"<el-dropdown-menu class"my-dropdown-menu"><el-dropdown-item :command"{ action: upgrade, data }">升級</el-dropdown-item><el-dropdown…

計算機網絡--HTTP協議

1. 什么是 HTTP 協議全稱&#xff1a;Hyper Text Transfer Protocol&#xff08;超文本傳輸協議&#xff09;作用&#xff1a;用于在服務器與客戶端&#xff08;通常是瀏覽器&#xff09;之間傳輸超文本數據&#xff08;如文字、圖片、視頻、音頻&#xff09;的應用層協議。工作…

Bee1.17.25更新Bug,完善功能.不支持NOSQL,分庫分表Sharding(2.X版有)

Bee 1.17.25 正常的ORM功能都有,但不支持NOSQL, 分庫分表Sharding; 若需要可使用2.X版. Bee, 接口簡單&#xff0c;功能齊全&#xff0c;性能好&#xff0c;支持原生分頁性能更高&#xff1b;還有分庫分表 (Sharding 分片) 功能&#xff0c;也支持 MongoDB ORM. Bee Hiberna…

RAG流程全解析:從數據到精準答案

Rag流程分析第一部分&#xff1a;數據處理與向量化 原始文檔進入系統&#xff0c;先經過格式識別&#xff0c;把 pdf、docx、pptx、掃描圖片等統一轉成文字流。文字流丟進分段器&#xff0c;按固定長度或語義邊界切成若干文本塊&#xff0c;每個塊再生成唯一 id。如果文檔里有表…

Matplotlib數據可視化實戰:Matplotlib圖表注釋與美化入門

圖表注釋與標簽&#xff1a;提升數據可視化效果 學習目標 通過本課程的學習&#xff0c;學員將掌握如何使用Matplotlib在圖表中添加文本注釋、圖例、標題和軸標簽&#xff0c;從而提高圖表的可讀性和信息傳達能力。本課程將通過實際案例&#xff0c;幫助學員理解每個元素的作用…

GitLab 安全漏洞 CVE-2025-7739 解決方案

本分分享極狐GitLab 補丁版本 18.2.2, 18.1.4, 18.0.6 的詳細內容。這幾個版本包含重要的缺陷和安全修復代碼&#xff0c;我們強烈建議所有私有化部署用戶應該立即升級到上述的某一個版本。對于極狐GitLab SaaS&#xff0c;技術團隊已經進行了升級&#xff0c;無需用戶采取任何…

C端高并發項目都有哪些

C端&#xff08;用戶端&#xff09;高并發項目通常涉及大規模用戶直接訪問的服務&#xff0c;其核心挑戰是如何在海量用戶同時請求下&#xff0c;保證系統的穩定性、高性能、高可用和一致性。以下是一些典型的C端高并發項目類型和具體案例&#xff1a;?核心類型與典型案例&…

OSCP - Proving Grounds - Shenzi

主要知識點 路徑爆破小技巧 windows AlwaysInstallElevated 提權 具體步驟 依舊是nmap開始&#xff0c;其中80/443/139/445端口值得關注一下 Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-01 15:06 UTC Nmap scan report for 192.168.53.55 Host is up (0.0008…

結合BI多維度異常分析(日期-> 商家/渠道->日期(商家/渠道))

技術手段&#xff1a; BI工具&#xff08;finereport &#xff09;、python、sql 數據更新&#xff1a; 每日零點更新數據。&#xff08;獨立開發&#xff09; 商業智能分析平臺 | Python/FineReport/SQLAlchemy 項目描述 業務價值 &#xff1a;解決原有系統無法快速定位傭金異…

計算機畢設Spark項目實戰:基于大數據技術的就業數據分析系統Django+Vue開發指南

&#x1f393; 作者&#xff1a;計算機畢設小月哥 | 軟件開發專家 &#x1f5a5;? 簡介&#xff1a;8年計算機軟件程序開發經驗。精通Java、Python、微信小程序、安卓、大數據、PHP、.NET|C#、Golang等技術棧。 &#x1f6e0;? 專業服務 &#x1f6e0;? 需求定制化開發源碼提…

如何讓FastAPI任務系統在失敗時自動告警并自我修復?

url: /posts/2f104637ecc916e906c002fa79ab8c80/ title: 如何讓FastAPI任務系統在失敗時自動告警并自我修復? date: 2025-08-20T08:18:42+08:00 lastmod: 2025-08-20T08:18:42+08:00 author: cmdragon summary: FastAPI 和 Celery 結合提供了強大的異步任務處理能力,但在分布…

Gitee倉庫 日常操作詳細步驟

新建倉庫 → 上傳代碼 步驟1、打開Gitee倉庫網站&#xff1a;開源軟件 - Gitee.com 步驟2、點擊右上角加號 點擊新建倉庫。 步驟3、設置倉庫名 &#xff0c;選擇是否開源 &#xff0c;點擊創建。 步驟4、記住遠程倉庫URL 步驟5、本地新建文件夾&#xff0c;然后進行上傳代碼…

Python采集易貝(eBay)商品詳情API接口,json數據返回

Python采集易貝(eBay)商品詳情API接口要采集eBay商品詳情&#xff0c;你可以使用eBay官方提供的API。以下是使用Python通過eBay Finding API獲取商品詳情的完整示例&#xff1a;準備工作注冊賬號并獲取API密鑰&#xff1a;選擇適合的API&#xff08;如Finding API、Shopping AP…

如何將任意文件一鍵轉為PDF?

無論你用什么軟件打開文件&#xff08;Word、Excel、網頁、CAD圖紙、圖片等&#xff09;&#xff0c;只要能打印&#xff0c;就可以通過虛擬打印機將其轉為PDF&#xff0c;確保對方收到的文件看起來和你看到的一模一樣。它是小巧實用的PDF虛擬打印工具&#xff0c;采用安裝包形…

遷移學習+多模態融合破解跨域難題,解鎖視覺感知新范式

在近期的頂會頂刊中&#xff0c;遷移學習與多模態融合的熱度居高不下&#xff0c;相關成果頻出&#xff0c;部分模型在特定任務里性能提升極為顯著。登上頂刊 TPAMI 2025 的某篇研究&#xff0c;借助語言引導的關系遷移&#xff0c;大幅提升了少樣本類增量學習中模型的泛化能力…

C語言---分隔符、常量、注釋、標識符、關鍵字、空格

文章目錄分隔符注釋注意標識符標識符的定義標識符的命名要求合法與非法標識符示例關鍵字關鍵字定義關鍵字一覽(按功能分類)空格一、空格的作用&#xff1a;分隔令牌 (Tokens)空格的使用場景必須用空格分隔的情況不能有空格的情況分隔符 分隔符名稱主要用途;分號語句結束符,逗號…

創建Vue項目的不同方式及項目規范化配置

1 項目的創建與運行 1.1 基于webpack構建工具——vue-cli腳手架 1. 安裝腳手架 &#xff1a;npm i -g vue/cli # 安裝一次即可&#xff0c;之前安裝過則無需重復安裝 2. 切換到項目所在目錄 &#xff1a;cd 項目所在目錄 3. 創建項目 &#xff1a;vue create 項目名 4. 自定…