仓库管理系统16--入库管理

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

1、创建物资入库用户控件 

<UserControl x:Class="West.StoreMgr.View.InStoreView"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" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"DataContext="{Binding Source={StaticResource Locator},Path=InStore}"  ><i:Interaction.Triggers><i:EventTrigger EventName="Loaded"><i:InvokeCommandAction Command="{Binding LoadCommand}"/></i:EventTrigger></i:Interaction.Triggers><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="0 10 0 10"><StackPanel Orientation="Horizontal" VerticalAlignment="Center"><TextBlock Margin="0 0 10 0" Text="选择仓库:" VerticalAlignment="Center" Width="80"/><ComboBox x:Name="comboboxGoodsType" Margin="0 0 10 0" ItemsSource="{Binding StoreList}" SelectedItem="{Binding Store}" DisplayMemberPath="Name" SelectedValuePath="Id" Width="150" Height="30" /><TextBlock Margin="0 0 10 0" Text="选择供应商:" VerticalAlignment="Center" Width="80"/><ComboBox x:Name="comboboxSpec" Margin="0 0 10 0" ItemsSource="{Binding SupplierList}" SelectedItem="{Binding Supplier}" DisplayMemberPath="Name" SelectedValuePath="Id" Width="150" Height="30" /></StackPanel><StackPanel Orientation="Horizontal" VerticalAlignment="Center"  Margin="0 10 0 10"><Button Content="选择入库物资..." Command="{Binding OpenSelectGoodsWindow}"/><TextBlock Margin="0 0 10 0" Text=" 序号:" VerticalAlignment="Center" Width="80"/><TextBlock Margin="0 0 10 0" Text="{Binding InStore.GoodsSerial,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="150" Height="30" /><TextBlock Margin="0 0 10 0" Text="物资名称:" VerticalAlignment="Center" Width="80"/><TextBlock Margin="0 0 10 0" Text="{Binding InStore.Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="150" Height="30" /><TextBlock Margin="30 0 10 0" Text="单位:" VerticalAlignment="Center" Width="auto"/><TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding InStore.Unit,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="150" Height="30" /></StackPanel><StackPanel Orientation="Horizontal" VerticalAlignment="Center"  Margin="0 10 0 10"><TextBlock Margin="0 0 10 0" Text="入库数量:" VerticalAlignment="Center" Width="80"/><TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding InStore.Number,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="150" Height="30" /><TextBlock Margin="0 0 10 0" Text="入库价格:" VerticalAlignment="Center" Width="80"/><TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding InStore.Price,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="150" Height="30" /><TextBlock Margin="0 0 10 0" Text="备注:" VerticalAlignment="Center" Width="80"/><TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding InStore.Tag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="150" Height="30" /></StackPanel><StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0 10 0 10"> <!--button--><Button Margin="542 0 0 0" Height="36" Width="199" Grid.Row="3" FontSize="20"Content="增 加" Style="{StaticResource ButtonStyle}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:InStoreView}}"Command="{Binding AddCommand}"/></StackPanel></StackPanel> </Grid><!--浏览--><Grid Grid.Row="2" Margin="10 0 10 10"><DataGrid ItemsSource="{Binding InStoreList}" CanUserDeleteRows="False" CanUserAddRows="False" AutoGenerateColumns="False"><DataGrid.Columns><DataGridTextColumn Header="序号" Binding="{Binding GoodsSerial}"/><DataGridTextColumn Header="名称" Binding="{Binding Name}"/><DataGridTextColumn Header="仓库" Binding="{Binding StoreName}"/><DataGridTextColumn Header="供应商" Binding="{Binding SupplierName}"/><DataGridTextColumn Header="入库数量" Binding="{Binding Number}"/><DataGridTextColumn Header="入库价格" Binding="{Binding Price}" IsReadOnly="True"/><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:GoodsView},Path=DataContext.EditCommand}"CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}" Tag="{Binding}" Style="{StaticResource DataGridButtonStyle}" /><Button Content="删除" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:GoodsView},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>

 2、创建视图模型InStoreViewModel

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.View;
using West.StoreMgr.Service;
using West.StoreMgr.Model;
using West.StoreMgr.Windows;
using West.StoreMgr.Helper.AutoMapper;namespace West.StoreMgr.ViewModel
{/// <summary>/// 物资入库viewmodel/// </summary>public class InStoreViewModel : ViewModelBase{//添加public RelayCommand<UserControl> AddCommand{get{var command = new RelayCommand<UserControl>((obj) =>{if (!(obj is InStoreView view)) return;if (string.IsNullOrEmpty(InStore.Name) == true|| string.IsNullOrEmpty(InStore.GoodsSerial) == true){MsgWinHelper.ShowError("序号和名字不能为空");return;}InStore.InsertDate = DateTime.Now;InStore.UserInfoId = AppData.Instance.User.Id;if (Store.Id == 0){MsgWinHelper.ShowError("仓库不能为空");return;}if (Supplier.Id == 0){MsgWinHelper.ShowError("供应商不能为空");return;}InStore.StoreId = Store.Id;InStore.StoreName = Store.Name;InStore.SupplierId = Supplier.Id;InStore.SupplierName = Supplier.Name;//实体映射 var newInstore = Configration.Mapper.Map<InStore>(InStore);var service = new InStoreService();int count = service.Insert(newInstore);if (count > 0){//及时更新当前物资的存量if (Goods != null){Goods.Quant += InStore.Number;GoodsService goodsService = new GoodsService();count = goodsService.Update(this.Goods);}InStoreList = new InStoreService().Select();InStore = new InStoreEx();MsgWinHelper.ShowMessage("操作成功"); }else{MsgWinHelper.ShowError("操作失败");}});return command;}}//加载数据public RelayCommand LoadCommand{get{return new RelayCommand(() =>{StoreList = new StoreService().Select();SupplierList = new SupplierService().Select();InStoreList = new InStoreService().Select();});}}private Store store = new Store();/// <summary>/// 当前仓库/// </summary>public Store Store{get { return store; }set { store = value; RaisePropertyChanged(); }}private List<Store> storeList = new List<Store>();/// <summary>/// 仓库集合/// </summary>public List<Store> StoreList{get { return storeList; }set { storeList = value; RaisePropertyChanged(); }} private Supplier supplier = new Supplier();/// <summary>/// 当前供应商/// </summary>public Supplier Supplier{get { return supplier; }set { supplier = value; RaisePropertyChanged(); }} private List<Supplier> supplierList = new List<Supplier>();/// <summary>/// 供应商集合/// </summary>public List<Supplier> SupplierList{get { return supplierList; }set { supplierList = value; RaisePropertyChanged(); }}private InStoreEx instore = new InStoreEx();public InStoreEx InStore{get { return instore; }set { instore = value; RaisePropertyChanged(); }}private List<InStore> inStoreList = new List<InStore>();/// <summary>/// 入库历史记录/// </summary>public List<InStore> InStoreList{get { return inStoreList; }set { inStoreList = value; RaisePropertyChanged(); }}private Goods goods = new Goods();/// <summary>/// 当前选择的资物对象/// </summary>public Goods Goods{get { return goods; }set { goods = value; RaisePropertyChanged(); }}public RelayCommand OpenSelectGoodsWindow{get{return new RelayCommand(() =>{var window = new SelectGoodsWindow();var result = window.ShowDialog();if (result.HasValue && result.Value == true){var vm = window.DataContext as SelectGoodsViewModel;InStore.GoodsSerial = vm.Goods.Serial;InStore.Name = vm.Goods.Name;this.Goods = vm.Goods;}});}}}
}

