Files
CleanMachine/CleanMachineHMI/frmChild/frmEditContaminationDtl.cs

136 lines
6.1 KiB
C#
Raw Normal View History

2021-06-05 14:17:30 +08:00
using CleanMachineHMI.forms;
using CleanMachineHMI.FrmUserControl;
using CleanMachineHMI.Utils;
2021-12-26 21:30:02 +08:00
using Krypton.Toolkit;
2021-06-05 14:17:30 +08:00
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;
2021-12-27 09:51:57 +08:00
2021-06-05 14:17:30 +08:00
using System.Windows.Forms;
namespace CleanMachineHMI.frmChild
{
public partial class frmEditContaminationDtl : KryptonForm
{
public frmEditContaminationDtl()
{
InitializeComponent();
_InfoLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode);
}
private DataTable _InfoLanguageTextList;
public string ContaminationDtlId { 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()
{
txtContaminationDTLCode.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
txtContaminationDTLCode.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
txtContaminationDTLName.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
txtContaminationDTLName.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
}
private void frmEditContaminationDtl_Load(object sender, EventArgs e)
{
try
{
InitControlEvent();
2022-03-18 19:06:26 +08:00
this.SetFormControlText();
2021-06-05 14:17:30 +08:00
string sql = $@"select CONTAMINATION_TYPE_CODE,CONTAMINATION_TYPE_NAME from BAS_CONTAMINATION_TYPE where DEL_FLAG=0";
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
cmbContaminationType.Items.Add(new ListItem
{
Value = "0",
Text = "Please Select",
});
foreach (DataRow item in dt.Rows)
{
cmbContaminationType.Items.Add(new ListItem
{
Value = item["CONTAMINATION_TYPE_CODE"].ToString(),
Text = item["CONTAMINATION_TYPE_NAME"].ToString(),
});
}
cmbContaminationType.SelectedIndex = 0;
}
string sql1 = $@"SELECT B.CONTAMINATION_TYPE_CODE,B.CONTAMINATION_TYPE_NAME,A.CONTAMINATION_DTL_CODE,A.CONTAMINATION_DTL_NAME FROM BAS_CONTAMINATION_DTL A LEFT JOIN BAS_CONTAMINATION_TYPE B ON A.CONTAMINATION_TYPE_CODE = B.CONTAMINATION_TYPE_CODE WHERE A.CONTAMINATION_DTL_ID = '{ContaminationDtlId}'";
DataTable dt1 = LeadDbHelperSQLite.Query(sql1).Tables[0];
if (dt1 != null && dt1.Rows.Count > 0)
{
txtContaminationDTLCode.Text = dt1.Rows[0]["CONTAMINATION_DTL_CODE"].ToString();
txtContaminationDTLCode.Enabled = false;
txtContaminationDTLName.Text = dt1.Rows[0]["CONTAMINATION_DTL_NAME"].ToString();
cmbContaminationType.Text = dt1.Rows[0]["CONTAMINATION_TYPE_NAME"].ToString();
cmbContaminationType.Enabled = false;
}
kryptonPanel1.Focus();
}
catch (Exception ex)
{
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("编辑污染明细数据界面加载异常", "LoadEditFrmExp") + $":【{ex.Message}】!");
2021-06-05 14:17:30 +08:00
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
try
{
if (cmbContaminationType.SelectedIndex == 0)
{
//KryptonMessageBox.Show("请选择污染类型!");
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("请选择污染类型!", "SelectContaminationTypeInfo"));
2021-06-05 14:17:30 +08:00
return;
}
if (string.IsNullOrEmpty(txtContaminationDTLCode.Text))
{
//KryptonMessageBox.Show("请输入污染明细编码!");
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("请输入污染明细编码!", "EnterContaminationDtlCodeInfo"));
2021-06-05 14:17:30 +08:00
return;
}
if (string.IsNullOrEmpty(txtContaminationDTLName.Text))
{
//KryptonMessageBox.Show("请输入污染明细名称!");
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("请输入污染明细名称!", "EnterContaminationDtlNameInfo"));
2021-06-05 14:17:30 +08:00
return;
}
2021-12-31 16:27:14 +08:00
string sql = $@"update BAS_CONTAMINATION_DTL set CONTAMINATION_DTL_NAME = '{txtContaminationDTLName.Text}',UPDATE_BY = '{GlobalHelper.UserInfo.UserId}',UPDATE_TIME = datetime('now', 'localtime') where CONTAMINATION_DTL_ID = '{ContaminationDtlId}'";
2021-06-05 14:17:30 +08:00
int row = LeadDbHelperSQLite.ExecuteSql(sql);
if (row > 0)
{
//KryptonMessageBox.Show("修改污染明细数据成功!");
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("新增污染明细数据成功!", "EditSuccessInfo"));
2021-06-05 14:17:30 +08:00
frmContaminationDTL.RefreshFrmHost();
this.Close();
}
else
{
//KryptonMessageBox.Show("修改污染明细数据失败!");
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("新增污染明细数据失败!", "EditFailInfo"));
2021-06-05 14:17:30 +08:00
}
}
catch (Exception ex)
{
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("编辑污染明细数据发生异常", "EditContaminationDtlDataExp") + $":【{ex.Message}】!");
2021-06-05 14:17:30 +08:00
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}