Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement
This commit is contained in:
commit
141d791c40
9 files changed
+976
-120
No files matched your search
+10
-15
@@ -9,18 +9,13 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="630" d:DesignWidth="1280">
|
||||
<Grid>
|
||||
<Rectangle Margin="0,0,0,0" Fill="#FFCCCCCC" VerticalAlignment="Top" Height="40"/>
|
||||
<Button Content="{x:Static lang:Resources.edit}" x:Name="ProgramgroupView_edit" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="200,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_edit_Click"/>
|
||||
<Button Content="{x:Static lang:Resources.New}" x:Name="ProgramgroupView_new" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="0,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_new_Click"/>
|
||||
<Button Content="{x:Static lang:Resources.Rename}" x:Name="ProgramgroupView_Rename" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="400,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Rename_Click"/>
|
||||
<Button Content="{x:Static lang:Resources.Remark}" x:Name="ProgramgroupView_Remark" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="600,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Remark_Click"/>
|
||||
|
||||
<DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" PreviewMouseLeftButtonUp="Grid_PreviewMouseLeftButtonUp" MouseDoubleClick="Grid_MouseDoubleClick" d:ItemsSource="{d:SampleData ItemCount=90}"
|
||||
AutoGenerateColumns="False" MinColumnWidth="30" HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9"
|
||||
GridLinesVisibility="All" BorderBrush="#CCCCCC" BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right"
|
||||
Grid.ColumnSpan="2" AllowDrop="False" CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False"
|
||||
CanUserResizeColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" HeadersVisibility ="Column" Background="White"
|
||||
SelectionMode="Single" FontSize="15" Margin="0,0,0,60">
|
||||
<DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" d:ItemsSource="{d:SampleData ItemCount=90}"
|
||||
PreviewMouseLeftButtonUp="Grid_PreviewMouseLeftButtonUp" MouseDoubleClick="Grid_MouseDoubleClick"
|
||||
Background="White" HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9"
|
||||
GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" FontSize="15"
|
||||
Grid.ColumnSpan="2" CanUserResizeRows="False" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||
CanUserAddRows="False" CanUserDeleteRows="False" HeadersVisibility ="Column" SelectionMode="Single"
|
||||
Margin="0,0,0,60">
|
||||
<DataGrid.RowStyle >
|
||||
<Style TargetType="{x:Type DataGridRow}">
|
||||
<Setter Property="Height" Value="30" />
|
||||
@@ -53,7 +48,7 @@
|
||||
<!--列信息绑定-->
|
||||
<DataGridTextColumn Header="ProcessID" Binding="{Binding ProgramID}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:Resources.ProcessName}" Width="400" Binding="{Binding ProgramName}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:Resources.Group}" Width="90" Binding="{Binding Group}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:Resources.Group}" Width="90" Binding="{Binding Groups}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:Resources.Step}" Width="90" Binding="{Binding Step}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:Resources.Time}" Width="100" Binding="{Binding Time}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:Resources.Remark}" Width="*" Binding="{Binding Notes}" IsReadOnly="True"/>
|
||||
@@ -103,11 +98,11 @@
|
||||
</ListViewItem>
|
||||
</ListView>
|
||||
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
|
||||
<ListViewItem Width="350" MouseLeftButtonUp="ListViewItem_Delete" x:Name="Group">
|
||||
<ListViewItem Width="350" MouseLeftButtonUp="ListViewItem_Delete">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="Group" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
|
||||
<TextBlock Text="{x:Static lang:Resources.Group}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
||||
<ComboBox Width="200" VerticalAlignment="Center" Background="White" Height="40" FontSize="20" />
|
||||
<ComboBox x:Name="Group" Width="200" VerticalAlignment="Center" Background="White" Height="40" FontSize="20" />
|
||||
</StackPanel>
|
||||
</ListViewItem>
|
||||
</ListView>
|
||||
|
||||
+58
-103
@@ -17,6 +17,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
{
|
||||
InitializeComponent();
|
||||
Programgroup_sql();
|
||||
|
||||
string[] group_data = { "en-US", "zh-CN", "zh-TW" };
|
||||
Group.ItemsSource = group_data;
|
||||
}
|
||||
|
||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||
@@ -35,9 +38,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
if (sql != null) Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
||||
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
|
||||
//sql.Clear(); //清除缓存
|
||||
//System.GC.Collect();
|
||||
}
|
||||
|
||||
private void ProgramgroupView_edit_Click(object sender, RoutedEventArgs e)
|
||||
@@ -47,94 +47,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
container.Content = new ProgramstepsView();*/
|
||||
}
|
||||
|
||||
private void ProgramgroupView_new_Click(object sender, RoutedEventArgs e)//新建按钮
|
||||
{
|
||||
/* InputBox frm = new InputBox();
|
||||
frm.Accept += new EventHandler(InputBox_new_accept);
|
||||
frm.ShowDialog();*/
|
||||
}
|
||||
|
||||
// void InputBox_new_accept(object sender, EventArgs e)//新建按钮窗口返回
|
||||
// {
|
||||
//事件的接收者通过一个简单的类型转换得到InputBox的引用
|
||||
/* InputBox frm = (InputBox)sender;
|
||||
//接收到InputBox的TextBox值
|
||||
string VALUE = frm.InputValue;
|
||||
|
||||
string ID = (StrToInt.To16Convert10( DateTime.Now.ToString("yy"))+ StrToInt.To16Convert10(DateTime.Now.ToString("MM"))+StrToInt.To16Convert10(DateTime.Now.ToString("dd"))).ToString()+
|
||||
DateTime.Now.ToString("HH")+DateTime.Now.ToString("mm")+DateTime.Now.ToString("ss"); //id为时间合
|
||||
|
||||
Dictionary<string, object> Program_new = new Dictionary<string, object>();//缓存函数
|
||||
Program_new.Add("ProgramName", VALUE);
|
||||
Program_new.Add("ProgramID", ID);
|
||||
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_Numder = VALUE;
|
||||
Programgroup_ID = ID;
|
||||
|
||||
Programgroup_sql();*/
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
private void ProgramgroupView_Rename_Click(object sender, RoutedEventArgs e)//重命名按钮
|
||||
{
|
||||
/* if (Programgroup_ID == null) return;
|
||||
InputBox frm = new InputBox();
|
||||
frm.Accept += new EventHandler(InputBox_Rename_accept);
|
||||
frm.ShowDialog();*/
|
||||
}
|
||||
void InputBox_Rename_accept(object sender, EventArgs e)//重命名按钮窗口返回
|
||||
{
|
||||
//事件的接收者通过一个简单的类型转换得到InputBox的引用
|
||||
/* InputBox frm = (InputBox)sender;
|
||||
//接收到InputBox的TextBox值
|
||||
string VALUE = frm.InputValue;
|
||||
Dictionary<string, object> Program_Rename = new Dictionary<string, object>();//缓存函数
|
||||
Program_Rename.Add("ProgramName", VALUE);
|
||||
|
||||
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
SQLiteHelpers.Update("ProgramName", Program_Rename, "ProgramID='"+ Programgroup_ID + "'",null);
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
|
||||
|
||||
Programgroup_sql();
|
||||
Programgroup_Numder = null;
|
||||
Programgroup_ID = null;*/
|
||||
}
|
||||
|
||||
private void ProgramgroupView_Remark_Click(object sender, RoutedEventArgs e)//备注
|
||||
{
|
||||
/* if (Programgroup_ID == null) return;
|
||||
InputBox frm = new InputBox();
|
||||
frm.Accept += new EventHandler(InputBox_Remark_accept);
|
||||
frm.ShowDialog();*/
|
||||
}
|
||||
void InputBox_Remark_accept(object sender, EventArgs e)//备注按钮窗口返回
|
||||
{
|
||||
//事件的接收者通过一个简单的类型转换得到InputBox的引用
|
||||
/* InputBox frm = (InputBox)sender;
|
||||
//接收到InputBox的TextBox值
|
||||
string VALUE = frm.InputValue;
|
||||
Dictionary<string, object> Program_Remark = new Dictionary<string, object>();//缓存函数
|
||||
Program_Remark.Add("Notes", VALUE);
|
||||
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
SQLiteHelpers.Update("ProgramName", Program_Remark, "ProgramID='" + Programgroup_ID + "'", null);
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
|
||||
Programgroup_sql();
|
||||
Programgroup_Numder = null;
|
||||
Programgroup_ID = null;*/
|
||||
}
|
||||
|
||||
public static string Programgroup_Numder { get; set; }
|
||||
public static string Programgroup_ID { get; set; }
|
||||
@@ -152,6 +72,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
Remark.IsEnabled = true;
|
||||
Delete.IsEnabled = true;
|
||||
}
|
||||
|
||||
private void Grid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)//双击表格编辑事件
|
||||
{
|
||||
|
||||
@@ -169,12 +90,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
InputBox frm = (InputBox)sender;
|
||||
//接收到InputBox的TextBox值
|
||||
string VALUE = frm.InputValue;
|
||||
|
||||
string ID = DateTime.Now.ToString("yyMMddHHmmss"); //id为时间合
|
||||
|
||||
Dictionary<string, object> Program_new = new Dictionary<string, object>();//缓存函数
|
||||
Program_new.Add("ProgramName", VALUE);
|
||||
Program_new.Add("ProgramID", ID);
|
||||
Program_new.Add("Groups", Group.Text);
|
||||
Program_new.Add("Step", "0");
|
||||
Program_new.Add("Time", "0:00");
|
||||
Program_new.Add("Notes", null);
|
||||
@@ -190,7 +110,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
Programgroup_sql();
|
||||
}
|
||||
|
||||
private void ListViewItem_edit(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
private void ListViewItem_edit(object sender, System.Windows.Input.MouseButtonEventArgs e)//编辑事件
|
||||
{
|
||||
edit.IsEnabled = false;
|
||||
Rename.IsEnabled = false;
|
||||
@@ -198,29 +118,72 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
Delete.IsEnabled = false;
|
||||
}
|
||||
|
||||
private void ListViewItem_Rename(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
private void ListViewItem_Rename(object sender, System.Windows.Input.MouseButtonEventArgs e)//重命名
|
||||
{
|
||||
edit.IsEnabled = false;
|
||||
Rename.IsEnabled = false;
|
||||
Remark.IsEnabled = false;
|
||||
Delete.IsEnabled = false;
|
||||
Delete.IsEnabled = false;
|
||||
if (Programgroup_ID == null) return;
|
||||
InputBox frm = new InputBox();
|
||||
frm.Accept += new EventHandler(InputBox_Rename_accept);
|
||||
frm.ShowDialog();
|
||||
}
|
||||
void InputBox_Rename_accept(object sender, EventArgs e)//重命名按钮窗口返回
|
||||
{
|
||||
//事件的接收者通过一个简单的类型转换得到InputBox的引用
|
||||
InputBox frm = (InputBox)sender;
|
||||
//接收到InputBox的TextBox值
|
||||
string VALUE = frm.InputValue;
|
||||
Dictionary<string, object> Program_Rename = new Dictionary<string, object>();//缓存函数
|
||||
Program_Rename.Add("ProgramName", VALUE);
|
||||
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
SQLiteHelpers.Update("ProgramName", Program_Rename, "ProgramID='" + Programgroup_ID + "'", null);
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
|
||||
Programgroup_sql();
|
||||
Programgroup_Numder = null;
|
||||
Programgroup_ID = null;
|
||||
}
|
||||
|
||||
private void ListViewItem_Remark(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
private void ListViewItem_Remark(object sender, System.Windows.Input.MouseButtonEventArgs e)//备注
|
||||
{
|
||||
edit.IsEnabled = false;
|
||||
Rename.IsEnabled = false;
|
||||
Remark.IsEnabled = false;
|
||||
Delete.IsEnabled = false;
|
||||
if (Programgroup_ID == null) return;
|
||||
InputBox frm = new InputBox();
|
||||
frm.Accept += new EventHandler(InputBox_Remark_accept);
|
||||
frm.ShowDialog();
|
||||
}
|
||||
void InputBox_Remark_accept(object sender, EventArgs e)//备注按钮窗口返回
|
||||
{
|
||||
//事件的接收者通过一个简单的类型转换得到InputBox的引用
|
||||
InputBox frm = (InputBox)sender;
|
||||
//接收到InputBox的TextBox值
|
||||
string VALUE = frm.InputValue;
|
||||
Dictionary<string, object> Program_Remark = new Dictionary<string, object>();//缓存函数
|
||||
Program_Remark.Add("Notes", VALUE);
|
||||
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
SQLiteHelpers.Update("ProgramName", Program_Remark, "ProgramID='" + Programgroup_ID + "'", null);
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
|
||||
Programgroup_sql();
|
||||
Programgroup_Numder = null;
|
||||
Programgroup_ID = null;
|
||||
}
|
||||
|
||||
private void ListViewItem_Delete(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
private void ListViewItem_Delete(object sender, System.Windows.Input.MouseButtonEventArgs e)//删除
|
||||
{
|
||||
edit.IsEnabled = false;
|
||||
Rename.IsEnabled = false;
|
||||
Remark.IsEnabled = false;
|
||||
Delete.IsEnabled = false;
|
||||
|
||||
if (Programgroup_Numder == null) return;
|
||||
///弹窗提示确认删除
|
||||
if (System.Windows.Forms.MessageBox.Show(Properties.Resources.Confirm + Properties.Resources.Delete + Programgroup_Numder, "Delete ",
|
||||
@@ -236,14 +199,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
Programgroup_Numder = null;
|
||||
Programgroup_ID = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<UserControl x:Class="SunlightCentralizedControlManagement_SCCM_.View.ProgramstepsView "
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
|
||||
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
|
||||
xmlns:ConvertMoels="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ConvertMoels"
|
||||
mc:Ignorable="d" Loaded="UserControl_Loaded"
|
||||
d:DesignHeight="630" d:DesignWidth="1280">
|
||||
<UserControl.Resources>
|
||||
<ConvertMoels:RowToIndexConverter x:Key="RowToIndexConverter"/>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Rectangle Margin="0,0,0,0" Fill="#FFCCCCCC" VerticalAlignment="Top" Height="40"/>
|
||||
<Button Content="{x:Static lang:Resources.edit}" x:Name="ProgramgroupView_edit" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="0,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_edit_Click"/>
|
||||
<Button Content="{x:Static lang:Resources.Quit}" x:Name="ProgramgroupView_Quit" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="400,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Quit_Click"/>
|
||||
<Button Content="{x:Static lang:Resources.Delete}" x:Name="ProgramgroupView_del" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="800,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_del_Click"/>
|
||||
<Button Content="{x:Static lang:Resources.Insert}" x:Name="ProgramgroupView_Insert" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="200,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Insert_Click"/>
|
||||
<Button Content="{x:Static lang:Resources.Save}" x:Name="ProgramgroupView_Save" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="600,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Save_Click"/>
|
||||
<TextBlock x:Name="p_title" FontSize="20" VerticalAlignment="Top" Height="40" Margin="1000,0,0,0" />
|
||||
|
||||
<DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_SelectionChanged"
|
||||
Margin="0,40,0,0" d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
|
||||
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" AllowDrop="False"
|
||||
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
||||
CanUserAddRows="True" CanUserDeleteRows="False" HeadersVisibility ="Column"
|
||||
Background="White" SelectionMode="Single" FontSize="15">
|
||||
<DataGrid.RowStyle >
|
||||
<Style TargetType="{x:Type DataGridRow}">
|
||||
<Setter Property="Height" Value="30" />
|
||||
<Setter Property="FontSize" Value="25" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
|
||||
<Setter Property="Background" Value="#FFFFFFFF" />
|
||||
</Trigger>
|
||||
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
|
||||
<Setter Property="Background" Value="#FFF0F0F0" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="False"/>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.CellStyle>
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="MinWidth" Value="20"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#FFC0C0C0"/>
|
||||
<Setter Property="BorderBrush" Value="#FFC0C0C0"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.CellStyle>
|
||||
|
||||
<DataGrid.Columns>
|
||||
<!--列信息绑定-->
|
||||
<DataGridTextColumn Binding="{Binding ProgramID}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
<DataGridTextColumn Binding="{Binding Program}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:Resources.Step}" Binding="{Binding Step}" Width="60" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:Resources.Code}" Width="100" Binding="{Binding StepID}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:Resources.Directives}" Width="300" Binding="{Binding StepName}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:Resources.ParameterSet}" Width="*" Binding="{Binding ParameterName}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Binding="{Binding Parameter1}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
<DataGridTextColumn Binding="{Binding Parameter2}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
<DataGridTextColumn Binding="{Binding Parameter3}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
<DataGridTextColumn Binding="{Binding Parameter4}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
<DataGridTextColumn Binding="{Binding Parameter5}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
<DataGridTextColumn Binding="{Binding Parameter6}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
<DataGridTextColumn Binding="{Binding Parameter7}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
<DataGridTextColumn Binding="{Binding Parameter8}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
<DataGridTextColumn Binding="{Binding Parameter9}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
<DataGridTextColumn Binding="{Binding Parameter10}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,241 @@
|
||||
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Entity;
|
||||
using System.Data.SQLite;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||
//using static SunlightCentralizedControlManagement_SCCM_.Windows.ViewStep;
|
||||
|
||||
namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
{
|
||||
/// <summary>
|
||||
/// ProgramgroupView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ProgramstepsView : UserControl
|
||||
{
|
||||
public ProgramstepsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ProgramID = ProgramgroupView.Programgroup_ID;
|
||||
ProgramNAME = ProgramgroupView.Programgroup_Numder;
|
||||
this.p_title.Text = ProgramNAME;
|
||||
|
||||
Programgroup_sql();
|
||||
}
|
||||
|
||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
||||
DataSet sql; //内存数据缓存
|
||||
|
||||
string ProgramID;
|
||||
string ProgramNAME;
|
||||
|
||||
public void Programgroup_sql()
|
||||
{
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
|
||||
string sql_script = "select * from ProgramSteps where ProgramID='" + ProgramID + "' order by Step asc";
|
||||
|
||||
if (sql != null) sql.Clear(); //清空缓存
|
||||
sql = SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取计划表写入缓存
|
||||
//sql.Tables[0].Rows.Add(datatable_t);
|
||||
DataRow dr = sql.Tables[0].NewRow();//添加表数据
|
||||
dr["ProgramID"] = ProgramID;
|
||||
dr["Program"] = ProgramNAME;
|
||||
sql.Tables[0].Rows.Add(dr);
|
||||
Dat();
|
||||
if (sql != null) Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
|
||||
//sql.Clear(); //清除缓存
|
||||
//System.GC.Collect();
|
||||
}
|
||||
|
||||
public void Dat()//行号刷新
|
||||
{
|
||||
int a = sql.Tables[0].Rows.Count;
|
||||
for (int i = 0; i < a; i++)
|
||||
{
|
||||
DataRow dr = sql.Tables[0].Rows[i];
|
||||
dr.BeginEdit();
|
||||
dr["Step"] = i + 1;
|
||||
dr.EndEdit();
|
||||
}
|
||||
}
|
||||
|
||||
string Numder = null;
|
||||
string ID = null;
|
||||
string P1, P2, P3, P4, P5;
|
||||
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)//表格选择事件
|
||||
{
|
||||
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
|
||||
if (rownum != -1)//判断鼠标定位是否有效
|
||||
{
|
||||
ID = (Grid.Columns[2].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
||||
Numder = (Grid.Columns[3].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
||||
P1 = (Grid.Columns[6].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第6列,
|
||||
P2 = (Grid.Columns[7].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第7列,
|
||||
P3 = (Grid.Columns[8].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第8列,
|
||||
P4 = (Grid.Columns[9].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第9列,
|
||||
P5 = (Grid.Columns[10].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第10列,
|
||||
}
|
||||
}
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)//打开页面时的操作
|
||||
{
|
||||
if (ID == null) ID = sql.Tables[0].Rows.Count.ToString();
|
||||
Grid.SelectedIndex = Convert.ToInt32(ID)-1;
|
||||
}
|
||||
public static T GetVisualChild<T>(Visual parent) where T : Visual
|
||||
{
|
||||
T child = default(T);
|
||||
int numVisuals = VisualTreeHelper.GetChildrenCount(parent);
|
||||
for (int i = 0; i < numVisuals; i++)
|
||||
{
|
||||
Visual v = (Visual)VisualTreeHelper.GetChild(parent, i);
|
||||
child = v as T;
|
||||
if (child == null)
|
||||
{
|
||||
child = GetVisualChild<T>(v);
|
||||
}
|
||||
if (child != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
private void ProgramgroupView_edit_Click(object sender, RoutedEventArgs e)//编辑
|
||||
{
|
||||
/* if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0";P2 = "0";P3 = "0";P4 = "0";P5 = "0"; }
|
||||
if (ID == null) ID = sql.Tables[0].Rows.Count.ToString();
|
||||
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
|
||||
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
|
||||
viewstop.data = ID;
|
||||
viewstop.ShowDialog();*/
|
||||
}
|
||||
/* private void Address_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
|
||||
{
|
||||
int i = sql.Tables[0].Rows.Count;
|
||||
int n = StrToInt.To16Convert10(ID);
|
||||
if (i == n)
|
||||
{
|
||||
DataRow dr_ = sql.Tables[0].NewRow();//添加表数据
|
||||
dr_["ProgramID"] = ProgramID;
|
||||
dr_["Program"] = ProgramNAME;
|
||||
sql.Tables[0].Rows.Add(dr_);
|
||||
Dat();
|
||||
ID = (n+1).ToString();
|
||||
}
|
||||
|
||||
DataRow dr = sql.Tables[0].Rows[n-1];
|
||||
dr.BeginEdit();
|
||||
dr["StepID"] = e.StepID;
|
||||
dr["StepName"] = e.StepNAME;
|
||||
dr["ParameterName"] = e.PNAME;
|
||||
dr["Parameter1"] = e.P1;
|
||||
dr["Parameter2"] = e.P2;
|
||||
dr["Parameter3"] = e.P3;
|
||||
dr["Parameter4"] = e.P4;
|
||||
dr["Parameter5"] = e.P5;
|
||||
dr.EndEdit();
|
||||
|
||||
Grid.ItemsSource = sql.Tables[0].DefaultView;
|
||||
}
|
||||
*/
|
||||
private void ProgramgroupView_Quit_Click(object sender, RoutedEventArgs e)//退出
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;//隐藏控件
|
||||
}
|
||||
|
||||
private void ProgramgroupView_del_Click(object sender, RoutedEventArgs e)//删除行
|
||||
{
|
||||
int d = 0;
|
||||
int a = sql.Tables[0].Rows.Count;
|
||||
|
||||
if (ID != null) { d = Convert.ToInt32(ID); } else { return; }
|
||||
if (a != d)//如果删除不是最后一行执行
|
||||
{
|
||||
sql.Tables[0].Rows.RemoveAt(d - 1);
|
||||
|
||||
Dat();
|
||||
Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
||||
}
|
||||
}
|
||||
|
||||
private void ProgramgroupView_Insert_Click(object sender, RoutedEventArgs e)//插入行
|
||||
{
|
||||
int d = 0;
|
||||
if (ID != null) { d = Convert.ToInt32(ID); } else { return; }
|
||||
DataRow dr = sql.Tables[0].NewRow();//添加表数据
|
||||
dr["ProgramID"] = ProgramID;
|
||||
dr["Program"] = ProgramNAME;
|
||||
sql.Tables[0].Rows.InsertAt(dr, d - 1);
|
||||
ID = null;
|
||||
|
||||
Dat();
|
||||
Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
||||
}
|
||||
|
||||
private void ProgramgroupView_Save_Click(object sender, RoutedEventArgs e)//保存
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
SQLiteHelpers.Delete("ProgramSteps", "ProgramID = '" + ProgramID + "'", null);
|
||||
|
||||
DataTable data_t = new DataTable();
|
||||
data_t = sql.Tables[0].Clone();
|
||||
|
||||
int a = sql.Tables[0].Rows.Count;
|
||||
for (int i = 0; i < a - 1; i++)
|
||||
{
|
||||
data_t.Clear();//清空
|
||||
|
||||
DataRow dt = sql.Tables[0].Rows[i];//行转换
|
||||
DataRow dr = data_t.NewRow();
|
||||
dr.ItemArray = dt.ItemArray;
|
||||
data_t.Rows.InsertAt(dr, 0);
|
||||
|
||||
r = SQLiteHelpers.InsertData("ProgramSteps", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
||||
}
|
||||
|
||||
Dictionary<string, object> Program_Step = new Dictionary<string, object>();//缓存函数
|
||||
Program_Step.Add("Step", a-1);
|
||||
SQLiteHelpers.Update("ProgramName", Program_Step, "ProgramID='" + ProgramID + "'", null);
|
||||
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
if (r != 0)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show(ProgramNAME, Properties.Resources.Save);
|
||||
this.Visibility = Visibility.Collapsed;//隐藏控件
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user