添加排程页面机组选择
This commit is contained in:
commit
2263777da5
4 files changed
+147
-2
No files matched your search
@@ -172,6 +172,9 @@
|
|||||||
<Compile Include="WindowsView\InputBox.xaml.cs">
|
<Compile Include="WindowsView\InputBox.xaml.cs">
|
||||||
<DependentUpon>InputBox.xaml</DependentUpon>
|
<DependentUpon>InputBox.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="WindowsView\MachineSelection.xaml.cs">
|
||||||
|
<DependentUpon>MachineSelection.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="WindowsView\ViewStep.xaml.cs">
|
<Compile Include="WindowsView\ViewStep.xaml.cs">
|
||||||
<DependentUpon>ViewStep.xaml</DependentUpon>
|
<DependentUpon>ViewStep.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -257,6 +260,10 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="WindowsView\MachineSelection.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="WindowsView\ViewStep.xaml">
|
<Page Include="WindowsView\ViewStep.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
||||||
|
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@@ -17,6 +18,7 @@ using System.Windows.Navigation;
|
|||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using TouchSocket.Core;
|
using TouchSocket.Core;
|
||||||
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||||
|
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.MachineSelection;
|
||||||
|
|
||||||
namespace SunlightCentralizedControlManagement_SCCM_.View
|
namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||||
{
|
{
|
||||||
@@ -40,9 +42,16 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
comboBoxMachine.ItemsSource = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换机台
|
comboBoxMachine.ItemsSource = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换机台
|
||||||
comboBoxProgram.ItemsSource = ProgramName.AsEnumerable().Select(rowdata => rowdata.Field<string>("ProgramName")).ToList();//转换工艺代码
|
comboBoxProgram.ItemsSource = ProgramName.AsEnumerable().Select(rowdata => rowdata.Field<string>("ProgramName")).ToList();//转换工艺代码
|
||||||
}
|
}
|
||||||
private void Multi_Click(object sender, RoutedEventArgs e)
|
private void Multi_Click(object sender, RoutedEventArgs e)//机台组
|
||||||
{
|
{
|
||||||
|
MachineSelection machineSelection = new MachineSelection();
|
||||||
|
machineSelection.AddressUpdated += new MachineSelection.AddressUpdateHandler(Address_ButtonClicked);
|
||||||
|
//machineSelection.data = "ID";
|
||||||
|
machineSelection.ShowDialog();
|
||||||
|
}
|
||||||
|
private void Address_ButtonClicked(object sender, AddressUpdateEventArgs e)//机台组返回结果
|
||||||
|
{
|
||||||
|
if(!string.IsNullOrEmpty(e.Groups)) comboBoxMachine.Text = e.Groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<Window x:Class="SunlightCentralizedControlManagement_SCCM_.WindowsView.MachineSelection"
|
||||||
|
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:SunlightCentralizedControlManagement_SCCM_.WindowsView"
|
||||||
|
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
|
||||||
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
|
mc:Ignorable="d" WindowStyle="None"
|
||||||
|
Title="MachineSelection" Height="300" Width="600">
|
||||||
|
<Grid>
|
||||||
|
<ScrollViewer Margin="0" VerticalScrollBarVisibility="Auto">
|
||||||
|
<WrapPanel Orientation="Horizontal" x:Name="MachineView" Background="White" Margin="0,0,0,60">
|
||||||
|
</WrapPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
|
<Button Content="{x:Static lang:Resources.YES}" HorizontalAlignment="Right" Height="35" Margin="0,0,50,10"
|
||||||
|
VerticalAlignment="Bottom" Width="80" Click="Button_Click"/>
|
||||||
|
<Button Content="{x:Static lang:Resources.Quit}" HorizontalAlignment="Right" Height="35" Margin="0,0,150,10"
|
||||||
|
VerticalAlignment="Bottom" Width="80" Click="Button_Quit"/>
|
||||||
|
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,80,0,10" x:Name="comboBoxMachine"
|
||||||
|
VerticalAlignment="Bottom" Width="200" FontSize="15" IsEditable="True" IsReadOnly="True" BorderBrush="#FF673AB7"
|
||||||
|
DropDownClosed="comboBoxMachine_DropDownClosed"/>
|
||||||
|
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,80,0,10" TextWrapping="Wrap"
|
||||||
|
Text="{x:Static lang:Resources.MachineGroup}" VerticalAlignment="Bottom" Width="120" FontSize="25"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
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;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||||
|
|
||||||
|
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// MachineSelection.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class MachineSelection : Window
|
||||||
|
{
|
||||||
|
public string data { get; set; }
|
||||||
|
//声明一个更新Address的委托
|
||||||
|
public delegate void AddressUpdateHandler(object sender, AddressUpdateEventArgs e);
|
||||||
|
//声明一个更新Address的事件
|
||||||
|
public event AddressUpdateHandler AddressUpdated;
|
||||||
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||||
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
||||||
|
private string MACHINEDATA;
|
||||||
|
DataTable machine_table;
|
||||||
|
private List<string> machine;
|
||||||
|
|
||||||
|
CheckBox[] checkBoxes = new CheckBox[999];
|
||||||
|
public MachineSelection()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
|
comboBoxMachine.ItemsSource = SQLiteHelpers.ExecuteDataSet("select * from MachinesGroups order by Name desc", null).Tables[0].
|
||||||
|
AsEnumerable().Select(rowdata => rowdata.Field<string>("Name")).ToList();//转换代码
|
||||||
|
machine_table = SQLiteHelpers.ExecuteDataSet("select * from Machines order by Name desc", null).Tables[0];
|
||||||
|
SQLiteHelpers.Close(); //关闭连接
|
||||||
|
|
||||||
|
machine = machine_table.AsEnumerable().Select(rowdata => rowdata.Field<string>("Name")).ToList();//转换代码
|
||||||
|
|
||||||
|
for (int i = 0; i < machine.Count; i++)
|
||||||
|
{
|
||||||
|
checkBoxes[i] = new CheckBox();
|
||||||
|
checkBoxes[i].Content = machine[i].ToString();
|
||||||
|
checkBoxes[i].FontSize = 20;
|
||||||
|
checkBoxes[i].Width = 80;
|
||||||
|
checkBoxes[i].Height = 50;
|
||||||
|
MachineView.Children.Add(checkBoxes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comboBoxMachine_DropDownClosed(object sender, EventArgs e)//选择设备组
|
||||||
|
{
|
||||||
|
MachineView.Children.Clear();
|
||||||
|
machine = machine_table.Select("Groups='"+ comboBoxMachine.Text+"'").
|
||||||
|
AsEnumerable().Select(rowdata => rowdata.Field<string>("Name")).ToList();//转换代码
|
||||||
|
for (int i = 0; i < machine.Count; i++)
|
||||||
|
{
|
||||||
|
checkBoxes[i] = new CheckBox();
|
||||||
|
checkBoxes[i].Content = machine[i].ToString();
|
||||||
|
checkBoxes[i].FontSize = 20;
|
||||||
|
checkBoxes[i].Width = 80;
|
||||||
|
checkBoxes[i].Height = 50;
|
||||||
|
MachineView.Children.Add(checkBoxes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_Click(object sender, RoutedEventArgs e)//确认按钮
|
||||||
|
{
|
||||||
|
for (int i = 0; i < machine.Count; i++)
|
||||||
|
{
|
||||||
|
if((bool)checkBoxes[i].IsChecked) MACHINEDATA= MACHINEDATA+"+"+ checkBoxes[i].Content;
|
||||||
|
}
|
||||||
|
AddressUpdated(this, new AddressUpdateEventArgs(MACHINEDATA.Remove(0, 1)));
|
||||||
|
this.Close(); //关闭窗口
|
||||||
|
}
|
||||||
|
private void Button_Quit(object sender, RoutedEventArgs e)//退出
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AddressUpdateEventArgs : System.EventArgs
|
||||||
|
{
|
||||||
|
public AddressUpdateEventArgs(string dGroups)
|
||||||
|
{
|
||||||
|
this.Groups = dGroups;
|
||||||
|
}
|
||||||
|
public string Groups { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user