123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804 |
- using ComponentFactory.Krypton.Toolkit;
- using NXWMS.Client.Code.Extends;
- using NXWMS.Client.Model.AppModels.Condition;
- using NXWMS.Client.Model.AppModels.Condition.SysSettings;
- using NXWMS.Client.Model.AppModels.Result;
- using NXWMS.Client.Model.AppModels.Result.SysSettings;
- using NXWMS.Client.Model.CoreModels;
- using NXWMS.Client.String.Enums;
- using NXWMS.Commons;
- using NXWMS.Services;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace NXWMS.Forms.SysSettings
- {
- public partial class frmRole : KryptonForm
- {
- /// <summary>
- /// 界面最后执行操作
- /// </summary>
- private EnumOperation _LastOperation;
- /// <summary>
- /// 窗体类名
- /// </summary>
- private string _CrrentClassName;
- /// <summary>
- /// 客户端字段排序列表
- /// </summary>
- private List<ClientFieldOrderResult> _clientFieldOrderList;
- /// <summary>
- /// 菜单层级列表
- /// </summary>
- private List<MenuLevelResult> _menuLevelList;
- /// <summary>
- /// 选择行主键列表
- /// </summary>
- private List<string> _CheckRowIdList = new List<string>();
- /// <summary>
- /// 当前页面操作的主键
- /// </summary>
- private string _PrimaryKey = "ROLE_ID";
- public frmRole()
- {
- InitializeComponent();
- _CrrentClassName = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName;
- InitData();
- InitControl();
- }
- protected override CreateParams CreateParams
- {
- get
- {
- CreateParams cp = base.CreateParams;
- cp.ExStyle |= 0x02000000;
- return cp;
- }
- }
- /// <summary>
- /// 控件初始化
- /// </summary>
- private void InitControl()
- {
- CheckForIllegalCrossThreadCalls = false;
- //groupOperation.LostFocus += new EventHandler(groupOperation_LostFocus);
- //groupOperation.GotFocus += new EventHandler(groupOperation_GostFocus);
- //界面数据初始化
- dataGridView.CellClick += new DataGridViewCellEventHandler(dataGridView_CellClick);
- dataGridView.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientFieldOrderList), false);
- //菜单列表添加
- //treeViewMainMenu.Scrollable = true;
- //treeViewMainMenu.ShowPlusMinus = true;
- //treeViewMainMenu.ShowRootLines = true;
- //treeViewMainMenu.Nodes.Clear();
- var menuList = _menuLevelList.Where((x, i) => _menuLevelList.FindIndex(z => z.MainMenuId == x.MainMenuId) == i).Distinct().ToList();
- foreach (var item in (from x in menuList
- select new
- { x.MainMenuId, x.MainMenuName, x.MainMenuCode, x.MainMenuOrder, x.MainMenuURL }).Distinct())
- {
- var newTreeNode = new TreeNode
- {
- Checked = true,
- Name = item.MainMenuId.ToString(),
- Text = item.MainMenuName,
- };
- newTreeNode.Checked = false;
- //var f1 = treeViewMainMenu.Nodes.Add(newTreeNode);
- }
- //treeViewMainMenu.ExpandAll();
- //treeViewMainMenu.NodeMouseDoubleClick += new
- // TreeNodeMouseClickEventHandler(TreeMainMenuNodeDoubleClick);
- //暂时用代码限制长度,不用表配置之类做了..
- txtSearchRoleCode.SetControlBase(50);
- txtSearchRoleName.SetControlBase(100);
- //txtRoleCode.SetControlBase(50);
- //txtRoleName.SetControlBase(100);
- _pageSize = 20;
- _pageIndex = 1;
- }
- /// <summary>
- /// 选中授权
- /// </summary>
- private RolePermissionResult _selectRolePermission;
- /// <summary>
- /// 主菜单双击
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void TreeMainMenuNodeDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- var menuView = sender as KryptonTreeView;
- var selectedNode = menuView.SelectedNode;
- if (selectedNode == null)
- {
- return;
- }
- //菜单列表添加
- //treeViewMenu.Scrollable = true;
- //treeViewMenu.ShowPlusMinus = true;
- //treeViewMenu.ShowRootLines = true;
- //treeViewMenu.Nodes.Clear();
- _selectMainMenuIndex = e.Node.Index;
- foreach (var item in (from x in _menuLevelList.Where(m => m.MainMenuId == int.Parse(selectedNode.Name))
- select new
- { x.MenuCode, x.MenuName, x.MenuId, x.MenuOrder, x.MenuURL }).Distinct())
- {
- var newTreeNode = new TreeNode
- {
- Checked = true,
- Name = item.MenuId.ToString(),
- Text = item.MenuName,
- };
- newTreeNode.Checked = false;
- //var f1 = treeViewMenu.Nodes.Add(newTreeNode);
- }
- //treeViewMenu.ExpandAll();
- //授权打勾
- if (!_menuCheckList.Any())
- {
- _selectRolePermission = SysSettingsServices.roleService.GetPermissionInfo(new RolePermissionCondition
- {
- OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- RoleId = _selectRoleId,
- }).Data;
- //foreach (TreeNode item in treeViewMainMenu.Nodes)
- //{
- // item.Checked = false;
- //}
- //foreach (TreeNode item in treeViewMenu.Nodes)
- //{
- // item.Checked = false;
- //}
- //foreach (var item in _selectRolePermission.RoleMenuList.Where(m => m.MainMenuId != null).Distinct().ToList())
- //{
- // if (treeViewMainMenu.Nodes[item.MainMenuId.Value.ToString()] != null)
- // {
- // treeViewMainMenu.Nodes[item.MainMenuId.Value.ToString()].Checked = true;
- // }
- // if (treeViewMenu.Nodes[item.MainMenuId.Value.ToString()] != null)
- // {
- // treeViewMenu.Nodes[item.MainMenuId.Value.ToString()].Checked = true;
- // }
- //}
- }
- else
- {
- //foreach (TreeNode item in treeViewMenu.Nodes)
- //{
- // item.Checked = false;
- //}
- //foreach (var item in _menuCheckList)
- //{
- // if (treeViewMenu.Nodes[item.ToString()] != null)
- // {
- // treeViewMenu.Nodes[item.ToString()].Checked = true;
- // }
- //}
- }
- //treeViewMenu.NodeMouseDoubleClick += new
- // TreeNodeMouseClickEventHandler(TreeMenuNodeDoubleClick);
- }
- /// <summary>
- /// 菜单双击
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void TreeMenuNodeDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- var menuView = sender as KryptonTreeView;
- var selectedNode = menuView.SelectedNode;
- if (selectedNode == null)
- {
- return;
- }
- _selectMenuIndex = e.Node.Index;
- //菜单列表添加
- //treeViewFunction.Scrollable = true;
- //treeViewFunction.ShowPlusMinus = true;
- //treeViewFunction.ShowRootLines = true;
- //treeViewFunction.Nodes.Clear();
- foreach (var item in (from x in _menuLevelList.Where(m => m.MenuId == int.Parse(selectedNode.Name) && m.FunctionCode != null)
- select new
- { x.FunctionCode, x.FunctionName, x.FunctionId, x.FunctionOrder, x.FunctionURL }).Distinct())
- {
- var newTreeNode = new TreeNode
- {
- Checked = true,
- Name = item.FunctionId.ToString(),
- Text = item.FunctionName,
- };
- newTreeNode.Checked = false;
- //var f1 = treeViewFunction.Nodes.Add(newTreeNode);
- }
- //treeViewFunction.ExpandAll();
- //foreach (TreeNode item in treeViewFunction.Nodes)
- //{
- // item.Checked = false;
- //}
- //授权打勾
- if (!_menuCheckList.Any())
- {
- var menuList = _selectRolePermission;
- foreach (var item in menuList.RoleMenuList.Where(m => m.MainMenuId != null))
- {
- //if (treeViewFunction.Nodes[item.MainMenuId.Value.ToString()] != null)
- //{
- // treeViewFunction.Nodes[item.MainMenuId.Value.ToString()].Checked = true;
- //}
- }
- }
- else
- {
- foreach (var item in _menuCheckList)
- {
- //if (treeViewFunction.Nodes[item.ToString()] != null)
- //{
- // treeViewFunction.Nodes[item.ToString()].Checked = true;
- //}
- }
- }
- }
- /// <summary>
- /// 获取授权菜单列表
- /// </summary>
- /// <returns></returns>
- private List<int> GetPermissionMenuIdList()
- {
- var permissionList = new List<int>();
- //foreach (TreeNode item in treeViewMainMenu.Nodes)
- //{
- // if (item.Checked)
- // {
- // permissionList.Add(Convert.ToInt32(item.Name));
- // }
- //}
- //foreach (TreeNode item in treeViewMenu.Nodes)
- //{
- // if (item.Checked)
- // {
- // permissionList.Add(Convert.ToInt32(item.Name));
- // }
- //}
- //foreach (TreeNode item in treeViewFunction.Nodes)
- //{
- // if (item.Checked)
- // {
- // permissionList.Add(Convert.ToInt32(item.Name));
- // }
- //}
- return permissionList;
- }
- /// <summary>
- /// 数据初始化
- /// </summary>
- private void InitData()
- {
- //获取数据源配置
- var result = ConfigServices.configService.GetDataViewOrderList(new ClientFieldOrderCondition { SourceCode = $"{_CrrentClassName}" });
- if (result.Status == OperateStatus.Success)
- {
- _clientFieldOrderList = result.Data;
- }
- //获取菜单层级
- var menuResult = SysSettingsServices.menuService.GetLevelList(new MenuLevelCondition { });
- if (menuResult.Status == OperateStatus.Success)
- {
- _menuLevelList = menuResult.Data;
- }
- _menuCheckList = new List<int>();
- }
- /// <summary>
- /// ESC撤销此次编辑操作
- /// </summary>
- /// <param name="msg"></param>
- /// <param name="keyData"></param>
- /// <returns></returns>
- protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
- {
- int WM_KEYDOWN = 256;
- int WM_SYSKEYDOWN = 260;
- if (msg.Msg == WM_KEYDOWN | msg.Msg == WM_SYSKEYDOWN)
- {
- switch (keyData)
- {
- case Keys.Escape:
- //if (groupOperation.Visible)
- //{
- // btnExit_Click(null, null);
- //}
- break;
- }
- }
- return false;
- }
- private void groupOperation_LostFocus(object sender, EventArgs e)
- {
- }
- private void groupOperation_GostFocus(object sender, EventArgs e)
- {
- //groupOperation.Values.Heading = _LastOperation.Display();
- //groupOperation.Values.Image = Image.FromFile(_LastOperation.ImagePath());
- //groupOperation.Text = $"{ _LastOperation.Display()}数据";
- //lbStatusMessage.Visible = true;
- }
- private int _pageSize;
- private int _pageIndex;
- private int _totalCount;
- private void btnSearch_Click(object sender, EventArgs e)
- {
- _pageIndex = 1;
- var loadfrm = new frmLoading();
- loadfrm.Show();
- var message = loadfrm.EventCalExec(LoadSearch, this.pageTool.PageIndex, this.pageTool.PageSize);
- pageTool.DataCount = _totalCount;
- if (!string.IsNullOrWhiteSpace(message))
- {
- KryptonMessageBox.Show($"查询失败!\r\n{message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- private string LoadSearch(int pageIndex, int pageSize)
- {
- var result = SysSettingsServices.roleService.GetList(new RoleSearchCondition
- {
- RoleCode = txtSearchRoleCode.Text,
- RoleName = txtSearchRoleName.Text,
- PageIndex = pageIndex,
- PageSize = pageSize,
- IsUsed = chkSearchUse.Checked,
- });
- if (result.Status == OperateStatus.Success)
- {
- _totalCount = result.Data.TotalCount;
- _pageIndex = pageIndex;
- _pageSize = pageSize;
- if (result.Data.RowData.Any())
- {
- dataGridView.Columns.Clear();
- dataGridView.DataSource = result.Data.RowData.ToList();
- dataGridView.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientFieldOrderList));
- }
- else
- {
- if (dataGridView.DataSource != null)
- {
- dataGridView.DataSource = new List<RoleResult>();
- }
- dataGridView.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientFieldOrderList), false);
- }
- return string.Empty;
- }
- else
- {
- return result.Message;
- }
- }
- private void btnAdd_Click(object sender, EventArgs e)
- {
- //if (!groupOperation.Visible)
- //{
- var frm = new ChildFrm.frmRoleEdit();
- frm.LastOperation = EnumOperation.Add;
- frm.tableLayoutPanelInput.SetGroupControlsEmpty(dataGridView);
- frm.MenuLevelList = this._menuLevelList;
- frm.InitControl();
- if (frm.ShowDialog() == DialogResult.OK)
- {
- this.btnSearch_Click(null, null);
- }
- //richDescibe.Text = "";
- //_LastOperation = EnumOperation.Add;
- //txtRoleCode.Enabled = true;
- //kryptonNavigatorOperation.SelectedPage = kryptonPageInfo;
- //groupOperation.Visible = true;
- //groupOperation.Focus();
- //}
- }
- private int _selectIndex;
- private int _selectRoleId;
- private void btnEdit_Click(object sender, EventArgs e)
- {
- dataGridView_CellDoubleClick(null, null);
- }
- private void btnRemove_Click(object sender, EventArgs e)
- {
- if (_CheckRowIdList.Count == 0)
- {
- return;
- }
- if (KryptonMessageBox.Show($"确认删除选中数据?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
- {
- _LastOperation = EnumOperation.Remove;
- var editResult = SysSettingsServices.roleService.Deleted(new RoleCondition
- {
- OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- RoleIds = string.Join(",", _CheckRowIdList)
- });
- if (editResult.Status == OperateStatus.Success)
- {
- KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- //groupOperation.Visible = false;
- btnSearch_Click(null, null);
- }
- }
- }
- private void dataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- SelectInit();
- if (_selectIndex >= 0)
- {
- var frm = new ChildFrm.frmRoleEdit();
- frm.LastOperation = EnumOperation.Edit;
- //txtRoleCode.Enabled = false;
- //kryptonNavigatorOperation.SelectedPage = kryptonPageInfo;
- frm.tableLayoutPanelInput.SetGroupControls(dataGridView, dataGridView.Rows[_selectIndex]);
- //richDescibe.Text = dataGridView.Rows[_selectIndex].Cells["DESCRIBE"].Value == null ? "" :
- //dataGridView.Rows[_selectIndex].Cells["DESCRIBE"].Value.ToString();
- //groupOperation.Visible = true;
- _selectRolePermission = SysSettingsServices.roleService.GetPermissionInfo(new RolePermissionCondition
- {
- OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- RoleId = _selectRoleId,
- }).Data;
- var menuList = _selectRolePermission;
- foreach (var item in menuList.RoleMenuList.Where(m => m.MainMenuId != null))
- {
- if (frm.treeViewMainMenu.Nodes[item.MainMenuId.Value.ToString()] != null)
- {
- frm. treeViewMainMenu.Nodes[item.MainMenuId.Value.ToString()].Checked = true;
- }
- }
- if (frm.ShowDialog()==DialogResult.OK)
- {
- this.btnSearch_Click(null, null);
- }
- }
- }
- private void SelectInit()
- {
- _selectIndex = dataGridView.SelectedRows[0].Index;
- if (_selectIndex >= 0)
- {
- _selectRoleId = Convert.ToInt32(dataGridView.Rows[_selectIndex].Cells[_PrimaryKey].Value);
- }
- }
- //private void btnSave_Click(object sender, EventArgs e)
- //{
- // if (string.IsNullOrWhiteSpace(txtRoleCode.Text))
- // {
- // KryptonMessageBox.Show($"请输入角色编码。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- // return;
- // }
- // if (string.IsNullOrWhiteSpace(txtRoleName.Text))
- // {
- // KryptonMessageBox.Show($"请输入角色名称。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- // return;
- // }
- // _menuCheckList = new List<int>();
- // switch (_LastOperation)
- // {
- // case EnumOperation.Add:
- // var addResult = SysSettingsServices.roleService.Add(new RoleCondition
- // {
- // OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- // IsUsed = chkUse.Checked,
- // RoleCode = txtRoleCode.Text,
- // RoleName = txtRoleName.Text,
- // Describe = richDescibe.Text,
- // PermissionMenuIdList = GetPermissionMenuIdList(),
- // });
- // if (addResult.Status == OperateStatus.Success)
- // {
- // KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- // groupOperation.Visible = false;
- // btnSearch_Click(null, null);
- // dataGridView.ClearSelection();
- // }
- // else
- // {
- // KryptonMessageBox.Show($"操作失败!\r\n{addResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- // }
- // break;
- // case EnumOperation.Edit:
- // var editResult = SysSettingsServices.roleService.Edit(new RoleCondition
- // {
- // OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- // IsUsed = chkUse.Checked,
- // RoleCode = txtRoleCode.Text,
- // RoleName = txtRoleName.Text,
- // RoleId = _selectRoleId,
- // Describe = richDescibe.Text,
- // PermissionMenuIdList = GetPermissionMenuIdList(),
- // });
- // if (editResult.Status == OperateStatus.Success)
- // {
- // KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- // groupOperation.Visible = false;
- // btnSearch_Click(null, null);
- // dataGridView.ClearSelection();
- // }
- // else
- // {
- // KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- // }
- // break;
- // }
- //}
- private void btnExit_Click(object sender, EventArgs e)
- {
- if (KryptonMessageBox.Show($"确认退出 {_LastOperation.Display()} 数据操作?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
- {
- _menuCheckList = new List<int>();
- //groupOperation.Visible = false;
- }
- else
- {
- //groupOperation.Visible = true;
- //groupOperation.Focus();
- }
- }
- private Point mouse_offset;
- private void groupOperation_MouseDown(object sender, MouseEventArgs e)
- {
- mouse_offset = new Point(-e.X, -e.Y);
- }
- private void groupOperation_MouseMove(object sender, MouseEventArgs e)
- {
- ((Control)sender).Cursor = Cursors.Arrow;
- if (e.Button == MouseButtons.Left)
- {
- Point mousePos = MousePosition;
- mousePos.Offset(mouse_offset.X, mouse_offset.Y);
- ((Control)sender).Location = ((Control)sender).Parent.PointToClient(mousePos);
- Application.DoEvents();
- }
- }
- private void btnSearchExport_Click(object sender, EventArgs e)
- {
- this.dataGridView.DataGridViewExport($"{AppConfig.CurrentMenu.FirstOrDefault()}列表" + DateTime.Now.ToString("yyyyMMddHH"));
- }
- private int _selectMainMenuIndex;
- private int _selectMenuIndex;
- private int _selectFunctionIndex;
- /// <summary>
- /// 选中的所有菜单
- /// </summary>
- private List<int> _menuCheckList;
- private void treeViewMainMenu_AfterCheck(object sender, TreeViewEventArgs e)
- {
- if (e.Action == TreeViewAction.ByMouse)
- {
- //foreach (TreeNode child in treeViewMenu.Nodes)
- //{
- // child.Checked = e.Node.Checked;
- // if (!_menuCheckList.Where(s => s == int.Parse(child.Name)).Any())
- // {
- // if (child.Checked)
- // {
- // _menuCheckList.Add(int.Parse(child.Name));
- // }
- // }
- // else
- // {
- // if (!child.Checked)
- // {
- // _menuCheckList.Remove(int.Parse(child.Name));
- // }
- // }
- //}
- }
- }
- private void treeViewMenu_AfterCheck(object sender, TreeViewEventArgs e)
- {
- if (e.Action == TreeViewAction.ByMouse)
- {
- //foreach (TreeNode child in treeViewFunction.Nodes)
- //{
- // child.Checked = e.Node.Checked;
- // if (!_menuCheckList.Where(s => s == int.Parse(child.Name)).Any())
- // {
- // if (child.Checked)
- // {
- // _menuCheckList.Add(int.Parse(child.Name));
- // }
- // }
- // else
- // {
- // if (!child.Checked)
- // {
- // _menuCheckList.Remove(int.Parse(child.Name));
- // }
- // }
- //}
- int index = 0;
- //foreach (TreeNode child in treeViewMenu.Nodes)
- //{
- // if (child.Checked)
- // {
- // index++;
- // }
- //}
- //if (index > 0)
- //{
- // treeViewMainMenu.Nodes[_selectMainMenuIndex].Checked = true;
- //}
- //else
- //{
- // treeViewMainMenu.Nodes[_selectMainMenuIndex].Checked = false;
- //}
- }
- }
- private void treeViewFunction_AfterCheck(object sender, TreeViewEventArgs e)
- {
- if (e.Action == TreeViewAction.ByMouse)
- {
- _selectFunctionIndex = e.Node.Index;
- int index = 0;
- //foreach (TreeNode child in treeViewFunction.Nodes)
- //{
- // if (child.Checked)
- // {
- // index++;
- // }
- // if (!_menuCheckList.Where(s => s == int.Parse(child.Name)).Any())
- // {
- // if (child.Checked)
- // {
- // _menuCheckList.Add(int.Parse(child.Name));
- // }
- // }
- // else
- // {
- // if (!child.Checked)
- // {
- // _menuCheckList.Remove(int.Parse(child.Name));
- // }
- // }
- //}
- //if (index > 0)
- //{
- // treeViewMenu.Nodes[_selectMenuIndex].Checked = true;
- //}
- //else
- //{
- // treeViewMenu.Nodes[_selectMenuIndex].Checked = false;
- //}
- //index = 0;
- //foreach (TreeNode child in treeViewMenu.Nodes)
- //{
- // if (child.Checked)
- // {
- // index++;
- // }
- //}
- //if (index > 0)
- //{
- // treeViewMainMenu.Nodes[_selectMainMenuIndex].Checked = true;
- //}
- //else
- //{
- // treeViewMainMenu.Nodes[_selectMainMenuIndex].Checked = false;
- //}
- }
- }
- private void dataGridView_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
- {
- e.Row.HeaderCell.Value = string.Format("{0}", (_pageIndex - 1) * _pageSize + e.Row.Index + 1);
- }
- private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.RowIndex >= 0 && e.ColumnIndex == 0)
- {
- if (this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null)
- {
- if (!_CheckRowIdList.Where(s => s == dataGridView.Rows[e.RowIndex].Cells[_PrimaryKey].Value.ToString()).Any())
- {
- _CheckRowIdList.Add(dataGridView.Rows[e.RowIndex].Cells[_PrimaryKey].Value.ToString());
- }
- this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = 1;
- }
- else if (dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "1")
- {
- if (_CheckRowIdList.Where(s => s == dataGridView.Rows[e.RowIndex].Cells[_PrimaryKey].Value.ToString()).Any())
- {
- _CheckRowIdList.Remove(dataGridView.Rows[e.RowIndex].Cells[_PrimaryKey].Value.ToString());
- }
- this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = 0;
- }
- else
- {
- if (!_CheckRowIdList.Where(s => s == dataGridView.Rows[e.RowIndex].Cells[_PrimaryKey].Value.ToString()).Any())
- {
- _CheckRowIdList.Add(dataGridView.Rows[e.RowIndex].Cells[_PrimaryKey].Value.ToString());
- }
- this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = 1;
- }
- }
- }
- private void pageTool_OnPageChange(int PageIndex, int PageSzie)
- {
- this.btnSearch_Click(null, null);
- }
- private void btnClear_Click(object sender, EventArgs e)
- {
- this.txtSearchRoleCode.Text = "";
- this.txtSearchRoleName.Text = "";
- this.chkSearchUse.Checked = true;
- }
- }
- }
|