仓库管理系统17--客户管理

news2024/10/7 20:35:20

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

 

1、添加用户控件 

<UserControl x:Class="West.StoreMgr.View.CustomerView"
             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=Customer}"
             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="10">
            <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">
                <StackPanel  Orientation="Horizontal" VerticalAlignment="Center">
                    <TextBlock Margin="0 0 10 0" Text="客户名称:" VerticalAlignment="Center"/>
                    <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding Customer.Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="230" Height="30" />
                    <TextBlock Margin="0 0 10 0" Text="备注:" VerticalAlignment="Center"/>
                    <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding Customer.Tag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="400" Height="30" />
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0 10 0 10">
                    <TextBlock Margin="0 0 10 0" Text="电话号码:" VerticalAlignment="Center"/>
                    <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding Customer.Telephone,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="120" Height="30" />
                    <TextBlock Margin="0 0 10 0" Text="邮箱:" VerticalAlignment="Center"/>
                    <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding Customer.Email,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="150" Height="30" />
                    <TextBlock Margin="0 0 10 0" Text="地址:" VerticalAlignment="Center"/>
                    <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding Customer.Address,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="315" Height="30" />
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="200 10 0 10"  >
                    <Button Margin="18 0 0 0" Height="36" Width="199" FontSize="20" 
                    Content="增 加" Style="{StaticResource ButtonStyle}" 
                    CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:GoodsTypeView}}"
                    Command="{Binding AddCommand}"/>
                </StackPanel>
            </StackPanel> 
        </Grid>

        <!--浏览-->
        <Grid Grid.Row="2" Margin="10 0 10 10">
            <DataGrid ItemsSource="{Binding CustomerList}" CanUserAddRows="False" AutoGenerateColumns="False">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="序号" Binding="{Binding Id}"/>
                    <DataGridTextColumn Header="名字" Binding="{Binding Name}"/>
                    <DataGridTextColumn Header="电话" Binding="{Binding Telephone}"/>
                    <DataGridTextColumn Header="邮箱" Binding="{Binding Email}"/>
                    <DataGridTextColumn Header="地址" Binding="{Binding Address}"/>
                    <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:CustomerView},Path=DataContext.EditCommand}"
                                            CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}" 
                                            Tag="{Binding}" 
                                            Style="{StaticResource DataGridButtonStyle}" />
                                    <Button Content="删除" 
                                            Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:CustomerView},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.Service;
using CommonServiceLocator;
using West.StoreMgr.Helper;
using static West.StoreMgr.Windows.MsgBoxWindow;
using West.StoreMgr.Windows;

namespace West.StoreMgr.ViewModel
{
    /// <summary>
    /// 客户管理viewmodel
    /// </summary>
    public class CustomerViewModel : ViewModelBase
    {
        public CustomerViewModel()
        {
            CustomerList = new CustomerService().Select();
        }
        private Customer customer = new Customer();
        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(); }
        }

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

                    Customer.InsertDate = DateTime.Now;

                    CustomerService service = new CustomerService();
                    int count = service.Insert(Customer);
                    if (count > 0)
                    {
                        CustomerList = service.Select();
                        MsgWinHelper.ShowMessage("操作成功");
                        Customer = new Customer();
                    }
                    else
                    {
                        MsgWinHelper.ShowError("操作失败");
                    }
                });

                return command;
            }
        }

        //修改
        public RelayCommand<Button> EditCommand
        {
            get
            {
                var command = new RelayCommand<Button>((view) =>
                {
                    var old = view.Tag as Customer;
                    if (old == null) return;
                    var model = ServiceLocator.Current.GetInstance<EditCustomerViewModel>();
                    model.Customer = old;
                    var window = new EditCustomerWindow();
                    window.ShowDialog();
                    CustomerList = new CustomerService().Select();
                });

                return command;
            }
        }

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

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

                return command;
            }
        }
    }
}

3、修改客户窗体

