165 lines
7.1 KiB
C#
165 lines
7.1 KiB
C#
|
|
using CleanMachineHMI.forms;
|
|||
|
|
using CleanMachineHMI.FrmUserControl;
|
|||
|
|
using CleanMachineHMI.Utils;
|
|||
|
|
using ComponentFactory.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.Web.UI.WebControls;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
|
|||
|
|
namespace CleanMachineHMI.frmChild
|
|||
|
|
{
|
|||
|
|
public partial class frmAddContaminationDtl : KryptonForm
|
|||
|
|
{
|
|||
|
|
public frmAddContaminationDtl()
|
|||
|
|
{
|
|||
|
|
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()
|
|||
|
|
{
|
|||
|
|
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 frmAddContaminationDtl_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
InitControlEvent();
|
|||
|
|
this.SetFormControlText(GlobalHelper.LanguageCode);
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
kryptonPanel1.Focus();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("新增污染明细界面加载异常", "LoadAddFrmExp") + $":【{ex.Message}】!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (cmbContaminationType.SelectedIndex == 0)
|
|||
|
|
{
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请选择污染类型!", "SelectContaminationTypeInfo"));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(txtContaminationDTLCode.Text))
|
|||
|
|
{
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入污染明细编码!", "EnterContaminationDtlCodeInfo"));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(txtContaminationDTLName.Text))
|
|||
|
|
{
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入污染明细名称!", "EnterContaminationDtlNameInfo"));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
string sqlIsExistCode = $@"SELECT 1 FROM BAS_CONTAMINATION_DTL WHERE CONTAMINATION_TYPE_CODE = '{((ListItem)cmbContaminationType.SelectedItem).Value}' AND CONTAMINATION_DTL_CODE = '{txtContaminationDTLCode.Text}'";
|
|||
|
|
DataTable dtIsExistCode = LeadDbHelperSQLite.Query(sqlIsExistCode).Tables[0];
|
|||
|
|
if (dtIsExistCode != null && dtIsExistCode.Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
//KryptonMessageBox.Show($"污染明细条码:【{txtContaminationDTLCode.Text}】已经存在,请重新输入!");
|
|||
|
|
KryptonMessageBox.Show($"Pollution detail code: 【{txtContaminationDTLCode.Text}】already exist, please re-enter!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
string sql = $@"
|
|||
|
|
INSERT INTO BAS_CONTAMINATION_DTL (
|
|||
|
|
CONTAMINATION_TYPE_CODE,
|
|||
|
|
CONTAMINATION_DTL_CODE,
|
|||
|
|
CONTAMINATION_DTL_NAME,
|
|||
|
|
USED_FLAG,
|
|||
|
|
DEL_FLAG,
|
|||
|
|
CREATE_BY,
|
|||
|
|
CREATE_TIME,
|
|||
|
|
UPDATE_BY,
|
|||
|
|
UPDATE_TIME,
|
|||
|
|
DATA_VERSION,
|
|||
|
|
REMARKS1,
|
|||
|
|
REMARKS2,
|
|||
|
|
REMARKS3,
|
|||
|
|
REMARKS4,
|
|||
|
|
REMARKS5
|
|||
|
|
)
|
|||
|
|
VALUES
|
|||
|
|
(
|
|||
|
|
'{((ListItem)cmbContaminationType.SelectedItem).Value}',
|
|||
|
|
'{txtContaminationDTLCode.Text}',
|
|||
|
|
'{txtContaminationDTLName.Text}',
|
|||
|
|
1,
|
|||
|
|
0,
|
|||
|
|
'{GlobalHelper.UserInfo.USER_ID}',
|
|||
|
|
datetime('now', 'localtime'),
|
|||
|
|
'{GlobalHelper.UserInfo.USER_ID}',
|
|||
|
|
datetime('now', 'localtime'),
|
|||
|
|
0,
|
|||
|
|
NULL,
|
|||
|
|
NULL,
|
|||
|
|
NULL,
|
|||
|
|
NULL,
|
|||
|
|
NULL
|
|||
|
|
);
|
|||
|
|
";
|
|||
|
|
int row = LeadDbHelperSQLite.ExecuteSql(sql);
|
|||
|
|
if (row > 0)
|
|||
|
|
{
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("新增污染明细数据成功!", "AddSuccessInfo"));
|
|||
|
|
frmContaminationDTL.RefreshFrmHost();
|
|||
|
|
this.Close();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("新增污染明细数据失败!", "AddFailInfo"));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("新增污染明细数据发生异常", "AddContaminationDtlDataExp") + $":【{ex.Message}】!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnEdit_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.Close();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|