Files

77 lines
2.9 KiB
C#
Raw Permalink Normal View History

2021-06-05 14:17:30 +08:00
using CleanMachineHMI.Domain.Enums;
using CleanMachineHMI.Utils;
2021-12-26 21:30:02 +08:00
using Krypton.Toolkit;
2021-06-05 14:17:30 +08:00
using LeadDataBaseUtility;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CleanMachineHMI.FrmUserControl
{
[FormType(EnumFormType.Maintenance)]
public partial class frmMaintenance : UserControl
{
public frmMaintenance()
{
InitializeComponent();
}
private void kbtn_Pass_Yes_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(kryptonTextBox1.Text))
{
KryptonMessageBox.Show("The code cannot be empty !");
return;
}
string sqlParam = $@"SELECT * FROM SYS_PARAMETER";
DataTable dtParam = LeadDbHelperSQLite.Query(sqlParam).Tables[0];
if (dtParam != null && dtParam.Rows.Count > 0)
{
string maintainRelieveCode = dtParam.Select("PARAMETER_CODE = 'MaintainRelieveCode'")[0]["PARAMETER_VALUE"].ToString();
if (kryptonTextBox1.Text == maintainRelieveCode)
{
bool canOperate = Convert.ToBoolean(PlcOperationHelper.Instance.ReadPlcItem("SelfCheckPassFlag", PlcItemTypeDesc.M));
//自检通过则切换至主界面,否则进入自检画面
if (canOperate)
{
frmMainNew.SwitchFrmMenu(EnumFormType.MainDetail, true);
}
else
{
frmMainNew.SwitchFrmMenu(EnumFormType.MechineCheck, true);
}
string sqlUpdateParam = $@"update SYS_PARAMETER set PARAMETER_VALUE = '0' WHERE PARAMETER_CODE = 'MaintainFlag'";
LeadDbHelperSQLite.ExecuteSql(sqlUpdateParam);
string sqlUpdateRunTimeLen = $@"UPDATE SYS_PARAMETER set PARAMETER_VALUE = '0' WHERE PARAMETER_CODE = 'SysRuningTimeLen'";
LeadDbHelperSQLite.ExecuteSql(sqlUpdateRunTimeLen);
frmMainNew.RemoveMaintainingFlag();
}
else
{
KryptonMessageBox.Show("Inputted maintenance uncode error !");
return;
}
}
}
catch (Exception ex)
{
KryptonMessageBox.Show(ex.Message);
}
}
private void btn_logout_Click(object sender, EventArgs e)
{
GlobalHelper.LoginForm.Show();
GlobalHelper.MainFormNew.Hide();
}
}
}