添加项目文件。
This commit is contained in:
143
CleanMachineHMI/frmChild/frmEditRole.cs
Normal file
143
CleanMachineHMI/frmChild/frmEditRole.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
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 frmEditRole : KryptonForm
|
||||
{
|
||||
public frmEditRole()
|
||||
{
|
||||
InitializeComponent();
|
||||
_ComboBoxLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode, "KryptonComboBox");
|
||||
_InfoLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode);
|
||||
}
|
||||
private DataTable _ComboBoxLanguageTextList;
|
||||
private DataTable _InfoLanguageTextList;
|
||||
public string RoleId { 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()
|
||||
{
|
||||
txtRoleCode.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
||||
txtRoleCode.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
||||
|
||||
txtRoleName.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
||||
txtRoleName.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
||||
}
|
||||
private void frmEditRole_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
InitControlEvent();
|
||||
this.SetFormControlText(GlobalHelper.LanguageCode);
|
||||
if (GlobalHelper.LanguageCode == "English")
|
||||
{
|
||||
kcmb_roleGrade.Items.Clear();
|
||||
foreach (DataRow item in _ComboBoxLanguageTextList.GetComBoboxItemArr(kcmb_roleGrade.Name, "KryptonComboBox"))
|
||||
{
|
||||
kcmb_roleGrade.Items.Add(item["CONTROL_NAME"].ToString());
|
||||
}
|
||||
}
|
||||
kcmb_roleGrade.SelectedIndex = 0;
|
||||
string sql = $@"SELECT * FROM SYS_ROLE WHERE ROLE_ID = '{RoleId}'";
|
||||
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
txtRoleCode.Text = dt.Rows[0]["ROLE_CODE"].ToString();
|
||||
txtRoleCode.Enabled = false;
|
||||
txtRoleName.Text = dt.Rows[0]["ROLE_NAME"].ToString();
|
||||
if (Convert.ToInt32(dt.Rows[0]["ROLE_GRADE"]) == 100)
|
||||
{
|
||||
kcmb_roleGrade.SelectedIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
kcmb_roleGrade.SelectedIndex = 2;
|
||||
}
|
||||
kcmb_roleGrade.Enabled = false;
|
||||
}
|
||||
kryptonPanel1.Focus();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("编辑角色数据界面加载异常", "LoadEditFrmExp") + $":【{ex.Message}】!");
|
||||
}
|
||||
}
|
||||
|
||||
private void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtRoleName.Text))
|
||||
{
|
||||
//KryptonMessageBox.Show("请输入角色名称!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入角色名称!", "EnterRoleNameInfo"));
|
||||
return;
|
||||
}
|
||||
int roleGrade = 0;
|
||||
if (kcmb_roleGrade.SelectedIndex == 0)
|
||||
{
|
||||
//KryptonMessageBox.Show("请选择角色级别!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请选择角色级别!", "SelectRoleGradeInfo"));
|
||||
return;
|
||||
}
|
||||
else if (kcmb_roleGrade.SelectedIndex == 1)
|
||||
{
|
||||
//string sqlIsExistAdmin = $@"SELECT 1 FROM SYS_ROLE WHERE ROLE_GRADE = '100'";
|
||||
//DataTable dtIsExistAdmin = LeadDbHelperSQLite.Query(sqlIsExistAdmin).Tables[0];
|
||||
//if (dtIsExistAdmin != null && dtIsExistAdmin.Rows.Count > 0)
|
||||
//{
|
||||
// KryptonMessageBox.Show($"管理员角色只能存在一个,请重新选择!");
|
||||
// return;
|
||||
//}
|
||||
roleGrade = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
roleGrade = 1;
|
||||
}
|
||||
string sql = $@"update SYS_ROLE set ROLE_CODE = '{txtRoleCode.Text}',ROLE_NAME = '{txtRoleName.Text}',ROLE_GRADE = '{roleGrade}',UPDATE_BY = '{GlobalHelper.UserInfo.USER_ID}',UPDATE_TIME = datetime('now', 'localtime') where ROLE_ID = '{RoleId}'";
|
||||
int row = LeadDbHelperSQLite.ExecuteSql(sql);
|
||||
if (row > 0)
|
||||
{
|
||||
//KryptonMessageBox.Show("修改角色数据成功!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("修改角色数据成功!", "EditSuccessInfo"));
|
||||
frmRole.RefreshFrmHost();
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
//KryptonMessageBox.Show("修改角色数据失败!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("修改角色数据失败!", "EditFailInfo"));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("编辑角色数据发生异常", "EditRoleDataExp") + $":【{ex.Message}】!");
|
||||
}
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user