3、选择物资窗体

4、选择物资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 West.StoreMgr.Service;namespace West.StoreMgr.ViewModel
{/// <summary>/// 选择物资viewmodel/// </summary>public class SelectGoodsViewModel : ViewModelBase{/// <summary>///窗体加载命令/// </summary>public RelayCommand LoadCommand{get{return new RelayCommand(() =>{GoodsList = new GoodsService().Select();});}}private Goods goods = new Goods();/// <summary>/// 物资/// </summary>public Goods Goods{get { return goods; }set { goods = value; RaisePropertyChanged(); }}private List<Goods> goodsList = new List<Goods>();/// <summary>/// 物资列表/// </summary>public List<Goods> GoodsList{get { return goodsList; }set { goodsList = value; RaisePropertyChanged(); }}}
}

5、运行效果

 

 

 

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

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

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

相关文章

CAS自旋解析

CAS全称CompareAndSwap(比较并交换)&#xff0c;是cpu的指令&#xff0c;调用时不涉及上下文的切换。Java中属于乐观锁的一种&#xff0c;具体流程如下图&#xff1a; 具体的实现使用的是Unsafe类去调用native修饰的compareAndSwap方法&#xff0c;4个字段分别是对象实例&#…

PTA—C语言期末复习(判断题)

1. C语言程序是从源文件的第一条语句开始执行的 &#xff08;F&#xff09; 在 C 语言中&#xff0c;程序是从 main 函数开始执行的&#xff0c;而不是从源文件的第一条语句开始执行 2. 若变量定义为double x;&#xff0c;则x % 2是符合C语言语法的表达式 &#xff08;F&#…