<Window x:Class="West.StoreMgr.Windows.EditCustomerWindow"
        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=EditCustomer}"
        Title="修改客户窗体" Height="320" Width="700">
    <Grid Background="#E4ECEF">

        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition Height="100"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Border Background="#72BBE5" Grid.Row="0"  Margin="0">
            <TextBlock Text="修改客户数据" FontSize="18" VerticalAlignment="Center" Foreground="#1F3C4C" Margin="0 0 10 0"/>
        </Border>
        <StackPanel Grid.Row="1" Margin="0 10 0 0">
            <StackPanel  Orientation="Horizontal" VerticalAlignment="Center">
                <TextBlock Margin="0 0 10 0" Text="客户名称:" VerticalAlignment="Center"/>
                <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding Customer.Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="220" Height="30" />
                <TextBlock Margin="0 0 10 0" Text="备注:" VerticalAlignment="Center"/>
                <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding Customer.Tag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="354" Height="30" />
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="0 10 0 10">
                <TextBlock Margin="0 0 10 0" Text="电话号码:" VerticalAlignment="Center"/>
                <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding Customer.Telephone,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="130" Height="30" />
                <TextBlock Margin="0 0 10 0" Text="邮箱:" VerticalAlignment="Center"/>
                <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding Customer.Email,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="160" Height="30" />
                <TextBlock Margin="0 0 10 0" Text="地址:" VerticalAlignment="Center"/>
                <TextBox  HorizontalAlignment="Left" VerticalAlignment="Center" TextAlignment="Left" VerticalContentAlignment="Center" Margin="0 0 10 0" Text="{Binding Customer.Address,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="240" Height="30" />
            </StackPanel>
        </StackPanel>
        <StackPanel Grid.Row="2" Margin="0 10 0 0">
            <Button Margin="18 -10 0 0" Height="36" Width="199"  FontSize="20"
            Content="修 改" Style="{StaticResource ButtonStyle}" 
            CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:EditCustomerWindow}}"
            Command="{Binding EditCommand}"/>
        </StackPanel>
    </Grid>
</Window>

4、运行效果

 

 

 

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

 

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

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

相关文章

信息安全前沿技术有哪些?

目前信息安全领域&#xff08;不限于技术层面&#xff09;有哪些前沿的研究方向&#xff0c;代表人物有哪些&#xff1f;有哪些新的研究成果&#xff1f;以及从哪些地方可以获得这些咨询&#xff1f; 我在做 system 方向的安全研究&#xff0c;最近发现其实中美两国都在 TEE (…

洞察数据资产的奥秘:深入剖析数据资产在企业运营中的核心作用,提出一套全面、系统的数据资产解决方案,帮助企业实现数据资产的最大化利用和增值

一、引言 在数字化浪潮汹涌的今天&#xff0c;数据已成为企业最宝贵的资产之一。数据资产不仅记录了企业的历史运营轨迹&#xff0c;更蕴含着指导未来决策的智慧。然而&#xff0c;如何有效管理、利用这些数据资产&#xff0c;使其转化为企业的竞争优势和利润增长点&#xff0…

【ArcGIS 脚本工具】拯救密恐,隐藏唯一值渲染图层的标记符号

最近拿到了【Hello 图狗】制作的三调/变更样式符号库&#xff0c;确实比之前网上下载的版本好用很多。 ArcGIS Pro三调23变更符号库V1.02&#xff08;汇总&#xff09;_中大比例尺.stylx和样式属性对调 不过使用过程中触发了一个旧病&#xff0c;就是匹配样式之后&#xff0c;…

网络配置(IP、NETMASK、GATEWAY、DNS、DHCP) <持续更新中>

参考&#xff1a; 初学Linux之网络配置(IP、NETMASK、GATEWAY、DNS、DHCP)-CSDN博客【学习笔记】网关 & 路由_网关和路由-CSDN博客【学习笔记】计算机网络 IP地址与MAC地址_根据mac分配ip-CSDN博客【学习笔记】TCP 和 UDP 协议_tcp 发送 syn 应答没有syn ack-CSDN博客 一…

若依 ruoyi 分离版 vue 简单的行内编辑实现

需要实现的效果&#xff1a;双击文本 - 修改文本 - 保存修改。 原码&#xff1a;仅文本显示文字内容 <el-table-column label"商品" align"center" prop"goodsName" width"200" v-if"columns[1].visible" /> 实现…

小程序web-view无法打开该页面的解决方法

问题&#xff1a;开发者工具可以正常打开&#xff0c;正式上线版小程序使用 web-view 组件测试时提示&#xff1a;“无法打开该页面&#xff0c;不支持打开 https://xxxxxx&#xff0c;请在“小程序右上角更多->反馈与投诉”中和开发者反馈。” 解决方法&#xff1a;需要配…

Altium Designer的元件库 PCB库 3D库神器

元件库 PCB库 3D库神器 对于硬件工程师来说贸泽是一个器件选型相当方便的电子商城,虽然购买元器件比立创商城要慢和贵,但是,上面的物料种类、选型的便捷性要远远好于立创商城;而且,它上面的大多数元件都有自己的元件封装、PCB封装、3D模型,这就对实际的开发节省了好多绘…

Java | Leetcode Java题解之第191题位1的个数

题目&#xff1a; 题解&#xff1a; public class Solution {public int hammingWeight(int n) {int ret 0;while (n ! 0) {n & n - 1;ret;}return ret;} }

52、基于K 均值聚类实现基于颜色的分割(matlab)

1、K 均值聚类实现基于颜色的分割原理及流程 K 均值聚类是一种常用的聚类算法&#xff0c;通过将数据点分配到 K 个簇中&#xff0c;每个簇的中心代表簇的平均值来实现聚类的目的。 基于颜色的分割的原理是利用像素的颜色信息来对图像进行分割。首先需要将图像的每个像素点表…

