倉庫管理系統16--入庫管理

原創不易,打字不易,截圖不易,多多點贊,送人玫瑰,留有余香,財務自由明日實現。??

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.pswp.cn/diannao/37011.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/37011.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/37011.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

CAS自旋解析

CAS全稱CompareAndSwap(比較并交換)&#xff0c;是cpu的指令&#xff0c;調用時不涉及上下文的切換。Java中屬于樂觀鎖的一種&#xff0c;具體流程如下圖&#xff1a; 具體的實現使用的是Unsafe類去調用native修飾的compareAndSwap方法&#xff0c;4個字段分別是對象實例&#…

PTA—C語言期末復習(判斷題)

1. C語言程序是從源文件的第一條語句開始執行的 &#xff08;F&#xff09; 在 C 語言中&#xff0c;程序是從 main 函數開始執行的&#xff0c;而不是從源文件的第一條語句開始執行 2. 若變量定義為double x;&#xff0c;則x % 2是符合C語言語法的表達式 &#xff08;F&#…

通過nginx去除 api url前綴 并保持后面剩余的url不變向后臺請求

如 我前臺瀏覽器向后臺請求的接口是 http://127.0.0.1:5099/api/sample/sample/getbuttonlist 實際的請求接口傳向 http://192.168.3.71:5099/sample/sample/getbuttonlist 方法是向config中加入下面這樣一個server server {listen 5099;location /api/ {rewrite ^/a…

HTML流星雨

目錄 寫在前面 完整代碼 代碼分析 系列文章 寫在最后 寫在前面 歲月如梭&#xff0c;光陰似箭&#xff0c;不知不覺暑假就要來嘍&#xff0c;本期小編用HTML給大家手搓了一個炫酷的流星雨動畫&#xff0c;一起來看看吧。 完整代碼 <!DOCTYPE html> <html lang…

項目風險管理系統有哪些?分享11款主流項目管理系統

本文將分享11款主流項目管理系統&#xff1a;PingCode、Worktile、StandardFusion、MasterControl、ClickUp、SAI360、Netwrix Auditor、MetricStream、Wrike、Celoxis、Zoho Projects。 在項目管理中&#xff0c;風險管理不僅是一個挑戰&#xff0c;也是保證項目順利進行的關鍵…

探索Vim的文本處理能力:精通查找與替換

探索Vim的文本處理能力&#xff1a;精通查找與替換 Vim&#xff0c;作為Linux終端下的王牌文本編輯器&#xff0c;以其強大的功能和靈活性深受開發者和系統管理員的喜愛。在Vim中進行查找和替換是文本編輯中的一項基礎且重要的操作。本文將詳細解釋如何在Vim中執行查找和替換文…

Linux Redis 服務設置開機自啟動

文章目錄 前言一、準備工作二、操作步驟2.1 修改redis.conf文件2.2 創建啟動腳本2.3 設置redis 腳本權限2.4 設置開機啟動2.5 驗證 總結 前言 請各大網友尊重本人原創知識分享&#xff0c;謹記本人博客&#xff1a;南國以南i、 提示&#xff1a;以下是本篇文章正文內容&#x…

編程的難點在哪?是邏輯、算法,還是模塊、框架的掌握?

&#x1f446;點擊關注 回復『新人禮』獲取學習禮包&#x1f446; 很多新手程序員在一開始都是滿懷熱情地投入到編程的學習&#xff0c;但卻在學習過程中處處碰壁&#xff0c;導致放棄。 編程的難點在于邏輯、數學、算法&#xff0c;還是模塊、框架、接口的掌握&#xff1f;但…

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

Android InputDispatcher分發輸入事件

派發循環是指 InputDispatcher 不斷地派發隊列取出事件&#xff0c;尋找合適的窗口并進行發送的過程&#xff0c;是 InputDispatcher 線程的主要工作 事件發送循環是 InputDispatcher 通過 Connection 對象將事件發送給窗口&#xff0c;并接受其反饋的過程 InputDispatcher —…

Spring Boot跨域請求關鍵處理技術解析

