仓库管理系统14--仓库设置

news2024/10/7 14:26:48

1、添加窗体

 

<UserControl x:Class="West.StoreMgr.View.StoreView"
             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=Store}"
             d:DesignHeight="450" 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="Horizontal" VerticalAlignment="Center">
                <TextBlock Margin="0 0 10 0" Text="仓库名称:" VerticalAlignment="Center"/>
                <TextBox Margin="0 0 10 0" Text="{Binding Store.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 Store.Tag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="200" Height="30" />
                <!--button-->
                <Button Margin="18 0 0 0" Height="36" Width="199" Grid.Row="3" FontSize="20" 
                      Content="增 加" Style="{StaticResource ButtonStyle}" 
                      CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:GoodsTypeView}}"
                      Command="{Binding AddCommand}"/>
            </StackPanel>
        </Grid>

        <!--浏览-->
        <Grid Grid.Row="2" Margin="10 0 10 10">
            <DataGrid ItemsSource="{Binding StoreList}" CanUserAddRows="False" AutoGenerateColumns="False">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="序号" Binding="{Binding Id}"/>
                    <DataGridTextColumn Header="物资类型" Binding="{Binding Name}"/>
                    <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:StoreView},Path=DataContext.EditCommand}"
                                          CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}" 
                                          Tag="{Binding}" 
                                          Style="{StaticResource DataGridButtonStyle}" />
                                    <Button Content="删除" 
                                          Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:StoreView},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.Service;
using CommonServiceLocator;
using West.StoreMgr.Windows;
using static West.StoreMgr.Windows.MsgBoxWindow;

namespace West.StoreMgr.ViewModel
{
    /// <summary>
    /// 仓库设置viewmodel
    /// </summary>
    public class StoreViewModel : ViewModelBase
    {
        public StoreViewModel()
        {
            StoreList = new StoreService().Select();
        }
        private Store store = new Store();
        public Store Store
        {
            get { return store; }
            set { store = value; RaisePropertyChanged(); }
        }

        private List<Store> storeList = new List<Store>();

        public List<Store> StoreList
        {
            get { return storeList; }
            set { storeList = value; RaisePropertyChanged(); }
        }

        //增加
        public RelayCommand<UserControl> AddCommand
        {
            get
            {
                var command = new RelayCommand<UserControl>((view) =>
                {
                    if (string.IsNullOrEmpty(Store.Name) == true)
                    { 
                        MsgWinHelper.ShowError("不能为空!");
                        return;
                    }

                    Store.InsertDate = DateTime.Now;

                    var service = new StoreService();
                    int count = service.Insert(Store);
                    if (count > 0)
                    {
                        StoreList = service.Select(); 
                        MsgWinHelper.ShowMessage("添加成功!");
                        Store = new Store();
                    }
                    else
                    {
                        MsgWinHelper.ShowError("添加失败!");
                    }
                });

                return command;
            }
        }

        //修改
        public RelayCommand<Button> EditCommand
        {
            get
            {
                var command = new RelayCommand<Button>((view) =>
                {
                    var old = view.Tag as Store;
                    if (old == null) return;
                    var model = ServiceLocator.Current.GetInstance<EditStoreViewModel>();
                    model.Store = old;
                    var window = new EditStoreWindow();
                    window.ShowDialog();
                    StoreList = new StoreService().Select();
                });

                return command;
            }
        }

        //删除
        public RelayCommand<Button> DeleteCommand
        {
            get
            {
                var command = new RelayCommand<Button>((view) =>
                {
                    if (MsgWinHelper.ShowQuestion("您确定要删除该仓库吗?") == CustomMessageBoxResult.OK)
                    {
                        var old = view.Tag as Store;
                        if (old == null) return;

                        var service = new StoreService();
                        int count = service.Delete(old);
                        if (count > 0)
                        {
                            StoreList = service.Select();
                            MsgWinHelper.ShowMessage("操作成功!");
                        }
                        else
                        {
                            MsgWinHelper.ShowError("操作失败!");
                        }
                    }
                });

                return command;
            }
        }
    }
}

3、修改仓库窗体

