diff --git a/DyeingComputer.csproj b/DyeingComputer.csproj
index 9bea985..9e5a76c 100644
--- a/DyeingComputer.csproj
+++ b/DyeingComputer.csproj
@@ -127,6 +127,9 @@
WorkOrderView.xaml
+
+ InputBox.xaml
+
MSBuild:Compile
Designer
@@ -179,6 +182,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
@@ -255,7 +262,6 @@
-
diff --git a/View/ProgramgroupView.xaml.cs b/View/ProgramgroupView.xaml.cs
index 842d448..35686c2 100644
--- a/View/ProgramgroupView.xaml.cs
+++ b/View/ProgramgroupView.xaml.cs
@@ -1,4 +1,5 @@
-using System;
+using DyeingComputer.Windows;
+using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
@@ -38,7 +39,7 @@ namespace DyeingComputer.View
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
- string sql_script = "select * from ProgramName";
+ string sql_script = "select * from ProgramName order by ProgramID desc";
if (sql != null) sql.Clear(); //清空缓存
sql = SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取计划表写入缓存
@@ -60,9 +61,33 @@ namespace DyeingComputer.View
}
- private void ProgramgroupView_new_Click(object sender, RoutedEventArgs e)
+ private void ProgramgroupView_new_Click(object sender, RoutedEventArgs e)//新建按钮
{
+ InputBox frm = new InputBox();
+ frm.Accept += new EventHandler(InputBox_accept);
+ frm.Show();
+ }
+
+ void InputBox_accept(object sender, EventArgs e)//新建按钮窗口返回
+ {
+ //事件的接收者通过一个简单的类型转换得到InputBox的引用
+ InputBox frm = (InputBox)sender;
+ //接收到InputBox的TextBox值
+ string VALUE = frm.InputValue;
+
+ Dictionary Program_new = new Dictionary();//缓存函数
+ Program_new.Add("ProgramName", VALUE);
+ Program_new.Add("ProgramID", DateTime.Now.ToString("yyMMddHHmmss"));
+ Program_new.Add("Step", "0");
+ Program_new.Add("Time", "0:00");
+ Program_new.Add("Notes", null);
+
+ SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
+ SQLiteHelpers.Open(); //打开数据库
+ SQLiteHelpers.InsertData("ProgramName", Program_new);// 执行插入
+ SQLiteHelpers.Close(); //关闭连接
+ Programgroup_sql();
}
private void ProgramgroupView_del_Click(object sender, RoutedEventArgs e)
diff --git a/Windows/InputBox.xaml b/Windows/InputBox.xaml
new file mode 100644
index 0000000..6352fed
--- /dev/null
+++ b/Windows/InputBox.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
diff --git a/Windows/InputBox.xaml.cs b/Windows/InputBox.xaml.cs
new file mode 100644
index 0000000..cd12e9d
--- /dev/null
+++ b/Windows/InputBox.xaml.cs
@@ -0,0 +1,55 @@
+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 DyeingComputer.Windows
+{
+ ///
+ /// InputBox.xaml 的交互逻辑
+ ///
+ public partial class InputBox : Window
+ {
+ public InputBox()
+ {
+ InitializeComponent();
+ }
+
+ public string InputValue
+ {
+ get
+ {
+ return Boxx.Text;
+ }
+ set
+ {
+ this.Boxx.Text = value;
+ }
+ }
+
+ public event EventHandler Accept;
+
+ private void YES_Click(object sender, RoutedEventArgs e)
+ {
+ if (Accept != null)
+ {
+ Accept(this, EventArgs.Empty);
+ }
+ this.Close(); //为了测试效果,点击Done以后先不关闭窗口
+ }
+
+ private void NO_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close(); //为了测试效果,点击Done以后先不关闭窗口
+ }
+ }
+}