HTML流星雨

目录 写在前面 完整代码 代码分析 系列文章 写在最后 写在前面 岁月如梭&#xff0c;光阴似箭&#xff0c;不知不觉暑假就要来喽&#xff0c;本期小编用HTML给大家手搓了一个炫酷的流星雨动画&#xff0c;一起来看看吧。 完整代码 <!DOCTYPE html> <html lang…

项目风险管理系统有哪些?分享11款主流项目管理系统

本文将分享11款主流项目管理系统&#xff1a;PingCode、Worktile、StandardFusion、MasterControl、ClickUp、SAI360、Netwrix Auditor、MetricStream、Wrike、Celoxis、Zoho Projects。 在项目管理中&#xff0c;风险管理不仅是一个挑战&#xff0c;也是保证项目顺利进行的关键…

Linux Redis 服务设置开机自启动

文章目录 前言一、准备工作二、操作步骤2.1 修改redis.conf文件2.2 创建启动脚本2.3 设置redis 脚本权限2.4 设置开机启动2.5 验证 总结 前言 请各大网友尊重本人原创知识分享&#xff0c;谨记本人博客&#xff1a;南国以南i、 提示&#xff1a;以下是本篇文章正文内容&#x…

编程的难点在哪?是逻辑、算法,还是模块、框架的掌握?

&#x1f446;点击关注 回复『新人礼』获取学习礼包&#x1f446; 很多新手程序员在一开始都是满怀热情地投入到编程的学习&#xff0c;但却在学习过程中处处碰壁&#xff0c;导致放弃。 编程的难点在于逻辑、数学、算法&#xff0c;还是模块、框架、接口的掌握&#xff1f;但…

idea Error running ‘Application‘

1、Error running ‘Application’ Error running ApplicationError running Application. Command line is too long.Shorten the command line via JAR manifest or via a classpath file and rerun.找到 .idea/libraies/workspace.xml 中的 PropertiesComponent 属性&#…

大模型赋能全链路可观测性:运维效能的革新之旅

目录 全链路可观测工程与大模型结合---提升运维效能 可观测性&#xff08;Observability&#xff09;在IT系统中的应用及其重要性 统一建设可观测数据 统一建设可观测数据的策略与流程 全链路的构成和监控形态 云上的全链路可视方案 为什么一定是Copilot 大模型的Copilo…

mov和mp4区别是什么?苹果的原创和时代的宠儿

在数字媒体领域&#xff0c;视频格式的选择往往决定了观看体验的质量和文件的兼容性。在众多视频格式中&#xff0c;MOV和MP4无疑是最具代表性的两种&#xff0c;它们分别承载着苹果和互联网世界的技术革新与历史变迁。本文将带您穿越时间的长廊&#xff0c;探索MOV与MP4的发展…

区间DP——AcWing 320. 能量项链

区间DP 定义 区间动态规划&#xff08;Interval Dynamic Programming&#xff09;&#xff0c;简称区间DP&#xff0c;是动态规划领域的一个重要分支&#xff0c;专门用于解决涉及区间问题的最优化问题。这类问题通常需要在给定的一组区间上找到最优解&#xff0c;比如求解最…

