You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
181 lines
7.5 KiB
181 lines
7.5 KiB
using DyeingComputer.UserClass;
|
|
using DyeingComputer.Windows;
|
|
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 ProgramgroupView : UserControl
|
|
{
|
|
public ProgramgroupView()
|
|
{
|
|
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 = MainWindow.SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取计划表写入缓存
|
|
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)
|
|
{
|
|
if (Programgroup_ID == null) return;
|
|
|
|
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(); //打开数据库
|
|
MainWindow.SQLiteHelpers.InsertData("ProgramName", Program_new);// 执行插入
|
|
//SQLiteHelpers.Close(); //关闭连接
|
|
|
|
Programgroup_Numder = VALUE;
|
|
Programgroup_ID = ID;
|
|
|
|
Programgroup_sql();
|
|
}
|
|
|
|
private void ProgramgroupView_del_Click(object sender, RoutedEventArgs e)//删除
|
|
{
|
|
if(Programgroup_Numder == null)return;
|
|
///弹窗提示确认删除
|
|
if (System.Windows.Forms.MessageBox.Show(Properties.Resources.Confirm + Properties.Resources.Delete + Programgroup_Numder, "Delete ",
|
|
System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
|
|
{
|
|
///执行删除
|
|
//SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
//SQLiteHelpers.Open(); //打开数据库
|
|
MainWindow.SQLiteHelpers.Delete("ProgramName", "ProgramID='" + Programgroup_ID + "'", null);
|
|
//SQLiteHelpers.Close();
|
|
Programgroup_sql();
|
|
}
|
|
Programgroup_Numder = null;
|
|
Programgroup_ID = null;
|
|
}
|
|
|
|
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(); //打开数据库
|
|
MainWindow.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(); //打开数据库
|
|
MainWindow.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; }
|
|
|
|
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列,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|