📄 rc_dbrecorrightmanage.pas
字号:
unit RC_DBRecorRightManage;
{
代码单元名称:通用权限分配工具记录权限分配窗口
从属软件:大连资金清算中心打码机管理信息系统
开发单位:大连理工大学计算机技术研究所软件工程研究室
作者:王树润
时间:2001,1,30
}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ToolWin, StdCtrls, ExtCtrls, Buttons, ImgList, Mask;
type
TRC_DfmDBRecordRightManage = class(TForm)
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
CloseToolButton: TToolButton;
ConfirmToolButton: TToolButton;
ImageList1: TImageList;
addBtn: TSpeedButton;
delBtn: TSpeedButton;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
FieldNameComboBox: TComboBox;
ComputeComboBox: TComboBox;
XZLojiSelect: TRadioGroup;
GroupBox2: TGroupBox;
ConditionListBox: TListBox;
MaskEdit1: TMaskEdit;
procedure CloseToolButtonClick(Sender: TObject);
procedure addBtnClick(Sender: TObject);
procedure delBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ConfirmToolButtonClick(Sender: TObject);
procedure FieldNameComboBoxChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
FieldTypes: TStrings;
TreeView1: TTreeView;
constructor Create(Owner: TComponent; ATreeView: TTreeView); overload;
end;
implementation
uses RC_DataModule1;
var
RC_DBRecorRightManage_EditContent: string;
{$R *.DFM}
//构造函数======================================================================
constructor TRC_DfmDBRecordRightManage.Create(Owner: TComponent; ATreeView:
TTreeView);
begin
inherited Create(Owner);
TreeView1 := ATreeView;
end;
//窗体==========================================================================
procedure TRC_DfmDBRecordRightManage.FormShow(Sender: TObject);
begin
FieldTypes := TStringList.Create;
with RC_DfmDataModule1.DTableFieldQuery do
begin
if Active then
Close;
Sql.Clear;
Sql.Add('Select *');
Sql.Add('From ' + 'D' + Copy(TreeView1.Selected.Text, 1, pos('_',
TreeView1.Selected.Text) - 1));
try
OPen;
except
ShowMessage('无法打开库表!');
Exit;
end;
while not Eof do
begin
if FieldByName('FieldType').AsString = 'ftInteger' then
FieldTypes.Add('数值')
else
FieldTypes.Add('非数值');
FieldNameComboBox.Items.Add(FieldByName('FieldNameE').AsString);
Next;
end;
end;
FieldNameComboBox.ItemIndex := 0;
ComputeComboBox.ItemIndex := 0;
if FieldTypes[FieldNameComboBox.ItemIndex] = '数值' then
begin
MaskEdit1.EditMask := '!999999999999999;1;';
RC_DBRecorRightManage_EditContent := MaskEdit1.Text;
end
else
begin
MaskEdit1.EditMask := '!cccccccccccccc;1;';
RC_DBRecorRightManage_EditContent := MaskEdit1.Text;
end;
end;
procedure TRC_DfmDBRecordRightManage.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
FieldTypes.Free;
end;
//按钮==========================================================================
procedure TRC_DfmDBRecordRightManage.CloseToolButtonClick(Sender: TObject);
begin
Close;
end;
procedure TRC_DfmDBRecordRightManage.addBtnClick(Sender: TObject);
var
WhereSqlString: string;
i: integer;
begin
if ComputeComboBox.ItemIndex = -1 then
begin
ShowMessage('请选择运算符!');
Exit;
end;
if ((MaskEdit1.Text = '') or (MaskEdit1.Text =
RC_DBRecorRightManage_EditContent)) then
begin
ShowMessage('请输入条件!');
Exit;
end;
WhereSqlString := Trim(FieldNameComboBox.Text) + ' ' +
Trim(ComputeComboBox.Text);
if FieldTypes[FieldNameComboBox.ItemIndex] = '数值' then
begin
MaskEdit1.EditMask := '!999999999999999;1;';
WhereSqlString := WhereSqlString + ' ' + Trim(MaskEdit1.Text);
end
else
begin
WhereSqlString := WhereSqlString + ' ' + '''' + Trim(MaskEdit1.Text) + '''';
MaskEdit1.EditMask := '!ccccccccccccccc;1;';
end;
if ConditionListBox.Items.Count <> 0 then
begin
for i := 0 to ConditionListBox.Items.Count - 1 do
if Pos(WhereSqlString, ConditionListBox.Items[i]) <> 0 then
Exit;
if XZLojiSelect.ItemIndex = 0 then
WhereSqlString := 'And ' + WhereSqlString
else if XZLojiSelect.ItemIndex = 1 then
WhereSqlString := 'Or ' + WhereSqlString
else
WhereSqlString := 'Not ' + WhereSqlString
end;
ConditionListBox.Items.Add(WhereSqlString);
end;
procedure TRC_DfmDBRecordRightManage.delBtnClick(Sender: TObject);
begin
if ConditionListBox.Items.Count = 0 then
Exit;
if ConditionListBox.ItemIndex <> -1 then
ConditionListBox.Items.Delete(ConditionListBox.ItemIndex);
if ConditionListBox.Items.Count <> 0 then
if ((Pos('And ', ConditionListBox.Items[0]) <> 0) or (Pos('Or ',
ConditionListBox.Items[0]) <> 0) or (Pos('not ', ConditionListBox.Items[0])
<> 0)) then
ConditionListBox.Items[0] := Copy(ConditionListBox.Items[0], Pos(' ',
ConditionListBox.Items[0]) + 1, 10000);
end;
procedure TRC_DfmDBRecordRightManage.ConfirmToolButtonClick(Sender: TObject);
var
i: integer;
TemporilyString: string;
begin
if ConditionListBox.Items.Count <> 0 then
begin
for i := 0 to ConditionListBox.Items.Count - 1 do
TemporilyString := TemporilyString + ' ' +
Trim(ConditionListBox.Items[i]);
if Pos('(', TreeView1.Selected.Text) = 0 then
TreeView1.Selected.Text := TreeView1.Selected.Text + '(' + TemporilyString
+ ')'
else
TreeView1.Selected.Text := Copy(TreeView1.Selected.Text, 1, pos('(',
TreeView1.Selected.Text) - 1) + '(' + TemporilyString + ')';
end;
Close;
end;
procedure TRC_DfmDBRecordRightManage.FieldNameComboBoxChange(Sender: TObject);
var
WhereSqlString: string;
begin
MaskEdit1.Text := '';
if FieldTypes[FieldNameComboBox.ItemIndex] = '数值' then
begin
MaskEdit1.EditMask := '!999999999999999;1;';
WhereSqlString := WhereSqlString + ' ' + MaskEdit1.Text;
RC_DBRecorRightManage_EditContent := MaskEdit1.Text;
end
else
begin
WhereSqlString := WhereSqlString + ' ' + '''' + MaskEdit1.Text + '''';
MaskEdit1.EditMask := '!ccccccccccccccc;1;';
RC_DBRecorRightManage_EditContent := MaskEdit1.Text;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -