Files
CleanMachine/CleanMachineHMI/frmChild/frmAddSheetType.cs

134 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;
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.Windows.Forms;
namespace CleanMachineHMI.frmChild
{
public partial class frmAddSheetType : KryptonForm
{
public frmAddSheetType()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(txtSheetTypeCode.Text))
{
//KryptonMessageBox.Show("请输入板材编码!");
2022-05-06 08:45:56 +08:00
KryptonMessageBox.Show(this.T("请输入板材编码!", "EnterSheetTypeCodeInfo"));
2021-06-05 14:17:30 +08:00
return;
}
if (string.IsNullOrEmpty(txtSheetTypeName.Text))
{
//KryptonMessageBox.Show("请输入板材名称!");
2022-05-06 08:45:56 +08:00
KryptonMessageBox.Show(this.T("请输入板材名称!", "EnterSheetTypeNameInfo"));
2021-06-05 14:17:30 +08:00
return;
}
string sqlIsExistCode = $@"SELECT 1 FROM BAS_SHEET_TYPE WHERE SHEET_TYPE_CODE = '{txtSheetTypeCode.Text}'";
DataTable dtIsExistCode = LeadDbHelperSQLite.Query(sqlIsExistCode).Tables[0];
if (dtIsExistCode != null && dtIsExistCode.Rows.Count > 0)
{
//KryptonMessageBox.Show($"板材条码:【{txtSheetTypeCode.Text}】已经存在,请重新输入!");
KryptonMessageBox.Show($"Sheet type code 【{txtSheetTypeCode.Text}】already exist, please re-enter!");
return;
}
string sql = $@"
INSERT INTO BAS_SHEET_TYPE (
SHEET_TYPE_CODE,
SHEET_TYPE_NAME,
USED_FLAG,
DEL_FLAG,
CREATE_BY,
CREATE_TIME,
UPDATE_BY,
UPDATE_TIME,
DATA_VERSION,
REMARKS1,
REMARKS2,
REMARKS3,
REMARKS4,
REMARKS5
)
VALUES
(
'{txtSheetTypeCode.Text}',
'{txtSheetTypeName.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
);
";
int row = LeadDbHelperSQLite.ExecuteSql(sql);
if (row > 0)
{
//KryptonMessageBox.Show("新增板材数据成功!");
2022-05-06 08:45:56 +08:00
KryptonMessageBox.Show(this.T("新增板材数据成功!", "AddSuccessInfo"));
2021-06-05 14:17:30 +08:00
frmSheetType.RefreshFrmHost();
this.Close();
}
else
{
//KryptonMessageBox.Show("新增板材数据失败!");
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("新增板材类型数据发生异常", "AddSheetTypeDataExp") + $":【{ex.Message}】!");
2021-06-05 14:17:30 +08:00
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
this.Close();
}
private void txt_GotFocus(object sender, EventArgs e)
{
KeyboardAutoPopUp.ShowInputPanel();
}
private void txt_LostFocus(object sender, EventArgs e)
{
KeyboardAutoPopUp.HideInputPanel();
}
private void InitControlEvent()
{
txtSheetTypeCode.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
txtSheetTypeCode.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
txtSheetTypeName.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
txtSheetTypeName.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
}
private void frmAddSheetType_Load(object sender, EventArgs e)
{
InitControlEvent();
2022-03-18 19:06:26 +08:00
this.SetFormControlText();
2021-06-05 14:17:30 +08:00
kryptonPanel1.Focus();
}
}
}