📄 frm_rightinfo.pas
字号:
unit Frm_RightInfo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Frm_Cargo, XPMenu, Grids, BaseGrid, AdvGrid, StdCtrls, Buttons,
CoolCtrls, GIFImage, ExtCtrls, THPanel, DB, ADODB;
type
TFrmRightInfo = class(TFrmCargo)
THPanel2: TTHPanel;
Label1: TLabel;
Label4: TLabel;
Label6: TLabel;
Label5: TLabel;
Label7: TLabel;
CoolPanel2: TCoolPanel;
THPP1: TCoolPanel;
EdtSortPos: TEdit;
EdtFuncName: TEdit;
EdtFuncNo: TEdit;
EdtRemark: TEdit;
EdtFuncViewName: TEdit;
BtnAdd: TBitBtn;
BtnEdit: TBitBtn;
BtnDelete: TBitBtn;
BtnCancel: TBitBtn;
GridFunc: TAdvStringGrid;
QryTemp: TADOQuery;
procedure BtnAddClick(Sender: TObject);
procedure BtnEditClick(Sender: TObject);
procedure BtnDeleteClick(Sender: TObject);
procedure BtnCancelClick(Sender: TObject);
procedure GridFuncRowChanging(Sender: TObject; OldRow, NewRow: Integer;
var Allow: Boolean);
private
IsEdit: Boolean;
{ Private declarations }
public
CurrentRow: Integer;
{ Public declarations }
end;
var
FrmRightInfo: TFrmRightInfo;
implementation
uses Frm_Main;
{$R *.dfm}
procedure TFrmRightInfo.BtnAddClick(Sender: TObject);
begin
inherited;
if FrmMain.IncludeValue('权限维护') then
else
begin
exit;
end;
EdtFuncNo.Text := '';
EdtFuncName.Text := '';
EdtFuncViewName.Text := '';
EdtSortPos.Text := '';
EdtRemark.Text := '';
BtnAdd.Enabled := False;
EdtFuncNo.SetFocus;
IsEdit := False;
end;
procedure TFrmRightInfo.BtnEditClick(Sender: TObject);
var
SqlStr, RightsValue, FuncName: string;
TempRowCount, i: Integer;
begin
inherited;
if FrmMain.IncludeValue('权限维护') then
else
begin
exit;
end;
if Trim(EdtFuncNO.Text) = '' then
begin
EdtFuncNO.SetFocus;
exit;
end;
if Trim(EdtFuncNo.Text) <> GridFunc.Cells[0, CurrentRow] then
begin
if FrmMain.CheckExistCount('FuncNO', EdtFuncNo.Text, 'SysFunc') > 0 then
begin
ShowMessage('代码已存在,请重新输入');
EdtFuncNo.SetFocus;
exit;
end;
end;
if Trim(EdtFuncName.Text) <> GridFunc.Cells[1, CurrentRow] then
begin
if FrmMain.CheckExistCount('FuncName', EdtFuncNo.Text, 'SysFunc') > 0 then
begin
EdtFuncNo.SetFocus;
exit;
end;
end;
if IsEdit then
begin
if (CurrentRow = 1) and (GridFunc.Cells[0, 1] = '') then
begin
Exit;
end;
try
if UpperCase(trim(EdtFuncNo.Text)) = UpperCase(GridFunc.Cells[0, CurrentRow]) then
else
begin
QryTemp.Close;
with QryTemp do
begin
Sql.Clear;
Sql.Text := 'Select RightsValue from FuncRights ';
Open;
if RecordCount > 0 then
begin
for i := 0 to RecordCount - 1 do
begin
RightsValue := FieldByName('RightsValue').AsString;
FuncName := '''' + GridFunc.Cells[3, CurrentRow] + '''';
if Pos(FuncName, RightsValue) > 0 then
begin
Exit;
end;
Next;
end;
end;
end;
end;
SqlStr := 'Update SysFunc Set FuncNO=''' + trim(EdtFuncNO.Text) + ''','
+ 'FuncName=''' + Trim(EdtFuncName.Text) + ''',FuncViewName=''' + Trim(EdtFuncViewName.Text) + ''',SortPos=''' + Trim(EdtSortPos.Text) + ''','
+ 'Remark=''' + trim(EdtRemark.Text) + ''' where FuncNo=''' + GridFunc.Cells[0, CurrentRow] + '''';
if FrmMain.ExecSQL(SqlStr) then
else
begin
exit;
end;
GridFunc.Cells[0, CurrentRow] := Trim(EdtFuncNO.Text);
GridFunc.Cells[1, CurrentRow] := Trim(EdtFuncName.Text);
GridFunc.Cells[2, CurrentRow] := Trim(EdtFuncViewName.Text);
GridFunc.Cells[3, CurrentRow] := Trim(EdtSortPos.Text);
GridFunc.Cells[4, CurrentROw] := Trim(EdtRemark.Text);
except
exit;
end;
end
else
begin
try
SqlStr := 'Insert into SysFunc(FuncNo,uncName,FuncViewName,SortPos,Remark) values(';
FrmMain.InsStr(SqlStr, Trim(EdtFuncNo.Text), ',');
FrmMain.InsStr(Sqlstr, Trim(EdtFuncName.Text), ',');
FrmMain.InsStr(Sqlstr, Trim(EdtFuncViewName.Text), ',');
FrmMain.InsStr(SqlStr, trim(EdtSortPos.Text), ',');
FrmMain.InsStr(Sqlstr, Trim(EdtRemark.Text), '');
if FrmMain.ExecSQL(SqlStr) then
else
begin
exit;
end;
IsEdit := True;
BtnAdd.Enabled := True;
TempRowCount := GridFunc.RowCount;
if GridFunc.Cells[0, 1] = '' then
begin
GridFunc.Cells[0, 1] := Trim(EdtFuncNO.Text);
GridFunc.Cells[1, 1] := trim(EdtFuncName.Text);
GridFunc.Cells[2, 1] := trim(EdtFuncViewName.Text);
GridFunc.Cells[3, 1] := trim(EdtSortPos.Text);
GridFunc.Cells[4, 1] := trim(EdtRemark.Text);
GridFunc.SelectRows(1, 1);
CurrentRow := 1;
end
else
begin
GridFunc.AddRow;
GridFunc.Cells[0, TempRowCount] := Trim(EdtFuncNo.Text);
GridFunc.Cells[1, TempRowCount] := trim(EdtFuncName.Text);
GridFunc.Cells[2, TempRowCount] := trim(EdtFuncViewName.Text);
GridFunc.Cells[3, TempRowCount] := trim(EdtSortPos.Text);
GridFunc.Cells[4, TempRowCount] := trim(EdtRemark.Text);
GridFunc.SelectRows(TempRowCount, 1);
CurrentRow := TempRowCount;
end;
except
exit;
end;
end;
end;
procedure TFrmRightInfo.BtnDeleteClick(Sender: TObject);
var
i: Integer;
Sqlstr, RightsValue, Funcname: string;
begin
inherited;
if FrmMain.IncludeValue('权限维护') then
else
begin
ShowMessage('对不起,你不具有该操作的权限!');
exit;
end;
if (CurrentRow = 1) and (GridFunc.Cells[0, 1] = '') then
exit;
if MessageDlg('是否删除所选中的记录,请确定', mtConfirmation,[mbYes,mbNo],1) = mrNO then
exit;
try
QryTemp.Close;
with QryTemp do
begin
Sql.Clear;
Sql.Text := 'Select RightsValue from FuncRights ';
Open;
if RecordCount > 0 then
begin
for i := 0 to RecordCount - 1 do
begin
RightsValue := FieldByName('RightsValue').AsString;
FuncName := '''' + GridFunc.Cells[3, CurrentRow] + '''';
if Pos(FuncName, RightsValue) > 0 then
begin
Exit;
end;
Next;
end;
end;
end;
SqlStr := 'Delete From SysFunc where FuncNo=''' + GridFunc.Cells[0, CurrentRow]+ '''';
if FrmMain.ExecSQL(SqlStr) then
else
begin
Exit;
end;
except
FrmMain.UseDB.RollbackTrans;
Exit;
end;
FrmMain.DeleteGridRow(GridFunc, 5, CurrentRow);
if GridFunc.Cells[0, CurrentRow] <> '' then
begin
EdtFuncNo.Text := GridFunc.Cells[0, CurrentRow];
EdtFuncName.Text := GridFunc.Cells[1, CurrentRow];
EdtFuncViewName.Text := GridFunc.Cells[2, CurrentRow];
EdtSortPos.Text := GridFunc.Cells[3, CurrentRow];
EdtRemark.Text := GridFunc.Cells[4, CurrentRow];
end;
end;
procedure TFrmRightInfo.BtnCancelClick(Sender: TObject);
begin
inherited;
Close;
end;
procedure TFrmRightInfo.GridFuncRowChanging(Sender: TObject; OldRow,
NewRow: Integer; var Allow: Boolean);
begin
inherited;
CurrentRow := NewRow;
if BtnAdd.Enabled = False then
begin
if MessageDlg('是否取消增加状态,请确定', mtConfirmation,[MbYes,MbNO] ,1) = mrNO then
exit;
BtnAdd.Enabled := True;
IsEdit := True;
end;
if (CurrentRow = 1) and (GridFunc.Cells[0, 1] = '') then
exit;
EdtFuncNo.Text := GridFunc.Cells[0, CurrentRow];
EdtFuncName.Text := GridFunc.Cells[1, CurrentRow];
EdtFuncViewName.Text := GridFunc.Cells[2, CurrentRow];
EdtSortPos.Text := GridFunc.Cells[3, CurrentRow];
EdtRemark.Text := GridFunc.Cells[4, CurrentRow];
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -