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 frmAddContaminationDtl : KryptonForm
{
public frmAddContaminationDtl ( )
{
InitializeComponent ( ) ;
}
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 ( ) ;
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 ] ;
2021-12-31 19:53:53 +08:00
cmbContaminationType . DisplayMember = "Text" ;
2021-06-05 14:17:30 +08:00
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 )
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "新增污染明细界面加载异常" , "LoadAddFrmExp" ) + $":【{ex.Message}】!" ) ;
2021-06-05 14:17:30 +08:00
}
}
private void btnAdd_Click ( object sender , EventArgs e )
{
try
{
if ( cmbContaminationType . SelectedIndex = = 0 )
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "请选择污染类型!" , "SelectContaminationTypeInfo" ) ) ;
2021-06-05 14:17:30 +08:00
return ;
}
if ( string . IsNullOrEmpty ( txtContaminationDTLCode . Text ) )
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "请输入污染明细编码!" , "EnterContaminationDtlCodeInfo" ) ) ;
2021-06-05 14:17:30 +08:00
return ;
}
if ( string . IsNullOrEmpty ( txtContaminationDTLName . Text ) )
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "请输入污染明细名称!" , "EnterContaminationDtlNameInfo" ) ) ;
2021-06-05 14:17:30 +08:00
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 ,
2022-05-06 12:28:16 +08:00
' { Global . UserInfo . UserId } ' ,
2021-06-05 14:17:30 +08:00
datetime ( ' now ' , ' localtime ' ) ,
2022-05-06 12:28:16 +08:00
' { Global . UserInfo . UserId } ' ,
2021-06-05 14:17:30 +08:00
datetime ( ' now ' , ' localtime ' ) ,
0 ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL
) ;
";
2022-05-16 09:03:42 +08:00
int row = LeadDbHelperSQLite . Execute ( sql ) ;
2021-06-05 14:17:30 +08:00
if ( row > 0 )
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "新增污染明细数据成功!" , "AddSuccessInfo" ) ) ;
2021-06-05 14:17:30 +08:00
frmContaminationDTL . RefreshFrmHost ( ) ;
this . Close ( ) ;
}
else
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "新增污染明细数据失败!" , "AddFailInfo" ) ) ;
2021-06-05 14:17:30 +08:00
}
}
catch ( Exception ex )
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "新增污染明细数据发生异常" , "AddContaminationDtlDataExp" ) + $":【{ex.Message}】!" ) ;
2021-06-05 14:17:30 +08:00
}
}
private void btnEdit_Click ( object sender , EventArgs e )
{
this . Close ( ) ;
}
}
}