仓库管理系统18--出库管理

news2024/12/29 10:04:17

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

1、创建用户控件OutStoreView

 

<UserControl x:Class="West.StoreMgr.View.OutStoreView"
             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"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             mc:Ignorable="d" 
             DataContext="{Binding Source={StaticResource Locator},Path=OutStore}"   >
    <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 CustomerList}" SelectedItem="{Binding Customer}" DisplayMemberPath="Name" SelectedValuePath="Id" Width="150" Height="30" />
                </StackPanel>
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center"  Margin="0 10 0 10">
                    <Button Background="BlanchedAlmond" FontFamily="微软雅黑" FontSize="15" Content="选择出库物资" Command="{Binding OpenSelectGoodsWindow}"/>
                    <TextBlock Margin="10 0 10 0" Text=" 序号:" VerticalAlignment="Center" Width="80"/>
                    <TextBox  Background="#E4ECEF" IsReadOnly="True" HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center"   Margin="0 0 10 0" Text="{Binding OutStore.GoodsSerialEx,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="150" Height="30" />
                    <TextBlock Margin="0 0 10 0" Text="物资名称:" VerticalAlignment="Center" Width="80"/>
                    <TextBox  Background="#E4ECEF" IsReadOnly="True" HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center"   Margin="0 0 10 0" Text="{Binding OutStore.NameEx,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="150" Height="30" />
                    <TextBlock Margin="7 0 10 0" Text="单位:" VerticalAlignment="Center" Width="auto"/>
                    <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding OutStore.UnitEx,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="170" 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 OutStore.NumberEx,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 OutStore.PriceEx,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 OutStore.TagEx,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="230" Height="30" />
                </StackPanel>
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0 10 0 10">                   
                    <Button Margin="542 0 0 0" Height="36" Width="199" FontSize="20"
                        Content="增 加" Style="{StaticResource ButtonStyle}" 
                        CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:OutStoreView}}"
                        Command="{Binding AddCommand}"/>
                </StackPanel>
            </StackPanel>
        </Grid>

        <!--浏览-->
        <Grid Grid.Row="2" Margin="10 -10 10 10">
            <DataGrid ItemsSource="{Binding OutStoreList}" 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 CustomerName}"/>
                    <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、创建出库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.View;
using West.StoreMgr.Service;

namespace West.StoreMgr.ViewModel
{
    /// <summary>
    /// 出库viewmodel
    /// </summary>
    public class OutStoreViewModel : ViewModelBase
    {
        //添加 
        public RelayCommand<UserControl> AddCommand
        {
            get
            {
                var command = new RelayCommand<UserControl>((obj) =>
                {
                    if (!(obj is OutStoreView view)) return;
                    if (string.IsNullOrEmpty(OutStore.Name) == true
                    || string.IsNullOrEmpty(OutStore.GoodsSerial) == true)
                    {
                        MsgWinHelper.ShowError("序号和名字不能为空");
                        return;
                    }

                    OutStore.InsertDate = DateTime.Now;
                    OutStore.UserInfoId = AppData.Instance.User.Id;

                    if (Store.Id == 0)
                    {
                        MsgWinHelper.ShowError("仓库不能为空");
                        return;
                    }

                    if (Customer.Id == 0)
                    {
                        MsgWinHelper.ShowError("客户不能为空");
                        return;
                    }

                    if (Goods.Quant < OutStore.Number)
                    {
                        MsgWinHelper.ShowError("存库不足");
                        return;
                    }

                    OutStore.StoreId = Store.Id;
                    OutStore.StoreName = Store.Name;
                    OutStore.CustomerId = Customer.Id;
                    OutStore.CustomerName = Customer.Name;


                    var service = new OutStoreService();
                    int count = service.Insert(OutStore);
                    if (count > 0)
                    {
                        //及时更新当前物资的存量
                        if (Goods != null)
                        {
                            Goods.Quant -= OutStore.Number;
                            GoodsService goodsService = new GoodsService();
                            count = goodsService.Update(this.Goods);
                        }
                        OutStoreList = new OutStoreService().Select();
                        OutStore = new OutStore();
                        MsgWinHelper.ShowMessage("操作成功");

                    }
                    else
                    {
                        MsgWinHelper.ShowError("操作失败");
                    }
                });

                return command;
            }
        }

