Merge branch 'master' of http://www.scserverddns.top:13000/sc/DyeingComputer
This commit is contained in:
commit
7a6b2306f0
3 files changed
+114
-3
No files matched your search
@@ -43,7 +43,7 @@ namespace DyeingComputer.View
|
|||||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
SQLiteHelpers.Open(); //打开数据库
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
|
|
||||||
string sql_script = "select * from Parameters";
|
string sql_script = "select * from Parameters order by ParameterID asc";
|
||||||
|
|
||||||
if (sql != null) sql.Clear(); //清空缓存
|
if (sql != null) sql.Clear(); //清空缓存
|
||||||
sql = SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取计划表写入缓存
|
sql = SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取计划表写入缓存
|
||||||
|
|||||||
+44
-2
@@ -4,9 +4,51 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:DyeingComputer.View"
|
xmlns:local="clr-namespace:DyeingComputer.View"
|
||||||
mc:Ignorable="d"
|
xmlns:lang="clr-namespace:DyeingComputer.Properties"
|
||||||
|
mc:Ignorable="d" Loaded="UserControl_Loaded"
|
||||||
d:DesignHeight="630" d:DesignWidth="1280" VerticalAlignment="Top">
|
d:DesignHeight="630" d:DesignWidth="1280" VerticalAlignment="Top">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<DataGrid x:Name="Grid" AlternationCount="2" Margin="0,0,0,0" d:ItemsSource="{d:SampleData ItemCount=99}" AutoGenerateColumns="False"
|
||||||
|
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" InputMethod.IsInputMethodEnabled ="False"
|
||||||
|
CellEditEnding="Grid_CellEditEnding" Background="White" SelectionMode="Single" FontSize="15" Cursor="AppStarting" >
|
||||||
|
<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.Type}" Width="200" Binding="{Binding Category}" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.Code}" Width="200" Binding="{Binding ParameterID}" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.Directives}" Width="*" Binding="{Binding ParameterName}" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.ParameterSet}" Width="400" Binding="{Binding Value}"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Controls.Primitives;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
@@ -12,6 +14,7 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using static DyeingComputer.UserClass.SqliteHelper;
|
||||||
|
|
||||||
namespace DyeingComputer.View
|
namespace DyeingComputer.View
|
||||||
{
|
{
|
||||||
@@ -23,6 +26,72 @@ namespace DyeingComputer.View
|
|||||||
public SysSetView()
|
public SysSetView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
set_sql();
|
||||||
|
}
|
||||||
|
|
||||||
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||||
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
||||||
|
DataSet sql; //内存数据缓存
|
||||||
|
|
||||||
|
public void set_sql()
|
||||||
|
{
|
||||||
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
|
|
||||||
|
string sql_script = "select * from System order by ParameterID asc";
|
||||||
|
|
||||||
|
if (sql != null) sql.Clear(); //清空缓存
|
||||||
|
sql = SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取计划表写入缓存
|
||||||
|
if (sql != null) Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
||||||
|
SQLiteHelpers.Close(); //关闭连接
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Grid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)//数据表输入事件
|
||||||
|
{
|
||||||
|
string ID;
|
||||||
|
string newValue = (e.EditingElement as TextBox).Text;//获得输入单元格信息
|
||||||
|
|
||||||
|
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
|
||||||
|
if (rownum != -1)//判断鼠标定位是否有效
|
||||||
|
{
|
||||||
|
ID = (Grid.Columns[1].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
||||||
|
|
||||||
|
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
|
||||||
|
datagrid_v.Add("Value", newValue);
|
||||||
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
|
SQLiteHelpers.Update("System", datagrid_v, "ParameterID ='" + ID + "'", null);//更新
|
||||||
|
SQLiteHelpers.Close();//关闭数据库
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)//打开页面时的操作
|
||||||
|
{
|
||||||
|
DataGridRow dr = (DataGridRow)Grid.ItemContainerGenerator.ContainerFromIndex(0);//取第0行单元格
|
||||||
|
DataGridCellsPresenter presenter = GetVisualChild<DataGridCellsPresenter>(dr);
|
||||||
|
DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(3); //取第3列每行单元格
|
||||||
|
cell.Focus();
|
||||||
|
Grid.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user