1、菜品设置介绍 

菜品设置跟餐桌设置的功能目的是相同的,包括了新增,删除,编辑,分页,查询,重置,全选,全消,列表功能,实现流程也是布局设计,后台逻辑,视图模型绑定,运行测试。

2、布局设计

Grid 是 WPF 中常用的布局控件,以行和列的形式组织子元素,支持灵活的尺寸定义和元素定位。

定义 Grid 的行和列通过 RowDefinitions 和 ColumnDefinitions 属性定义,支持多种尺寸单位:

固定尺寸:Width="100" 或 Height="50"
自动尺寸:Width="Auto"(根据内容调整)
比例尺寸:Width="*" 或 Width="2*"(按比例分配剩余空间)

StackPanel 是一个简单的布局控件,适合子元素的线性排列。通过 Orientation 属性可以控制排列方向(垂直或水平)。可以与其他布局控件嵌套使用以实现复杂布局。对于需要滚动或动态调整大小的场景。StackPanel 是 WPF 中的一个常用布局控件,用于沿水平或垂直方向堆叠子元素。默认情况下,子元素按垂直方向排列,但可以通过设置 Orientation 属性调整为水平排列。StackPanel 不会自动调整子元素的大小,通常用于简单的布局场景。

完整代码

<UserControlx:Class="HQ.fResApp.UControls.XiTongSheZhi"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:local="clr-namespace:HQ.fResApp.UControls"xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"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"Padding="20"d:DesignHeight="450"d:DesignWidth="1000"Background="#f6f9ff"mc:Ignorable="d"><UserControl.DataContext><vm:DiningDishTypeListVModel /></UserControl.DataContext><TabControlMargin="10"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="Aquamarine"BorderBrush="AliceBlue"BorderThickness="1"Cursor="Hand"FontFamily="黑体"FontSize="20"FontStyle="Normal"Header="餐桌类型设置"><Grid Margin="10"><Grid.ColumnDefinitions><ColumnDefinition Width="12*" /><ColumnDefinition Width="103*" /><ColumnDefinition Width="345*" /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="55" /><RowDefinition Height="15" /><RowDefinition /><RowDefinition Height="73" /></Grid.RowDefinitions><Grid Grid.ColumnSpan="3" Background="#ffffff"><Grid.ColumnDefinitions><ColumnDefinition Width="400*" /><ColumnDefinition Width="61*" /><ColumnDefinition Width="460" /></Grid.ColumnDefinitions><StackPanelGrid.ColumnSpan="3"Margin="0,0,410,0"Orientation="Horizontal"><TextBoxx:Name="keyWhereTab"Width="160"Height="40"Margin="0,15,20,0"pu:TextBoxHelper.Watermark="输入餐桌关键字"FontSize="15"Foreground="#909399"Text="{Binding DiningTypeKey, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /><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/search.png"pu:IconHelper.Width="40"Background="#FF009BFF"BorderBrush="#FF009BFF"Command="{Binding FindCommand}"CommandParameter="dining"Content="查询"Cursor="Hand"FontSize="16"Foreground="#ffffff"IsDefault="true" /><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="LightSlateGray"BorderBrush="#FF009BFF"Command="{Binding ResetCommand}"CommandParameter="dining"Content="重置"Cursor="Hand"FontSize="16"Foreground="#ffffff" /></StackPanel><StackPanelGrid.Column="2"Margin="80,0,0,0"HorizontalAlignment="Left"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="#65d17f"pu:ButtonHelper.Icon="/HQ.fResApp;component/Resources/icon/add.png"pu:IconHelper.Width="35"Background="#65d17f"BorderBrush="#65d17f"Command="{Binding AddCommand}"CommandParameter="dining"Content="新增"Cursor="Hand"FontSize="16"Foreground="#ffffff" /><ButtonWidth="100"Height="40"Margin="30,12,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="Black"BorderBrush="Black"Command="{Binding EditCommand}"CommandParameter="dining"Content="编辑"Cursor="Hand"FontSize="16"Foreground="#ffffff" /><ButtonWidth="100"Height="40"Margin="10,15,20,0"Padding="-10,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.ClickStyle="Sink"pu:ButtonHelper.CornerRadius="20"pu:ButtonHelper.HoverBrush="#FF5722"pu:ButtonHelper.Icon="/HQ.fResApp;component/Resources/icon/remove1.png"pu:IconHelper.Width="35"Background="#FF5722"BorderBrush="#FF5722"Command="{Binding DeleteCommand}"CommandParameter="dining"Content="删除"Cursor="Hand"FontSize="16"Foreground="#ffffff" /></StackPanel></Grid><Border Grid.Row="1" Grid.ColumnSpan="3" /><DataGridx:Name="dataListTab"Grid.Row="2"Grid.ColumnSpan="3"pu:DataGridHelper.ColumnHorizontalContentAlignment="Center"pu:DataGridHelper.HeaderBackground="#FF009BFF"pu:DataGridHelper.HeaderForeground="#ffffff"pu:DataGridHelper.HeaderMinHeight="50"pu:DataGridHelper.ResizeThumbThickness="0.5"pu:DataGridHelper.SelectedBackground="Transparent"pu:DataGridHelper.SelectedForeground="Red"AutoGenerateColumns="False"CanUserAddRows="False"CanUserDeleteRows="False"CanUserReorderColumns="False"CanUserResizeRows="False"Cursor="Pen"FontSize="16"ItemsSource="{Binding DiningTypeList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"SelectionMode="Extended"SelectionUnit="FullRow"><DataGrid.RowStyle><Style TargetType="DataGridRow"><EventSetter Event="MouseLeftButtonUp" Handler="DiningItem_GotFocus" /><Setter Property="Height" Value="40" /><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><!--  模板列  --><DataGridTemplateColumn><!--  模板列的头模板  --><DataGridTemplateColumn.HeaderTemplate><DataTemplate><CheckBoxVerticalAlignment="Center"pu:CheckBoxHelper.CheckBoxStyle="Switch"Command="{Binding DataContext.DiningCheckAllCmd, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"Content="全选"Foreground="#ffffff"IsChecked="{Binding DataContext.IsCheckAllDining, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" /></DataTemplate></DataGridTemplateColumn.HeaderTemplate><!--  模板列的单元格模板  --><DataGridTemplateColumn.CellTemplate><DataTemplate><CheckBoxHorizontalAlignment="Center"VerticalAlignment="Center"Command="{Binding DataContext.CheckDiningType, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=DataContext}"IsChecked="{Binding IsCheck, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn><!--  此处单元格绑定的属性是视图模型DiningDishTypeListVModel中的DiningTypeInfo属性的各个属性  --><DataGridTextColumnWidth="2*"Binding="{Binding DiningTypeInfo.rtName}"Header="餐桌类型名称"IsReadOnly="True" /><DataGridTextColumnWidth="2*"Binding="{Binding DiningTypeInfo.rtLeastCost}"Header="最低消费"IsReadOnly="True" /><DataGridTextColumnWidth="1*"Binding="{Binding DiningTypeInfo.rtMostNumber}"Header="容纳人数"IsReadOnly="True" /><DataGridTextColumnWidth="1*"Binding="{Binding DiningTypeInfo.rtAmount}"Header="房间个数"IsReadOnly="True" /><DataGridTextColumnWidth="3*"Binding="{Binding DiningTypeInfo.createDate, ConverterCulture=zh-CN, StringFormat=\{0:yyyy年MM月dd日 dddd HH时mm分\}}"Header="创建日期"IsReadOnly="True" /><DataGridTextColumnWidth="3*"Binding="{Binding DiningTypeInfo.lastUpDate, ConverterCulture=zh-CN, StringFormat=\{0:yyyy年MM月dd日 dddd HH时mm分\}}"Header="修改日期"IsReadOnly="True" /></DataGrid.Columns></DataGrid><Grid Grid.Row="3" Grid.ColumnSpan="3"><Grid.ColumnDefinitions><ColumnDefinition /><ColumnDefinition Width="250" /></Grid.ColumnDefinitions><!--  餐桌类型分页控件  --><pu:Paginationx:Name="tabPaginationTab"Height="45"Margin="0,0,20,0"HorizontalAlignment="Left"Background="#963F3F3F"CurrentIndex="{Binding DiningCurrentIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"CurrentIndexChanged="tabPaginationTab_CurrentIndexChanged"Cursor="Hand"HoverBrush="#FF009BFF"Spacing="15"TotalIndex="{Binding DiningTotalIndex, 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="txtTotalNumTab"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 DiningTotalNum, 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="txtPageSizeTab"Grid.Row="2"Width="30"Height="30"HorizontalAlignment="Center"pu:TextBoxHelper.CornerRadius="0"Text="{Binding DiningPageSize, 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></TabItem><TabItemBackground="Aquamarine"BorderBrush="AliceBlue"BorderThickness="1"Cursor="Hand"FontFamily="黑体"FontSize="20"FontStyle="Normal"Header="菜品类型设置"><Grid Margin="10"><Grid.ColumnDefinitions><ColumnDefinition Width="32*" /><ColumnDefinition Width="21*" /><ColumnDefinition Width="867*" /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="55" /><RowDefinition Height="15" /><RowDefinition /><RowDefinition Height="73" /></Grid.RowDefinitions><Grid Grid.ColumnSpan="3" Background="#ffffff"><Grid.ColumnDefinitions><ColumnDefinition /><ColumnDefinition Width="460" /></Grid.ColumnDefinitions><StackPanelGrid.ColumnSpan="2"Margin="0,0,385,0"Orientation="Horizontal"><TextBoxx:Name="keyPWhere"Width="160"Height="40"Margin="0,15,20,0"pu:TextBoxHelper.Watermark="输入菜品关键字"FontSize="15"Foreground="#909399"Text="{Binding DishTypeKey, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /><Buttonx:Name="btnPSearch"Width="100"Height="40"Margin="0,15,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}"CommandParameter="dish"Content="查询"Cursor="Hand"FontSize="16"Foreground="#ffffff"IsDefault="true" /><ButtonWidth="100"Height="40"Margin="0,15,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}"CommandParameter="dish"Content="重置"Cursor="Hand"FontSize="16"Foreground="#ffffff" /></StackPanel><StackPanelGrid.Column="1"HorizontalAlignment="Right"Orientation="Horizontal"><Buttonx:Name="btnPAdd"Width="100"Height="40"Margin="0,15,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/add.png"pu:IconHelper.Width="35"Background="#65d17f"BorderBrush="#65d17f"Command="{Binding AddCommand}"CommandParameter="dish"Content="新增"Cursor="Hand"FontSize="16"Foreground="#ffffff" /><ButtonWidth="100"Height="40"Margin="30,12,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="Black"BorderBrush="Black"Command="{Binding EditCommand}"CommandParameter="dish"Content="编辑"Cursor="Hand"FontSize="16"Foreground="#ffffff" /><Buttonx:Name="btnPDel"Width="100"Height="40"Margin="30,15,20,0"Padding="-10,0,0,0"pu:ButtonHelper.ButtonStyle="Standard"pu:ButtonHelper.ClickStyle="Sink"pu:ButtonHelper.CornerRadius="20"pu:ButtonHelper.HoverBrush="#FF5722"pu:ButtonHelper.Icon="/HQ.fResApp;component/Resources/icon/remove1.png"pu:IconHelper.Width="35"Background="#FF5722"BorderBrush="#FF5722"Command="{Binding DeleteCommand}"CommandParameter="dish"Content="删除"Cursor="Hand"FontSize="16"Foreground="#ffffff" /></StackPanel></Grid><Border Grid.Row="1" Grid.ColumnSpan="3" /><DataGridx:Name="dataPList"Grid.Row="2"Grid.ColumnSpan="3"pu:DataGridHelper.ColumnHorizontalContentAlignment="Center"pu:DataGridHelper.HeaderBackground="#FF009BFF"pu:DataGridHelper.HeaderForeground="#ffffff"pu:DataGridHelper.HeaderMinHeight="50"pu:DataGridHelper.ResizeThumbThickness="0.5"pu:DataGridHelper.SelectedBackground="Transparent"pu:DataGridHelper.SelectedForeground="red"AutoGenerateColumns="False"CanUserAddRows="False"CanUserDeleteRows="False"CanUserReorderColumns="False"CanUserResizeRows="False"Cursor="Pen"FontSize="16"ItemsSource="{Binding DishTypeList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"SelectionMode="Extended"SelectionUnit="FullRow"><DataGrid.RowStyle><Style TargetType="DataGridRow"><!--  Event绑定MouseLeftButtonUp表示鼠标点击事件,Handler表示具体的事件处理程序  --><EventSetter Event="MouseLeftButtonUp" Handler="DishItem_GotFocus" /><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><!--  模板列  --><DataGridTemplateColumn><!--  模板列的头模板  --><DataGridTemplateColumn.HeaderTemplate><DataTemplate><CheckBoxVerticalAlignment="Center"pu:CheckBoxHelper.CheckBoxStyle="Switch"Command="{Binding DataContext.DishCheckAllCmd, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"Content="全选"Foreground="#ffffff"IsChecked="{Binding DataContext.IsCheckAllDish, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" /></DataTemplate></DataGridTemplateColumn.HeaderTemplate><!--  模板列的单元格模板  --><DataGridTemplateColumn.CellTemplate><DataTemplate><CheckBoxName="chk"HorizontalAlignment="Center"VerticalAlignment="Center"Command="{Binding DataContext.CheckDishType, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=DataContext}"IsChecked="{Binding IsCheck, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn><!--  此处单元格绑定的属性是视图模型DiningDishTypeListVModel中的DishTypeInfo属性的各个属性  --><DataGridTextColumnWidth="3*"Binding="{Binding DishTypeInfo.mtName}"Header="菜品类型名称"IsReadOnly="True" /><DataGridTextColumnWidth="3*"Binding="{Binding DishTypeInfo.createDate, ConverterCulture=zh-CN, StringFormat=\{0:yyyy年MM月dd日 dddd HH时mm分\}}"Header="创建日期"IsReadOnly="True" /><DataGridTextColumnWidth="3*"Binding="{Binding DishTypeInfo.lastUpDate, ConverterCulture=zh-CN, StringFormat=\{0:yyyy年MM月dd日 dddd HH时mm分\}}"Header="修改日期"IsReadOnly="True" /></DataGrid.Columns></DataGrid><Grid Grid.Row="3" Grid.ColumnSpan="3"><Grid.ColumnDefinitions><ColumnDefinition /><ColumnDefinition Width="250" /></Grid.ColumnDefinitions><pu:Paginationx:Name="tabPPagination"Height="45"Margin="0,0,20,0"HorizontalAlignment="Left"Background="#963F3F3F"CurrentIndex="{Binding DishCurrentIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"CurrentIndexChanged="ProPagination_CurrentIndexChanged"Cursor="Hand"HoverBrush="#FF009BFF"Spacing="15"TotalIndex="{Binding DishTotalIndex, 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="txtPTotalNum"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 DishTotalNum, 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="txtPPageSize"Grid.Row="2"Width="25"Height="30"HorizontalAlignment="Center"pu:TextBoxHelper.CornerRadius="0"Text="{Binding DishPageSize, 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></TabItem></TabControl>
</UserControl>

