仓库管理系统12--供应商设置

devtools/2024/9/24 3:26:06/

1、添加供应商窗体

2、布局控件UI

 

<UserControl x:Class="West.StoreMgr.View.SupplierView"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"mc:Ignorable="d" DataContext="{Binding Source={StaticResource Locator},Path=Supplier}"d:DesignHeight="510" d:DesignWidth="800"><Grid><Grid.RowDefinitions><RowDefinition Height="50"/><RowDefinition/><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="20"><Grid.RowDefinitions><RowDefinition Height="30"/><RowDefinition/></Grid.RowDefinitions><Border Background="#72BBE5"><TextBlock Text="添加供应商" FontSize="18" VerticalAlignment="Center" Foreground="#1F3C4C" Margin="0 0 10 0"/></Border><StackPanel Grid.Row="1" Orientation="Vertical" VerticalAlignment="Center"  Margin="-4 10 0 10"><StackPanel Orientation="Horizontal" VerticalAlignment="Center"><TextBlock Margin="0 0 10 0" Text="供应商名称:" VerticalAlignment="Center"/><TextBox Margin="0 0 10 0" Text="{Binding Supplier.Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="100" Height="30" /><TextBlock Margin="0 0 10 0" Text="联系人:" VerticalAlignment="Center"/><TextBox Margin="0 0 10 0" Text="{Binding Supplier.Contact,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="200" Height="30" /><TextBlock Margin="0 0 10 0" Text="电话:" VerticalAlignment="Center"/><TextBox Margin="0 0 10 0" Text="{Binding Supplier.Telephone,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="200" Height="30" /></StackPanel><StackPanel Orientation="Horizontal" VerticalAlignment="Center"  Margin="0 10 0 10"><TextBlock Margin="0 0 10 0" Text="电子信箱:" VerticalAlignment="Center"/><TextBox Margin="0 0 10 0" Text="{Binding Supplier.Email,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="100" Height="30" /><TextBlock Margin="0 0 10 0" Text="地址:" VerticalAlignment="Center"/><TextBox Margin="0 0 10 0" Text="{Binding Supplier.Address,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="200" Height="30" /><TextBlock Margin="0 0 10 0" Text="备注:" VerticalAlignment="Center"/><TextBox Margin="0 0 10 0" Text="{Binding Supplier.Tag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="200" Height="30" /></StackPanel><StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="220 10 0 10"><!--button--><Button Margin="0 0 0 0" Height="36" FontSize="20" Width="199" Grid.Row="3" Content="增 加" Style="{StaticResource ButtonStyle}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:SupplierView}}"Command="{Binding AddCommand}"/></StackPanel></StackPanel></Grid><!--列表--><Grid Grid.Row="2" Margin="10 -20 10 10"><DataGrid ItemsSource="{Binding SupplierList}" CanUserAddRows="False" AutoGenerateColumns="False"><DataGrid.Columns><DataGridTextColumn Header="序号" Binding="{Binding Id}"/><DataGridTextColumn Header="供应商" Binding="{Binding Name}"/><DataGridTextColumn Header="联系人" Binding="{Binding Contact}"/><DataGridTextColumn Header="电话" Binding="{Binding Telephone}"/><DataGridTextColumn Header="邮箱" Binding="{Binding Email}"/><DataGridTextColumn Header="地址" Binding="{Binding Address}"/><DataGridTextColumn Header="备注" Binding="{Binding Tag}"/><DataGridTextColumn Header="日期" Binding="{Binding InsertDate}"/><DataGridTemplateColumn  Header="操作"><DataGridTemplateColumn.CellTemplate><DataTemplate><StackPanel Orientation="Horizontal"><Button Content="编辑" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:SupplierView},Path=DataContext.EditCommand}"CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}" Tag="{Binding}" Style="{StaticResource DataGridButtonStyle}" /><Button Content="删除" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:SupplierView},Path=DataContext.DeleteCommand}"CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}"Tag="{Binding}" Style="{StaticResource DataGridButtonStyle}" /></StackPanel></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn></DataGrid.Columns></DataGrid></Grid></Grid>
</UserControl>

 3、添加viewmodel

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using West.StoreMgr.Helper;
using West.StoreMgr.Service;
using CommonServiceLocator;
using West.StoreMgr.Windows;
using static West.StoreMgr.Windows.MsgBoxWindow;namespace West.StoreMgr.ViewModel
{/// <summary>/// 供应商viewmodel/// </summary>public class SupplierViewModel : ViewModelBase{public SupplierViewModel(){SupplierList = new SupplierService().Select();}private Supplier supplier = new Supplier();public Supplier Supplier{get { return supplier; }set { supplier = value; RaisePropertyChanged(); }}private List<Supplier> supplierList = new List<Supplier>();public List<Supplier> SupplierList{get { return supplierList; }set { supplierList = value; RaisePropertyChanged(); }}/// <summary>/// 添加/// </summary>public RelayCommand AddCommand{get{var command = new RelayCommand(() =>{if (string.IsNullOrEmpty(Supplier.Name) == true|| string.IsNullOrEmpty(Supplier.Contact) == true|| string.IsNullOrEmpty(Supplier.Telephone) == true){ MsgWinHelper.ShowError("不能为空!");return;}Supplier.InsertDate = DateTime.Now;var service = new SupplierService();int count = service.Insert(Supplier);if (count > 0){SupplierList = service.Select();MsgWinHelper.ShowMessage("添加成功!");Supplier = new Supplier();}else{MsgWinHelper.ShowError("添加失败!");}});return command;}}/// <summary>/// 修改/// </summary>public RelayCommand<Button> EditCommand{get{var command = new RelayCommand<Button>((view) =>{var old = view.Tag as Supplier;if (old == null) return;var model = ServiceLocator.Current.GetInstance<EditSupplierViewModel>();model.Supplier = old;var window = new EditSupplierWindow();window.ShowDialog();SupplierList = new SupplierService().Select();});return command;}}//删除public RelayCommand<Button> DeleteCommand{get{var command = new RelayCommand<Button>((view) =>{ if (MsgWinHelper.ShowQuestion("您确定要删除该空运详情单吗?") == CustomMessageBoxResult.OK){var old = view.Tag as Supplier;if (old == null) return;var service = new SupplierService();int count = service.Delete(old);if (count > 0){SupplierList = service.Select();MsgWinHelper.ShowMessage("删除成功!");}else{MsgWinHelper.ShowError("删除失败!");}}});return command;}}}
}

