/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_MST_0203.cs
* 2.功能描述:用户功能权限设置
* 编辑履历:
* 作者 日期 版本 修改内容
* 张国印 2014/09/17 1.00 新建
*******************************************************************************/
using System;
using System.Data;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseControls;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Basics.Library;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
namespace Dongke.IBOSS.PRD.Client.SystemModule
{
///
/// 用户功能权限设置
///
public partial class F_MST_0203 : FormBase
{
#region 成员变量
// 传过来的用户ID
private int _userID;
//页面的数据源
DataSet _userFunctionRightData;
//页面的数据源
DataSet _userFunctionRightData2;
// 系统功能ID
private string _functionCode = string.Empty;
// 系统功能ID
private string _functionCode2 = string.Empty;
// 是否需要触发After Check事件(性能改善)
private bool _needActionCheck = false;
// 是否需要触发After Check事件(性能改善)
private bool _needActionCheck2 = false;
// 用户授权方式 1:按站点 2:按用户
private int _licenseType;
// 保存时,用于返回超过授权站点数的明细
private string _overLicenseNumberFunctions;
// 保存时,用于返回超过授权站点数的明细
private string _overLicenseNumberFunctions2;
// 是否不限制功能权限
private bool isFunctionCodeAll = false;
// 是否不限制功能权限
private bool isFunctionCodeAll2 = false;
#endregion
#region 构造函数
///
/// 构造函数
///
///
public F_MST_0203(int userID)
{
InitializeComponent();
this._userID = userID;
// 设置标题
this.Text = FormTitles.F_MST_0203;
// 工具栏按钮文本赋值
this.btnSave.Text = ButtonText.BTN_SAVE;
this.btnCancel.Text = ButtonText.BTN_CLOSE;
this.dgvFunctionUsers.AutoGenerateColumns = false;
this.dgvFunctionUsers.Columns["UserCode"].ReadOnly = true;
this.dgvFunctionUsers.Columns["UserName"].ReadOnly = true;
this.dgvFunctionUsers.Columns["OrganizationName"].ReadOnly = true;
// 隐藏二期功能
this.tabControl1.TabPages.Remove(this.tabPage2);
}
///
/// 构造函数
///
///
/// 用户编码
public F_MST_0203(int userID, string userCode)
{
InitializeComponent();
this._userID = userID;
// 设置标题
this.Text = FormTitles.F_MST_0203;
// 工具栏按钮文本赋值
this.btnSave.Text = ButtonText.BTN_SAVE;
this.btnCancel.Text = ButtonText.BTN_CLOSE;
this.dgvFunctionUsers.AutoGenerateColumns = false;
this.dgvFunctionUsers.Columns["UserCode"].ReadOnly = true;
this.dgvFunctionUsers.Columns["UserName"].ReadOnly = true;
this.dgvFunctionUsers.Columns["OrganizationName"].ReadOnly = true;
this.lblUserCode.Text += userCode;
this.lblUserCode2.Text += userCode;
// 隐藏二期功能
this.tabControl1.TabPages.Remove(this.tabPage2);
}
#endregion
#region 事件
///
/// 页面加载事件
///
///
///
private void F_MST_0203_Load(object sender, EventArgs e)
{
try
{
// 保存按钮不可用
//this.btnSave.Enabled = false;
// 取得用户权限并赋值
this._needActionCheck = false;
this.SetControlsDataSource();
this._needActionCheck = true;
// 二期
// 取得用户权限并赋值
this._needActionCheck2 = false;
this.SetControlsDataSource2();
this._needActionCheck2 = true;
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 全选复选框勾选,功能节点树形全选或者全部取消
///
///
///
private void chkFunctionSelect_CheckedChanged(object sender, EventArgs e)
{
try
{
this._needActionCheck = false;
foreach (DataRow dataRow in _userFunctionRightData.Tables[0].Rows)
{
dataRow["Choose"] = this.chkFunctionSelect.Checked;
}
TreeNodeCollection nodes = this.tvwFunction.Nodes;
foreach (TreeNode node in nodes)
{
node.Checked = this.chkFunctionSelect.Checked;
CheckSubNodes(node, this.chkFunctionSelect.Checked);
}
this._needActionCheck = true;
// 保存按钮状态改变
//this.btnSave.Enabled = DataJudge.IsChange(this._userFunctionRightData);
//this.btnSave.Enabled = true;
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 功能权限选择之后,需要检查是否选择了子节点和父节点
///
///
///
private void tvwFunction_AfterCheck(object sender, TreeViewEventArgs e)
{
try
{
if (this._needActionCheck)
{
this.CheckControl(e);
// 将后台数据源的选择状态改变
string functionCode = e.Node.Tag.ToString();
foreach (DataRow dataRow in _userFunctionRightData.Tables[0].Rows)
{
if (functionCode == dataRow["FunctionCode"].ToString())
{
dataRow["Choose"] = e.Node.Checked;
break;
}
}
// 保存按钮状态改变
// this.btnSave.Enabled = DataJudge.IsChange(this._userFunctionRightData);
//this.btnSave.Enabled = true;
}
}
catch (Exception ex)
{
this.btnSave.Enabled = true;
this.btnCancel.Enabled = true;
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 功能权限树形选择之后显示该功能权限所有的使用用户
///
///
///
private void tvwFunction_AfterSelect(object sender, TreeViewEventArgs e)
{
try
{
if (e.Node.Name == Constant.INT_IS_ONE.ToString())
{
this._functionCode = e.Node.Tag.ToString();
this.btnSave.Enabled = false;
this.btnCancel.Enabled = false;
DataSet functionUsers = (DataSet)DoAsync(new BaseAsyncMethod(GetFunctionUsers));
//this.btnSave.Enabled = DataJudge.IsChange(this._userFunctionRightData);
this.btnSave.Enabled = true;
this.btnCancel.Enabled = true;
if (functionUsers != null)
{
this.dgvFunctionUsers.AutoGenerateColumns = false;
this.dgvFunctionUsers.DataSource = functionUsers.Tables[0];
this.dgvFunctionUsers.Columns["UserCode"].ReadOnly = true;
this.dgvFunctionUsers.Columns["UserName"].ReadOnly = true;
this.dgvFunctionUsers.Columns["OrganizationName"].ReadOnly = true;
}
}
}
catch (Exception ex)
{
//this.btnSave.Enabled = DataJudge.IsChange(this._userFunctionRightData);
this.btnSave.Enabled = true;
this.btnCancel.Enabled = true;
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 页面关闭时,需要确认是否关闭窗体
///
///
///
private void F_MST_0203_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
// 判断数据是否被修改过,修改过需要提示保存消息
if (DataJudge.IsChange(this._userFunctionRightData))
{
DialogResult result = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text,
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
// 保存数据
btnSave_Click(sender, e);
}
else if (result == DialogResult.Cancel)
{
e.Cancel = true;
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 功能树全部展开
///
///
///
private void btnFunctionExpandAll_Click(object sender, EventArgs e)
{
this.tvwFunction.ExpandAll();
}
///
/// 功能树全部关闭
///
///
///
private void btnFunctionCollapseAll_Click(object sender, EventArgs e)
{
this.tvwFunction.CollapseAll();
}
///
/// 关闭按钮按下事件
///
///
///
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 保存用户的功能权限
///
///
///
private void btnSave_Click(object sender, EventArgs e)
{
try
{
FunRightResultEntity returnAffectRows = (FunRightResultEntity)DoAsync(new BaseAsyncMethod(SaveUserFunctionRight));
this._overLicenseNumberFunctions = returnAffectRows.LicenseFunctions;
// 将DataGridView单元格的可写状态设置成不可写的
this.dgvFunctionUsers.Columns["UserCode"].ReadOnly = true;
this.dgvFunctionUsers.Columns["UserName"].ReadOnly = true;
this.dgvFunctionUsers.Columns["OrganizationName"].ReadOnly = true;
this._overLicenseNumberFunctions2 = returnAffectRows.LicenseFunctions;
// 将DataGridView单元格的可写状态设置成不可写的
this.dgvFunctionUsers2.Columns["UserCode2"].ReadOnly = true;
this.dgvFunctionUsers2.Columns["UserName2"].ReadOnly = true;
this.dgvFunctionUsers2.Columns["OrganizationName2"].ReadOnly = true;
// 保存设置好的 系统功能 隐藏价格
if (returnAffectRows.OperationStatus > Constant.INT_IS_ZERO)
{
this._userFunctionRightData.AcceptChanges();
// 提示信息
MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "功能权限", "保存"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
else if (returnAffectRows.OperationStatus == Constant.INT_IS_ZERO)
{
// 提示信息
MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "功能权限", "保存"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
// 提示信息
string functionOver = "";
if (_overLicenseNumberFunctions.Length > 100)
{
functionOver = _overLicenseNumberFunctions.Substring(0, 99) + "......";
}
else
{
functionOver = _overLicenseNumberFunctions;
}
MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
"以下的功能超出了授权功能数:\r\n" + functionOver),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
#region 私有方法
///
/// 为功能权限树形赋值
///
private void SetControlsDataSource()
{
try
{
// 根据用户ID取得用户的权限信息
DataSet userRightData = SystemModuleProxy.Service.GetUserFunctionRightInfo(_userID);
if (userRightData == null || userRightData.Tables.Count < Constant.INT_IS_ONE)
{
return;
}
this._userFunctionRightData = new DataSet();
DataTable functionTable = userRightData.Tables[0].Copy();
if (functionTable.Rows.Count > 0)
{
DataRow[] drAll = functionTable.Select("FunctionCode='[ALL]'");
if (drAll.Length > 0)
{
this.isFunctionCodeAll = true;//加载时是选中的,为了是判断保存按钮是否可用
this.chkFunctionCodeAll.Checked = true;
}
}
// 取得license文件中的功能权限
//DataTable licenseFunction = new DataTable();
//if (LogInUserInfo.CurrentUser.CurrentLicenseInfo == null || LogInUserInfo.CurrentUser.CurrentLicenseInfo.Tables.Count < 2)
//{
// return;
//}
//licenseFunction = LogInUserInfo.CurrentUser.CurrentLicenseInfo.Tables[1].Copy();
//_licenseType = Convert.ToInt32(LogInUserInfo.CurrentUser.CurrentLicenseInfo.Tables[0].Rows[0]["LicenseTypeID"]);
//// 剔除没有授权的功能
//for (int i = 0; i < functionTable.Rows.Count; i++)
//{
// DataRow[] filter = licenseFunction.Select("FunctionCode = '" + functionTable.Rows[i]["FunctionCode"] + "'");
// if (filter.Length < 1)
// {
// functionTable.Rows[i].Delete();
// }
// else
// {
// functionTable.Rows[i]["LicensesNumber"] = filter[0]["FunctionNumber"].ToString();
// }
//}
functionTable.AcceptChanges();
this._userFunctionRightData.Tables.Add(functionTable);
InitFunctionTreeView(this._userFunctionRightData.Tables[0]);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 为功能权限树形赋值(二期)
///
private void SetControlsDataSource2()
{
try
{
// 根据用户ID取得用户的权限信息
DataSet userRightData = SystemModuleProxy.Service.GetUserFunctionRightTwoInfo(_userID);
if (userRightData == null || userRightData.Tables.Count < Constant.INT_IS_ONE)
{
return;
}
this._userFunctionRightData2 = new DataSet();
DataTable functionTable = userRightData.Tables[0].Copy();
if (functionTable.Rows.Count > 0)
{
DataRow[] drAll = functionTable.Select("FunctionCode='[ALL2]'");
if (drAll.Length > 0)
{
this.isFunctionCodeAll2 = true;//加载时是选中的,为了是判断保存按钮是否可用
this.chkFunctionCodeAll2.Checked = true;
}
}
functionTable.AcceptChanges();
this._userFunctionRightData2.Tables.Add(functionTable);
InitFunctionTreeView2(this._userFunctionRightData2.Tables[0]);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 根据取得的数据生成权限树
///
///
private void InitFunctionTreeView(DataTable treeTable)
{
try
{
// 初期显示时,滚动条没有显示全部的tree节点。 by chenxy 2014-05-25
this.tvwFunction.Scrollable = false;
TreeNode node = null;
//DataRow[] warehouseRows = treeTable.Select("LEN(FunctionCode) = 2");
DataRow[] warehouseRows = treeTable.Select("LEN(FUNCTIONLEVEL) = 2");
// 递归生成功能权限树
this.InitTreeView(treeTable, warehouseRows, node);
// 初期显示时,滚动条没有显示全部的tree节点。 by chenxy 2014-05-25
this.tvwFunction.Scrollable = true;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 根据取得的数据生成权限树
///
///
private void InitFunctionTreeView2(DataTable treeTable)
{
try
{
// 初期显示时,滚动条没有显示全部的tree节点。 by chenxy 2014-05-25
this.tvwFunction2.Scrollable = false;
TreeNode node = null;
//DataRow[] warehouseRows = treeTable.Select("LEN(FunctionCode) = 2");
DataRow[] warehouseRows = treeTable.Select("LEN(FUNCTIONLEVEL) = 3");
// 递归生成功能权限树
this.InitTreeView2(treeTable, warehouseRows, node);
// 初期显示时,滚动条没有显示全部的tree节点。 by chenxy 2014-05-25
this.tvwFunction2.Scrollable = true;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 递归创建树
///
///
///
///
private void InitTreeView(DataTable treeTable, DataRow[] rows, TreeNode node)
{
try
{
foreach (DataRow row in rows)
{
TreeNode sNode;
if (node == null)
{
sNode = new TreeNode();
if (row["FunctionFlag"].ToString() == Constant.INT_IS_ONE.ToString())
{
sNode.Text = "[" + row["FUNCTIONLEVEL"].ToString() + "] " + row["FunctionName"].ToString();
//+ " ( " + row["UseLincenseNumber"].ToString() + " / " + row["LicensesNumber"].ToString() + " )";
}
else
{
sNode.Text = "[" + row["FUNCTIONLEVEL"].ToString() + "] " + row["FunctionName"].ToString();
}
sNode.Name = row["FunctionFlag"].ToString();
sNode.Tag = row["FunctionCode"].ToString();
if (row["Choose"].ToString() == Constant.INT_IS_ONE.ToString())
{
sNode.Checked = true;
}
this.tvwFunction.Nodes.Add(sNode);
}
else
{
if (row["FunctionFlag"].ToString() == Constant.INT_IS_ONE.ToString())
{
sNode = node.Nodes.Add("[" + row["FUNCTIONLEVEL"].ToString() + "] " + row["FunctionName"].ToString());
//+ " ( " + row["UseLincenseNumber"].ToString() + " / " + row["LicensesNumber"].ToString() + " )");
}
else
{
sNode = node.Nodes.Add("[" + row["FUNCTIONLEVEL"].ToString() + "] " + row["FunctionName"].ToString());
}
sNode.Name = row["FunctionFlag"].ToString();
sNode.Tag = row["FunctionCode"].ToString();
if (row["Choose"].ToString() == Constant.INT_IS_ONE.ToString())
{
sNode.Checked = true;
}
}
//string filterExpression = "FunctionCode LIKE '" + row["FunctionCode"].ToString()
// + "%' AND LEN(FunctionCode) = " + (row["FunctionCode"].ToString().Length + 2);
string filterExpression = "FUNCTIONLEVEL LIKE '" + row["FUNCTIONLEVEL"].ToString()
+ "%' AND LEN(FUNCTIONLEVEL) = " + (row["FUNCTIONLEVEL"].ToString().Length + 2);
DataRow[] subRows = treeTable.Select(filterExpression);
// 递归方法
InitTreeView(treeTable, subRows, sNode);
}
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 递归创建树
///
///
///
///
private void InitTreeView2(DataTable treeTable, DataRow[] rows, TreeNode node)
{
try
{
foreach (DataRow row in rows)
{
TreeNode sNode;
if (node == null)
{
sNode = new TreeNode();
if (row["FunctionFlag"].ToString() == Constant.INT_IS_ONE.ToString())
{
sNode.Text = "[" + row["FUNCTIONLEVEL"].ToString() + "] " + row["FunctionName"].ToString();
//+ " ( " + row["UseLincenseNumber"].ToString() + " / " + row["LicensesNumber"].ToString() + " )";
}
else
{
sNode.Text = "[" + row["FUNCTIONLEVEL"].ToString() + "] " + row["FunctionName"].ToString();
}
sNode.Name = row["FunctionFlag"].ToString();
sNode.Tag = row["FunctionCode"].ToString();
if (row["Choose"].ToString() == Constant.INT_IS_ONE.ToString())
{
sNode.Checked = true;
}
this.tvwFunction2.Nodes.Add(sNode);
}
else
{
if (row["FunctionFlag"].ToString() == Constant.INT_IS_ONE.ToString())
{
sNode = node.Nodes.Add("[" + row["FUNCTIONLEVEL"].ToString() + "] " + row["FunctionName"].ToString());
//+ " ( " + row["UseLincenseNumber"].ToString() + " / " + row["LicensesNumber"].ToString() + " )");
}
else
{
sNode = node.Nodes.Add("[" + row["FUNCTIONLEVEL"].ToString() + "] " + row["FunctionName"].ToString());
}
sNode.Name = row["FunctionFlag"].ToString();
sNode.Tag = row["FunctionCode"].ToString();
if (row["Choose"].ToString() == Constant.INT_IS_ONE.ToString())
{
sNode.Checked = true;
}
}
string filterExpression = "FUNCTIONLEVEL LIKE '" + row["FUNCTIONLEVEL"].ToString()
+ "%' AND LEN(FUNCTIONLEVEL) = " + (row["FUNCTIONLEVEL"].ToString().Length + 3);
DataRow[] subRows = treeTable.Select(filterExpression);
// 递归方法
InitTreeView2(treeTable, subRows, sNode);
}
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 递归选中节点或者取消选中节点
///
///
///
private void CheckSubNodes(TreeNode treeNode, bool nodeChecked)
{
foreach (TreeNode node in treeNode.Nodes)
{
node.Checked = nodeChecked;
if (node.Nodes.Count >Constant.INT_IS_ZERO)
{
this.CheckSubNodes(node, nodeChecked);
}
}
}
///
/// 节点 Checked 属性控制
///
///
private void CheckControl(TreeViewEventArgs e)
{
if (e.Action != TreeViewAction.Unknown)
{
if (e.Node != null && !Convert.IsDBNull(e.Node))
{
CheckParentNode(e.Node);
if (e.Node.Nodes.Count > Constant.INT_IS_ZERO)
{
CheckAllChildNodes(e.Node, e.Node.Checked);
}
}
}
}
///
/// 改变父节点的选中状态,此处为所有子节点不选中时才取消父节点选中,可以根据需要修改
///
///
private static void CheckParentNode(TreeNode curNode)
{
bool bChecked = false;
if (curNode.Parent != null)
{
if (curNode.Checked)
{
bChecked = true;
}
else
{
foreach (TreeNode node in curNode.Parent.Nodes)
{
if (node.Checked)
{
bChecked = true;
break;
}
}
}
if (bChecked != curNode.Parent.Checked)
{
curNode.Parent.Checked = bChecked;
CheckParentNode(curNode.Parent);
}
}
}
///
/// 改变所有子节点的状态
///
///
///
private static void CheckAllChildNodes(TreeNode pn, bool IsChecked)
{
foreach (TreeNode tn in pn.Nodes)
{
tn.Checked = IsChecked;
if (tn.Nodes.Count > Constant.INT_IS_ZERO)
{
CheckAllChildNodes(tn, IsChecked);
}
}
}
///
/// 根据系统功能ID取得使用该功能的用户列表
///
///
private DataSet GetFunctionUsers()
{
try
{
return SystemModuleProxy.Service.GetFunctionUsers(_functionCode);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 根据系统功能ID取得使用该功能的用户列表
///
///
private DataSet GetFunctionUsers2()
{
try
{
return SystemModuleProxy.Service.GetFunctionUsers(_functionCode2);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 保存用户的功能权限
///
///
/// 执行更新影响的数据行数
/// 大于0:正常操作,返回
/// 等于0:无任何影响行数
/// -1:更新的功能权限有超过授权站点数
///
private FunRightResultEntity SaveUserFunctionRight()
{
try
{
if (chkFunctionCodeAll.Checked)
{
if (this._userFunctionRightData.Tables[0].Select("FunctionCode='[ALL]'").Length == 0)
{
DataRow dr = this._userFunctionRightData.Tables[0].NewRow();
dr["FunctionCode"] = "[ALL]";
dr["Choose"] = 1;
this._userFunctionRightData.Tables[0].Rows.Add(dr);
}
}
else
{
if (this._userFunctionRightData.Tables[0].Select("FunctionCode='[ALL]'").Length > 0)
{
DataRow[] dr1 = this._userFunctionRightData.Tables[0].Select("FunctionCode='[ALL]'");
this._userFunctionRightData.Tables[0].Rows.Remove(dr1[0]);
}
}
// 二期
if (chkFunctionCodeAll2.Checked)
{
if (this._userFunctionRightData2.Tables[0].Select("FunctionCode='[ALL2]'").Length == 0)
{
DataRow dr = this._userFunctionRightData2.Tables[0].NewRow();
dr["FunctionCode"] = "[ALL2]";
dr["Choose"] = 1;
this._userFunctionRightData2.Tables[0].Rows.Add(dr);
}
}
else
{
if (this._userFunctionRightData.Tables[0].Select("FunctionCode='[ALL2]'").Length > 0)
{
DataRow[] dr1 = this._userFunctionRightData.Tables[0].Select("FunctionCode='[ALL2]'");
this._userFunctionRightData.Tables[0].Rows.Remove(dr1[0]);
}
}
//return SystemModuleProxy.Service.SaveUserFunctionRight(this._userFunctionRightData, this._userID, this._licenseType);
return SystemModuleProxy.Service.SaveUserFunctionTwoRight(this._userFunctionRightData, this._userID, this._licenseType, this._userFunctionRightData2);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
///
/// 不限制按钮选择事件
///
///
///
private void chkFunctionCodeAll_CheckedChanged(object sender, EventArgs e)
{
//try
//{
// if ((chkFunctionCodeAll.Checked && !this.isFunctionCodeAll) || (!chkFunctionCodeAll.Checked && this.isFunctionCodeAll))
// {
// // 保存按钮状态改变
// this.btnSave.Enabled = true;
// }
// else
// {
// this.btnSave.Enabled = false;
// }
// this.btnSave.Enabled = true;
//}
//catch (Exception ex)
//{
// // 对异常进行共通处理
// ExceptionManager.HandleEventException(this.ToString(),
// System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
//}
}
private void tvwFunction2_AfterSelect(object sender, TreeViewEventArgs e)
{
try
{
if (e.Node.Name == Constant.INT_IS_ONE.ToString())
{
this._functionCode2 = e.Node.Tag.ToString();
this.btnSave.Enabled = false;
this.btnCancel.Enabled = false;
DataSet functionUsers = (DataSet)DoAsync(new BaseAsyncMethod(GetFunctionUsers2));
//this.btnSave.Enabled = DataJudge.IsChange(this._userFunctionRightData2);
this.btnSave.Enabled = true;
this.btnCancel.Enabled = true;
if (functionUsers != null)
{
this.dgvFunctionUsers2.AutoGenerateColumns = false;
this.dgvFunctionUsers2.DataSource = functionUsers.Tables[0];
this.dgvFunctionUsers2.Columns["UserCode2"].ReadOnly = true;
this.dgvFunctionUsers2.Columns["UserName2"].ReadOnly = true;
this.dgvFunctionUsers2.Columns["OrganizationName2"].ReadOnly = true;
}
}
}
catch (Exception ex)
{
//this.btnSave.Enabled = DataJudge.IsChange(this._userFunctionRightData2);
this.btnSave.Enabled = true;
this.btnCancel.Enabled = true;
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
private void tvwFunction2_AfterCheck(object sender, TreeViewEventArgs e)
{
try
{
if (this._needActionCheck2)
{
this.CheckControl(e);
// 将后台数据源的选择状态改变
string functionID = e.Node.Tag.ToString();
foreach (DataRow dataRow in _userFunctionRightData2.Tables[0].Rows)
{
if (functionID ==dataRow["FunctionCode"].ToString())
{
dataRow["Choose"] = e.Node.Checked;
break;
}
}
// 保存按钮状态改变
//this.btnSave.Enabled = DataJudge.IsChange(this._userFunctionRightData2);
this.btnSave.Enabled = true;
}
}
catch (Exception ex)
{
this.btnSave.Enabled = true;
this.btnCancel.Enabled = true;
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
private void chkFunctionSelect2_CheckedChanged(object sender, EventArgs e)
{
try
{
this._needActionCheck2 = false;
foreach (DataRow dataRow in _userFunctionRightData2.Tables[0].Rows)
{
dataRow["Choose"] = this.chkFunctionSelect2.Checked;
}
TreeNodeCollection nodes = this.tvwFunction2.Nodes;
foreach (TreeNode node in nodes)
{
node.Checked = this.chkFunctionSelect2.Checked;
CheckSubNodes(node, this.chkFunctionSelect2.Checked);
}
this._needActionCheck2 = true;
// 保存按钮状态改变
//this.btnSave.Enabled = DataJudge.IsChange(this._userFunctionRightData2);
this.btnSave.Enabled = true;
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
private void btnFunctionExpandAll2_Click(object sender, EventArgs e)
{
this.tvwFunction2.ExpandAll();
}
private void btnFunctionCollapseAll2_Click(object sender, EventArgs e)
{
this.tvwFunction2.CollapseAll();
}
private void chkFunctionCodeAll2_CheckedChanged(object sender, EventArgs e)
{
//try
//{
// if (!this.btnSave.Enabled)
// {
// if ((chkFunctionCodeAll2.Checked && !this.isFunctionCodeAll2) || (!chkFunctionCodeAll2.Checked && this.isFunctionCodeAll2))
// {
// // 保存按钮状态改变
// this.btnSave.Enabled = true;
// }
// else
// {
// this.btnSave.Enabled = false;
// }
// }
// else
// {
// if(!chkFunctionCodeAll2.Checked)
// {
// // 保存按钮状态改变
// this.btnSave.Enabled = DataJudge.IsChange(this._userFunctionRightData2);
// }
// }
// this.btnSave.Enabled = true;
//}
//catch (Exception ex)
//{
// // 对异常进行共通处理
// ExceptionManager.HandleEventException(this.ToString(),
// System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
//}
}
}
}