3、视图模型

using HQ.BLL;
using HQ.Comm;
using HQ.COMM;
using HQ.fResApp.BaseModel;
using HQ.fResApp.Utils;
using HQ.fResApp.ViewModel.PageViewModel;
using HQ.fResApp.XWindows;
using HQ.MODEL.DBModel;
using HQ.MODEL.UIModel;
using Panuon.UI.Silver;
using Panuon.UI.Silver.Core;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Xml.Linq;namespace HQ.fResApp.ViewModel
{/// <summary>/// 餐桌类型和菜品类型viewmodel/// </summary>public class DiningDishTypeListVModel : ViewModelBase{DiningTypeBLL diningTypebll = new DiningTypeBLL();DishTypeBLL dishTypebll = new DishTypeBLL();#region 餐桌类型页面属性private ObservableCollection<DiningTypeCheckInfo> diningTypeList;/// <summary>/// 餐桌类型列表,页面绑定的数据源/// </summary>public ObservableCollection<DiningTypeCheckInfo> DiningTypeList{get { return diningTypeList; }set{diningTypeList = value;OnPropertyChanged();}}private string diningTypeKey = "";/// <summary>/// 餐桌关键字/// </summary>public string DiningTypeKey{get { return diningTypeKey; }set{diningTypeKey = value;OnPropertyChanged();}}private int diningCurrentIndex = 1;/// <summary>/// 餐桌类型当前页/// </summary>public int DiningCurrentIndex{get { return diningCurrentIndex; }set{diningCurrentIndex = value;OnPropertyChanged();}}private int diningTotalIndex;/// <summary>/// 餐桌类型总页数/// </summary>public int DiningTotalIndex{get { return diningTotalIndex; }set{diningTotalIndex = value;OnPropertyChanged();}}private int diningTotalNum;/// <summary>///  餐桌类型总条数/// </summary>public int DiningTotalNum{get { return diningTotalNum; }set{diningTotalNum = value;OnPropertyChanged();}}private int diningPageSize = 10;/// <summary>///  餐桌类型每页条数/// </summary>public int DiningPageSize{get { return diningPageSize; }set{diningPageSize = value;OnPropertyChanged();DiningTypeList = GetDingTypeTable();}}private bool isCheckAllDining = false;/// <summary>/// 餐桌全选状态/// </summary>public bool IsCheckAllDining{get { return isCheckAllDining; }set{isCheckAllDining = value;OnPropertyChanged();}}#endregion#region 菜品类型页面属性private ObservableCollection<DishTypeCheckInfo> dishTypeList;/// <summary>/// 菜品类型列表,页面绑定的数据源/// </summary>public ObservableCollection<DishTypeCheckInfo> DishTypeList{get { return dishTypeList; }set{dishTypeList = value;OnPropertyChanged();}}private string dishTypeKey = "";/// <summary>/// 菜品关键字/// </summary>public string DishTypeKey{get { return dishTypeKey; }set{dishTypeKey = value;OnPropertyChanged();}}private int dishCurrentIndex = 1;/// <summary>/// 菜品类型当前页/// </summary>public int DishCurrentIndex{get { return dishCurrentIndex; }set{dishCurrentIndex = value;OnPropertyChanged();}}private int dishTotalIndex;/// <summary>/// 菜品类型总页数/// </summary>public int DishTotalIndex{get { return dishTotalIndex; }set{dishTotalIndex = value;OnPropertyChanged();}}private int dishTotalNum;/// <summary>/// 菜品类型总条数/// </summary>public int DishTotalNum{get { return dishTotalNum; }set{dishTotalNum = value;OnPropertyChanged();}}private int dishPageSize = 10;/// <summary>///  菜品类型每页条数/// </summary>public int DishPageSize{get { return dishPageSize; }set{dishPageSize = value;OnPropertyChanged();DishTypeList = GetDishTypeTable();}}private bool isCheckAllDish = false;/// <summary>/// 餐桌全选状态/// </summary>public bool IsCheckAllDish{get { return isCheckAllDish; }set{isCheckAllDish = value;OnPropertyChanged();}}#endregionpublic DiningDishTypeListVModel(){DiningTypeList = GetDingTypeTable();DishTypeList = GetDishTypeTable();}/// <summary>/// 获取菜品类型列表/// </summary>/// <returns></returns>public ObservableCollection<DishTypeCheckInfo> GetDishTypeTable(){ObservableCollection<DishTypeCheckInfo> tableDataList = new ObservableCollection<DishTypeCheckInfo>();var _parms = new PageParm { page = DishCurrentIndex, limit = DishPageSize, key = DishTypeKey.Trim() };var _pageRes = dishTypebll.GetPagesAsync(_parms).Result;//分页查询if (_pageRes.statusCode == (int)ApiEnum.Status){var _pageResData = _pageRes.data;var _tabList = _pageResData.Items;if (_tabList != null && _tabList.Count != 0){ObservableCollection<DishTypeCheckInfo> proDataList = new ObservableCollection<DishTypeCheckInfo>();foreach (var item in _tabList){var _curTab = new DishTypeCheckInfo();_curTab.DishTypeInfo.mtGuid = item.mtGuid;_curTab.DishTypeInfo.mtName = item.mtName;_curTab.DishTypeInfo.createDate = item.createDate;_curTab.DishTypeInfo.lastUpDate = item.lastUpDate;_curTab.IsCheck = false;tableDataList.Add(_curTab);}DishTotalNum = (int)_pageResData.TotalItems;DishCurrentIndex = (int)_pageResData.CurrentPage;DishTotalIndex = (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>/// <returns></returns>public ObservableCollection<DiningTypeCheckInfo> GetDingTypeTable(){ObservableCollection<DiningTypeCheckInfo> tableDataList = new ObservableCollection<DiningTypeCheckInfo>();var _parms = new PageParm { page = DiningCurrentIndex, limit = DiningPageSize, key = DiningTypeKey.Trim() };var _pageRes = diningTypebll.GetPagesAsync(_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 _curTab = new DiningTypeCheckInfo();_curTab.DiningTypeInfo.rtGuid = item.rtGuid;_curTab.DiningTypeInfo.rtName = item.rtName;_curTab.DiningTypeInfo.rtLeastCost = item.rtLeastCost;_curTab.DiningTypeInfo.rtMostNumber = item.rtMostNumber;_curTab.DiningTypeInfo.rtAmount = item.rtAmount;_curTab.DiningTypeInfo.createDate = item.createDate;_curTab.DiningTypeInfo.lastUpDate = item.lastUpDate;_curTab.IsCheck = false; tableDataList.Add(_curTab);}DiningTotalNum = (int)_pageResData.TotalItems;DiningCurrentIndex = (int)_pageResData.CurrentPage;DiningTotalIndex = (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>public ICommand DiningCheckAllCmd{get{return new RelayCommand(o =>{//将业主列表每条记录的isCheck设为与标题状态一致foreach (var record in this.DiningTypeList){record.IsCheck = this.IsCheckAllDining;}});}}/// <summary>/// 菜品类型全选命令/// </summary>public ICommand DishCheckAllCmd{get{return new RelayCommand(o =>{//将业主列表每条记录的isCheck设为与标题状态一致foreach (var record in this.DishTypeList){record.IsCheck = this.IsCheckAllDish;}});}}/// <summary>/// 选择一条餐桌类型数据/// </summary>public ICommand CheckDiningType{get{return new RelayCommand(o =>{if (o != null){var item = o as DiningTypeCheckInfo;item.IsCheck = !item.IsCheck;}});}}/// <summary>/// 选择一条菜品类型数据/// </summary>public ICommand CheckDishType{get{return new RelayCommand(o =>{if (o != null){var item = o as DishTypeCheckInfo;item.IsCheck = !item.IsCheck;}});}} /// <summary>/// 查询按钮的命令处理/// </summary>public ICommand FindCommand{get{return new RelayCommand(o =>{string typeobj = o.ToString();//获取命令传递过来的参数,即控件的 CommandParameter参数//处理点击动作(餐桌还是菜品执行不同的处理)switch (typeobj){case "dining":DiningTypeList = GetDingTypeTable();break;case "dish":DishTypeList = GetDishTypeTable();break;}});}}/// <summary>/// 重置按钮的命令处理/// </summary>public ICommand ResetCommand{get{return new RelayCommand(o =>{string typeobj = o.ToString();//获取命令传递过来的参数,即控件的 CommandParameter参数//处理 (餐桌还是菜品执行不同的处理)switch (typeobj){case "dining":DiningCurrentIndex = 1;DiningPageSize = 10;DiningTypeKey = "";DiningTypeList = GetDingTypeTable();break;case "dish":DishCurrentIndex = 1;DishPageSize = 10;DishTypeKey = "";DishTypeList = GetDishTypeTable();break;}});}}/// <summary>/// 新增按钮的命令处理/// </summary>public ICommand AddCommand{get{return new RelayCommand(o =>{string typeobj = o.ToString();//获取命令传递过来的参数,即控件的 CommandParameter参数//处理点击动作(餐桌还是菜品执行不同的处理)switch (typeobj){case "dining":WindowX AddDining = new DiningTypeInfo();if (AddDining != null){AddDining.Closed += new EventHandler(RefreshDiningType);//注册关闭事件AddDining.ShowDialog();}break;case "dish":WindowX AddDish = new DishTypeInfo();if (AddDish != null){AddDish.Closed += new EventHandler(RefreshDishType);//注册关闭事件AddDish.ShowDialog();}break;}});}}/// <summary>/// 编辑按钮的命令处理/// </summary>public ICommand EditCommand{get{return new RelayCommand(o =>{string typeobj = o.ToString();//获取命令传递过来的参数,即控件的 CommandParameter参数//处理点击动作(餐桌还是菜品执行不同的处理)switch (typeobj){case "dining":List<string> delIds = new List<string>();delIds = this.DiningTypeList.Where(r => r.IsCheck == true).Select(r => r.DiningTypeInfo.rtGuid).ToList();if (delIds.Count == 0){MessageBoxX.Show("请选择要编辑的数据.", "提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Warning,ButtonBrush = "#F1C825".ToColor().ToBrush(),});return;}if (delIds.Count >= 2){var _msgRes = MessageBoxX.Show("对不起,一次只能编辑一条数据", "提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Info,ButtonBrush = "#F1C825".ToColor().ToBrush(),});}else{string selectid = delIds.First();//获取记录idWindowX EditWin = new DiningTypeInfo(selectid);if (EditWin != null){DiningDishTypeInfoVModel objvmodel = new DiningDishTypeInfoVModel();DiningType result = diningTypebll.GetModelById(x => x.rtGuid == selectid).Result.data;objvmodel.DiningTypeItem = result;EditWin.DataContext = objvmodel;EditWin.Closed += new EventHandler(RefreshDiningType);//注册关闭事件EditWin.ShowDialog();} }break;case "dish":List<string> dishtypeids = new List<string>();dishtypeids = this.DishTypeList.Where(r => r.IsCheck == true).Select(r => r.DishTypeInfo.mtGuid).ToList();if (dishtypeids.Count == 0){MessageBoxX.Show("请选择要编辑的数据.", "提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Warning,ButtonBrush = "#F1C825".ToColor().ToBrush(),});return;}if (dishtypeids.Count >= 2){var _msgRes = MessageBoxX.Show("对不起,一次只能编辑一条数据", "提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Info,ButtonBrush = "#F1C825".ToColor().ToBrush(),});}else{string selectid = dishtypeids.First();//获取记录idWindowX EditWin = new DishTypeInfo(selectid);if (EditWin != null){DiningDishTypeInfoVModel objvmodel = new DiningDishTypeInfoVModel();DishType result = dishTypebll.GetModelById(x => x.mtGuid == selectid).Result.data;objvmodel.DishTypeItem = result;EditWin.DataContext = objvmodel;EditWin.Closed += new EventHandler(RefreshDishType);//注册关闭事件EditWin.ShowDialog();} }break;}});}}/// <summary>/// 删除按钮的命令处理/// </summary>public ICommand DeleteCommand{get{return new RelayCommand(o =>{string typeobj = o.ToString();//获取命令传递过来的参数,即控件的 CommandParameter参数//处理点击动作(餐桌还是菜品执行不同的处理)switch (typeobj){case "dining":List<string> delIds = new List<string>();delIds = this.DiningTypeList.Where(r => r.IsCheck == true).Select(r => r.DiningTypeInfo.rtGuid).ToList();if (delIds.Count == 0){MessageBoxX.Show("请选择要删除的数据.", "提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Warning,ButtonBrush = "#F1C825".ToColor().ToBrush(),});return;}if (delIds.Count > 0){var _msgRes = MessageBoxX.Show("确定要删除吗?", "提示", Application.Current.MainWindow, MessageBoxButton.YesNo, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Warning,ButtonBrush = "#F1C825".ToColor().ToBrush(),});if (_msgRes == MessageBoxResult.No){return;}var res = new ApiResult<string>() { statusCode = (int)ApiEnum.Error };foreach (string id in delIds){res = diningTypebll.DeleteById(id).Result;}if (res.statusCode == (int)ApiEnum.Status){Notice.Show("成功删除【" + delIds.Count + "】条数据", "提示", 3, MessageBoxIcon.Success);}else{Notice.Show("删除失败!", "提示", 3, MessageBoxIcon.Error);Logger.Default.ProcessError(res.statusCode, "删除餐桌类型失败");}RefreshDiningType(null, null);}break;case "dish":List<string> dishids = new List<string>();dishids = this.DishTypeList.Where(r => r.IsCheck == true).Select(r => r.DishTypeInfo.mtGuid).ToList();if (dishids.Count == 0){MessageBoxX.Show("请选择要删除的数据.", "提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Warning,ButtonBrush = "#F1C825".ToColor().ToBrush(),});return;}if (dishids.Count > 0){var _msgRes = MessageBoxX.Show("确定要删除吗?", "提示", Application.Current.MainWindow, MessageBoxButton.YesNo, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Warning,ButtonBrush = "#F1C825".ToColor().ToBrush(),});if (_msgRes == MessageBoxResult.No){return;}var res2 = new ApiResult<string>() { statusCode = (int)ApiEnum.Error };foreach (string id in dishids){res2 = dishTypebll.DeleteById(id).Result;}if (res2.statusCode == (int)ApiEnum.Status){Notice.Show("成功删除【" + dishids.Count + "】条数据", "提示", 3, MessageBoxIcon.Success);}else{Notice.Show("删除失败!", "提示", 3, MessageBoxIcon.Error);Logger.Default.ProcessError(res2.statusCode, "删除餐桌类型失败");}RefreshDishType(null, null);}break;}});}}/// <summary>/// 刷新餐桌数据/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void RefreshDiningType(object sender, EventArgs e){DiningCurrentIndex = 1;DiningPageSize = 10;DiningTypeKey = "";DiningTypeList = GetDingTypeTable();}/// <summary>/// 刷新菜品数据/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void RefreshDishType(object sender, EventArgs e){DishCurrentIndex = 1;DishPageSize = 10;DishTypeKey = "";DishTypeList = GetDishTypeTable();}}
}

