Files

199 lines
7.5 KiB
C#
Raw Permalink Normal View History

2021-06-05 14:17:30 +08:00
using CleanMachineHMI.Domain.Enums;
using CleanMachineHMI.frmChild;
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.FrmUserControl
{
[FormType(EnumFormType.CleanMode)]
public partial class frmCleanMode : UserControl
{
public delegate void dlgRefreshFrmHost();
public static dlgRefreshFrmHost RefreshFrmHost;
public frmCleanMode()
{
InitializeComponent();
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}
public void Init()
{
var sql = $@"select CLEAN_MODE_ID 序号,CLEAN_MODE_CODE 清洁方式编码,CLEAN_MODE_NAME 清洁方式名称,CREATE_TIME 创建时间 from BAS_CLEAN_MODE where DEL_FLAG=0";
if (!string.IsNullOrEmpty(ktb_CleanModeCode.Text))
{
sql += $" AND CLEAN_MODE_CODE LIKE '%{ktb_CleanModeCode.Text}%'";
}
if (!string.IsNullOrEmpty(ktb_CleanModeName.Text))
{
sql += $" AND CLEAN_MODE_NAME LIKE '%{ktb_CleanModeName.Text}%'";
}
if (kdtp_CreateStartTime.Checked)
{
sql += $" AND CREATE_TIME >= '{kdtp_CreateStartTime.Value.ToString("yyyy-MM-dd HH:mm:ss")}'";
}
if (kdtp_CreateEndTime.Checked)
{
sql += $" AND CREATE_TIME <= '{kdtp_CreateEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss")}'";
}
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
dataGridView.Columns.Clear();
dataGridView.DataSource = dt;
2022-03-19 12:46:23 +08:00
dataGridView.SetDataViewColumnText(this.Name);
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()
{
ktb_CleanModeCode.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
ktb_CleanModeCode.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
ktb_CleanModeName.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
ktb_CleanModeName.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
}
private void frmCleanMode_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
kdtp_CreateStartTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
kdtp_CreateEndTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
kdtp_CreateStartTime.Checked = false;
kdtp_CreateEndTime.Checked = false;
RefreshFrmHost = new dlgRefreshFrmHost(Init);
Init();
foreach (Control item in tableLayoutPanel2.Controls)
{
if (item.Tag == null)
{
2022-05-06 12:28:16 +08:00
item.Enabled = Global.CheckRole(this.Name, item.Name);
2022-05-06 10:36:42 +08:00
//DataRow[] drs = GlobalHelper.RoleMenuPermission.Select($" MENU_URL = '{this.Name}' AND MENU_PID = '-1'");
//DataRow[] drs1 = GlobalHelper.RoleMenuPermission.Select($" MENU_URL = '{item.Name}' AND MENU_PID = '{drs[0]["MENU_ID"]}'");
//if (drs1.Length > 0)
//{
// item.Enabled = true;
//}
//else
//{
// item.Enabled = false;
//}
2021-06-05 14:17:30 +08:00
}
}
kryptonGroupBox2.Focus();
}
catch (Exception ex)
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox.Show(this.T("加载清洁方式界面发生异常", "LoadFrmCleanModeExp") + $":【{ex.Message}】!");
2021-06-05 14:17:30 +08:00
}
}
private void kbt_Query_Click(object sender, EventArgs e)
{
try
{
Init();
}
catch (Exception ex)
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox.Show(this.T("查询清洁方式数据发生异常", "QueryCleanModeData") + $":【{ex.Message}】!");
2021-06-05 14:17:30 +08:00
}
}
private void kbt_Reset_Click(object sender, EventArgs e)
{
ktb_CleanModeCode.Text = "";
ktb_CleanModeName.Text = "";
kdtp_CreateStartTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
kdtp_CreateEndTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
kdtp_CreateStartTime.Checked = false;
kdtp_CreateEndTime.Checked = false;
}
private void kbt_Add_Click(object sender, EventArgs e)
{
frmAddCleanCode frm = new frmAddCleanCode();
frm.ShowDialog();
}
private void kbt_Edit_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count > 0)
{
frmEditCleanCode frm = new frmEditCleanCode();
frm.CleanModeId = dataGridView.SelectedRows[0].Cells[0].Value.ToString();
frm.ShowDialog();
}
else
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox.Show(this.T("请选择要编辑的清洗方式数据行!", "SelectWantToEditRow"));
2021-06-05 14:17:30 +08:00
}
}
private void kbt_Delete_Click(object sender, EventArgs e)
{
try
{
if (dataGridView.SelectedRows.Count > 0)
{
2022-05-06 08:45:56 +08:00
DialogResult dr = KryptonMessageBox.Show(this.T("确定要删除所选的清洗方式数据吗?", "DeleteInfo"), "Prompt", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
2021-06-05 14:17:30 +08:00
if (dr == DialogResult.OK)
{
string CleanModeId = dataGridView.SelectedRows[0].Cells[0].Value.ToString();
string sql = $@"DELETE FROM BAS_CLEAN_MODE WHERE CLEAN_MODE_ID = '{CleanModeId}'";
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("删除清洗方式数据成功!", "DeleteSuccessInfo"));
2021-06-05 14:17:30 +08:00
RefreshFrmHost();
}
else
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox.Show(this.T("删除清洗方式数据失败!", "DeleteFailInfo"));
2021-06-05 14:17:30 +08:00
}
}
}
else
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox.Show(this.T("请选择要删除的清洗方式数据行!", "SelectWantToDeleteRow"));
2021-06-05 14:17:30 +08:00
}
}
catch (Exception ex)
{
2022-05-06 08:45:56 +08:00
KryptonMessageBox.Show(this.T("删除清洁方式数据发生异常", "DeleteCleanModeDataExp") + $":【{ex.Message}】!");
2021-06-05 14:17:30 +08:00
}
}
}
}