Files
CleanMachine/CleanMachineHMI/frmChild/frmAddCleanCode.cs

130 lines
5.2 KiB
C#
Raw Normal View History

2021-06-05 14:17:30 +08:00
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.Windows.Forms;
namespace CleanMachineHMI.frmChild
{
public partial class frmAddCleanCode : KryptonForm
{
public frmAddCleanCode()
{
InitializeComponent();
_InfoLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode);
}
private DataTable _InfoLanguageTextList;
private void frmAddCleanCode_Load(object sender, EventArgs e)
{
InitControlEvent();
this.SetFormControlText(GlobalHelper.LanguageCode);
}
private void txt_GotFocus(object sender, EventArgs e)
{
KeyboardAutoPopUp.ShowInputPanel();
}
private void txt_LostFocus(object sender, EventArgs e)
{
KeyboardAutoPopUp.HideInputPanel();
}
private void InitControlEvent()
{
txtCleanModeCode.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
txtCleanModeCode.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
txtCleanModeName.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
txtCleanModeName.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
}
private void btnAdd_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(txtCleanModeCode.Text))
{
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入清洗方式编码!", "EnterCleanCodeInfo"));
return;
}
if (string.IsNullOrEmpty(txtCleanModeName.Text))
{
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入清洗方式名称!", "EnterCleanNameInfo"));
return;
}
string sqlIsExistCode = $@"SELECT 1 FROM BAS_CLEAN_MODE WHERE CLEAN_MODE_CODE = '{txtCleanModeCode.Text}'";
DataTable dtIsExistCode = LeadDbHelperSQLite.Query(sqlIsExistCode).Tables[0];
if (dtIsExistCode != null && dtIsExistCode.Rows.Count > 0)
{
//KryptonMessageBox.Show($"清洗方式条码:【{txtCleanModeCode.Text}】已经存在,请重新输入!");
KryptonMessageBox.Show($"Clean methol code: 【{txtCleanModeCode.Text}】already exist, please re-enter!");
return;
}
string sql = $@"
INSERT INTO BAS_CLEAN_MODE (
CLEAN_MODE_CODE,
CLEAN_MODE_NAME,
USED_FLAG,
DEL_FLAG,
CREATE_BY,
CREATE_TIME,
UPDATE_BY,
UPDATE_TIME,
DATA_VERSION,
REMARKS1,
REMARKS2,
REMARKS3,
REMARKS4,
REMARKS5
)
VALUES
(
'{txtCleanModeCode.Text}',
'{txtCleanModeName.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"));
frmCleanMode.RefreshFrmHost();
this.Close();
}
else
{
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("新增清洗方式数据失败!", "AddFailInfo"));
}
}
catch (Exception ex)
{
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("新增清洗方式数据发生异常", "AddCleanModeDataExp") + $":【{ex.Message}】!");
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}