4、运行效果

5、修改供应商

1)UI布局

<Window x:Class="West.StoreMgr.Windows.EditSupplierWindow"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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:West.StoreMgr.Windows"mc:Ignorable="d"ResizeMode="NoResize"WindowStartupLocation="CenterScreen"DataContext="{Binding Source={StaticResource Locator},Path=EditSupplier}"Title="修改供应商" Height="450" Width="800"><Grid Background="#E4ECEF"><Grid Grid.Column="0"><Grid.ColumnDefinitions><ColumnDefinition Width="0.5*"/><ColumnDefinition/><ColumnDefinition Width="0.5*"/><ColumnDefinition/></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/><RowDefinition/></Grid.RowDefinitions><Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4"><Grid.ColumnDefinitions><ColumnDefinition></ColumnDefinition><ColumnDefinition></ColumnDefinition><ColumnDefinition></ColumnDefinition></Grid.ColumnDefinitions><Border Grid.Column="0" Height="2" Width="122" HorizontalAlignment="Center" VerticalAlignment="Center"><!--渐变色横条--><Border.Background><LinearGradientBrush StartPoint="0,0" EndPoint="1,1"><GradientStop Color="Red" Offset="0"></GradientStop><GradientStop Color="#6d6d6d"  Offset="1"></GradientStop></LinearGradientBrush></Border.Background></Border><TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Center" VerticalAlignment="Center" Text="修改供应商" FontSize="36"/><Border Grid.Column="2"  Height="2" Width="122" HorizontalAlignment="Center" VerticalAlignment="Center"><!--渐变色横条--><Border.Background><LinearGradientBrush StartPoint="0,0" EndPoint="1,1"><GradientStop Color="Red" Offset="1"></GradientStop><GradientStop Color="#6d6d6d"  Offset="0"></GradientStop></LinearGradientBrush></Border.Background></Border></Grid><TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="供应商" FontSize="20"/><TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="联系人" FontSize="20"/><TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="电话" FontSize="20"/><TextBox Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Supplier.Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="20" Width="200" Height="30"/><TextBox Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Supplier.Contact,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="20" Width="200" Height="30"/><TextBox Grid.Row="3" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Supplier.Telephone,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="20" Width="200" Height="30"/><TextBlock Grid.Row="1" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Text="电子邮箱" FontSize="20"/><TextBlock Grid.Row="2" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Text="地址" FontSize="20"/><TextBlock Grid.Row="3" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Text="备注" FontSize="20"/><TextBox Grid.Row="1" Grid.Column="3" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Supplier.Email,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="20" Width="200" Height="30"/><TextBox Grid.Row="2" Grid.Column="3" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Supplier.Address,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="20" Width="200" Height="30"/><TextBox Grid.Row="3" Grid.Column="3" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Supplier.Tag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="20" Width="200" Height="30"/><!--button--><StackPanel Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" Orientation="Horizontal" HorizontalAlignment="Right" ><Button  Height="45" Width="199" Grid.Row="4" FontSize="20"  Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Center" Margin="20 0 20 0"Content="修 改" Style="{StaticResource ButtonStyle}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:EditSupplierWindow}}"Command="{Binding EditCommand}"/><Button  Height="45" Width="199" Grid.Row="4"  FontSize="20"   Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Center" Margin="20 0 65 0"Content="取 消" Style="{StaticResource ButtonStyle}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:EditSupplierWindow}}"Command="{Binding CancelCommand}"/></StackPanel> </Grid> </Grid>
</Window>

 2)viewmodel

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using West.StoreMgr.Helper;
using West.StoreMgr.Service;namespace West.StoreMgr.ViewModel
{/// <summary>/// 编辑供应商viewmodel/// </summary>public class EditSupplierViewModel : ViewModelBase{private Supplier supplier = new Supplier();public Supplier Supplier{get { return supplier; }set { supplier = value; RaisePropertyChanged(); }}/// <summary>/// 修改/// </summary>public RelayCommand<Window> EditCommand{get{var command = new RelayCommand<Window>((window) =>{if (string.IsNullOrEmpty(Supplier.Name) == true|| string.IsNullOrEmpty(Supplier.Contact) == true|| string.IsNullOrEmpty(Supplier.Telephone) == true){ MsgWinHelper.ShowError("不能为空!");return;}var service = new SupplierService();int count = service.Update(Supplier);if (count > 0){MsgWinHelper.ShowMessage("修改成功!");window.Close();}else{ MsgWinHelper.ShowError("修改失败!");}});return command;}}/// <summary>/// 取消/// </summary>public RelayCommand<Window> CancelCommand{get{var command = new RelayCommand<Window>((window) =>{window.Close();});return command;}}}
}