Spring Boot跨域請求關鍵處理技術解析 在Web開發中&#xff0c;跨域請求是一個常見問題&#xff0c;尤其在微服務架構和前后端分離的開發模式中更為突出。Spring Boot作為一種流行的Java Web框架&#xff0c;提供了多種解決跨域請求的方法。本文將詳細解析Spring Boot中跨域請…

在 Qt 中設置 QMainWindow 的大小

問題描述 一位 Qt 新手提問&#xff0c;是否有辦法將 QMainWindow 的大小設置為用戶桌面大小的 70%。他嘗試過使用伸縮因子&#xff0c;但未成功。QWidget::setFixedSize 可以工作&#xff0c;但只能使用像素值。 解決方案 方案一&#xff1a;使用 QDesktopWidget 在 QMain…

大模型賦能全鏈路可觀測性:運維效能的革新之旅

目錄 全鏈路可觀測工程與大模型結合---提升運維效能 可觀測性&#xff08;Observability&#xff09;在IT系統中的應用及其重要性 統一建設可觀測數據 統一建設可觀測數據的策略與流程 全鏈路的構成和監控形態 云上的全鏈路可視方案 為什么一定是Copilot 大模型的Copilo…

mov和mp4區別是什么?蘋果的原創和時代的寵兒

在數字媒體領域&#xff0c;視頻格式的選擇往往決定了觀看體驗的質量和文件的兼容性。在眾多視頻格式中&#xff0c;MOV和MP4無疑是最具代表性的兩種&#xff0c;它們分別承載著蘋果和互聯網世界的技術革新與歷史變遷。本文將帶您穿越時間的長廊&#xff0c;探索MOV與MP4的發展…

A : 平面劃分

Description 一條直線可以把平面分成兩部分&#xff0c;兩條直線分成四部分。那么 n 條直線最多可以把平面分成幾部分&#xff1f; Input 多組數據&#xff0c;每組數據一個正整數 1≤&#xfffd;≤1000。 Output Sample #0 Input Copy 3 5 Output Copy 7 16 Hin…

區間DP——AcWing 320. 能量項鏈

區間DP 定義 區間動態規劃&#xff08;Interval Dynamic Programming&#xff09;&#xff0c;簡稱區間DP&#xff0c;是動態規劃領域的一個重要分支&#xff0c;專門用于解決涉及區間問題的最優化問題。這類問題通常需要在給定的一組區間上找到最優解&#xff0c;比如求解最…

福蘭農莊攜手越南NFC巨頭朱雀橋薇妮她百香果飲料,深化品質合作

近日&#xff0c;國內知名果汁品牌福蘭農莊成功與越南NFC行業領軍者朱雀橋建立深入合作關系。為了進一步提升產品品質和市場競爭力&#xff0c;福蘭農莊派遣專業團隊前往越南&#xff0c;深入VINUT百香果飲料的生產線&#xff0c;學習其從原料采購到產品上市的嚴格操作流程。 在…

IAR 常見報錯與實用小技巧(ZigBee)

一、報錯 1.未發現選擇目標 原因&#xff1a;硬件連接存在問題 解決方案&#xff1a;將數據線重新插拔或更換接口、數據線 2. 燒錄終止 原因&#xff1a;燒錄前未點擊仿真器復位按鈕 解決方案&#xff1a; 進行燒錄前點擊仿真器復位按鈕&#xff08;下載過程中不能按&#xff…

數據結構與算法 - 圖

博客主頁&#xff1a;誓則盟約系列專欄&#xff1a;IT競賽 專欄關注博主&#xff0c;后期持續更新系列文章如果有錯誤感謝請大家批評指出&#xff0c;及時修改感謝大家點贊&#x1f44d;收藏?評論? 圖的定義和基本概念&#xff1a; 圖&#xff08;Graph&#xff09;是一種由…

java+mysql圖書管理系統

完整代碼地址 1.運行效果圖 2.主要代碼 2.1.連接數據庫 package com.my.homework.utils;import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;public class JDBCUtils {public static Connection getConnection() throws Exception {…