福兰农庄携手越南NFC巨头朱雀桥薇妮她百香果饮料,深化品质合作

近日&#xff0c;国内知名果汁品牌福兰农庄成功与越南NFC行业领军者朱雀桥建立深入合作关系。为了进一步提升产品品质和市场竞争力&#xff0c;福兰农庄派遣专业团队前往越南&#xff0c;深入VINUT百香果饮料的生产线&#xff0c;学习其从原料采购到产品上市的严格操作流程。 在…

IAR 常见报错与实用小技巧(ZigBee)

一、报错 1.未发现选择目标 原因&#xff1a;硬件连接存在问题 解决方案&#xff1a;将数据线重新插拔或更换接口、数据线 2. 烧录终止 原因&#xff1a;烧录前未点击仿真器复位按钮 解决方案&#xff1a; 进行烧录前点击仿真器复位按钮&#xff08;下载过程中不能按&#xff…

数据结构与算法 - 图

博客主页&#xff1a;誓则盟约系列专栏&#xff1a;IT竞赛 专栏关注博主&#xff0c;后期持续更新系列文章如果有错误感谢请大家批评指出&#xff0c;及时修改感谢大家点赞&#x1f44d;收藏⭐评论✍ 图的定义和基本概念&#xff1a; 图&#xff08;Graph&#xff09;是一种由…

java+mysql图书管理系统

完整代码地址 1.运行效果图 2.主要代码 2.1.连接数据库 package com.my.homework.utils;import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;public class JDBCUtils {public static Connection getConnection() throws Exception {…

点云处理实战 点云平面拟合

目录 一、什么是平拟合 二、拟合步骤 三、数学原理 1、平面拟合 2、PCA过程 四、代码 一、什么是平拟合 平面拟合是指在三维空间中找到一个平面,使其尽可能接近给定的点云。最小二乘法是一种常用的拟合方法,通过最小化误差平方和来找到最优的拟合平面。 二、拟合步骤…

keepalived脑裂和haproxy

1.用keepalived管理nginx服务 7-1和7-2配置 #安装nginx systemctl stop firewalld setenforce 0 yum install epel-release.noarch -y yum install -y nginx systemctl start nginxvim /etc/nginx/nginx.confupstream web {server 192.168.91.102;server 192.168.91.10…

笔记本电脑升级实战手册[1]:开始之前的准备与清单

文章目录 前言&#xff1a;一、升级流程1. 备份2. 清灰换硅脂3. 扩展内存与硬盘4. 硬盘设置5. 系统重装6. 升级后性能测试 二、升级清单1. 工具清单2. 升级清单 总结&#xff1a; 前言&#xff1a; 将要毕业之际&#xff0c;发现我的笔记本电脑已经陪我“征战沙场”快有四年之…

揭秘教学新利器:SmartEDA电路仿真软件,让电子学习更生动!

在数字化教育浪潮中&#xff0c;一款名为SmartEDA的电路仿真软件逐渐崭露头角&#xff0c;以其直观、易操作的特点&#xff0c;为电子学习领域带来了革命性的变化。今天&#xff0c;就让我们一起探讨如何使用SmartEDA进行教学&#xff0c;让电子学习变得更加生动有趣&#xff0…

Android源码——Handler机制(一)

Android源码——Handler机制&#xff08;一&#xff09; Handler机制概述介绍Handler机制模型Handler机制架构 Handler机制源码解析ActivityThreadLooperHandler Handler机制概述 介绍 Handler是Android消息机制的上层接口。Handler可以将一个任务切换到Handler所在的线程中去…

网络物理隔离后 可以用保密U盘进行数据安全交换吗?

企业用的保密U盘通常被设计用于存储和传输敏感信息&#xff0c;以确保数据的安全和保密性。 在网络之间实现了物理隔离后&#xff0c;使用保密U盘进行数据安全交换是一种常见的做法。物理隔离确保了两个网络之间的完全分离&#xff0c;因此使用保密U盘可以作为一种安全的手段来…