|
@ -1,4 +1,5 @@ |
|
|
using SunlightCentralizedControlManagement_SCCM_.UserClass; |
|
|
using SunlightCentralizedControlManagement_SCCM_.UserClass; |
|
|
|
|
|
using SunlightCentralizedControlManagement_SCCM_.WindowsView; |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Data; |
|
|
using System.Data; |
|
@ -22,8 +23,10 @@ using System.Windows.Media.Animation; |
|
|
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 System.Xml.Linq; |
|
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper; |
|
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper; |
|
|
//using static SunlightCentralizedControlManagement_SCCM_.Windows.ViewStep;
|
|
|
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep; |
|
|
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement; |
|
|
|
|
|
|
|
|
namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
{ |
|
|
{ |
|
@ -49,7 +52,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
|
|
|
|
|
string ProgramID; |
|
|
string ProgramID; |
|
|
string ProgramNAME; |
|
|
string ProgramNAME; |
|
|
|
|
|
string Numder = null; |
|
|
|
|
|
string ID = null; |
|
|
|
|
|
string P1, P2, P3, P4, P5; |
|
|
public void Programgroup_sql() |
|
|
public void Programgroup_sql() |
|
|
{ |
|
|
{ |
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
@ -67,9 +72,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
Dat(); |
|
|
Dat(); |
|
|
if (sql != null) Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
|
|
if (sql != null) Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
|
|
SQLiteHelpers.Close(); //关闭连接
|
|
|
SQLiteHelpers.Close(); //关闭连接
|
|
|
|
|
|
|
|
|
//sql.Clear(); //清除缓存
|
|
|
|
|
|
//System.GC.Collect();
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void Dat()//行号刷新
|
|
|
public void Dat()//行号刷新
|
|
@ -84,24 +86,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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)//打开页面时的操作
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)//打开页面时的操作
|
|
|
{ |
|
|
{ |
|
|
if (ID == null) ID = sql.Tables[0].Rows.Count.ToString(); |
|
|
if (ID == null) ID = sql.Tables[0].Rows.Count.ToString(); |
|
@ -125,18 +109,69 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return child; |
|
|
return child; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void Grid_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)//表格选择事件
|
|
|
|
|
|
{ |
|
|
|
|
|
edit.IsEnabled = true; |
|
|
|
|
|
Insert.IsEnabled = true; |
|
|
|
|
|
Delete.IsEnabled = true; |
|
|
|
|
|
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 ProgramgroupView_edit_Click(object sender, RoutedEventArgs e)//编辑
|
|
|
private void Grid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)//双击表格编辑事件
|
|
|
{ |
|
|
{ |
|
|
/* if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0";P2 = "0";P3 = "0";P4 = "0";P5 = "0"; } |
|
|
edit.IsEnabled = true; |
|
|
|
|
|
Insert.IsEnabled = true; |
|
|
|
|
|
Delete.IsEnabled = true; |
|
|
|
|
|
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列,
|
|
|
|
|
|
|
|
|
|
|
|
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 ListViewItem_Quit(object sender, System.Windows.Input.MouseButtonEventArgs e)//退出事件
|
|
|
|
|
|
{ |
|
|
|
|
|
this.Visibility = Visibility.Collapsed;//隐藏控件
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void ListViewItem_edit(object sender, System.Windows.Input.MouseButtonEventArgs e)//编辑事件
|
|
|
|
|
|
{ |
|
|
|
|
|
edit.IsEnabled = false; |
|
|
|
|
|
Insert.IsEnabled = false; |
|
|
|
|
|
Delete.IsEnabled = false; |
|
|
|
|
|
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(); |
|
|
if (ID == null) ID = sql.Tables[0].Rows.Count.ToString(); |
|
|
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5); |
|
|
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5); |
|
|
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked); |
|
|
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked); |
|
|
viewstop.data = ID; |
|
|
viewstop.data = ID; |
|
|
viewstop.ShowDialog();*/ |
|
|
viewstop.ShowDialog(); |
|
|
} |
|
|
} |
|
|
/* private void Address_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
|
|
|
private void Address_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
|
|
|
{ |
|
|
{ |
|
|
int i = sql.Tables[0].Rows.Count; |
|
|
int i = sql.Tables[0].Rows.Count; |
|
|
int n = StrToInt.To16Convert10(ID); |
|
|
int n = StrToInt.To16Convert10(ID); |
|
@ -147,10 +182,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
dr_["Program"] = ProgramNAME; |
|
|
dr_["Program"] = ProgramNAME; |
|
|
sql.Tables[0].Rows.Add(dr_); |
|
|
sql.Tables[0].Rows.Add(dr_); |
|
|
Dat(); |
|
|
Dat(); |
|
|
ID = (n+1).ToString(); |
|
|
ID = (n + 1).ToString(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
DataRow dr = sql.Tables[0].Rows[n-1]; |
|
|
DataRow dr = sql.Tables[0].Rows[n - 1]; |
|
|
dr.BeginEdit(); |
|
|
dr.BeginEdit(); |
|
|
dr["StepID"] = e.StepID; |
|
|
dr["StepID"] = e.StepID; |
|
|
dr["StepName"] = e.StepNAME; |
|
|
dr["StepName"] = e.StepNAME; |
|
@ -164,30 +199,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
|
|
|
|
|
Grid.ItemsSource = sql.Tables[0].DefaultView; |
|
|
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)//插入行
|
|
|
private void ListViewItem_Insert(object sender, System.Windows.Input.MouseButtonEventArgs e)//插入事件
|
|
|
{ |
|
|
{ |
|
|
int d = 0; |
|
|
edit.IsEnabled = false; |
|
|
|
|
|
Insert.IsEnabled = false; |
|
|
|
|
|
Delete.IsEnabled = false; int d = 0; |
|
|
if (ID != null) { d = Convert.ToInt32(ID); } else { return; } |
|
|
if (ID != null) { d = Convert.ToInt32(ID); } else { return; } |
|
|
DataRow dr = sql.Tables[0].NewRow();//添加表数据
|
|
|
DataRow dr = sql.Tables[0].NewRow();//添加表数据
|
|
|
dr["ProgramID"] = ProgramID; |
|
|
dr["ProgramID"] = ProgramID; |
|
@ -199,8 +216,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
|
|
Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void ProgramgroupView_Save_Click(object sender, RoutedEventArgs e)//保存
|
|
|
private void ListViewItem_Save(object sender, System.Windows.Input.MouseButtonEventArgs e)//保存事件
|
|
|
{ |
|
|
{ |
|
|
|
|
|
edit.IsEnabled = false; |
|
|
|
|
|
Insert.IsEnabled = false; |
|
|
|
|
|
Delete.IsEnabled = false; |
|
|
int r = 0; |
|
|
int r = 0; |
|
|
|
|
|
|
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
@ -224,7 +244,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Dictionary<string, object> Program_Step = new Dictionary<string, object>();//缓存函数
|
|
|
Dictionary<string, object> Program_Step = new Dictionary<string, object>();//缓存函数
|
|
|
Program_Step.Add("Step", a-1); |
|
|
Program_Step.Add("Step", a - 1); |
|
|
SQLiteHelpers.Update("ProgramName", Program_Step, "ProgramID='" + ProgramID + "'", null); |
|
|
SQLiteHelpers.Update("ProgramName", Program_Step, "ProgramID='" + ProgramID + "'", null); |
|
|
|
|
|
|
|
|
SQLiteHelpers.Close(); //关闭连接
|
|
|
SQLiteHelpers.Close(); //关闭连接
|
|
@ -235,7 +255,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void ListViewItem_Delete(object sender, System.Windows.Input.MouseButtonEventArgs e)//删除事件
|
|
|
|
|
|
{ |
|
|
|
|
|
edit.IsEnabled = false; |
|
|
|
|
|
Insert.IsEnabled = false; |
|
|
|
|
|
Delete.IsEnabled = false; |
|
|
|
|
|
|
|
|
} |
|
|
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; //转换显示计划表
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|