|
|
|
using DyeingComputer.UserClass;
|
|
|
|
using DyeingComputer.ViewModel;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Data;
|
|
|
|
using System.Linq;
|
|
|
|
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>
|
|
|
|
/// TechnologicalProcessView.xaml 的交互逻辑
|
|
|
|
/// </summary>
|
|
|
|
public partial class TechnologicalProcessView : UserControl
|
|
|
|
{
|
|
|
|
public TechnologicalProcessView()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static object workName;
|
|
|
|
|
|
|
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
|
|
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
|
|
|
DataSet sql; //内存数据缓存
|
|
|
|
|
|
|
|
public void TechnologicalProcess_sql()
|
|
|
|
{
|
|
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
|
|
int r = 0;
|
|
|
|
string sql_script = "select * from ProgramSteps where ProgramID = '" + workName + "'";
|
|
|
|
|
|
|
|
if (sql != null) sql.Clear(); //清空缓存
|
|
|
|
sql = SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取表写入缓存
|
|
|
|
name.Text = SQLiteHelpers.ExecuteScalar("select ProgramName from ProgramName where ProgramID = '" + workName + "'", null).ToString();
|
|
|
|
if (sql != null) Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
|
|
|
|
|
|
|
SQLiteHelpers.Delete("RUN",null,null);
|
|
|
|
DataTable data_t = new DataTable();
|
|
|
|
data_t = sql.Tables[0].Clone();
|
|
|
|
data_t.Columns.Add("DYELOT",typeof(string));
|
|
|
|
int a = sql.Tables[0].Rows.Count;
|
|
|
|
for (int i = 0; i < a; i++)
|
|
|
|
{
|
|
|
|
data_t.Clear();//清空
|
|
|
|
DataRow dt = sql.Tables[0].Rows[i];//行转
|
|
|
|
DataRow dr = data_t.NewRow();
|
|
|
|
dr.ItemArray = dt.ItemArray;
|
|
|
|
dr.BeginEdit(); //添加订单号
|
|
|
|
dr["DYELOT"] = MainWindowViewModel.WorkNumder;
|
|
|
|
dr.EndEdit();
|
|
|
|
data_t.Rows.InsertAt(dr, 0); //行转换
|
|
|
|
|
|
|
|
r = SQLiteHelpers.InsertData("RUN", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
|
|
|
}
|
|
|
|
SQLiteHelpers.Close(); //关闭连接
|
|
|
|
}
|
|
|
|
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
if(workName !=null) TechnologicalProcess_sql();
|
|
|
|
//Grid.SelectedIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|