<Window x:Class="West.StoreMgr.Windows.EditStoreWindow"
        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"
         DataContext="{Binding Source={StaticResource Locator},Path=EditStore}"
        Title="EditStoreWindow" Height="450" Width="800">
    <Grid  Background="#E4ECEF">
        <!--Edit-->
        <Grid Grid.Row="0" 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="Horizontal" VerticalAlignment="Center">
                <TextBlock Margin="0 0 10 0" Text="仓库名称:" VerticalAlignment="Center"/>
                <TextBox Margin="0 0 10 0" Text="{Binding Store.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 Store.Tag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="200" Height="30" />
                <!--button-->
                <Button Margin="18 0 0 0" Height="36" Width="199" Grid.Row="3" 
                    Content="修改" Style="{StaticResource ButtonStyle}" 
                    CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:EditStoreWindow}}"
                    Command="{Binding EditCommand}"/>
            </StackPanel>
        </Grid>
    </Grid>
</Window>

 4、运行效果

 

 

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

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

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

相关文章

算法金 | 没有思考过 Embedding,不足以谈 AI

大侠幸会&#xff0c;在下全网同名「算法金」 0 基础转 AI 上岸&#xff0c;多个算法赛 Top 「日更万日&#xff0c;让更多人享受智能乐趣」 抱个拳&#xff0c;送个礼 在当今的人工智能&#xff08;AI&#xff09;领域&#xff0c;Embedding 是一个不可或缺的概念。如果你没有…

背靠广汽、小马智行,如祺出行打得过滴滴和百度吗?

©自象限原创 作者丨艾AA 编辑丨薛黎 北京时间6月14日凌晨&#xff0c;在特斯拉股东大会上&#xff0c;马斯克阐述了对Robotaxi&#xff08;自动驾驶出租车&#xff09;商业模式的构想——特斯拉不仅会运营自己的无人驾驶出租车车队&#xff0c;还可以让特斯拉车主们的爱…

面试突击:Java 集合知识体系梳理

本文已收录于&#xff1a;https://github.com/danmuking/all-in-one&#xff08;持续更新&#xff09; 前言 哈喽&#xff0c;大家好&#xff0c;我是 DanMu。在 Java 开发中&#xff0c;集合类对象绝对是被使用最频繁的对象之一。因此&#xff0c;深入了解集合类对象的底层数…

Python操作MySQL数据库--使用pymysql模块

Python操作MySQL数据库--使用pymysql模块 一、新建数据库和数据表1.1 新建book数据库1.2 新建bookprice数据表二、连接数据库2.1 建立数据库连接三、新增数据3.1 新增单条数据3.2 新增多条数据3.3 批量新增四、修改数据4.1 修改单条数据4.2 修改多条数据五、删除数据5.1 删除单…

Linux系统相关函数总结

在应用程序当中&#xff0c;有时往往需要去获取到一些系统相关的信息&#xff0c;譬如时间、日期、以及其它一些系统相关信息&#xff0c;本章将向大家介绍如何通过 Linux 系统调用或 C 库函数获取这些系统信息。除此之外&#xff0c;还会向大家介绍 Linux 系统下的/proc 虚拟文…

springboot 缓存框架Cache整合redis组成二级缓存

springboot 缓存框架Cache整合redis组成二级缓存 项目性能优化的解决方案除开硬件外的方案无非就是优化sql&#xff0c;减少sql 的执行时间&#xff0c;合理运用缓存让同样的请求和数据库之间的连接尽量减少&#xff0c;内存的处理速度肯定比直接查询数据库来的要快一些。今天就…

代码随想录——跳跃游戏Ⅱ(Leetcode 45)