3)运行效果

 

6、删除供应商

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


http://www.ppmy.cn/devtools/56840.html

相关文章

构建LangChain应用程序的示例代码:48、如何使用非文本生成工具创建多模态代理

多模态输出&#xff1a;图像和文本 这个示例展示了如何使用非文本生成工具来创建多模态代理。 本例仅限于文本和图像输出&#xff0c;并使用UUID在工具和代理之间传输内容。 本例使用Steamship生成和存储生成的图像。生成的内容默认受到身份验证保护。 您可以在这里获取Ste…

XMind2TestCase:高效测试用例设计工具

XMind2TestCase&#xff1a;高效测试用例设计工具 引言传统测试用例设计的问题1. Excel表格的局限性2. 传统测试管理工具的不足3. 自研测试管理工具的挑战 思维导图在测试用例设计中的应用思维导图的优势思维导图的挑战 简介安装使用方式命令行调用使用Web界面 使用示例XMind文…

Linux运维:MySQL数据库(1)

1.信息与数据&#xff1a; 数据是信息的载体&#xff0c;信息是数据的内涵。数据库就是存储数据的仓库&#xff0c;并长期存储在计算机磁盘中&#xff0c;可由多个用户和应用程序共享的数据集合&#xff0c;就是数据库。 2.数据库中的数据的特点&#xff1a; 2.1.数据是按照某…

Java nio 的线程通信机制线程通信Pipe

Java的Pipe是一种新的线程通信机制&#xff0c;传统的线程通信可以是通过共享内存的方式&#xff0c;socket等方式&#xff0c;而Pipe是通过Java NIO 通信的方式实现共享内存&#xff0c;优点类似于go语言的管道 先上代码 public static void main(String[] args) throws IOEx…

Java外卖霸王餐外卖小程序+APP+公众号+H5多端霸王餐源码

&#x1f354;【开篇&#xff1a;美食不等待&#xff0c;霸王餐新风尚&#xff01;】&#x1f354; 你还在为午餐晚餐吃什么而纠结吗&#xff1f;还在为外卖费用心疼钱包吗&#xff1f;今天&#xff0c;就带你揭秘一个吃货界的超级秘密武器——“外卖霸王餐免费吃”小程序APP公…

Linux: network: 丢包分析的另一个途径 tracing

丢包的另一个思路&#xff0c;内核里有些counter的计数&#xff0c;记录的不准确。这个时候怎么办&#xff1f;就需要使用另外一个方式&#xff1a;/sys/kernel/debug/tracing/event/skb/kfree_skb 的跟踪功能。这个算是对counter的一个补充&#xff0c;可以拿来做统计分析使用…

YOLOV++ 详解 | 网络结构、代码解析、YOLOV 论文阅读、初识 VID

前言 代码地址&#xff1a;https://github.com/YuHengsss/YOLOV 本文网络结构按 YOLOV SwinTiny 绘制&#xff0c;不同的模型主要差异在于 Backbone&#xff0c;VID 相关的部分基本相同。 Predict Input 代码基于 vid_demo。首先会读取视频中的所有帧&#xff08;只能用短视频…

6.27数据分析实训任务1.1(python)

import pandas as pd import matplotlib.pyplot as plt # 读取 CSV 文件 data pd.read_csv(r"C:\Users\XXGC\Desktop\shiuxun3.csv") # 将订单创建时间转换为 datetime 类型 data["订单创建时间"] pd.to_datetime(data["订单创建时间"]) # …