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

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.rhkb.cn/news/367437.html

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

相关文章

使用python做飞机大战

代码地址: 点击跳转

【论文阅读】伸缩密度比估计:Telescoping Density-Ratio Estimation

文章目录 一、文章概览&#xff08;一&#xff09;问题提出&#xff08;二&#xff09;文章工作 二、判别比估计和密度鸿沟问题三、伸缩密度比估计&#xff08;一&#xff09;核心思想&#xff08;二&#xff09;路标创建&#xff08;三&#xff09;桥梁构建&#xff08;四&…

Linux 生产消费者模型

&#x1f493;博主CSDN主页:麻辣韭菜&#x1f493;   ⏩专栏分类&#xff1a;Linux初窥门径⏪   &#x1f69a;代码仓库:Linux代码练习&#x1f69a;   &#x1f339;关注我&#x1faf5;带你学习更多Linux知识   &#x1f51d; 前言 1. 生产消费者模型 1.1 什么是生产消…

每日一题——Python实现PAT乙级1005 继续(3n+1)猜想(举一反三+思想解读+逐步优化)五千字好文

一个认为一切根源都是“自己不够强”的INTJ 个人主页&#xff1a;用哲学编程-CSDN博客专栏&#xff1a;每日一题——举一反三Python编程学习Python内置函数 Python-3.12.0文档解读 目录 我的写法 代码逻辑概述 时间复杂度分析 空间复杂度分析 总结 我要更强 代码优化点…

Nginx详解-安装配置等

目录 一、引言 1.1 代理问题 1.2 负载均衡问题 1.3 资源优化 1.4 Nginx处理 二、Nginx概述 三、Nginx的安装 3.1 安装Nginx 3.2 Nginx的配置文件 四、Nginx的反向代理【重点】 4.1 正向代理和反向代理介绍 4.2 基于Nginx实现反向代理 4.3 关于Nginx的location路径…

Jetson系列机载电脑创建热点模式配置方法

Jetson nano为例—— 创建热点模式配置方法 1.1、新建一个 WiFi 在屏幕右上角找到网络图标&#xff0c;点击后选择“Edit Connections”选项&#xff0c;进入选择网络连接页面&#xff0c;然后点击左下角加号&#xff0c;新建一个连接&#xff0c;类型选择 WiFi 后点击 “cre…

如何选择适合自己的巴比达内网穿透方案

选择适合自己的巴比达内网穿透方案&#xff0c;需要考虑几个关键因素&#xff0c;包括您的具体需求、安全性要求、技术水平以及预算。以下是一些选择巴比达内网穿透方案的建议步骤&#xff1a; 1. 确定需求和用途 首先&#xff0c;需要明确您希望通过内网穿透实现的具体目标和…

【linux学习---1】点亮一个LED---驱动一个GPIO

文章目录 1、原理图找对应引脚2、IO复用3、IO配置4、GPIO配置5、GPIO时钟使能6、总结 1、原理图找对应引脚 从上图 可以看出&#xff0c; 蜂鸣器 接到了 BEEP 上&#xff0c; BEEP 就是 GPIO5_IO05 2、IO复用 查找IMX6UL参考手册 和 STM32一样&#xff0c;如果某个 IO 要作为…

DP:解决路径问题

文章目录 二维DP模型如何解决路径问题有关路径问题的几个问题1.不同路径2.不同路径Ⅱ3.下降路径最小和4.珠宝的最高价值5.地下城游戏 总结 二维DP模型 二维动态规划&#xff08;DP&#xff09;模型是一种通过引入两个维度的状态和转移方程来解决复杂问题的技术。它在许多优化和…

使用VMware创建Ubuntu 24.04【一】

系列文章目录 第二章 使用Ubuntu安装Frappe-Bench【二】 文章目录 系列文章目录前言相关链接下载地址虚拟机创建与运行初始化系统中配置 前言 VMware是一个虚拟化软件&#xff0c;它允许用户在一台计算机上模拟多个虚拟计算机环境。通过使用VMware&#xff0c;用户可以轻松地…

【Python】已解决:AttributeError: ‘function’ object has no attribute ‘ELement’