        //加载数据
        public RelayCommand LoadCommand
        {
            get
            {
                return new RelayCommand(() =>
                {
                    StoreList = new StoreService().Select();
                    CustomerList = new CustomerService().Select();
                    OutStoreList = new OutStoreService().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 Customer customer = new Customer();
        /// <summary>
        /// 当前客户
        /// </summary>
        public Customer Customer
        {
            get { return customer; }
            set { customer = value; RaisePropertyChanged(); }
        } 

        private List<Customer> customerList = new List<Customer>();
        /// <summary>
        /// 客户集合
        /// </summary>
        public List<Customer> CustomerList
        {
            get { return customerList; }
            set { customerList = value; RaisePropertyChanged(); }
        }


        private OutStore outstore = new OutStore();
        /// <summary>
        /// 出库
        /// </summary>
        public OutStore OutStore
        {
            get { return outstore; }
            set { outstore = value; RaisePropertyChanged(); }
        }

        private List<OutStore> outStoreList = new List<OutStore>();
        /// <summary>
        /// 出库历史记录
        /// </summary>
        public List<OutStore> OutStoreList
        {
            get { return outStoreList; }
            set { outStoreList = value; RaisePropertyChanged(); }
        }
         
        private Goods goods = new Goods();
        /// <summary>
        /// 当前选择的资物对象
        /// </summary>
        public Goods Goods
        {
            get { return goods; }
            set { goods = value; RaisePropertyChanged(); }
        }

        /// <summary>
        /// 选择出库物资命令
        /// </summary>
        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;
                        OutStore.GoodsSerialEx = vm.Goods.Serial;
                        OutStore.NameEx = vm.Goods.Name;
                        this.Goods = vm.Goods;
                    }
                });
            }
        }
    }
}

 3、运行效果

 

 

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

 

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

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

相关文章

C++【函数重载】【附有C语言为何不能实现函数重载的讲解】

P. S.&#xff1a;以下代码均在VS2019环境下测试&#xff0c;不代表所有编译器均可通过。 P. S.&#xff1a;测试代码均未展示头文件stdio.h的声明&#xff0c;使用时请自行添加。 博主主页&#xff1a;LiUEEEEE                        …

【股指期权投教】一手股指期权大概多少钱?

一手股指期权的权利金大概在几千人民币左右&#xff0c;如果是作为期权卖方还需要另外缴纳保证金的。国内的股指期权有三种&#xff0c;沪深300、上证50、中证1000股指期权&#xff0c;每点合约人民币100 元。 期权合约的价值计算可以通过此公式得出&#xff1a;权利金的支付或…

C++继承(2)

目录 1.如何实现一个不可以被继承的类 2.继承和友元函数 3.继承和静态成员变量 4.菱形&#xff08;虚拟&#xff09;继承 &#xff08;1&#xff09;单继承和多继承 &#xff08;2&#xff09;菱形继承 &#xff08;3&#xff09;菱形继承的特殊情况 &#xff08;4&…

Unity2D - 状态机(State Machine)详解

1. 状态机概述 在角色的生成中&#xff0c;由于事件的不同&#xff0c;动作的不同&#xff0c;角色会处于不同的状态中。例如对战冒险游戏&#xff0c;面临Boss的攻击&#xff0c;角色会受到例如中毒&#xff0c;恐惧等Debuff效果&#xff0c;若单纯的在一个脚本中使用if等语句…

Linux Swap

Swap: 页面换出&#xff1a;就是在 Swap 机制下&#xff0c;当内存资源紧张时&#xff0c;内核就会把不经常使用的这些匿名页中的数据写入到 Swap 分区或者 Swap 文件中。从而释放这些数据所占用的内存空间。 页面换入&#xff1a;就是当进程再次访问那些被换出的数据时&…

中医对于帕金森病的病因和症状有何解释?

中医对帕金森病的病因解释 中医认为帕金森病的病因复杂多样&#xff0c;涉及多个方面。首先&#xff0c;精神因素如长期的情绪抑郁、悲伤、忧虑等精神不畅可能导致气机郁结&#xff0c;气血运行障碍&#xff0c;进而影响脑部神经系统的功能。其次&#xff0c;肝郁气滞也被认为…

怎么把amr格式转换为mp3格式?这6个mp3格式转换方法不容错过!

怎么把amr格式转换为mp3格式&#xff1f;AMR&#xff08;自适应多速率&#xff09;是一种音频编码格式&#xff0c;通常用于存储基于语音的文件&#xff0c;例如语音记录和VoIP应用&#xff0c;在3G移动设备上使用。它具有非常高的压缩比&#xff0c;导致声音质量较差。早期的安…

【Python机器学习】分类向量——数字可以编码分类变量

在adult数据集的例子中&#xff0c;分类变量被编码为字符。一方面可能会有拼写错误&#xff0c;但另一方面&#xff0c;它明确的将一个变量标记为分类变量。无论是为了便于存储还是因为数据的手机方式&#xff0c;分类变量通常被编码为整数。 假设adult数据集中的人口普查数据…

使用shell脚本编写监控系统资源(CPU,内存,磁盘)使用情况