题目链接 贪心 class Solution {public int jump(int[] nums) {if(nums.length 1){return 0;}int count 0;// 当前覆盖最远距离下标int curDistance 0;// 下一步覆盖距离最远下标int nextDistance 0;for(int i 0; i < nums.length; i){nextDistance Math.max(nums[…

搭建 MySQL MHA

搭建 MySQL MHA 搭建 MySQL MHA实验拓扑图实验环境实验思路MHA架构故障模拟 实验部署数据库安装主从复制部署时间同步主服务器配置从服务器配置创建链接 MHA搭建安装依赖的环境安装 node 组件安装 manager 组件配置无密码认证在 manager 节点上配置 MHA管理 mysql 节点服务器创…

【Git】远程仓库

一、常用的托管服务[远程仓库] 二、注册码云 三、创建远程仓库 四、配置SSH公钥 五、操作远程仓库 5.1、添加远程仓库 5.2、查看远程仓库 5.3、推送到远程仓库 5.4、 本地分支与远程分支的关联关系 5.5、从远程仓库克隆 5.6、从远程仓库中抓取和拉取 5.7、解决合并冲突 一、常…

Python 算法交易实验73 QTV200第二步: 数据清洗并写入ClickHouse

说明 先检查一下昨天启动的worker是否正常工作&#xff0c;然后做一些简单的清洗&#xff0c;存入clickhouse。 内容 1 检查数据 from Basefuncs import * # 将一般字符串转为UCS 名称 def dt_str2ucs_blockname(some_dt_str):some_dt_str1 some_dt_str.replace(-,.).re…

简单粗暴-安装detectron2

文章目录 一、下载detectron2二、修改文件三、安装detectron2参考文献&#xff1a; 其他配置版本&#xff1a; torch1.12.1CUDA&#xff1a;11.6python&#xff1a;3.9 建议以上配置&#xff0c;其他配置未测试&#xff0c;如果CUDA版本不匹配的话&#xff0c;可以多配置不同版…

达梦数据库的系统视图v$locked_object

达梦数据库的系统视图v$locked_object 在达梦数据库&#xff08;Dameng Database&#xff09;中&#xff0c;V$LOCKED_OBJECT 视图提供了与数据库中被锁定对象相关的信息。这通常用于监控和诊断数据库中的锁定问题&#xff0c;帮助管理员了解哪些对象被锁定了&#xff0c;以及…

PyCharm2024 for mac Python编辑开发

Mac分享吧 文章目录 效果一、下载软件二、开始安装1、双击运行软件&#xff08;适合自己的M芯片版或Intel芯片版&#xff09;&#xff0c;将其从左侧拖入右侧文件夹中&#xff0c;等待安装完毕2、应用程序显示软件图标&#xff0c;表示安装成功3、打开访达&#xff0c;点击【文…

自动建立用户练习

一丶编辑文本存放用户名 vim userlist 二丶编辑文本存放需要创建用户的密码 vim passlist 三丶编辑脚本 vim create_user.sh #!bin/bash [ "$#" -lt "2" ] && { #echo error please input userlist anpassli…

postgre事务id用完后,如何解决这个问题

在PG中事务年龄不能超过2^31 &#xff08;2的31次方2,147,483,648&#xff09;&#xff0c;如果超过了&#xff0c;这条数据就会丢失。 PG中不允许这种情况出现&#xff0c;当事务的年龄离2^31还有1千万的时候&#xff0c;数据库的日志中就会 有如下告警&#xff1a; warning:…

【第一周】认识小程序

目录 认识小程序发展历史发展前景发展优势个人企业/创业 账号申请开发工具下载流程使用说明 协作项目交流收益渠道 认识小程序 发展历史 微信小程序自2016年首次提出以来&#xff0c;经历了快速的发展和完善过程&#xff0c;以下是其主要发展历史节点&#xff1a; 2016年1月…

监控员工电脑的软件有哪些?6款企业必备的电脑监控软件

监控员工电脑的软件在企业管理和网络安全领域扮演着重要角色&#xff0c;它们可以帮助企业提高工作效率&#xff0c;确保数据安全&#xff0c;以及合规性。以下是六款知名的员工电脑监控软件&#xff1a; 1.安企神 - 一个全面的企业级电脑监控和管理解决方案。 2.Work Examine…

从单点到全景:视频汇聚/安防监控EasyCVR全景视频监控技术的演进之路

在当今日新月异的科技浪潮中&#xff0c;安防监控领域的技术发展日新月异&#xff0c;全景摄像机便是这一领域的杰出代表。它以其独特的360度无死角监控能力&#xff0c;为各行各业提供了前所未有的安全保障&#xff0c;成为现代安防体系中的重要组成部分。 一、全景摄像机的技…

个人支付系统实现

基础首页&#xff1a; 订单&#xff1a; 智能售卡系统 基于webmanworkerman开发 禁用函数检查 使用这个脚本检查是否有禁用函数。命令行运行curl -Ss https://www.workerman.net/check | php 如果有提示Function 函数名 may be disabled. Please check disable_functions in …

仓库管理系统13--物资设置

1、添加窗体 2、设计UI界面 注意这个下拉框的绑定&#xff0c;你看到的选项是由displaymember决定&#xff0c;当你选择了哪个选项时&#xff0c;后台绑定这个选项的ID <UserControl x:Class"West.StoreMgr.View.GoodsView"xmlns"http://schemas.microsoft…