如何用CSS样式实现一个优雅的渐变效果?

CSS渐变效果 CSS渐变&#xff08;Gradients&#xff09;是一种让两种或多种颜色平滑过渡的视觉效果&#xff0c;广泛应用于网页背景、按钮、边框等&#xff0c;以创造丰富的视觉体验。CSS提供了线性渐变&#xff08;Linear Gradients&#xff09;和径向渐变&#xff08;Radial…

性能之巅的巴比达内网穿透访问单位的web管理系统

在这个数字化飞速发展的时代&#xff0c;作为一名IT部门的小主管&#xff0c;我经常面临着一项挑战&#xff1a;如何在外网环境下高效、安全地访问我们单位内部部署的Web管理系统。这不仅仅是关乎我个人的工作效率&#xff0c;更是影响到整个团队能否快速响应市场需求的关键。直…

GPT-4o首次引入!全新图像自动评估基准发布!

目录 01 什么是DreamBench&#xff1f; 02 与人类对齐的自动化评估 03 更全面的个性化数据集 04 实验结果 面对层出不穷的个性化图像生成技术&#xff0c;一个新问题摆在眼前&#xff1a;缺乏统一标准来衡量这些生成的图片是否符合人们的喜好。 对此&#xff0c;来自清华大…

高级运维工程师讲述银河麒麟V10SP1服务器加固收回权限/tmp命令引起生产mysql数据库事故实战

高级运维工程师讲述银河麒麟V10SP1服务器加固收回权限/tmp命令引起生产MySql数据库事故实战 一、前言 作为运维工程师经常会对生产服务器进行安全漏洞加固&#xff0c;一般服务厂商、或者甲方信息安全中心提供一些安全的shell脚本&#xff0c;一般这种shell脚本都是收回权限&…

Websocket在Java中的实践——自动注册端点

大纲 依赖自动注册端点端点测试 在 《Websocket在Java中的实践——握手拦截器》中我们使用握手拦截器实现了路径解析的工作。这个过程略显复杂&#xff0c;因为路径解析这样比较底层的工作应该由框架来解决&#xff0c;而不应该交由开发者来做。本文介绍的自动注册端点的功能就…

开箱即用的fastposter海报生成器

什么是 fastposter ? fastposter 海报生成器是一款快速开发海报的工具。只需上传一张背景图&#xff0c;在对应的位置放上组件&#xff08;文字、图片、二维码、头像&#xff09;即可生成海报。 点击代码直接生成各种语言 SDK 的调用代码&#xff0c;方便快速开发。 软件特性&…

2024高考录取分数线一览表(含一本线、二本线、专科线)

2024年全国各地的高考录取分数线已经全部公布&#xff0c;查大学网&#xff08;www.chadaxue.com&#xff09;为大家整理全国31个省市高考录取分数线汇总&#xff0c;包括本科批&#xff08;一本分数线线和二本分数线&#xff09;、专科批和特殊类招生控制分数线汇总&#xff0…

ArcGIS中将测绘数据投影坐标(平面坐标)转地理坐标(球面经纬度坐标)

目录 前言1.测绘数据预览1.1 确定带号1.2 为什么是对Y轴分带&#xff0c;而不是对X轴分带&#xff1f; 2 测绘数据转shp2.1 添加数据2.2 显示XY数据2.3 添加经纬度字段2.4 计算经纬度 3.shp数据重投影4.总结 前言 最近在刚好在做一个小功能&#xff0c;将测绘数据转为经纬度坐标…

2024年值得信赖的在线代理IP服务商

在当今的网络世界中&#xff0c;代理IP服务成为了许多企业和个人在进行网络数据处理、多账号管理等任务时不可或缺的工具。然而&#xff0c;面对市场上众多的代理IP服务商&#xff0c;如何挑选出真正值得信赖的服务商成为了一大难题。作为专业的测评团队&#xff0c;我们近期对…

cuda编码入门学习笔记

在日常深度学习和科学计算中,使用图形处理器(GPU)进行加速是一个常见的做法。CUDA (Compute Unified Device Architecture) 是英伟达公司提供的用于GPU编程的平台和编程模型。同时它是一种并行计算模型,允许开发人员使用标准C语言对GPU进行编程。CUDA的核心思想是将任务分解为…

React+TS前台项目实战(二十一)-- Search业务组件封装实现全局搜索

文章目录 前言一、Search组件封装1. 效果展示2. 功能分析3. 代码详细注释4. 使用方式 二、搜索结果展示组件封装1. 功能分析2. 代码详细注释 三、引用到文件&#xff0c;自行取用总结 前言 今天&#xff0c;我们来封装一个业务灵巧的组件&#xff0c;它集成了全局搜索和展示搜…