仓库管理系统22--出库查询

发布于:2024-07-01 ⋅ 阅读:(16) ⋅ 点赞:(0)

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

1、添加用户控件QueryOutStoreView

<UserControl x:Class="West.StoreMgr.View.QueryOutStoreView"
             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=QueryOutStore}"
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition Height="auto"/>
            <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.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Text="请输入物资名称" FontSize="16" HorizontalAlignment="Right" VerticalAlignment="Center"/>
            <TextBox Grid.Column="1" FontSize="18" Margin="10 0 10 0" Text="{Binding GoodsName,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center"/>
            <!--button-->
            <Button Grid.Column="2"  Height="36" Width="139" 
                Content="查询" Style="{StaticResource ButtonStyle}" 
                Command="{Binding QueryCommand}"/>
            <Button Grid.Column="3" Margin="30 0 0 0" Height="36" Width="139" FontSize="20" Background="DarkBlue"
               Content="清 空" Style="{StaticResource ButtonStyle}" 
               Command="{Binding ClearCommand}"/>
        </Grid>

        <!--浏览-->
        <Grid Grid.Row="2" Margin="10 0 10 10">
            <DataGrid ItemsSource="{Binding Outstores}" 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}"/>
                </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 West.StoreMgr.Helper;
using West.StoreMgr.Service;

namespace West.StoreMgr.ViewModel
{
    /// <summary>
    /// 出库查询viewmodel
    /// </summary>
    public class QueryOutStoreViewModel : ViewModelBase
    {
        private string goodsName = string.Empty;
        /// <summary>
        /// 物资名称
        /// </summary>
        public string GoodsName
        {
            get { return goodsName; }
            set { goodsName = value; RaisePropertyChanged(); }
        }

        private List<OutStore> outstoresList = null;
        /// <summary>
        /// 查询结果
        /// </summary>
        public List<OutStore> OutstoresList
        {
            get { return outstoresList; }
            set { outstoresList = value; RaisePropertyChanged(); }
        }

        //查询命令

        public RelayCommand QueryCommand
        {
            get
            {
                return new RelayCommand(() =>
                {
                    string objName = goodsName.Trim();
                    var goods = new OutStoreService().Select();
                    if (string.IsNullOrEmpty(objName))
                    {
                        OutstoresList = goods;
                    }
                    else
                    {
                        OutstoresList = goods.Where(t => t.Name.Contains(objName)).ToList();
                        if (OutstoresList.Count == 0)
                        {
                            MsgWinHelper.ShowError("没有查询到!");
                            return;
                        }
                    }
                });
            }
        }

        /// <summary>
        /// 初始时加载所有
        /// </summary>
        public RelayCommand LoadCommand
        {
            get
            {
                return new RelayCommand(() =>
                {
                    GoodsName = "";
                    OutstoresList = new OutStoreService().Select();
                });
            }
        }


        /// <summary>
        /// 清空
        /// </summary>
        public RelayCommand ClearCommand
        {
            get
            {
                return new RelayCommand(() =>
                {
                    GoodsName = "";
                    OutstoresList = new OutStoreService().Select();
                });
            }
        }
    }
}

 3、运行效果

 


网站公告

今日签到

点亮在社区的每一天
去签到