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

news2024/11/26 15:25:45

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

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.coloradmin.cn/o/1873143.html

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

相关文章

市场拓展招聘:完整指南

扩大招聘业务会给你带来很多挑战&#xff0c;更不用说你已经在处理的问题了。助教专业人士每周花近13个小时为一个角色寻找候选人。此外&#xff0c;客户的需求也在不断变化&#xff0c;招聘机构之间的竞争也在加剧。毫无疑问&#xff0c;对增长有战略的方法会有很大的帮助。一…

RocketMq源码解析九:刷盘机制及过期文件删除

一、刷盘机制 刷盘策略在不同时间进行刷写磁盘。RocketMQ的存储是基于JDK NIO的内存映射机制(MappedByteBuffer)的,消息存储首先将消息追加到内存,再根据配置的刷写磁盘 同步刷盘表示消息追加到内存后,立即将数据刷写到文件系统中。代码的调用链如下: submi…

web使用cordova打包Andriod

一.安装Gradel 1.下载地址 Gradle Distributions 2.配置环境 3.测试是否安装成功 在cmd gradle -v 二.创建vite项目 npm init vitelatest npm install vite build 三.创建cordova项目 1.全局安装cordova npm install -g cordova 2. 创建项目 cordova create cordova-app c…

学习过程中遇到的 部分问题及解决办法

1.安装build wheel时报错&#xff1a; The detected CUDA version (12.1) mismatches the version that was used to compile PyTorch (11.7). Please make sure to use the same CUDA versions. 由于cuda版本和 当前虚拟环境中的pytorch-cudatoolkit版本不同&#xff0c; 解…

梦想CAD二次开发

1.mxdraw简介 mxdraw是一个HTML5 Canvas JavaScript框架&#xff0c;它在THREE.js的基础上扩展开发&#xff0c;为用户提供了一套在前端绘图更为方便&#xff0c;快捷&#xff0c;高效率的解决方案&#xff0c;mxdraw的实质为一个前端二维绘图平台。你可以使用mxdraw在画布上绘…

【系统架构设计师】五、计算机网络(概念|通信技术|网络技术)

目录 一、计算机网络概念 二、通信技术 三、网络技术 3.1 局域网(LAN) 3.1.1 局域网拓扑结构 3.1.2 局域网协议 3.2 无线局域网(WLAN) 3.3 广域网(WAN) 3.4 城域网&#xff08;MAN) 3.5 移动通信网 四、组网技术 4.1 OSI七层模型 4.1.1 交换机 4.1.2 路由器 4.2…

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 属性&#…

python数据分析与可视化二

公共部分 # 引入数据分析工具 Pandas import pandas as pd # 引入数据可视化工具 Matplotlib import matplotlib.pyplot as plt # 引入科学计算库numpy import numpy as np from scipy import stats #解决输出时列名对齐问题 pd.set_option(display.unicode.east_asian_wid…

《数据结构与算法基础 by王卓老师》学习笔记——2.2线性表的案例引入

案例一&#xff1a;一元多项式的运算 案例二&#xff1a;稀疏多项式的运算 案例三&#xff1a;图书信息管理系统 总结

慢动作视频怎么制作?5种方法,轻松制作慢动作视频

在短视频风靡的当下&#xff0c;慢动作视频凭借其独特的视觉效果和引人入胜的节奏感&#xff0c;成为了吸引观众眼球的利器。你是否也想知道如何制作这种令人心动的慢动作视频呢&#xff1f;下面教大家5种能够制作出慢动作视频的方法&#xff0c;一起来学习下吧。 方法一&#…

Nginx反向代理实现Vue跨域注意事项

1、通过搜索引擎访问Nginx官网——免费使用——NGINX开源版(免费下载)或者通过以下链接直接访问Nginx下载页面下载对应的版本(下载页面)。以下以1.24.0为例 2、修改nginx的配置文件&#xff0c;在conf文件夹下&#xff0c;文件名为nginx.conf&#xff1b;以下是我修改完的配置…

2024我们该学习大模型吗?

一、引言 在快速变化的科技行业中&#xff0c;人工智能&#xff08;AI&#xff09;大模型已成为研究和应用的热点。随着AI技术的不断进步&#xff0c;特别是在自然语言处理、计算机视觉和机器学习平台等领域&#xff0c;许多专业人士开始将目光投向AI大模型的开发和应用。 二…

MobPush iOS端海外推送最佳实现

推送注册 在AppDelegate里进行SDK初始化&#xff08;也可以在Info.plist文件中进行AppKey&#xff0c;AppSecret的配置&#xff09;并对通知功能进行注册以及设置推送的环境和切换海外服务器等&#xff0c;参考如下步骤代码&#xff1a; <span style"background-colo…

[漏洞复现] MetInfo5.0.4文件包含漏洞

[漏洞复现] MetInfo5.0.4文件包含漏洞 MetInfo5.0.4 漏洞代码审计 漏洞出现在about/index.php中&#xff0c;因为利用了动态地址&#xff0c;所以存在漏洞。 漏洞检查语句&#xff08;&#xff01;192.168.109.100是我的服务器ip&#xff0c;需要换成自己的&#xff09;&…

[BUUCTF从零单排] Web方向 02.Web入门篇之『常见的搜集』解题思路(dirsearch工具详解)

这是作者新开的一个专栏《BUUCTF从零单排》&#xff0c;旨在从零学习CTF知识&#xff0c;方便更多初学者了解各种类型的安全题目&#xff0c;后续分享一定程度会对不同类型的题目进行总结&#xff0c;并结合CTF书籍和真实案例实践&#xff0c;希望对您有所帮助。当然&#xff0…

jupyter安装及使用

引言 之前安装了anaconda&#xff0c;然后conda的环境管理里面就有jupyter&#xff0c;但是我一直没用过。 但是我用过colab&#xff0c;从使用体验上来说&#xff0c;非常相似&#xff0c;这次给服务器装了一个jupyter&#xff0c;然后我本地连接远程的来用&#xff0c;还挺…

一种502 bad gateway nginx/1.18.0的解决办法

背景:上线的服务突然挂掉了 step1&#xff0c;去后端日志查看&#xff0c;发现并无异常&#xff0c;就是请求无法被接收 step2&#xff0c;查看了nginx的错误日志&#xff0c;发现该文件为空 step3&#xff0c;查看了niginx的运行日志&#xff0c;发现了以下问题 [error] 38#…

C++ 106 之 list容器

#include <iostream> #include <string> using namespace std; // #include <vector> // 容器头文件 #include <algorithm> // 标准算法头文件 #include <list>void printList(const list<int> & list1){for(list<int>::const…

半小时速通Python爬虫!GitHub开源的Python爬虫入门教程

今天给小伙伴们带来了一篇详细介绍 Python 爬虫入门的教程&#xff0c;从实战出发&#xff0c;适合初学者。 小伙伴们只需在阅读过程紧跟文章思路&#xff0c;理清相应的实现代码&#xff0c;30 分钟即可学会编写简单的 Python 爬虫。 这篇 Python 爬虫教程主要讲解以下 5 部…

flutter开发实战-ListWheelScrollView与自定义TimePicker时间选择器

flutter开发实战-ListWheelScrollView与自定义TimePicker 最近在使用时间选择器的时候&#xff0c;需要自定义一个TimePicker效果&#xff0c;当然这里就使用了ListWheelScrollView。ListWheelScrollView与ListView类似&#xff0c;但ListWheelScrollView渲染效果类似滚筒效果…