168 lines
7.1 KiB
C#
168 lines
7.1 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 frmAddContaminationType : KryptonForm
|
|
{
|
|
public frmAddContaminationType()
|
|
{
|
|
InitializeComponent();
|
|
_InfoLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode);
|
|
}
|
|
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()
|
|
{
|
|
txtContaminationTypeCode.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
|
txtContaminationTypeCode.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
|
|
|
txtContaminationTypeName.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
|
txtContaminationTypeName.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
|
}
|
|
|
|
private void frmAddContaminationType_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];
|
|
cmbCleanMode.DisplayMember = "Text";
|
|
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;
|
|
}
|
|
kryptonPanel1.Focus();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
KryptonMessageBox.Show(this.GetInfoText("新增污染类型界面加载异常", "LoadAddFrmExp") + $":【{ex.Message}】!");
|
|
}
|
|
}
|
|
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (cmbCleanMode.SelectedIndex == 0)
|
|
{
|
|
KryptonMessageBox.Show(this.GetInfoText("请选择清洗方式!", "SelectCleanModeInfo"));
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(txtContaminationTypeCode.Text))
|
|
{
|
|
//KryptonMessageBox.Show("请输入污染类型编码!");
|
|
KryptonMessageBox.Show(this.GetInfoText("请输入污染类型编码!", "EnterContaminationTypeCodeInfo"));
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(txtContaminationTypeName.Text))
|
|
{
|
|
//KryptonMessageBox.Show("请输入污染类型名称!");
|
|
KryptonMessageBox.Show(this.GetInfoText("请输入污染类型名称!", "EnterContaminationTypeNameInfo"));
|
|
return;
|
|
}
|
|
string sqlIsExistCode = $@"SELECT 1 FROM BAS_CONTAMINATION_TYPE WHERE CLEAN_MODE_CODE = '{((ListItem)cmbCleanMode.SelectedItem).Value}' AND CONTAMINATION_TYPE_CODE = '{txtContaminationTypeCode.Text}'";
|
|
DataTable dtIsExistCode = LeadDbHelperSQLite.Query(sqlIsExistCode).Tables[0];
|
|
if (dtIsExistCode != null && dtIsExistCode.Rows.Count > 0)
|
|
{
|
|
//KryptonMessageBox.Show($"污染类型条码:【{txtContaminationTypeCode.Text}】已经存在,请重新输入!");
|
|
KryptonMessageBox.Show($"Pollution type code: 【{txtContaminationTypeCode.Text}】already exist, please re-enter!");
|
|
return;
|
|
}
|
|
string sql = $@"
|
|
INSERT INTO BAS_CONTAMINATION_TYPE (
|
|
CONTAMINATION_TYPE_CODE,
|
|
CONTAMINATION_TYPE_NAME,
|
|
CLEAN_MODE_CODE,
|
|
USED_FLAG,
|
|
DEL_FLAG,
|
|
CREATE_BY,
|
|
CREATE_TIME,
|
|
UPDATE_BY,
|
|
UPDATE_TIME,
|
|
DATA_VERSION,
|
|
REMARKS1,
|
|
REMARKS2,
|
|
REMARKS3,
|
|
REMARKS4,
|
|
REMARKS5
|
|
)
|
|
VALUES
|
|
(
|
|
'{txtContaminationTypeCode.Text}',
|
|
'{txtContaminationTypeName.Text}',
|
|
'{((ListItem)cmbCleanMode.SelectedItem).Value}',
|
|
1,
|
|
0,
|
|
'{GlobalHelper.UserInfo.UserId}',
|
|
datetime('now', 'localtime'),
|
|
'{GlobalHelper.UserInfo.UserId}',
|
|
datetime('now', 'localtime'),
|
|
0,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL
|
|
);
|
|
";
|
|
int row = LeadDbHelperSQLite.ExecuteSql(sql);
|
|
if (row > 0)
|
|
{
|
|
KryptonMessageBox.Show(this.GetInfoText("新增污染类型数据成功!", "AddSuccessInfo"));
|
|
frmContaminationType.RefreshFrmHost();
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
KryptonMessageBox.Show(this.GetInfoText("新增污染类型数据失败!", "AddFailInfo"));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
KryptonMessageBox.Show(this.GetInfoText("新增污染类型数据发生异常", "AddContaminationTypeDataExp") + $":【{ex.Message}】!");
|
|
}
|
|
}
|
|
|
|
private void btnEdit_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|