using CleanMachineHMI.forms; using CleanMachineHMI.FrmUserControl; 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.frmChild { public partial class frmEditParamater : KryptonForm { public frmEditParamater() { InitializeComponent(); } public string ParamaterId { get; set; } private void txt_GotFocus(object sender, EventArgs e) { KeyboardAutoPopUp.ShowInputPanel(); } private void txt_LostFocus(object sender, EventArgs e) { KeyboardAutoPopUp.HideInputPanel(); } private void InitControlEvent() { txtValue.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件 txtValue.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件 } private void frmEditParamater_Load(object sender, EventArgs e) { try { InitControlEvent(); this.SetFormControlText(); string sql = $@"SELECT * FROM SYS_PARAMETER WHERE PARAMETER_ID = '{ParamaterId}'"; DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0]; if (dt != null && dt.Rows.Count > 0) { txtKey.Text = dt.Rows[0]["PARAMETER_CODE"].ToString(); txtKey.Enabled = false; txtValue.Text = dt.Rows[0]["PARAMETER_VALUE"].ToString(); } kryptonPanel1.Focus(); } catch (Exception ex) { KryptonMessageBox.Show(this.T("编辑参数数据界面加载异常", "LoadEditFrmExp") + $":【{ex.Message}】!"); } } private void btnAdd_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtValue.Text)) { //KryptonMessageBox.Show("请输入参数值!"); KryptonMessageBox.Show(this.T("请输入参数值!", "EnterparamaterVlaueInfo")); return; } string sql = $@"update SYS_PARAMETER set PARAMETER_VALUE = '{txtValue.Text}',UPDATE_BY = '{Global.UserInfo.UserId}',UPDATE_TIME = datetime('now', 'localtime') where PARAMETER_ID = '{ParamaterId}'"; int row = LeadDbHelperSQLite.Execute(sql); if (row > 0) { //KryptonMessageBox.Show("修改参数信息数据成功!"); KryptonMessageBox.Show(this.T("编辑参数数据成功!", "EditSuccessInfo")); frmParamater.RefreshFrmHost(); this.Close(); } else { //KryptonMessageBox.Show("修改参数信息数据失败!"); KryptonMessageBox.Show(this.T("编辑参数数据失败!", "EditFailInfo")); } } catch (Exception ex) { KryptonMessageBox.Show(this.T("编辑参数数据发生异常", "EditParamaterDataExp") + $":【{ex.Message}】!"); } } private void btnEdit_Click(object sender, EventArgs e) { this.Close(); } } }