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 ;
using System.Web.UI.WebControls ;
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 ( ) ;
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 ;
}
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 )
{
KryptonMessageBox . Show ( _InfoLanguageTextList . GetInfoText ( "编辑污染明细数据界面加载异常" , "LoadEditFrmExp" ) + $":【{ex.Message}】!" ) ;
}
}
private void btnAdd_Click ( object sender , EventArgs e )
{
try
{
if ( cmbContaminationType . SelectedIndex = = 0 )
{
//KryptonMessageBox.Show("请选择污染类型!");
KryptonMessageBox . Show ( _InfoLanguageTextList . GetInfoText ( "请选择污染类型!" , "SelectContaminationTypeInfo" ) ) ;
return ;
}
if ( string . IsNullOrEmpty ( txtContaminationDTLCode . Text ) )
{
//KryptonMessageBox.Show("请输入污染明细编码!");
KryptonMessageBox . Show ( _InfoLanguageTextList . GetInfoText ( "请输入污染明细编码!" , "EnterContaminationDtlCodeInfo" ) ) ;
return ;
}
if ( string . IsNullOrEmpty ( txtContaminationDTLName . Text ) )
{
//KryptonMessageBox.Show("请输入污染明细名称!");
KryptonMessageBox . Show ( _InfoLanguageTextList . GetInfoText ( "请输入污染明细名称!" , "EnterContaminationDtlNameInfo" ) ) ;
return ;
}
string sql = $@"update BAS_CONTAMINATION_DTL set CONTAMINATION_DTL_NAME = '{txtContaminationDTLName.Text}',UPDATE_BY = '{GlobalHelper.UserInfo.USER_ID}',UPDATE_TIME = datetime('now', 'localtime') where CONTAMINATION_DTL_ID = '{ContaminationDtlId}'" ;
int row = LeadDbHelperSQLite . ExecuteSql ( sql ) ;
if ( row > 0 )
{
//KryptonMessageBox.Show("修改污染明细数据成功!");
KryptonMessageBox . Show ( _InfoLanguageTextList . GetInfoText ( "新增污染明细数据成功!" , "EditSuccessInfo" ) ) ;
frmContaminationDTL . RefreshFrmHost ( ) ;
this . Close ( ) ;
}
else
{
//KryptonMessageBox.Show("修改污染明细数据失败!");
KryptonMessageBox . Show ( _InfoLanguageTextList . GetInfoText ( "新增污染明细数据失败!" , "EditFailInfo" ) ) ;
}
}
catch ( Exception ex )
{
KryptonMessageBox . Show ( _InfoLanguageTextList . GetInfoText ( "编辑污染明细数据发生异常" , "EditContaminationDtlDataExp" ) + $":【{ex.Message}】!" ) ;
}
}
private void btnEdit_Click ( object sender , EventArgs e )
{
this . Close ( ) ;
}
}
}