Files
CleanMachine/CleanMachineHMI/frmChild/frmEditCleanCode.cs
gongxh f3e77f63c0 11
2022-05-16 09:03:42 +08:00

108 lines
4.0 KiB
C#

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 frmEditCleanCode : KryptonForm
{
public frmEditCleanCode()
{
InitializeComponent();
}
public string CleanModeId { get; set; }
private void frmAddCleanCode_Load(object sender, EventArgs e)
{
InitControlEvent();
this.SetFormControlText();
}
private void txt_GotFocus(object sender, EventArgs e)
{
KeyboardAutoPopUp.ShowInputPanel();
}
private void txt_LostFocus(object sender, EventArgs e)
{
KeyboardAutoPopUp.HideInputPanel();
}
private void InitControlEvent()
{
txtCleanModeCode.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
txtCleanModeCode.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
txtCleanModeName.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
txtCleanModeName.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
}
private void frmEditCleanCode_Load(object sender, EventArgs e)
{
try
{
InitControlEvent();
string sql = $@"SELECT * FROM BAS_CLEAN_MODE WHERE CLEAN_MODE_ID = '{CleanModeId}'";
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
txtCleanModeCode.Text = dt.Rows[0]["CLEAN_MODE_CODE"].ToString();
txtCleanModeCode.Enabled = false;
txtCleanModeName.Text = dt.Rows[0]["CLEAN_MODE_NAME"].ToString();
}
this.SetFormControlText();
kryptonPanel1.Focus();
}
catch (Exception ex)
{
KryptonMessageBox.Show(this.T("修改清洁方式数据界面加载异常", "LoadEditFrmExp") + $":【{ex.Message}】!");
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(txtCleanModeName.Text))
{
//KryptonMessageBox.Show("请输入板材名称!");
KryptonMessageBox.Show(this.T("请输入清洗方式名称!", "EnterCleanNameInfo"));
return;
}
string sql = $@"update BAS_CLEAN_MODE set CLEAN_MODE_NAME = '{txtCleanModeName.Text}',UPDATE_BY = '{Global.UserInfo.UserId}',UPDATE_TIME = datetime('now', 'localtime') where CLEAN_MODE_ID = '{CleanModeId}'";
int row = LeadDbHelperSQLite.Execute(sql);
if (row > 0)
{
//KryptonMessageBox.Show("修改清洗方式数据成功!");
KryptonMessageBox.Show(this.T("编辑清洗方式数据成功!", "EditSuccessInfo"));
frmCleanMode.RefreshFrmHost();
this.Close();
}
else
{
//KryptonMessageBox.Show("修改清洗方式数据失败!");
KryptonMessageBox.Show(this.T("编辑清洗方式数据失败!", "EditFailInfo"));
}
}
catch (Exception ex)
{
KryptonMessageBox.Show(this.T("编辑清洗方式数据发生异常", "EditCleanModeDataExp") + $":【{ex.Message}】!");
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}