Files
CleanMachine/CleanMachineHMI/frmChild/frmAddContaminationType.cs

167 lines
6.9 KiB
C#
Raw Permalink 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 frmAddContaminationType : KryptonForm
{
public frmAddContaminationType()
{
InitializeComponent();
}
2022-03-18 21:25:34 +08:00
2021-06-05 14:17:30 +08:00
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();
2022-03-18 19:06:26 +08:00
this.SetFormControlText();
2021-06-05 14:17:30 +08:00
string sql = $@"select CLEAN_MODE_CODE,CLEAN_MODE_NAME from BAS_CLEAN_MODE where DEL_FLAG=0";
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
2021-12-31 19:53:53 +08:00
cmbCleanMode.DisplayMember = "Text";
2021-06-05 14:17:30 +08:00
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)
{
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("新增污染类型界面加载异常", "LoadAddFrmExp") + $":【{ex.Message}】!");
2021-06-05 14:17:30 +08:00
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
try
{
if (cmbCleanMode.SelectedIndex == 0)
{
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("请选择清洗方式!", "SelectCleanModeInfo"));
2021-06-05 14:17:30 +08:00
return;
}
if (string.IsNullOrEmpty(txtContaminationTypeCode.Text))
{
//KryptonMessageBox.Show("请输入污染类型编码!");
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("请输入污染类型编码!", "EnterContaminationTypeCodeInfo"));
2021-06-05 14:17:30 +08:00
return;
}
if (string.IsNullOrEmpty(txtContaminationTypeName.Text))
{
//KryptonMessageBox.Show("请输入污染类型名称!");
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("请输入污染类型名称!", "EnterContaminationTypeNameInfo"));
2021-06-05 14:17:30 +08:00
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,
2021-12-31 16:27:14 +08:00
'{GlobalHelper.UserInfo.UserId}',
2021-06-05 14:17:30 +08:00
datetime('now', 'localtime'),
2021-12-31 16:27:14 +08:00
'{GlobalHelper.UserInfo.UserId}',
2021-06-05 14:17:30 +08:00
datetime('now', 'localtime'),
0,
NULL,
NULL,
NULL,
NULL,
NULL
);
";
int row = LeadDbHelperSQLite.ExecuteSql(sql);
if (row > 0)
{
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("新增污染类型数据成功!", "AddSuccessInfo"));
2022-01-13 10:43:45 +08:00
frmContaminationType.RefreshFrmHost();
2021-06-05 14:17:30 +08:00
this.Close();
}
else
{
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("新增污染类型数据失败!", "AddFailInfo"));
2021-06-05 14:17:30 +08:00
}
}
catch (Exception ex)
{
2022-03-18 19:06:26 +08:00
KryptonMessageBox.Show(this.GetInfoText("新增污染类型数据发生异常", "AddContaminationTypeDataExp") + $":【{ex.Message}】!");
2021-06-05 14:17:30 +08:00
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}