165 lines
7.4 KiB
C#
165 lines
7.4 KiB
C#
|
|
using CleanMachineHMI.forms;
|
|||
|
|
using CleanMachineHMI.FrmUserControl;
|
|||
|
|
using CleanMachineHMI.Utils;
|
|||
|
|
using ComponentFactory.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.frmChild
|
|||
|
|
{
|
|||
|
|
public partial class frmAddWaringMsg : KryptonForm
|
|||
|
|
{
|
|||
|
|
public frmAddWaringMsg()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
_ComboBoxLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode, "KryptonComboBox");
|
|||
|
|
_InfoLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode);
|
|||
|
|
}
|
|||
|
|
private DataTable _ComboBoxLanguageTextList;
|
|||
|
|
private DataTable _InfoLanguageTextList;
|
|||
|
|
private void txt_GotFocus(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
KeyboardAutoPopUp.ShowInputPanel();
|
|||
|
|
}
|
|||
|
|
private void txt_LostFocus(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
KeyboardAutoPopUp.HideInputPanel();
|
|||
|
|
}
|
|||
|
|
private void InitControlEvent()
|
|||
|
|
{
|
|||
|
|
txtWarningCode.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
|||
|
|
txtWarningCode.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
|||
|
|
|
|||
|
|
txtWarningName.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
|||
|
|
txtWarningName.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
|||
|
|
|
|||
|
|
txtWarningMessage.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
|||
|
|
txtWarningMessage.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
|||
|
|
|
|||
|
|
ktb_PlcCode.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
|||
|
|
ktb_PlcCode.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void frmAddWaringMsg_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
InitControlEvent();
|
|||
|
|
this.SetFormControlText(GlobalHelper.LanguageCode);
|
|||
|
|
if (GlobalHelper.LanguageCode == "English")
|
|||
|
|
{
|
|||
|
|
kcmb_WarningType.Items.Clear();
|
|||
|
|
foreach (DataRow item in _ComboBoxLanguageTextList.GetComBoboxItemArr(kcmb_WarningType.Name, "KryptonComboBox"))
|
|||
|
|
{
|
|||
|
|
kcmb_WarningType.Items.Add(item["CONTROL_NAME"].ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
kcmb_WarningType.SelectedIndex = 0;
|
|||
|
|
kryptonPanel1.Focus();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(txtWarningCode.Text))
|
|||
|
|
{
|
|||
|
|
//KryptonMessageBox.Show("请输入报警条码!");
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入报警条码!", "EnterWarningCodeInfo"));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(txtWarningName.Text))
|
|||
|
|
{
|
|||
|
|
//KryptonMessageBox.Show("请输入报警名称!");
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入报警名称!", "EnterWarningNameInfo"));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (kcmb_WarningType.SelectedIndex == 0)
|
|||
|
|
{
|
|||
|
|
//KryptonMessageBox.Show("请选择报警类型!");
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请选择报警类型!", "SelectWarningTypeInfo"));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
string sqlIsExistCode = $@"SELECT 1 FROM BAS_WARNING WHERE WARNING_TYPE = '{kcmb_WarningType.SelectedIndex}' AND PLC_ITEM_CODE = '{ktb_PlcCode.Text}' AND WARNING_CODE = '{txtWarningCode.Text}'";
|
|||
|
|
DataTable dtIsExistCode = LeadDbHelperSQLite.Query(sqlIsExistCode).Tables[0];
|
|||
|
|
if (dtIsExistCode != null && dtIsExistCode.Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
//KryptonMessageBox.Show($"相同报警类类型:【{kcmb_WarningType.Text}】,PLC条码:【{ktb_PlcCode.Text}】的报警编码:【{txtWarningCode.Text}】已经存在,请重新输入!");
|
|||
|
|
KryptonMessageBox.Show($"Same alarm type: [{kcmb_WarningType.Text}],PLC item code: [{ktb_PlcCode.Text}] alarm code: [{txtWarningCode.Text}] already exists, please re-enter!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
string sql = $@"
|
|||
|
|
INSERT INTO BAS_WARNING (
|
|||
|
|
WARNING_CODE,
|
|||
|
|
WARNING_NAME,
|
|||
|
|
PLC_ITEM_CODE,
|
|||
|
|
WARNING_TYPE,
|
|||
|
|
WARNING_MESSAGE,
|
|||
|
|
USED_FLAG,
|
|||
|
|
DEL_FLAG,
|
|||
|
|
CREATE_BY,
|
|||
|
|
CREATE_TIME,
|
|||
|
|
UPDATE_BY,
|
|||
|
|
UPDATE_TIME,
|
|||
|
|
DATA_VERSION,
|
|||
|
|
REMARKS1,
|
|||
|
|
REMARKS2,
|
|||
|
|
REMARKS3,
|
|||
|
|
REMARKS4,
|
|||
|
|
REMARKS5
|
|||
|
|
)
|
|||
|
|
VALUES
|
|||
|
|
(
|
|||
|
|
'{txtWarningCode.Text}',
|
|||
|
|
'{txtWarningName.Text}',
|
|||
|
|
'{ktb_PlcCode.Text}',
|
|||
|
|
'{kcmb_WarningType.SelectedIndex}',
|
|||
|
|
'{txtWarningMessage.Text}',
|
|||
|
|
1,
|
|||
|
|
0,
|
|||
|
|
'{GlobalHelper.UserInfo.USER_ID}',
|
|||
|
|
datetime('now', 'localtime'),
|
|||
|
|
'{GlobalHelper.UserInfo.USER_ID}',
|
|||
|
|
datetime('now', 'localtime'),
|
|||
|
|
0,
|
|||
|
|
NULL,
|
|||
|
|
NULL,
|
|||
|
|
NULL,
|
|||
|
|
NULL,
|
|||
|
|
NULL
|
|||
|
|
);
|
|||
|
|
";
|
|||
|
|
int row = LeadDbHelperSQLite.ExecuteSql(sql);
|
|||
|
|
if (row > 0)
|
|||
|
|
{
|
|||
|
|
//KryptonMessageBox.Show("新增基础报警数据成功!");
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("新增基础报警数据成功!", "AddSuccessInfo"));
|
|||
|
|
frmWarning.RefreshFrmHost();
|
|||
|
|
this.Close();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//KryptonMessageBox.Show("新增基础报警数据失败!");
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("新增基础报警数据失败!", "AddFailInfo"));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
//KryptonMessageBox.Show(ex.Message);
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("新增基础报警数据发生异常", "AddWarningDataExp") + $":【{ex.Message}】!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnEdit_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.Close();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|