4、新增菜品和编辑菜品

新增和编辑操作时,使用相同的UI布局 

using HQ.COMM;
using HQ.fResApp.BaseModel;
using HQ.MODEL.DBModel;
using Panuon.UI.Silver.Core;
using Panuon.UI.Silver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using HQ.BLL;
using HQ.fResApp.Utils;
using System.Xml.Linq;
using System.Windows.Controls;
using System.Net.Http.Headers;
using System.Web.Configuration;namespace HQ.fResApp.ViewModel
{public class DiningDishTypeInfoVModel : ViewModelBase{#region 属性变量DiningTypeBLL diningTypeBLL = new DiningTypeBLL();DishTypeBLL dishtypeBLL = new DishTypeBLL();public string actionType = "新增";//餐桌动作类型public string actionType2 = "新增";//菜品动作类型WindowX currentwin = null;private DiningType diningTypeIItem = new DiningType();/// <summary>/// 餐桌实体/// </summary>public DiningType DiningTypeItem{get { return diningTypeIItem; }set{diningTypeIItem = value;OnPropertyChanged();}}private DishType dishTypeItem = new DishType();/// <summary>/// 餐桌实体/// </summary>public DishType  DishTypeItem{get { return dishTypeItem; }set{dishTypeItem = value;OnPropertyChanged();}}#endregion#region 命令/// <summary>/// 保存再新增命令处理/// </summary>public ICommand InsertCommand{get{return new RelayCommand(o =>{string opt = o.ToString();//获取命令参数,并根据不同参数判断处理switch (opt){case "dining"://餐桌DiningInsertHandler();break;case "dish"://菜品DishInsertHandler();break;} });}}/// <summary>/// 处理菜品添加程序/// </summary>private void DishInsertHandler(){if (DishTypeItem.mtName == null){MessageBoxX.Show("***菜品名称不能为空***", "警告提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Warning,ButtonBrush = "#F1C825".ToColor().ToBrush(),});return;}DishTypeItem.mtName = DishTypeItem.mtName.Trim();if (DishTypeItem.mtName == ""){MessageBoxX.Show("***菜品名称不能为空***", "警告提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Warning,ButtonBrush = "#F1C825".ToColor().ToBrush(),});return;}SaveDishType();}/// <summary>/// 处理餐桌添加程序 /// </summary>private void DiningInsertHandler(){if (DiningTypeItem.rtName == null){MessageBoxX.Show("***餐桌名称不能为空***", "警告提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Warning,ButtonBrush = "#F1C825".ToColor().ToBrush(),});return;}DiningTypeItem.rtName = DiningTypeItem.rtName.Trim();if (DiningTypeItem.rtName == ""){MessageBoxX.Show("***餐桌名称不能为空***", "警告提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Warning,ButtonBrush = "#F1C825".ToColor().ToBrush(),});return;}SaveDiningType();}/// <summary>/// 保存并返回命令处理/// </summary>public ICommand SaveCommand{get{return new RelayCommand(o =>{currentwin = (WindowX)o;//获取命令传递过来的参数,该参数绑定的就是整个DiningTypeAdd.xaml这个窗体string formname = currentwin.Name;//获取窗体名称switch(formname){case "diningaddwin":if(DiningTypeItem.rtGuid == null){actionType = "新增";}else{actionType = "编辑";} DiningInsertHandler();break;case "dishaddWin":if (DishTypeItem.mtGuid == null){actionType2 = "新增";}else{actionType2 = "编辑";}DishInsertHandler();break;}if (currentwin != null){currentwin.Close();}//if (DiningTypeItem.rtName == null)//{//    MessageBoxX.Show("***餐桌名称不能为空***", "警告提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations()//    {//        MessageBoxIcon = MessageBoxIcon.Warning,//        ButtonBrush = "#F1C825".ToColor().ToBrush(),//    });//    return;//}//DiningTypeItem.rtName = DiningTypeItem.rtName.Trim();//if (DiningTypeItem.rtName == "")//{//    MessageBoxX.Show("***餐桌名称不能为空***", "警告提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations()//    {//        MessageBoxIcon = MessageBoxIcon.Warning,//        ButtonBrush = "#F1C825".ToColor().ToBrush(),//    });//    return;//}//if (DiningTypeItem.rtGuid != null)//{//    actionType = "编辑";//}//SaveDiningType();//if (currentwin != null)//{//    currentwin.Close();//}});}}#endregion#region Function/// <summary>/// 保存餐桌/// </summary>/// <returns></returns>public void SaveDiningType(){ //根据不同动作类型处理switch (actionType){ case "新增":var findobj = diningTypeBLL.IsExistAsync(x => x.rtName == DiningTypeItem.rtName.Trim()).Result;//查询是否存在//新增前必须判断是否重复if (findobj.data.Any){MessageBoxX.Show("【" + DiningTypeItem.rtName + "】餐桌已存在,请勿重复添加", "失败提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Error,ButtonBrush = "#F1C825".ToColor().ToBrush(),});currentwin = null;return;}DiningTypeItem.rtGuid = Guid.NewGuid().ToString();DiningTypeItem.createDate = DateTime.Now;DiningTypeItem.lastUpDate = DateTime.Now;var _addRes = diningTypeBLL.AddAsync(DiningTypeItem).Result;if (_addRes.statusCode == (int)ApiEnum.Status){Notice.Show("添加成功!", "提示", 3, MessageBoxIcon.Success);DiningTypeItem = new DiningType();//创建新对象的目的在于让页面上控件的值清空}else{Notice.Show("添加失败!", "提示", 3, MessageBoxIcon.Error);Logger.Default.ProcessError(_addRes.statusCode, "添加餐桌类型失败");}break;case "编辑":DiningTypeItem.lastUpDate = DateTime.Now;var _addRes2 = diningTypeBLL.UpdateModel(DiningTypeItem).Result;if (_addRes2.statusCode == (int)ApiEnum.Status){Notice.Show("保存成功!", "提示", 3, MessageBoxIcon.Success); }else{Notice.Show("保存失败!", "提示", 3, MessageBoxIcon.Error);Logger.Default.ProcessError(_addRes2.statusCode, "添加餐桌类型失败");}break;} }/// <summary>/// 保存菜品/// </summary>private void SaveDishType(){//根据不同动作类型处理switch (actionType2){case "新增":var findobj = dishtypeBLL.IsExistAsync(x => x.mtName == DishTypeItem.mtName.Trim()).Result;//查询是否存在//新增前必须判断是否重复if (findobj.data.Any){MessageBoxX.Show("【" + DishTypeItem.mtName + "】餐桌已存在,请勿重复添加", "失败提示", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations(){MessageBoxIcon = MessageBoxIcon.Error,ButtonBrush = "#F1C825".ToColor().ToBrush(),});currentwin = null;return;}DishTypeItem.mtGuid = Guid.NewGuid().ToString();DishTypeItem.createDate = DateTime.Now;DishTypeItem.lastUpDate = DateTime.Now;var _addRes = dishtypeBLL.AddAsync(DishTypeItem).Result;if (_addRes.statusCode == (int)ApiEnum.Status){Notice.Show("添加成功!", "提示", 3, MessageBoxIcon.Success);DishTypeItem = new DishType();//创建新对象的目的在于让页面上控件的值清空}else{Notice.Show("添加失败!", "提示", 3, MessageBoxIcon.Error);Logger.Default.ProcessError(_addRes.statusCode, "添加餐桌类型失败");}break;case "编辑":DishTypeItem.lastUpDate = DateTime.Now;var _addRes2 = dishtypeBLL.UpdateModel(DishTypeItem).Result;if (_addRes2.statusCode == (int)ApiEnum.Status){Notice.Show("保存成功!", "提示", 3, MessageBoxIcon.Success);}else{Notice.Show("保存失败!", "提示", 3, MessageBoxIcon.Error);Logger.Default.ProcessError(_addRes2.statusCode, "添加餐桌类型失败");}break;}}#endregion}
}

5、运行测试

这个Panuon.UI.Silver做的样式还是蛮漂亮的,加上MaterialDesignThemes和AduSkin搭配,效果是扛把子。

原创不易,打字截图不易,走过路过,不要错过,欢迎点赞,收藏,转载,复制,抄袭,留言,动动你的金手指,早日实现财务自由!

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

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

aave v3 存款与借款利息的计算方式

本文只涉及到利率计算的数学原理&#xff0c;不作源码解析:存款首先我们假设小明在aave里面存了10000usdt&#xff0c;存的时候年化收益率是5%,那么半年后其存款的利息是多少呢?常规的计算方式如下:利息10000*5%*(存款的时长/一年的时长)这么做有什么问题呢&#xff1f;假设现…

Windows MCP.Net:基于.NET的Windows桌面自动化MCP服务器深度解析

&#x1f4cb; 目录 项目概述 技术架构深度解析 核心功能模块详解 代码实现分析 使用场景与实战案例 性能优化与最佳实践 扩展开发指南 总结与展望 项目概述 什么是Windows-MCP.Net&#xff1f; Windows MCP.Net是一个基于.NET 10.0开发的Windows桌面自动化MCP&…

Boost.Asio学习(7):Boost.Beast实现简易http服务器

namespace beast boost::beast;beast::flat_buffer是一个用于 Boost.Asio 和 Boost.Beast 网络读写的缓冲区实现。专为 一次性顺序读取 / 消费 场景设计&#xff0c;比 std::string 或 std::vector 高效&#xff0c;因为它是扁平内存结构&#xff08;contiguous memory&#x…

深入解析JVM内存区域划分:从理论到实践

Java虚拟机&#xff08;JVM&#xff09;是Java程序运行的核心环境&#xff0c;它负责管理内存分配、垃圾回收、字节码执行等关键任务。理解JVM的内存区域划分&#xff0c;对于优化Java应用性能、排查内存问题&#xff08;如OutOfMemoryError、StackOverflowError&#xff09;至…

滑窗|贪心|✅滚动数组

lc17.08pair按身高升序、相同时体重降序排序结果是找体重序列的最长递增子序列长度核心&#xff1a;转化为二维最长递增子序列问题求解vector<int> dp;for (auto& p : hw) {int w p.second;auto it lower_bound(dp.begin(), dp.end(), w);if (it dp.end()) {dp.pu…

深入理解数据库架构:从原理到实践的完整指南

一、数据库存储架构的多维度分类体系 1.1 基于数据组织方式的存储架构分类 数据库的存储架构从根本上决定了其性能特征、适用场景和扩展能力。理解不同的数据组织方式是选择合适数据库技术的基础&#xff0c;这种分类不仅反映了技术实现的差异&#xff0c;更体现了对不同业务需…

体彩排列三第2025218期号码分析

大家好&#xff0c;本人蔡楚门来此平台分享一下本期得经验和思路&#xff0c;希望能够给大家带来好的运气和灵感&#xff01;体彩排列三第2025218期号码分析&#xff0c;大小号码数字分析&#xff0c;上期开出全小号码最多&#xff0c;最近两期的开奖号码全部都是全小号码最多&…

java设计模式之迪米特法则介绍与说明

一、核心概念与目标 基本定义 迪米特法则的核心思想是&#xff1a;一个对象应该对其他对象尽可能少地了解&#xff0c;仅与直接关联的对象&#xff08;即“朋友”&#xff09;通信&#xff0c;避免与“陌生人”产生直接交互。 直接朋友&#xff1a;包括当前对象的成员变量、方法…

2024-2025华为ICT大赛中国区 实践赛昇腾AI赛道(高职组)全国总决赛 理论部分真题+解析

Part 1 昇腾AI全栈系统模块(共6题)&#xff1a;1、许多计算芯片可以设计作为人工智能的计算芯片&#xff0c;但不同的芯片计算性能不同&#xff0c;昇腾计算芯片是一种()芯片。(单选题)A.CPU B.GPU C. NPU D.TPU正确答案&#xff1a;C解析&#xff1a;A项CPU中央处理器的架…

网络安全和基础设施安全局 (CISA) 表示微分段不再是可选的

网络安全和基础设施安全局 (CISA) 最近发布了一系列指导文件中的第一份&#xff0c;旨在帮助联邦机构实施微分段&#xff0c;作为其零信任架构 (ZTA) 战略的一部分&#xff0c;以遵守2022 年白宫的授权。 该文件《零信任中的微分段&#xff0c;第一部分&#xff1a;介绍和规划…

Spring Boot SseEmitter 重复请求问题深度分析与解决方案

1. 前言 在使用 Spring Boot 开发流式接口(Server-Sent Events)时,我们遇到了一个令人困惑的问题:每次 SseEmitter 完成后,都会触发第二次请求,导致重复请求检测机制误报。本文将详细记录问题的发现、分析过程以及最终的解决方案。 2. 系统架构背景 2.1 请求处理架构 …

心路历程-三个了解敲开linux的大门

学习前都爱唠叨一番&#xff1a; 了解一下&#xff1a;互联网的发展是离不开服务器的&#xff0c;而服务器的系统主流的还是Linux&#xff1b;这个是有数据进行支撑的&#xff1b;这个只是作为了解而已&#xff0c;我们并不买课&#xff0c;也不做什么买卖的行为&#xff0c;仅…

关于“双指针法“的总结

笔者这些天终于达成了只狼的全成就&#xff0c;甚是欢喜。然而乐极生悲&#xff0c;最近做了些算法题&#xff0c;竟没有一道靠自己做出来。感觉算法题常常用到“双指针法”呢……为什么到现在我还是做不出来这些算法题……今天就来试着总结一下它的使用场景吧。快慢指针法又名…

基于51单片机的智能吊灯

基于 51 单片机的智能吊灯设计与实现论文简纲一、引言1.1 研究背景与意义阐述传统照明设备在节能性、智能化方面的不足&#xff0c;结合智能家居产业发展趋势&#xff0c;说明设计基于 51 单片机的智能吊灯对提升生活便利性、降低能耗的现实意义。1.2 国内外研究现状简要介绍当…

CF每日三题(1500-1700)

1792C 逆向思维1036D 前缀和尺取1598D 组合数学取三元组 将二元组放在坐标系中更好找到规律 1792C 思维 1500 参考题解 正难则反 注意是对一个排列进行操作&#xff0c;最后还原成1,2,…,n 每次选两个数字很难想&#xff0c;反着想就是把1-n的排列变成所给数组的逆操作&#x…

Boost搜索引擎项目(详细思路版)

目录 项目相关背景 搜索引擎原理技术栈和项目环境 导入数据到自己的本地 数据去标签与数据清洗模块 Enumfile(src_path, &file_list)递归式写入 Parsehtml(file_list, &results)去标签 bool Parsetitle(const string& file, string* title)拆分标题 bool Pa…

AI产品经理面试宝典第69天:大模型稳定性评估与AI伦理挑战面试题全解析

1. AI伦理与技术挑战 1.1 问:你认为AI的最大挑战是什么? 答:AI面临的最大挑战是算法偏见与模型黑箱问题。具体表现为: 数据偏见放大:训练数据中隐含的性别、种族等偏见会被模型继承,如招聘算法中的性别歧视案例 决策透明性缺失:深度学习模型的可解释性不足,医疗诊断场…

【build】RDK构建系统v0.1 (持续更新。。。。)

一、 项目概述RDK构建系统是一个用于构建和定制嵌入式系统的自动化工具&#xff0c;通过简单的命令行操作&#xff0c;您可以完成从下载依赖包、定制根文件系统、构建内核到打包镜像的完整流程。该系统采用模块化设计&#xff0c;提供了丰富的配置选项&#xff0c;适用于不同的…

关于RSA和AES加密

RSA非对称加密 非对称加密不能传输大数据量&#xff0c;但比对称加密要安全&#xff0c;所以传输密码一般就是用的非对称加密 接口拿到RSA公钥然后再加密之后传给后端就好了 let crypt new JSEncrypt(); crypt.setPublicKey(res.message); // console.log(加密前:, data); let…

云蝠智能VoiceAgent:AI赋能售后服务场景的创新实践

引言&#xff1a;售后服务数字化转型的必然趋势在数字经济时代&#xff0c;售后服务已成为企业核心竞争力的重要组成部分。据统计&#xff0c;优质的售后服务能够提升客户留存率高达67%&#xff0c;同时降低客户获取成本约30%。然而&#xff0c;传统售后服务模式面临着人力成本…