&#x1f3e1;作者主页&#xff1a;点击&#xff01; &#x1f6e0;️Shell编程专栏&#xff1a;点击&#xff01; ⏰️创作时间&#xff1a;2024年6月20日16点30分 &#x1f004;️文章质量&#xff1a;95分 目录 ————前言———— 1.本章目标 2.编写脚本 1.获取内…

Go 中使用map时注意的问题

&#x1f49d;&#x1f49d;&#x1f49d;欢迎莅临我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 推荐:「stormsha的主页」…

uniapp uniCloud云开发

uniCloud概述 uniCloud 是 DCloud 联合阿里云、腾讯云、支付宝云&#xff0c;为开发者提供的基于 serverless 模式和 js 编程的云开发平台。 uniCloud 的 web控制台地址&#xff1a;https://unicloud.dcloud.net.cn 文档&#xff1a;https://doc.dcloud.net.cn/uniCloud/ un…

AI绘画:P图如此丝滑,OpenAI上线ChatGPT图像编辑功能,DallE-3绘画如此简单

大家好我是极客菌&#xff0c;用ChatGPT的DallE-3进行AI绘画对很多人来说是一个门槛很低的选择&#xff0c;现在OpenAI又重磅上线了图像编辑器功能(DallE editor)&#xff0c;可以很方便的对图片的局部进行修改&#xff0c;而且支持中文&#xff0c;主打一个功能强大且好用&…

论文学习——一种自适应提升的动态多目标优化进化算法

论文题目&#xff1a;A dynamic multi-objective optimization evolutionary algorithm with adaptive boosting 一种自适应提升的动态多目标优化进化算法&#xff08;Hu Peng a,b,∗, Jianpeng Xiong a, Chen Pi a, Xinyu Zhou c, Zhijian Wu d&#xff09;IEEE Swarm and Ev…

FreeSWITCH 1.10.10 简单图形化界面24-呼入呼出编码

FreeSWITCH 1.10.10 简单图形化界面24-呼入呼出编码 FreeSWITCH GUI界面预览00、安装FreeSWITCH GUI先看使用手册1、语音接听还是视频接听2、排查 FreeSWITCH GUI界面预览 http://myfs.f3322.net:8020/ 用户名&#xff1a;admin&#xff0c;密码&#xff1a;admin FreeSWITCH…

MySQL之如何定位慢查询

1、如何定位慢查询 1.1、使用开源工具 调试工具&#xff1a;Arthas 运维工具&#xff1a;Promethuss、Skywalking 1.2、MySQL自带慢日志 慢查询日志记录了所有执行时间超过指定参数&#xff08;long_query_time&#xff0c;单位&#xff1a;秒&#xff0c;默认10秒&#x…

The difference between Manhattan distance and Cosine Distance

题意&#xff1a;为什么即使返回了相同的文本块&#xff0c;曼哈顿距离&#xff08;Manhattan Distance&#xff09;和余弦距离&#xff08;Cosine Distance&#xff09;之间还是存在差异&#xff1f; 问题背景&#xff1a; I am using the qdrant DB and client for embeddin…

探索LangChain-Chatchat 0.3:一体化Agent与强大RAG模型的全面入门指南

介绍 LangChain-Chatchat 支持RAG和Agent0.3版本跟大模型解耦,支持Xinference、Ollama、LocalAI、FastChat、One API,可以非常方便的切换各个模型,本文只是介绍XinferenceXorbits Inference (Xinference) 是一个开源平台&#xff0c;用于简化各种 AI 模型的运行和集成。借助 X…

论文辅导 | 基于贝叶斯优化-卷积神经网络-双向长短期记忆神经网络的锂电池健康状态评估

辅导文章 模型描述 准确估计电池健康状态是设备稳定运行的关键。针对当前健康状态研究中容量难以直接测量、估计模型调参费时等问题&#xff0c;提出基于多健康特征的贝叶斯优化&#xff08;BO&#xff09;算法优化卷积神经网络&#xff08;CNN&#xff09;与双向长短期记忆&a…

气膜仓库的优势与应用—轻空间

随着现代物流和存储需求的不断增长&#xff0c;传统仓库的建设和运营成本日益增加&#xff0c;企业需要寻找更加灵活、高效和经济的解决方案。在这种背景下&#xff0c;气膜仓库作为一种新型仓储形式&#xff0c;以其独特的优势和广泛的应用前景&#xff0c;逐渐受到市场的青睐…

视频号视频怎么保存到手机,视频号视频怎么保存到手机相册里,苹果手机电脑都可以用

随着数字媒体的蓬勃发展&#xff0c;视频已成为我们日常生活中不可或缺的一部分。视频号作为众多视频分享平台中的一员&#xff0c;吸引了大量用户上传和分享各类精彩视频。然而&#xff0c;有时我们可能希望将视频号上的视频下载下来,以下将详细介绍如何将视频号的视频。 方法…