ab56a9bcf7
SVN-Revision: r240
207 lines
7.3 KiB
C#
207 lines
7.3 KiB
C#
using Lskj.Business.Impl;
|
|
using Lskj.Control;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Util;
|
|
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 Lskj.PubUserTomodule
|
|
{
|
|
public partial class FrmPermissionClassification : BaseForm
|
|
{
|
|
/// <summary>
|
|
/// 角色表
|
|
/// </summary>
|
|
/// <value>The parent value.</value>
|
|
public DataTable RoleTable
|
|
{
|
|
get { return this.RoleControlEx.gridControl.DataSource as DataTable; }
|
|
set { this.RoleControlEx.gridControl.DataSource = value; }
|
|
}
|
|
/// <summary>
|
|
///人员表
|
|
/// </summary>
|
|
/// <value>The parent value.</value>
|
|
public DataTable PersonnelTable
|
|
{
|
|
get { return this.PeopleControlEx.gridControl.DataSource as DataTable; }
|
|
set { this.PeopleControlEx.gridControl.DataSource = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 传入的权限人员
|
|
/// </summary>
|
|
public string AuthorizedName
|
|
{
|
|
get { return this.textPersonnelList.Text; }
|
|
set { this.textPersonnelList.Text = value; }
|
|
}
|
|
|
|
public string Promptinformation
|
|
{
|
|
get { return this.groupBox4.Text; }
|
|
set { this.groupBox4.Text = value; }
|
|
}
|
|
|
|
public bool SaveRole = false;
|
|
|
|
/// <summary>
|
|
/// 点击确定事件,把当前的选中的名字传出了
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
public event ClickTheOKButton onClickTheOKButton;
|
|
public delegate void ClickTheOKButton(string Name);
|
|
|
|
|
|
public FrmPermissionClassification()
|
|
{
|
|
InitializeComponent();
|
|
//添加角色,人员表的表格列
|
|
InitializeColumns();
|
|
//拖拽
|
|
InitializeDrag();
|
|
InitSpliterPosition();
|
|
this.splitMain.SplitterPositionChanged += SplitMain_SplitterPositionChanged;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:初始化分割条位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-15</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitSpliterPosition()
|
|
{
|
|
string spliterPosition = IniHelper.Read(string.Format("FrmPermissionClassification__splitMain{0}", "PubUserTomodule"));;
|
|
if (!string.IsNullOrEmpty(spliterPosition)) this.splitMain.SplitterPosition = Convert.ToInt32(spliterPosition);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分割条改变时
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SplitMain_SplitterPositionChanged(object sender, EventArgs e)
|
|
{
|
|
IniHelper.Write(string.Format("FrmPermissionClassification__splitMain{0}", "PubUserTomodule"), this.splitMain.SplitterPosition + "");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 默认绑定列数据
|
|
/// </summary>
|
|
private void InitializeColumns()
|
|
{
|
|
this.PeopleControlEx.GridView.Columns.AddVisible("员工ID", "员工ID");
|
|
this.PeopleControlEx.GridView.Columns.AddVisible("员工工号", "员工工号");
|
|
this.PeopleControlEx.GridView.Columns.AddVisible("员工姓名", "员工姓名");
|
|
this.PeopleControlEx.GridView.Columns.AddVisible("所属部门", "所属部门");
|
|
this.RoleControlEx.GridView.Columns.AddVisible("roleName", "角色");
|
|
|
|
this.PeopleControlEx.GridView.OptionsBehavior.Editable = false;
|
|
this.RoleControlEx.GridView.OptionsBehavior.Editable = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 默认绑定拖拽
|
|
/// </summary>
|
|
private void InitializeDrag()
|
|
{
|
|
//角色,人员拖拽到人员文本框
|
|
//角色
|
|
GridDragMemo dragMemo = new GridDragMemo(this.RoleControlEx.GridView, this.textPersonnelList);
|
|
dragMemo.OnDragComplete += DragMemo_OnDragComplete;
|
|
//人员
|
|
GridDragMemo dragMemo2 = new GridDragMemo(this.PeopleControlEx.GridView, this.textPersonnelList);
|
|
dragMemo2.OnDragComplete += DragMemo_OnDragComplete;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 角色或人员拖拽到文本
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void DragMemo_OnDragComplete(object sender, GridDragMemoArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.GridViewSelectRows == null || e.GridViewSelectRows.Length == 0) return;
|
|
string userNames = string.Empty;
|
|
List<string> texts = textPersonnelList.Text.Split(',').ToList();
|
|
|
|
int index = this.xtraTabControl2.SelectedTabPageIndex;//0为角色,1为人员
|
|
|
|
if (index==1)
|
|
{
|
|
if (textPersonnelList.Text.Contains("{&"))
|
|
{
|
|
textPersonnelList.Text = "";
|
|
}
|
|
//人员
|
|
foreach (DataRow item in e.GridViewSelectRows)
|
|
{
|
|
if (!texts.Contains(item["员工姓名"] + ""))
|
|
{
|
|
userNames += item["员工姓名"] + ",";
|
|
texts.Add(item["员工姓名"] + "");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//角色
|
|
foreach (DataRow item in e.GridViewSelectRows)
|
|
{
|
|
string id = item["id"] + "";
|
|
if (SaveRole)
|
|
{
|
|
//直接保存角色(只能保存单个)
|
|
textPersonnelList.Text = "{&"+item["id"] +","+ item["roleName"]+"&}";
|
|
|
|
}
|
|
else {
|
|
//把角色换成对应人员保存
|
|
DataTable Roledetailed = PowerImpl.GetWorkUsers(id);
|
|
if (Roledetailed != null && Roledetailed.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow dr in Roledetailed.Rows)
|
|
{
|
|
if (!texts.Contains(dr["员工姓名"] + ""))
|
|
{
|
|
userNames += dr["员工姓名"] + ",";
|
|
texts.Add(dr["员工姓名"] + "");
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
textPersonnelList.Text += userNames;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
if (onClickTheOKButton != null) onClickTheOKButton(this.textPersonnelList.Text);
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|