添加项目文件。
This commit is contained in:
33
MetroGauges/Database/Forms/ProSetting.xaml
Normal file
33
MetroGauges/Database/Forms/ProSetting.xaml
Normal file
@@ -0,0 +1,33 @@
|
||||
<Window x:Class="MetroGauges.Database.Forms.ProSetting"
|
||||
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:MetroGauges.Database.Forms"
|
||||
mc:Ignorable="d"
|
||||
Title="设置块属性信息" Height="470.279" Width="332.618" WindowStartupLocation="CenterScreen" WindowStyle="None" ShowInTaskbar="False" >
|
||||
<Grid>
|
||||
<Button x:Name="btAdd" Content="添加" HorizontalAlignment="Left" Margin="143,91,0,0" VerticalAlignment="Top" Width="75" Click="btAdd_Click"/>
|
||||
<Button x:Name="btcancel" Content="关闭" HorizontalAlignment="Left" Margin="232,91,0,0" VerticalAlignment="Top" Width="75" Click="btcancel_Click" RenderTransformOrigin="0.536,-6.49"/>
|
||||
|
||||
<Label Content="属性名:" HorizontalAlignment="Left" Margin="21,10,0,0" VerticalAlignment="Top"/>
|
||||
<Label Content="属性值:" HorizontalAlignment="Left" Margin="21,54,0,0" VerticalAlignment="Top"/>
|
||||
<TextBox HorizontalAlignment="Left" Height="35" Margin="75,3,0,0" TextWrapping="Wrap" x:Name="txtName" VerticalAlignment="Top" Width="210"/>
|
||||
<TextBox HorizontalAlignment="Left" Height="35" Margin="75,38,0,0" TextWrapping="Wrap" x:Name="txtValue" VerticalAlignment="Top" Width="210"/>
|
||||
|
||||
<DataGrid x:Name="dgFileds" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True" Margin="10,128,10,10" >
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="属性名" Width="120" Binding="{Binding Display}" />
|
||||
<DataGridTextColumn Header="属性值" Width="*" Binding="{Binding Fieldvalue}" />
|
||||
<DataGridTemplateColumn Header="">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Image Width="16" Height="16" Tag="{Binding Id}" Margin="10,0,0,0" Cursor="Hand" Source="/MetroGauges;component/Resources/Icon/DeleteRed16.png" MouseLeftButtonDown="Image_MouseLeftButtonDown" ></Image>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
83
MetroGauges/Database/Forms/ProSetting.xaml.cs
Normal file
83
MetroGauges/Database/Forms/ProSetting.xaml.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using MetroGauges.Database.Enitys;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MetroGauges.Database.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// ProSetting.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ProSetting : Window
|
||||
{
|
||||
private BlockInfo blockInfo;
|
||||
public ProSetting()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void BindData(BlockInfo Info)
|
||||
{
|
||||
blockInfo = Info;
|
||||
dgFileds.ItemsSource = blockInfo.FieldData;
|
||||
}
|
||||
|
||||
private void btAdd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
int r;
|
||||
if (int.TryParse(txtName.Text, out r))
|
||||
{
|
||||
MessageBox.Show("属性名不能为数字");
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(txtName.Text))
|
||||
{
|
||||
MessageBox.Show("请录入属性名");
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(txtValue.Text))
|
||||
{
|
||||
MessageBox.Show("请录入属性值");
|
||||
return;
|
||||
}
|
||||
FieldInfo fieldInfo = new FieldInfo();
|
||||
fieldInfo.Blockid = blockInfo.Id;
|
||||
fieldInfo.Display = txtName.Text;
|
||||
fieldInfo.Fieldname = txtName.Text;
|
||||
fieldInfo.Fieldvalue = txtValue.Text;
|
||||
|
||||
bool reuslt = BlockDAL.CreateField(fieldInfo);
|
||||
if (reuslt)
|
||||
{
|
||||
blockInfo.FieldData.Add(fieldInfo);
|
||||
txtName.Text = "";
|
||||
txtValue.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void btcancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
int id =int.Parse((sender as Image).Tag.ToString());
|
||||
BlockDAL.DeleteFiled(id);
|
||||
FieldInfo fieldInfo = blockInfo.FieldData.Where(p => p.Id == id).FirstOrDefault();
|
||||
blockInfo.FieldData.Remove(fieldInfo);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
18
MetroGauges/Database/Forms/frmAddGroup.xaml
Normal file
18
MetroGauges/Database/Forms/frmAddGroup.xaml
Normal file
@@ -0,0 +1,18 @@
|
||||
<Window x:Class="MetroGauges.Database.Forms.frmAddGroup"
|
||||
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:MetroGauges.Database.Forms"
|
||||
mc:Ignorable="d"
|
||||
Title="添加分类" Height="156.437" Width="305.58" WindowStartupLocation="CenterScreen" ShowInTaskbar="False" WindowStyle="None">
|
||||
<Grid>
|
||||
|
||||
|
||||
<Button x:Name="btAdd" Content="确定" HorizontalAlignment="Left" Margin="96,88,0,0" VerticalAlignment="Top" Width="75" Click="btAdd_Click"/>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="10,50,0,0" TextWrapping="Wrap" Text="分类名称:" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="txtGroup" HorizontalAlignment="Left" Height="36" Margin="66,37,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="194"/>
|
||||
<Button x:Name="btcancel" Content="取消" HorizontalAlignment="Left" Margin="184,88,0,0" VerticalAlignment="Top" Width="75" Click="btcancel_Click"/>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
43
MetroGauges/Database/Forms/frmAddGroup.xaml.cs
Normal file
43
MetroGauges/Database/Forms/frmAddGroup.xaml.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MetroGauges.Database.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// frmAddGroup.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class frmAddGroup : Window
|
||||
{
|
||||
public frmAddGroup()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void btcancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btAdd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(txtGroup.Text))
|
||||
{
|
||||
MessageBox.Show("名称否允许为空!","错误");
|
||||
return;
|
||||
}
|
||||
this.DialogResult = true;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user