Merge branch 'master' of http://scddns.f3322.net:13000/sc/Audit_APP
This commit is contained in:
commit
7118885ffe
3 files changed
+29
-6
No files matched your search
+7
-1
@@ -55,7 +55,13 @@
|
||||
</DataGrid.CellStyle>
|
||||
<DataGrid.Columns>
|
||||
<!--列信息绑定-->
|
||||
<DataGridTextColumn Header="序号" Width="50" FontSize="15" MaxWidth="50" MinWidth="20" CanUserReorder="False"/>
|
||||
<DataGridTemplateColumn Header=" 序号" Width="50" MinWidth="10" IsReadOnly="True">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock FontSize="15" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow}}, Path=Header}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"></TextBlock>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Header="原料代码" Width="130" FontSize="15" Binding="{Binding ProductCode}" MaxWidth="130" MinWidth="100" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="原料名称" Width="200" FontSize="15" Binding="{Binding ProductName}" MaxWidth="200" MinWidth="200" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="价格(¥/kg)" Width="100" FontSize="15" Binding="{Binding Price}" MaxWidth="100" MinWidth="100" CanUserReorder="False"/>
|
||||
|
||||
+13
-1
@@ -33,12 +33,23 @@ namespace Audit.View
|
||||
public StuffView()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataGridStuff.LoadingRow += new EventHandler<DataGridRowEventArgs>(this.DataGridEquipment_LoadingRow);//生成序列号
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成序列号的方法
|
||||
/// </summary>
|
||||
private void DataGridEquipment_LoadingRow(object sender, DataGridRowEventArgs e)
|
||||
{
|
||||
e.Row.Header = e.Row.GetIndex() + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 公共变量数组实体
|
||||
/// </summary>
|
||||
private Product product = new Product();//最终存入sql的实体
|
||||
private Product product_temp = new Product();//取出自sql的实体缓存
|
||||
public static Boolean Button_sql = false;
|
||||
|
||||
private void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件
|
||||
{
|
||||
@@ -89,7 +100,7 @@ namespace Audit.View
|
||||
new ProductProvider().Delete(product_temp);//删除数据库原目标信息。
|
||||
var count = new ProductProvider().Insert(product);//添加数据库信息。
|
||||
if (count == 0) System.Windows.MessageBox.Show("ERR.C0110-1:添加失败", "错误");//判断执行是否成功
|
||||
|
||||
else Button_sql = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +113,7 @@ namespace Audit.View
|
||||
{
|
||||
var count = new ProductProvider().Delete(product);//删除数据库目标信息。
|
||||
if (count == 0) System.Windows.MessageBox.Show("ERR.C0110-2:删除失败", "错误");//判断执行是否成功
|
||||
else Button_sql = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GalaSoft.MvvmLight;
|
||||
using Audit.View;
|
||||
using GalaSoft.MvvmLight;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -42,15 +43,19 @@ namespace Audit.ViewModel
|
||||
public StuffViewModel()
|
||||
{
|
||||
products = new ProductProvider().Select();
|
||||
DispatcherTimer timer = new DispatcherTimer();//每5秒调用一次Tick_Event
|
||||
timer.Interval = TimeSpan.FromSeconds(5);
|
||||
DispatcherTimer timer = new DispatcherTimer();//每0.5秒调用一次Tick_Event
|
||||
timer.Interval = TimeSpan.FromSeconds(0.5);
|
||||
timer.Tick += Tick_Event;
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
void Tick_Event(object sender, EventArgs e)
|
||||
{
|
||||
Product = new ProductProvider().Select();//扫描数据库
|
||||
if (StuffView.Button_sql == true)
|
||||
{
|
||||
Product = new ProductProvider().Select();
|
||||
StuffView.Button_sql = false;
|
||||
}//扫描数据库
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user