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 frmEditContaminationType : KryptonForm
{
public frmEditContaminationType ( )
{
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 ) ; //失去焦点后发生事件
}
public string ContaminationId { get ; set ; }
private void frmEditContaminationType_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 ] ;
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 ;
}
string sql1 = $@"SELECT A.CONTAMINATION_TYPE_CODE,A.CONTAMINATION_TYPE_NAME,B.CLEAN_MODE_CODE,B.CLEAN_MODE_NAME FROM BAS_CONTAMINATION_TYPE A LEFT JOIN BAS_CLEAN_MODE B ON A.CLEAN_MODE_CODE = B.CLEAN_MODE_CODE WHERE A.CONTAMINATION_TYPE_ID = '{ContaminationId}'" ;
DataTable dt1 = LeadDbHelperSQLite . Query ( sql1 ) . Tables [ 0 ] ;
if ( dt1 ! = null & & dt1 . Rows . Count > 0 )
{
txtContaminationTypeCode . Text = dt1 . Rows [ 0 ] [ "CONTAMINATION_TYPE_CODE" ] . ToString ( ) ;
txtContaminationTypeCode . Enabled = false ;
txtContaminationTypeName . Text = dt1 . Rows [ 0 ] [ "CONTAMINATION_TYPE_NAME" ] . ToString ( ) ;
cmbCleanMode . Text = dt1 . Rows [ 0 ] [ "CLEAN_MODE_NAME" ] . ToString ( ) ;
cmbCleanMode . Enabled = false ;
}
kryptonPanel1 . Focus ( ) ;
}
catch ( Exception ex )
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "编辑污染类型界面加载异常" , "LoadEditFrmExp" ) + $":【{ex.Message}】!" ) ;
2021-06-05 14:17:30 +08:00
}
}
private void btnAdd_Click ( object sender , EventArgs e )
{
try
{
if ( cmbCleanMode . SelectedIndex = = 0 )
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "请选择清洗方式!" , "SelectCleanModeInfo" ) ) ;
2021-06-05 14:17:30 +08:00
return ;
}
if ( string . IsNullOrEmpty ( txtContaminationTypeCode . Text ) )
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "请输入污染类型编码!" , "EnterContaminationTypeCodeInfo" ) ) ;
2021-06-05 14:17:30 +08:00
return ;
}
if ( string . IsNullOrEmpty ( txtContaminationTypeName . Text ) )
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "请输入污染类型名称!" , "EnterContaminationTypeNameInfo" ) ) ;
2021-06-05 14:17:30 +08:00
return ;
}
2022-05-06 12:28:16 +08:00
string sql = $@"update BAS_CONTAMINATION_TYPE set CONTAMINATION_TYPE_NAME = '{txtContaminationTypeName.Text}',UPDATE_BY = '{Global.UserInfo.UserId}',UPDATE_TIME = datetime('now', 'localtime') where CONTAMINATION_TYPE_ID = '{ContaminationId}'" ;
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 ( "编辑污染类型数据成功!" , "EditSuccessInfo" ) ) ;
2021-06-05 14:17:30 +08:00
frmContaminationType . RefreshFrmHost ( ) ;
this . Close ( ) ;
}
else
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "编辑污染类型数据失败!" , "EditFailInfo" ) ) ;
2021-06-05 14:17:30 +08:00
}
}
catch ( Exception ex )
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox . Show ( this . T ( "编辑污染类型数据发生异常" , "EditContaminationTypeDataExp" ) + $":【{ex.Message}】!" ) ;
2021-06-05 14:17:30 +08:00
}
}
private void btnEdit_Click ( object sender , EventArgs e )
{
this . Close ( ) ;
}
}
}