11 changed files with 245 additions and 9 deletions
@ -0,0 +1,66 @@ |
|||||
|
<UserControl x:Class="DyeingComputer.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:DyeingComputer.View" |
||||
|
xmlns:lang="clr-namespace:DyeingComputer.Properties" |
||||
|
mc:Ignorable="d" |
||||
|
d:DesignHeight="630" d:DesignWidth="1280" HorizontalAlignment="Left"> |
||||
|
<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" /> |
||||
|
<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" /> |
||||
|
<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"/> |
||||
|
<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" /> |
||||
|
<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" /> |
||||
|
|
||||
|
<DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_SelectionChanged" |
||||
|
Margin="0,40,0,0" d:ItemsSource="{d:SampleData ItemCount=20}" 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"> |
||||
|
<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 Header="{x:Static lang:Resources.Step}" Width="60" Binding="{Binding ProgramName}" IsReadOnly="True"/> |
||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.Code}" Width="100" Binding="{Binding Step}" IsReadOnly="True"/> |
||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.Directives}" Width="200" Binding="{Binding Time}" IsReadOnly="True"/> |
||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.ParameterSet}" Width="*" Binding="{Binding Notes}" IsReadOnly="True"/> |
||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.Remark}" Width="*" Binding="{Binding Notes}" IsReadOnly="True"/> |
||||
|
</DataGrid.Columns> |
||||
|
</DataGrid> |
||||
|
|
||||
|
</Grid> |
||||
|
</UserControl> |
||||
@ -0,0 +1,69 @@ |
|||||
|
using DyeingComputer.UserClass; |
||||
|
using DyeingComputer.Windows; |
||||
|
using formula_manage.UserClass; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Data; |
||||
|
using System.Linq; |
||||
|
using System.Net; |
||||
|
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.Animation; |
||||
|
using System.Windows.Media.Imaging; |
||||
|
using System.Windows.Navigation; |
||||
|
using System.Windows.Shapes; |
||||
|
using static DyeingComputer.UserClass.SqliteHelper; |
||||
|
|
||||
|
namespace DyeingComputer.View |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// ProgramgroupView.xaml 的交互逻辑
|
||||
|
/// </summary>
|
||||
|
public partial class ProgramstepsView : UserControl |
||||
|
{ |
||||
|
public ProgramstepsView() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
Programgroup_sql(); |
||||
|
} |
||||
|
|
||||
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
||||
|
DataSet sql; //内存数据缓存
|
||||
|
|
||||
|
public void Programgroup_sql() |
||||
|
{ |
||||
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
|
SQLiteHelpers.Open(); //打开数据库
|
||||
|
|
||||
|
string sql_script = "select * from ProgramName order by ProgramID desc"; |
||||
|
|
||||
|
if (sql != null) sql.Clear(); //清空缓存
|
||||
|
sql = SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取计划表写入缓存
|
||||
|
// if (sql != null) Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
||||
|
|
||||
|
SQLiteHelpers.Close(); //关闭连接
|
||||
|
|
||||
|
//sql.Clear(); //清除缓存
|
||||
|
//System.GC.Collect();
|
||||
|
} |
||||
|
|
||||
|
string Programgroup_Numder = null; |
||||
|
string Programgroup_ID = null; |
||||
|
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)//表格选择事件
|
||||
|
{ |
||||
|
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
|
||||
|
if (rownum != -1)//判断鼠标定位是否有效
|
||||
|
{ |
||||
|
Programgroup_ID = (Grid.Columns[0].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
||||
|
Programgroup_Numder = (Grid.Columns[1].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue