|
|
|
using DyeingComputer.UserClass;
|
|
|
|
using DyeingComputer.View;
|
|
|
|
using DyeingComputer.ViewModel;
|
|
|
|
using DyeingComputer.Windows;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
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.Imaging;
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
using static DyeingComputer.UserClass.SqliteHelper;
|
|
|
|
|
|
|
|
namespace DyeingComputer
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// MainWindow.xaml 的交互逻辑
|
|
|
|
/// </summary>
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
{
|
|
|
|
public MainWindow()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
SQLiteStrat();
|
|
|
|
|
|
|
|
DataContext = new MainWindowViewModel();//绑定后台
|
|
|
|
container.Content = new TechnologicalProcessView();//默认打开信息页面(TechnologicalProcessView)
|
|
|
|
MainWindowViewModel.ViewID = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SQLiteHelper SQLiteChartAdress = null; //定义数据库
|
|
|
|
public static SQLiteHelper SQLiteHelpers = null; //定义数据库
|
|
|
|
private readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
|
|
|
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 数据库检查读取
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
private bool SQLiteStrat()
|
|
|
|
{
|
|
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
|
|
|
|
|
|
SQLiteChartAdress = new SQLiteHelper(ChartAdress); //数据库连接路径
|
|
|
|
SQLiteChartAdress.Open(); //打开数据库
|
|
|
|
|
|
|
|
bool result_System = SQLiteHelpers.TableExists("System"); //检查表格是否存在(存在返回true)
|
|
|
|
bool result_IOName = SQLiteHelpers.TableExists("IOName");
|
|
|
|
bool result_ProgramName = SQLiteHelpers.TableExists("ProgramName");
|
|
|
|
bool result_ProgramSteps = SQLiteHelpers.TableExists("ProgramSteps");
|
|
|
|
bool result_RUN = SQLiteHelpers.TableExists("RUN");
|
|
|
|
bool result_Dyelot = SQLiteHelpers.TableExists("Dyelot");
|
|
|
|
bool result_Parameters = SQLiteHelpers.TableExists("Parameters");
|
|
|
|
bool result_WorkOrder = SQLiteHelpers.TableExists("WorkOrder");
|
|
|
|
bool result_WorkorderSteps = SQLiteHelpers.TableExists("WorkorderSteps");
|
|
|
|
|
|
|
|
if (!result_System) LogGing.LogGingDATA("Master_System_Table_Loss");
|
|
|
|
if (!result_IOName) LogGing.LogGingDATA("Master_IOName_Table_Loss");
|
|
|
|
if (!result_ProgramName) LogGing.LogGingDATA("Master_ProgramName_Table_Loss");
|
|
|
|
if (!result_ProgramSteps) LogGing.LogGingDATA("Master_ProgramSteps_Table_Loss");
|
|
|
|
if (!result_RUN) LogGing.LogGingDATA("Master_RUN_Table_Loss");
|
|
|
|
if (!result_Dyelot) LogGing.LogGingDATA("Master_Dyelot_Table_Loss");
|
|
|
|
if (!result_Parameters) LogGing.LogGingDATA("Master_Parameters_Table_Loss");
|
|
|
|
if (!result_WorkOrder) LogGing.LogGingDATA("Master_WorkOrder_Table_Loss");
|
|
|
|
if (!result_WorkorderSteps) LogGing.LogGingDATA("Master_WorkorderSteps_Table_Loss");
|
|
|
|
if (!result_System || !result_IOName || !result_ProgramName || !result_ProgramSteps || !result_RUN || !result_Dyelot || !result_Parameters || !result_WorkOrder || !result_WorkorderSteps)
|
|
|
|
{
|
|
|
|
// SQLiteHelpers.Close();
|
|
|
|
MessageBox.Show(Properties.Resources.SysDatLoss);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// SQLiteHelpers.Close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 工具栏状态
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
/// <param name="e"></param>
|
|
|
|
private void RadioButton_toolbar(object sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
if (!(sender is RadioButton button)) return;
|
|
|
|
if (string.IsNullOrEmpty(button.Name.ToString())) return;
|
|
|
|
switch (button.Name.ToString())
|
|
|
|
{
|
|
|
|
case "Next":
|
|
|
|
this.In_Out.Visibility = Visibility.Visible;
|
|
|
|
this.Sys_Set.Visibility = Visibility.Visible;
|
|
|
|
this.Parameter_Set.Visibility = Visibility.Visible;
|
|
|
|
this.Program_group.Visibility = Visibility.Visible;
|
|
|
|
this.Engineer_Set.Visibility = Visibility.Visible;
|
|
|
|
this.Previous.Visibility = Visibility.Visible;
|
|
|
|
this.Work_Order.Visibility = Visibility.Collapsed;
|
|
|
|
this.Technological_Process.Visibility = Visibility.Collapsed;
|
|
|
|
this.Curve_Diagram.Visibility = Visibility.Collapsed;
|
|
|
|
this.Equipment_Simulation.Visibility = Visibility.Collapsed;
|
|
|
|
this.History_Records.Visibility = Visibility.Collapsed;
|
|
|
|
this.Next.Visibility = Visibility.Collapsed;
|
|
|
|
break;
|
|
|
|
case "Previous":
|
|
|
|
this.In_Out.Visibility = Visibility.Collapsed;
|
|
|
|
this.Sys_Set.Visibility = Visibility.Collapsed;
|
|
|
|
this.Parameter_Set.Visibility = Visibility.Collapsed;
|
|
|
|
this.Program_group.Visibility = Visibility.Collapsed;
|
|
|
|
this.Engineer_Set.Visibility = Visibility.Collapsed;
|
|
|
|
this.Previous.Visibility = Visibility.Collapsed;
|
|
|
|
this.Work_Order.Visibility = Visibility.Visible;
|
|
|
|
this.Technological_Process.Visibility = Visibility.Visible;
|
|
|
|
this.Curve_Diagram.Visibility = Visibility.Visible;
|
|
|
|
this.Equipment_Simulation.Visibility = Visibility.Visible;
|
|
|
|
this.History_Records.Visibility = Visibility.Visible;
|
|
|
|
this.Next.Visibility = Visibility.Visible;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 功能页面
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
/// <param name="e"></param>
|
|
|
|
private void RadioButton_Page(object sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
if (!(sender is RadioButton button)) return;
|
|
|
|
if (string.IsNullOrEmpty(button.Name.ToString())) return;
|
|
|
|
switch (button.Name.ToString())
|
|
|
|
{
|
|
|
|
case "Work_Order":
|
|
|
|
container.Content = new WorkOrderView();
|
|
|
|
MainWindowViewModel.ViewID = 0;
|
|
|
|
break;
|
|
|
|
case "Technological_Process":
|
|
|
|
container.Content = new TechnologicalProcessView();
|
|
|
|
MainWindowViewModel.ViewID = 1;
|
|
|
|
break;
|
|
|
|
case "Curve_Diagram":
|
|
|
|
container.Content = new CurveDiagramView();
|
|
|
|
MainWindowViewModel.ViewID = 2;
|
|
|
|
break;
|
|
|
|
case "Equipment_Simulation":
|
|
|
|
container.Content = new EquipmentSimulationView();
|
|
|
|
MainWindowViewModel.ViewID = 3;
|
|
|
|
break;
|
|
|
|
case "History_Records":
|
|
|
|
container.Content = new HistoryRecordsView();
|
|
|
|
MainWindowViewModel.ViewID = 4;
|
|
|
|
break;
|
|
|
|
case "In_Out":
|
|
|
|
container.Content = new InOutView();
|
|
|
|
MainWindowViewModel.ViewID = 5;
|
|
|
|
break;
|
|
|
|
case "Sys_Set":
|
|
|
|
container.Content = new SysSetView();
|
|
|
|
MainWindowViewModel.ViewID = 6;
|
|
|
|
break;
|
|
|
|
case "Parameter_Set":
|
|
|
|
container.Content = new ParameterSetView();
|
|
|
|
MainWindowViewModel.ViewID = 7;
|
|
|
|
break;
|
|
|
|
case "Program_group":
|
|
|
|
container.Content = new ProgramgroupView();
|
|
|
|
MainWindowViewModel.ViewID = 8;
|
|
|
|
break;
|
|
|
|
case "Engineer_Set":
|
|
|
|
container.Content = new EngineerSetView();
|
|
|
|
MainWindowViewModel.ViewID = 9;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
|
{
|
|
|
|
((Image)sender).RenderTransform = new ScaleTransform(0.9,0.9);
|
|
|
|
}
|
|
|
|
private void Image_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
|
|
{
|
|
|
|
((Image)sender).RenderTransform = Transform.Identity;
|
|
|
|
MainWindowViewModel.UserInfoStart = 901;
|
|
|
|
MainWindowViewModel.UserInfo = Properties.Resources.Unlock;
|
|
|
|
}//解锁
|
|
|
|
|
|
|
|
private void Image_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
|
|
|
|
{
|
|
|
|
((Image)sender).RenderTransform = new ScaleTransform(0.9, 0.9);
|
|
|
|
}
|
|
|
|
private void Image_MouseLeftButtonUp_1(object sender, MouseButtonEventArgs e)
|
|
|
|
{
|
|
|
|
((Image)sender).RenderTransform = Transform.Identity;
|
|
|
|
MainWindowViewModel.UserInfoStart = 901;
|
|
|
|
if (MainWindowViewModel._AUTO_bool)
|
|
|
|
{ MainWindowViewModel.UserInfo = Properties.Resources.Auto; }
|
|
|
|
else { MainWindowViewModel.UserInfo = Properties.Resources.Manual; }
|
|
|
|
}//手动
|
|
|
|
}
|
|
|
|
}
|