做游戏出租的网站好,店面设计ppt,做服装设计有什么网站可以参考,浙江企业网站建设1、添加窗体 2、设计UI界面 注意这个下拉框的绑定#xff0c;你看到的选项是由displaymember决定#xff0c;当你选择了哪个选项时#xff0c;后台绑定这个选项的ID
UserControl x:ClassWest.StoreMgr.View.GoodsViewxmlnshttp://schemas.microsoft…1、添加窗体 2、设计UI界面 注意这个下拉框的绑定你看到的选项是由displaymember决定当你选择了哪个选项时后台绑定这个选项的ID
UserControl x:ClassWest.StoreMgr.View.GoodsViewxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:dhttp://schemas.microsoft.com/expression/blend/2008 xmlns:localclr-namespace:West.StoreMgr.View xmlns:ihttp://schemas.microsoft.com/expression/2010/interactivitymc:Ignorabled DataContext{Binding Source{StaticResource Locator},PathGoods}!--加载页面时获取物资列表数据--i:Interaction.Triggersi:EventTrigger EventNameLoadedi:InvokeCommandAction Command{Binding LoadCommand}//i:EventTrigger/i:Interaction.TriggersGridGrid.RowDefinitionsRowDefinition Height50/RowDefinition/RowDefinition//Grid.RowDefinitions!--标题--StackPanel Background#EDF0F6 OrientationHorizontalTextBlock Margin10 0 0 0 Text#xf015; FontSize20 FontFamily/Fonts/#FontAwesome HorizontalAlignmentLeft VerticalAlignmentCenter Foreground#797672/TextBlock Margin10 0 0 0 Text首页 物资管理 FontSize20 FontFamily/Fonts/#FontAwesome HorizontalAlignmentLeft VerticalAlignmentCenter Foreground#797672//StackPanel!--增加--Grid Grid.Row1 Margin20Grid.RowDefinitionsRowDefinition Height30/RowDefinition//Grid.RowDefinitionsBorder Background#72BBE5TextBlock Text添加物资 FontSize18 VerticalAlignmentCenter Foreground#1F3C4C Margin0 0 10 0//BorderStackPanel Grid.Row1 OrientationVertical VerticalAlignmentCenter Margin0 10 0 10StackPanel OrientationHorizontal VerticalAlignmentCenterTextBlock Margin0 0 10 0 Text物资类别: VerticalAlignmentCenter Width80/!--下拉框绑定后台类别列表--ComboBox x:NamecomboboxGoodsType Margin0 0 10 0 ItemsSource{Binding GoodsTypeList} DisplayMemberPathName SelectedValuePathId Width150 Height30 /TextBlock Margin0 0 10 0 Text规格型号: VerticalAlignmentCenter Width80/!--下拉框绑定后台规格列表--ComboBox x:NamecomboboxSpec Margin0 0 10 0 ItemsSource{Binding SpecList} DisplayMemberPathName SelectedValuePathId Width150 Height30 //StackPanelStackPanel OrientationHorizontal VerticalAlignmentCenter Margin0 10 0 10TextBlock Margin0 0 10 0 Text 序号: VerticalAlignmentCenter Width80/TextBox HorizontalAlignmentLeft VerticalAlignmentCenter TextAlignmentLeft VerticalContentAlignmentCenter Margin0 0 10 0 Text{Binding Goods.Serial,ModeTwoWay,UpdateSourceTriggerPropertyChanged} Width150 Height30 /TextBlock Margin0 0 10 0 Text物资名称: VerticalAlignmentCenter Width80/TextBox HorizontalAlignmentLeft VerticalAlignmentCenter TextAlignmentLeft VerticalContentAlignmentCenter Margin0 0 10 0 Text{Binding Goods.Name,ModeTwoWay,UpdateSourceTriggerPropertyChanged} Width150 Height30 /TextBlock Margin0 0 10 0 Text单位: VerticalAlignmentCenter Width80/TextBox HorizontalAlignmentLeft VerticalAlignmentCenter TextAlignmentLeft VerticalContentAlignmentCenter Margin0 0 10 0 Text{Binding Goods.Unit,ModeTwoWay,UpdateSourceTriggerPropertyChanged} Width150 Height30 //StackPanelStackPanel OrientationHorizontal VerticalAlignmentCenter Margin0 10 0 10TextBlock Margin0 0 10 0 Text库存最小值: VerticalAlignmentCenter Width80/TextBox HorizontalAlignmentLeft VerticalAlignmentCenter TextAlignmentLeft VerticalContentAlignmentCenter Margin0 0 10 0 Text{Binding Goods.Min,ModeTwoWay,UpdateSourceTriggerPropertyChanged} Width150 Height30 /TextBlock Margin0 0 10 0 Text库存最大值: VerticalAlignmentCenter Width80/TextBox HorizontalAlignmentLeft VerticalAlignmentCenter TextAlignmentLeft VerticalContentAlignmentCenter Margin0 0 10 0 Text{Binding Goods.Max,ModeTwoWay,UpdateSourceTriggerPropertyChanged} Width150 Height30 /TextBlock Margin0 0 10 0 Text备注: VerticalAlignmentCenter Width80/TextBox HorizontalAlignmentLeft VerticalAlignmentCenter TextAlignmentLeft VerticalContentAlignmentCenter Margin0 0 10 0 Text{Binding Goods.Tag,ModeTwoWay,UpdateSourceTriggerPropertyChanged} Width150 Height30 //StackPanelStackPanel OrientationHorizontal VerticalAlignmentCenter Margin0 10 0 10 Button Margin542 0 0 0 Height36 Width199 Grid.Row3 Content增加 Style{StaticResource ButtonStyle} CommandParameter{Binding RelativeSource{RelativeSource ModeFindAncestor,AncestorTypelocal:GoodsView}}Command{Binding AddCommand}//StackPanel/StackPanel /Grid!--浏览--Grid Grid.Row2 Margin10 0 10 10DataGrid ItemsSource{Binding GoodsList} CanUserDeleteRowsFalse CanUserAddRowsFalse AutoGenerateColumnsFalseDataGrid.ColumnsDataGridTextColumn Header序号 Binding{Binding Serial}/DataGridTextColumn Header名称 Binding{Binding Name}/DataGridTextColumn Header单位 Binding{Binding Unit}/DataGridTextColumn Header最小库存 Binding{Binding Min}/DataGridTextColumn Header最大库存 Binding{Binding Max}/DataGridTextColumn Header当前库存 Binding{Binding Quant}/DataGridTextColumn Header物资类别 Binding{Binding GoodsTypeName} IsReadOnlyTrue/DataGridTextColumn Header规格型号 Binding{Binding SpecName} IsReadOnlyTrue/DataGridTextColumn Header备注 Binding{Binding Tag}/DataGridTextColumn Header日期 Binding{Binding InsertDate}/DataGridTemplateColumn Header操作DataGridTemplateColumn.CellTemplateDataTemplateStackPanel OrientationHorizontalButton Content编辑 Command{Binding RelativeSource{RelativeSource ModeFindAncestor,AncestorTypelocal:GoodsView},PathDataContext.EditCommand}CommandParameter{Binding RelativeSource{RelativeSource ModeSelf}} Tag{Binding} Style{StaticResource DataGridButtonStyle} /Button Content删除 Command{Binding RelativeSource{RelativeSource ModeFindAncestor,AncestorTypelocal:GoodsView},PathDataContext.DeleteCommand}CommandParameter{Binding RelativeSource{RelativeSource ModeSelf}}Tag{Binding} Style{StaticResource DataGridButtonStyle} //StackPanel/DataTemplate/DataGridTemplateColumn.CellTemplate/DataGridTemplateColumn/DataGrid.Columns/DataGrid/Grid/Grid
/UserControl3、添加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 CommonServiceLocator;
using West.StoreMgr.Service;
using West.StoreMgr.Helper;
using West.StoreMgr.View;
using West.StoreMgr.Windows;
using static West.StoreMgr.Windows.MsgBoxWindow;namespace West.StoreMgr.ViewModel
{/// summary/// 物资viewmodel/// /summarypublic class GoodsViewModel : ViewModelBase{public GoodsViewModel(){}private Goods goods new Goods();public Goods Goods{get { return goods; }set { goods value; RaisePropertyChanged(); }}private ListGoods goodsList new ListGoods();/// summary/// 物资列表/// /summarypublic ListGoods GoodsList{get { return goodsList; }set { goodsList value; RaisePropertyChanged(); }}private ListGoodsType goodsTypeList new ListGoodsType();/// summary/// 物资类别集合/// /summarypublic ListGoodsType GoodsTypeList{get { return goodsTypeList; }set { goodsTypeList value; RaisePropertyChanged(); }}private ListSpec specList new ListSpec();/// summary/// 物资规格集合/// /summarypublic ListSpec SpecList{get { return specList; }set { specList value; RaisePropertyChanged(); }}/// summary/// 加载页面时获取数据/// /summarypublic RelayCommand LoadCommand{get{return new RelayCommand(() {GoodsList new GoodsService().Select();//物资列表GoodsTypeList new GoodsTypeService().Select();//物资类别列表SpecList new SpecService().Select();//规格列表});}}//添加public RelayCommandUserControl AddCommand{get{var command new RelayCommandUserControl((obj) {if (!(obj is GoodsView view)) return;if (string.IsNullOrEmpty(Goods.Name) true|| string.IsNullOrEmpty(Goods.Serial) true){MsgWinHelper.ShowError(序号和名字不能为空);return;}Goods.InsertDate DateTime.Now;Goods.UserInfoId AppData.Instance.User.Id;var goodsType view.comboboxGoodsType.SelectedItem as GoodsType;//将选择的下拉框类别转换成物资类别对象var spec view.comboboxSpec.SelectedItem as Spec;//将选择的下拉框规格转换成物资规格对象if (goodsType ! null) Goods.GoodsTypeId goodsType.Id;if (spec ! null) Goods.SpecId spec.Id;var service new GoodsService();int count service.Insert(Goods);if (count 0){GoodsList service.Select(); MsgWinHelper.ShowMessage(物资添加成功);Goods new Goods();}else{MsgWinHelper.ShowError(物资添加失败);}});return command;}}//修改public RelayCommandButton EditCommand{get{var command new RelayCommandButton((view) {var old view.Tag as Goods;if (old null) return;var vm ServiceLocator.Current.GetInstanceEditGoodsViewModel();vm.Goods old;vm.GoodsType vm.GoodsTypeList.FirstOrDefault(t t.Id old.GoodsTypeId);vm.Spec vm.SpecList.FirstOrDefault(t t.Id old.SpecId);var window new EditGoodsWindow();window.ShowDialog();GoodsList new GoodsService().Select();});return command;}}//删除public RelayCommandButton DeleteCommand{get{var command new RelayCommandButton((view) {if (MsgWinHelper.ShowQuestion(您确定要删除该物资吗) CustomMessageBoxResult.OK){var old view.Tag as Goods;if (old null) return;var service new GoodsService();int count service.Delete(old);if (count 0){GoodsList service.Select();MsgWinHelper.ShowMessage(操作成功);}else{MsgWinHelper.ShowError(操作失败);}}});return command;}}}
}4、运行程序 5、修改物资
1添加窗体 2UI布局
Window x:ClassWest.StoreMgr.Windows.EditGoodsWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:localclr-namespace:West.StoreMgr.WindowsResizeModeNoResizeWindowStartupLocationCenterScreenmc:Ignorabled DataContext{Binding Source{StaticResource Locator},PathEditGoods}Title修改物资 Height410 Width800Grid Grid.Row1 Margin17 Background#E4ECEFGrid.RowDefinitionsRowDefinition Height30/RowDefinition//Grid.RowDefinitionsBorder Background#72BBE5TextBlock Text修改物资数据 FontSize18 VerticalAlignmentCenter Foreground#1F3C4C Margin0 0 10 0//BorderStackPanel Grid.Row1 OrientationVertical VerticalAlignmentCenter Margin0 10 0 10StackPanel OrientationHorizontal VerticalAlignmentCenterTextBlock Margin0 0 10 0 Text物资类别: VerticalAlignmentCenter Width80/ComboBox x:NamecomboboxGoodsType Margin0 0 10 0 ItemsSource{Binding GoodsTypeList} SelectedItem{Binding GoodsType} DisplayMemberPathName SelectedValuePathId Width150 Height30 /TextBlock Margin0 0 10 0 Text规格型号: VerticalAlignmentCenter Width80/ComboBox x:NamecomboboxSpec Margin0 0 10 0 ItemsSource{Binding SpecList} SelectedItem{Binding Spec} DisplayMemberPathName SelectedValuePathId Width150 Height30 //StackPanelStackPanel OrientationHorizontal VerticalAlignmentCenter Margin0 10 0 10TextBlock Margin0 0 10 0 Text 序号: VerticalAlignmentCenter Width80/TextBox Margin0 0 10 0 Text{Binding Goods.Serial,ModeTwoWay,UpdateSourceTriggerPropertyChanged} Width150 Height30 IsReadOnlyTrue /TextBlock Margin0 0 10 0 Text物资名称: VerticalAlignmentCenter Width80/TextBox Margin0 0 10 0 Text{Binding Goods.Name,ModeTwoWay,UpdateSourceTriggerPropertyChanged} Width150 Height30 /TextBlock Margin0 0 10 0 Text单位: VerticalAlignmentCenter Width80/TextBox Margin0 0 10 0 Text{Binding Goods.Unit,ModeTwoWay,UpdateSourceTriggerPropertyChanged} Width150 Height30 //StackPanelStackPanel OrientationHorizontal VerticalAlignmentCenter Margin0 10 0 10TextBlock Margin0 0 10 0 Text库存最小值: VerticalAlignmentCenter Width80/TextBox Margin0 0 10 0 Text{Binding Goods.Min,ModeTwoWay,UpdateSourceTriggerPropertyChanged} Width150 Height30 /TextBlock Margin0 0 10 0 Text库存最大值: VerticalAlignmentCenter Width80/TextBox Margin0 0 10 0 Text{Binding Goods.Max,ModeTwoWay,UpdateSourceTriggerPropertyChanged} Width150 Height30 /TextBlock Margin0 0 10 0 Text备注: VerticalAlignmentCenter Width80/TextBox Margin0 0 10 0 Text{Binding Goods.Tag,ModeTwoWay,UpdateSourceTriggerPropertyChanged} Width150 Height30 //StackPanelStackPanel OrientationHorizontal VerticalAlignmentCenter Margin0 10 0 10!--button--Button Margin542 0 0 0 Height36 Width199 Grid.Row3 FontSize21Content确 定 Style{StaticResource ButtonStyle} CommandParameter{Binding RelativeSource{RelativeSource ModeFindAncestor,AncestorTypelocal:EditGoodsWindow}}Command{Binding EditCommand}//StackPanel/StackPanel/Grid
/Window
3添加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;
using West.StoreMgr.Helper;
using West.StoreMgr.Service;namespace West.StoreMgr.ViewModel
{/// summary/// 修改物资viewmodel/// /summarypublic class EditGoodsViewModel : ViewModelBase{public EditGoodsViewModel(){GoodsTypeList new GoodsTypeService().Select();SpecList new SpecService().Select(); }private GoodsType goodsType new GoodsType();/// summary/// 物资类别/// /summarypublic GoodsType GoodsType{get { return goodsType; }set { goodsType value; RaisePropertyChanged(); }}private Spec spec new Spec();/// summary/// 物资规格/// /summarypublic Spec Spec{get { return spec; }set { spec value; RaisePropertyChanged(); }}private ListGoodsType goodsTypeList new ListGoodsType();/// summary/// 物资类别集合/// /summarypublic ListGoodsType GoodsTypeList{get { return goodsTypeList; }set { goodsTypeList value; RaisePropertyChanged(); }}private ListSpec specList new ListSpec();/// summary/// 物资规格集合/// /summarypublic ListSpec SpecList{get { return specList; }set { specList value; RaisePropertyChanged(); }}private Goods goods new Goods(); public Goods Goods{get { return goods; }set { goods value; RaisePropertyChanged(); }}//修改public RelayCommandWindow EditCommand{get{var command new RelayCommandWindow((window) {if (string.IsNullOrEmpty(Goods.Name) true|| string.IsNullOrEmpty(Goods.Serial) true){ MsgWinHelper.ShowError(序号和名字不能为空);return;}Goods.GoodsTypeId GoodsType.Id;Goods.SpecId Spec.Id;var service new GoodsService();int count service.Update(Goods);if (count 0){MsgWinHelper.ShowMessage(修改成功);window.Close();}else{MsgWinHelper.ShowError(修改失败);}});return command;}}//取消public RelayCommandWindow CancelCommand{get{var command new RelayCommandWindow((window) {window.Close();});return command;}}}
}4运行程序 6、删除物资 原创不易打字不易截图不易多多点赞送人玫瑰留有余香财务自由明日实现。