using CleanMachineHMI.Domain.Enums; using CleanMachineHMI.Utils; using Krypton.Toolkit; 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) { Global.LoginForm.Show(); Global.MainFormNew.Hide(); } } }