文章目录 一、分析问题背景二、可能出错的原因三、错误代码示例四、正确代码示例五、注意事项 已解决&#xff1a;AttributeError: ‘function’ object has no attribute ‘ELement’ 一、分析问题背景 在Python编程中&#xff0c;AttributeError通常表明你试图访问一个对象…

【Linux】生物信息学常用基本命令

wget网址用于直接从网上下载某个文件到服务器&#xff0c;当然也可以直接从网上先把东西下到本地然后用filezilla这个软件来传输到服务器上。 当遇到不会的命令时候&#xff0c;可以使用man “不会的命令”来查看这个命令的详细信息。比如我想要看看ls这个命令的详细用法&…

K8S 集群节点扩容

环境说明&#xff1a; 主机名IP地址CPU/内存角色K8S版本Docker版本k8s231192.168.99.2312C4Gmaster1.23.1720.10.24k8s232192.168.99.2322C4Gwoker1.23.1720.10.24k8s233&#xff08;需上线&#xff09;192.168.99.2332C4Gwoker1.23.1720.10.24 当现有集群中的节点资源不够用&…

FFmpeg教程-三-播放pcm文件-1

目录 一&#xff0c;下载SDL 二&#xff0c;在Qt中测试 1&#xff0c;在pro文件中加入路径 2&#xff0c;在.cpp文件中加入头文件 3&#xff0c;进行测试 4&#xff0c;显示结果 一&#xff0c;下载SDL 通过编程的方式播放音视频&#xff0c;也是需要用到这2个库: FFmpeg…

2本Top,4本纯正刊,25天即录!7月刊源表已更新!

本周投稿推荐 SCI • 能源技术类&#xff0c;1.5-2.0&#xff08;来稿即录25天&#xff09; • 计算机类&#xff0c;2.0-3.0&#xff08;纯正刊29天录用&#xff09; EI • 各领域沾边均可&#xff08;2天录用&#xff09; CNKI • 7天录用-检索&#xff08;急录友好&a…

Python处理异常用操作介绍

Python中的异常处理主要用于捕获和处理程序运行过程中出现的错误。 在编写Python程序时&#xff0c;我们经常会遇到各种错误&#xff0c;如语法错误、运行时错误等。为了确保程序的稳定性和健壮性&#xff0c;我们需要对可能出现的错误进行捕获和处理。本文将介绍Python中常用的…

【云原生监控】Prometheus 普罗米修斯从搭建到使用详解

目录 一、前言 二、服务监控概述 2.1 什么是微服务监控 2.2 微服务监控指标 2.3 微服务监控工具 三、Prometheus概述 3.1 Prometheus是什么 3.2 Prometheus 特点 3.3 Prometheus 架构图 3.3.1 Prometheus核心组件 3.3.2 Prometheus 工作流程 3.4 Prometheus 应用场景…

贪心算法——加工木棍(C++)

上大学&#xff0c;一天是一天&#xff0c;两天也是一天。 ——2024年6月27日 之前考试周断更了&#xff0c;今天重新开始&#xff01; 题目描述 有n根木棍&#xff0c;已知每根木棍的长度和重量。这些木棍在木工机器上加工&#xff0c;机器准备加工木棍需要一些时间&#xf…

GraalVM

文章目录 1、什么是GraalVM2、GraalVM的两种模式1_JIT模式2_AOT模式3_总结 3、应用场景1_SpringBoot搭建GraalVM应用2_函数计算3_Serverless应用 4、参数优化和故障诊断1_内存快照文件的获取2_运行时数据的获取 1、什么是GraalVM GraalVM是Oracle官方推出的一款高性能JDK&…

【HarmonyOS4学习笔记】《HarmonyOS4+NEXT星河版入门到企业级实战教程》课程学习笔记(十九)

课程地址&#xff1a; 黑马程序员HarmonyOS4NEXT星河版入门到企业级实战教程&#xff0c;一套精通鸿蒙应用开发 &#xff08;本篇笔记对应课程第 29 节&#xff09; P29《28.网络连接-第三方库axios》 要想使用第三方库axios&#xff0c;需要先安装ohpm&#xff0c;因为 axios…