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

131 lines
5.4 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 frmEditContaminationType : KryptonForm
{
public frmEditContaminationType()
{
InitializeComponent();
}
private void txt_GotFocus(object sender, EventArgs e)
{
KeyboardAutoPopUp.ShowInputPanel();
}
private void txt_LostFocus(object sender, EventArgs e)
{
KeyboardAutoPopUp.HideInputPanel();
}
private void InitControlEvent()
{
txtContaminationTypeCode.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
txtContaminationTypeCode.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
txtContaminationTypeName.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
txtContaminationTypeName.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
}
public string ContaminationId { get; set; }
private void frmEditContaminationType_Load(object sender, EventArgs e)
{
try
{
InitControlEvent();
this.SetFormControlText();
string sql = $@"select CLEAN_MODE_CODE,CLEAN_MODE_NAME from BAS_CLEAN_MODE where DEL_FLAG=0";
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
cmbCleanMode.Items.Add(new ListItem
{
Value = "0",
Text = "Please Select",
});
foreach (DataRow item in dt.Rows)
{
cmbCleanMode.Items.Add(new ListItem
{
Value = item["CLEAN_MODE_CODE"].ToString(),
Text = item["CLEAN_MODE_NAME"].ToString(),
});
}
cmbCleanMode.SelectedIndex = 0;
}
string sql1 = $@"SELECT A.CONTAMINATION_TYPE_CODE,A.CONTAMINATION_TYPE_NAME,B.CLEAN_MODE_CODE,B.CLEAN_MODE_NAME FROM BAS_CONTAMINATION_TYPE A LEFT JOIN BAS_CLEAN_MODE B ON A.CLEAN_MODE_CODE = B.CLEAN_MODE_CODE WHERE A.CONTAMINATION_TYPE_ID = '{ContaminationId}'";
DataTable dt1 = LeadDbHelperSQLite.Query(sql1).Tables[0];
if (dt1 != null && dt1.Rows.Count > 0)
{
txtContaminationTypeCode.Text = dt1.Rows[0]["CONTAMINATION_TYPE_CODE"].ToString();
txtContaminationTypeCode.Enabled = false;
txtContaminationTypeName.Text = dt1.Rows[0]["CONTAMINATION_TYPE_NAME"].ToString();
cmbCleanMode.Text = dt1.Rows[0]["CLEAN_MODE_NAME"].ToString();
cmbCleanMode.Enabled = false;
}
kryptonPanel1.Focus();
}
catch (Exception ex)
{
KryptonMessageBox.Show(this.T("编辑污染类型界面加载异常", "LoadEditFrmExp") + $":【{ex.Message}】!");
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
try
{
if (cmbCleanMode.SelectedIndex == 0)
{
KryptonMessageBox.Show(this.T("请选择清洗方式!", "SelectCleanModeInfo"));
return;
}
if (string.IsNullOrEmpty(txtContaminationTypeCode.Text))
{
KryptonMessageBox.Show(this.T("请输入污染类型编码!", "EnterContaminationTypeCodeInfo"));
return;
}
if (string.IsNullOrEmpty(txtContaminationTypeName.Text))
{
KryptonMessageBox.Show(this.T("请输入污染类型名称!", "EnterContaminationTypeNameInfo"));
return;
}
string sql = $@"update BAS_CONTAMINATION_TYPE set CONTAMINATION_TYPE_NAME = '{txtContaminationTypeName.Text}',UPDATE_BY = '{Global.UserInfo.UserId}',UPDATE_TIME = datetime('now', 'localtime') where CONTAMINATION_TYPE_ID = '{ContaminationId}'";
int row = LeadDbHelperSQLite.Execute(sql);
if (row > 0)
{
KryptonMessageBox.Show(this.T("编辑污染类型数据成功!", "EditSuccessInfo"));
frmContaminationType.RefreshFrmHost();
this.Close();
}
else
{
KryptonMessageBox.Show(this.T("编辑污染类型数据失败!", "EditFailInfo"));
}
}
catch (Exception ex)
{
KryptonMessageBox.Show(this.T("编辑污染类型数据发生异常", "EditContaminationTypeDataExp") + $":【{ex.Message}】!");
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}