diff --git a/SunlightCentralizedControlManagement_SCCM_.csproj b/SunlightCentralizedControlManagement_SCCM_.csproj
index ac0596a..50e7684 100644
--- a/SunlightCentralizedControlManagement_SCCM_.csproj
+++ b/SunlightCentralizedControlManagement_SCCM_.csproj
@@ -172,6 +172,9 @@
InputBox.xaml
+
+ MachineSelection.xaml
+
ViewStep.xaml
@@ -257,6 +260,10 @@
MSBuild:Compile
Designer
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer
diff --git a/View/ProductionPlanningEdit.xaml.cs b/View/ProductionPlanningEdit.xaml.cs
index 57c238b..3019046 100644
--- a/View/ProductionPlanningEdit.xaml.cs
+++ b/View/ProductionPlanningEdit.xaml.cs
@@ -1,4 +1,5 @@
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
+using SunlightCentralizedControlManagement_SCCM_.WindowsView;
using System;
using System.Collections.Generic;
using System.Data;
@@ -17,6 +18,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using TouchSocket.Core;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
+using static SunlightCentralizedControlManagement_SCCM_.WindowsView.MachineSelection;
namespace SunlightCentralizedControlManagement_SCCM_.View
{
@@ -40,9 +42,16 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
comboBoxMachine.ItemsSource = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field("name")).ToList();//转换机台
comboBoxProgram.ItemsSource = ProgramName.AsEnumerable().Select(rowdata => rowdata.Field("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)
diff --git a/WindowsView/MachineSelection.xaml b/WindowsView/MachineSelection.xaml
new file mode 100644
index 0000000..5ddc7f2
--- /dev/null
+++ b/WindowsView/MachineSelection.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WindowsView/MachineSelection.xaml.cs b/WindowsView/MachineSelection.xaml.cs
new file mode 100644
index 0000000..7301ffc
--- /dev/null
+++ b/WindowsView/MachineSelection.xaml.cs
@@ -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
+{
+ ///
+ /// MachineSelection.xaml 的交互逻辑
+ ///
+ 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 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("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("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("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; }
+ }
+ }
+}