sc 1 year ago
parent
commit
7b06aa8cad
  1. 8
      DyeingComputer.csproj
  2. 31
      View/ProgramgroupView.xaml.cs
  3. 14
      Windows/InputBox.xaml
  4. 55
      Windows/InputBox.xaml.cs

8
DyeingComputer.csproj

@ -127,6 +127,9 @@
<Compile Include="View\WorkOrderView.xaml.cs">
<DependentUpon>WorkOrderView.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\InputBox.xaml.cs">
<DependentUpon>InputBox.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -179,6 +182,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\InputBox.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
@ -255,7 +262,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Model\" />
<Folder Include="Windows\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommonServiceLocator">

31
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<string, object> Program_new = new Dictionary<string, object>();//缓存函数
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)

14
Windows/InputBox.xaml

@ -0,0 +1,14 @@
<Window x:Class="DyeingComputer.Windows.InputBox"
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:DyeingComputer.Windows"
mc:Ignorable="d"
Title="InputBox" Height="200" Width="400">
<Grid>
<TextBox x:Name="Boxx" HorizontalAlignment="Left" Height="36" Margin="39,31,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="319"/>
<Button Content="Button" HorizontalAlignment="Left" Height="35" Margin="58,104,0,0" VerticalAlignment="Top" Width="96" Click="YES_Click"/>
<Button Content="Button" HorizontalAlignment="Left" Height="35" Margin="158,104,0,0" VerticalAlignment="Top" Width="96" Click="NO_Click"/>
</Grid>
</Window>

55
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
{
/// <summary>
/// InputBox.xaml 的交互逻辑
/// </summary>
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以后先不关闭窗口
}
}
}
Loading…
Cancel
Save