📄 fyhjswhgj.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Sybase.DataWindow;
using Qeb.Support;
using Qeb.Support.Common;
using Qeb.DBProxy;
namespace Qeb.GY
{
public partial class FYhJsWhGj : Qeb.Control.FBase
{
private string m_Gh = "";
private string m_YhMc = "";
public FYhJsWhGj()
{
InitializeComponent();
}
private void FYhJsWhGj_load(object sender, EventArgs e)
{
this.Text = "对用户:" + m_YhMc + " 进行角色分配";
//初始化数据窗口
//Dwyhyyqx 为用户已有角色,DWqhwyqx为用户未有角色
this.Dwyhyyqx.LibraryList = PBL.GyPbl;
this.Dwyhyyqx.DataWindowObject = GyDataObjects.D_Gy_Yhwhgj;
this.DWqhwyqx.LibraryList = PBL.GyPbl;
this.DWqhwyqx.DataWindowObject = GyDataObjects.D_Gy_Yhjswh;
this.Dwyhyyqx.InitUI();
this.DWqhwyqx.InitUI();
try
{
Dwyhyyqx.SetProperty("DataWindow.ReadOnly", "Yes");
DWqhwyqx.SetProperty("DataWindow.ReadOnly", "Yes");
}
catch (Exception ex)
{
MessageBox.Show("设置数据窗口只读属性发生异常:" + ex.Message);
}
this.RetrieveData();
}
internal void SetUserMsg(string gh,string yhMc)
{
this.m_Gh = gh;
this.m_YhMc = yhMc;
}
private void RetrieveData()
{
try
{
DbProxyClient proxy = App.DbProxy;
proxy.Clear();
proxy.AddRetrieveParam("p_gh", m_Gh);
proxy.Retrieve(this.Dwyhyyqx);
proxy.Clear();
proxy.Retrieve(this.DWqhwyqx);
}
catch (Exception ex)
{
MessageBox.Show("检索数据出错:" + ex.Message, MsgTitle.Error);
}
try
{
DWqhwyqx.SetRedrawOff();
int rowFind = -1;
string yyJsId = ""; //当前已有角色ID
for (int i = 1; i < Dwyhyyqx.RowCount + 1; i++)
{
if (Dwyhyyqx.IsItemNull(i, "jsid"))
continue;
yyJsId = Dwyhyyqx.GetItemString(i, "jsid");
rowFind = DWqhwyqx.FindRow("jsid='" + yyJsId + "'", 1, DWqhwyqx.RowCount);
if (rowFind > 0)
{
DWqhwyqx.DeleteRow(rowFind);
}
}
}
catch(Exception ex)
{
MessageBox.Show("初始化未有角色时出错:" + ex.Message, MsgTitle.Error);
}
finally
{
DWqhwyqx.SetRedrawOn();
DWqhwyqx.Refresh();
}
}
//局部搜索(未拥有角色)
private void RetrieveData2()
{
try
{
DbProxyClient proxy = App.DbProxy;
proxy.Clear();
proxy.Retrieve(this.DWqhwyqx);
}
catch (Exception ex)
{
MessageBox.Show("检索数据出错:" + ex.Message, MsgTitle.Error);
}
int rowFind = -1;
string yyJsId = ""; //当前已有角色ID
for (int i = 1; i < Dwyhyyqx.RowCount + 1; i++)
{
if (Dwyhyyqx.IsItemNull(i, "jsid"))
continue;
yyJsId = Dwyhyyqx.GetItemString(i, "jsid");
rowFind = DWqhwyqx.FindRow("jsid='" + yyJsId + "'", 1, DWqhwyqx.RowCount);
if (rowFind > 0)
{
DWqhwyqx.DeleteRow(rowFind);
}
}
}
//删除用户已经一条角色
private void Bt_del_Click(object sender, EventArgs e)
{
if (Dwyhyyqx.RowCount < 1)
return;
else
{
int sleRow = -1; //当前选择行的行数
sleRow = Dwyhyyqx.CurrentRow;
if(sleRow<1)
{
MessageBox.Show("请选择角色!");
return;
}
else
{
Delrow(sleRow);
}
}
}
//添加该用户未拥有的一条角色
private void Bt_add_Click(object sender, EventArgs e)
{
if(DWqhwyqx.RowCount<1)
return;
else
{
int selRow = -1;
selRow = DWqhwyqx.CurrentRow;
if(selRow<1)
{
MessageBox.Show("请选择角色!");
return;
}
else
{
Addrow(selRow);
}
}
}
//删除该用户的所有角色
private void Bt_delall_Click(object sender, EventArgs e)
{
if (Dwyhyyqx.RowCount < 1)
return;
else
{
int i = 0;
do
{
Dwyhyyqx.DeleteRow(1);
}
while
(i < Dwyhyyqx.RowCount)
;
this.RetrieveData2();
if (BTsave.Enabled == false)
BTsave.Enabled = true;
}
}
//添加该用户未拥有的所有角色
private void Bt_addall_Click(object sender, EventArgs e)
{
if (DWqhwyqx.RowCount < 1)
return;
else
{
for (int i = 1; i < DWqhwyqx.RowCount + 1;i++ )
{
int insertRow = Dwyhyyqx.InsertRow(0);
Dwyhyyqx.SetRow(insertRow);
Dwyhyyqx.ScrollToRow(insertRow);
Dwyhyyqx.SetItemString(insertRow, "jsid", DWqhwyqx.GetItemString(i, "jsid"));
Dwyhyyqx.SetItemString(insertRow, "jsmc", DWqhwyqx.GetItemString(i, "jsmc"));
Dwyhyyqx.SetItemString(insertRow, "gh", m_Gh);
}
this.RetrieveData2();
if (BTsave.Enabled == false)
BTsave.Enabled = true;
}
}
//保存设置
private void BTsave_Click(object sender, EventArgs e)
{
Dwyhyyqx.AcceptText();
try
{
DbProxyClient proxy = App.DbProxy;
proxy.Clear();
proxy.AddDataWindow(this.Dwyhyyqx);
proxy.Update();
BTsave.Enabled = false;
}
catch (Exception ex)
{
MessageBox.Show("保存用户角色发生异常:" + ex.Message, MsgTitle.Error);
}
}
//重置该用户的角色
private void BTrebake_Click(object sender, EventArgs e)
{
if(BTsave.Enabled==true)
{
DialogResult result = MessageBox.Show(this, "数据已修改,是否需要保存?", MsgTitle.Prompt, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
return;
}
}
this.RetrieveData();
BTsave.Enabled = false;
}
//取消关闭
private void BTclose_Click(object sender, EventArgs e)
{
if (BTsave.Enabled == true)
{
DialogResult result = MessageBox.Show(this, "数据已修改,是否需要保存?", MsgTitle.Prompt, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
return;
}
}
this.Close();
}
//已有角色双击
private void Dwyhyyqx_DoubleClick(object sender, EventArgs e)
{
if (Dwyhyyqx.ObjectUnderMouse.RowNumber > 0)
{
Delrow(Dwyhyyqx.ObjectUnderMouse.RowNumber);
}
else
return;
}
// 删除一行
private void Delrow(int rowNum)
{
Dwyhyyqx.DeleteRow(rowNum);
this.RetrieveData2();
if (BTsave.Enabled == false)
BTsave.Enabled = true;
}
//增加一条用户角色
private void Addrow(int rowNum)
{
int insertRow = Dwyhyyqx.InsertRow(0);
Dwyhyyqx.SetRow(insertRow);
Dwyhyyqx.ScrollToRow(insertRow);
Dwyhyyqx.SetItemString(insertRow, "jsid", DWqhwyqx.GetItemString(rowNum, "jsid"));
Dwyhyyqx.SetItemString(insertRow, "jsmc", DWqhwyqx.GetItemString(rowNum, "jsmc"));
Dwyhyyqx.SetItemString(insertRow, "gh", m_Gh);
this.RetrieveData2();
if (BTsave.Enabled == false)
BTsave.Enabled = true;
}
//未有角色双击
private void DWqhwyqx_DoubleClick(object sender, EventArgs e)
{
if(DWqhwyqx.ObjectUnderMouse.RowNumber>0)
{
Addrow(DWqhwyqx.ObjectUnderMouse.RowNumber);
}
else
return;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -