📄 tas110_01.pas.svn-base
字号:
unit Tas110_01;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Bas200_04, ActnList, DB, ADODB, Menus, ComCtrls, ToolWin,
ExtCtrls, dxtree, dxdbtree, dxdbtrel, StdCtrls, Mask, DBCtrls;
type
TTas110_01Form = class(TBas200_04Form)
lblName: TLabel;
lblParent: TLabel;
lblClass: TLabel;
edtName: TDBEdit;
cbParent: TdxTreeViewEdit;
ADOQuery2: TADOQuery;
ADOQuery1T110_001: TAutoIncField;
ADOQuery1T110_002: TIntegerField;
ADOQuery1T110_003: TWideStringField;
ADOQuery1T110_004: TIntegerField;
ADOQuery1T110_005: TBooleanField;
cbClass: TdxDBLookupTreeView;
dsTas100: TDataSource;
qryTas100: TADOQuery;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ActInsertExecute(Sender: TObject);
procedure ActUpdateExecute(Sender: TObject);
procedure ActDeleteExecute(Sender: TObject);
procedure ActSaveExecute(Sender: TObject);
procedure cbParentKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cbParentCloseUp(Sender: TObject; Accept: Boolean);
private
{ Private declarations }
public
procedure SetInterface; override;
procedure ReportGetValue(const ParName: String; var ParValue: Variant); override;
{ Public declarations }
end;
var
Tas110_01Form: TTas110_01Form;
implementation
uses SYSDATA, CommFun;
{$R *.dfm}
procedure TTas110_01Form.SetInterface;
begin
inherited;
Caption:=GetDBString('TAS11001001'); //原因资料维护
lblClass.Caption:=GetDBString('TAS11001002'); //任务类别
lblName.Caption:=GetDBString('TAS11001003'); //原因名称
lblParent.Caption:=GetDBString('TAS11001004'); //上级原因
ADOQuery1T110_002.DisplayLabel:=GetDBString('TAS11001002'); //任务类别
ADOQuery1T110_003.DisplayLabel:=GetDBString('TAS11001003'); //原因名称
ADOQuery1T110_004.DisplayLabel:=GetDBString('TAS11001004'); //上级原因
end;
procedure TTas110_01Form.FormCreate(Sender: TObject);
begin
inherited;
SetInterface;
qryTas100.Open;
end;
procedure TTas110_01Form.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
qryTas100.Close;
end;
procedure TTas110_01Form.ActInsertExecute(Sender: TObject);
begin
inherited;
//新增
cbParent.Items:=dxDBTreeView1.Items;
cbParent.Text:='';
cbParent.Enabled:=True;
cbClass.Enabled:=True;
cbClass.SetFocus;
end;
procedure TTas110_01Form.ActUpdateExecute(Sender: TObject);
begin
inherited;
//修改
cbClass.Enabled:=False;
cbParent.Items:=dxDBTreeView1.Items;
if dxDBTreeView1.Selected.Parent<>nil then
cbParent.Text:=dxDBTreeView1.Selected.Parent.Text
else
cbParent.Text:='';
edtName.SetFocus;
//不能修改有子集,不能修改已被使用的原因记录
cbParent.Enabled:=(not dxDBTreeView1.Selected.HasChildren) and
(not IsExists('select 1 from TAS530 where T530_015 like '+''''+GetLikeMark+'['+ADOQuery1T110_001.AsString+']'+GetLikeMark+''''));
end;
procedure TTas110_01Form.ActDeleteExecute(Sender: TObject);
var
ATreeNode:TTreeNode;
begin
//删除
ATreeNode:=nil;
if dxDBTreeView1.Selected<>nil then
if dxDBTreeView1.Selected.Parent<>nil then ATreeNode:=dxDBTreeView1.Selected.Parent;
//检查原因资料是否已经在使用
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('select 1 from TAS530 where T530_015 like '+''''+GetLikeMark+'['+IntToStr(ADOQuery1T110_001.Value)+']'+GetLikeMark+'''');
SYSDM.qryQuery.Open;
if not SYSDM.qryQuery.IsEmpty then
begin
ShowMsg('UMS10000085'); //该记录已存在相关资料,不能删除该记录
Abort;
end;
inherited;
//修改"最低层否"标识
if ATreeNode=nil then Exit;
if not ATreeNode.HasChildren then
begin
ADOQuery1.Edit;
ADOQuery1T110_005.Value:=True;
ADOQuery1.Post;
end;
end;
procedure TTas110_01Form.ActSaveExecute(Sender: TObject);
var
AUpdateFlag:Boolean;
AName,S:string;
AClassNo, AParentNo:Integer;
begin
//保存
AUpdateFlag:=False;
//设置上级原因编号
ADOQuery1T110_004.Value:=0;
if cbParent.Text<>'' then
begin
ADOQuery2.Close;
ADOQuery2.Open;
if ADOQuery2.Locate('T110_003',cbParent.Text,[]) then
begin
ADOQuery2.Edit;
ADOQuery2.FieldByName('T110_005').Value:=False;
ADOQuery2.Post;
ADOQuery1T110_004.Value:=ADOQuery2.FieldByName('T110_001').Value;
ADOQuery1T110_005.Value:=True;
end;
end;
ADOQuery1T110_005.Value:=True;
if cbClass.Text='' then
begin
ShowMsg('UMS10000259'); //任务类别名称不能为空
cbClass.SetFocus;
Abort;
end;
AName:=trim(edtName.Text);
if AName='' then
begin
ShowMsg('UMS10000261'); //原因名称名称不能为空
edtName.SetFocus;
Abort;
end;
//检查上级原因是否已在使用
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('select 1 from TAS530 where T530_015 like '+''''+GetLikeMark+'['+IntToStr(ADOQuery1T110_004.Value)+']'+GetLikeMark+'''');
SYSDM.qryQuery.Open;
if not SYSDM.qryQuery.IsEmpty then
begin
if ShowDialog('UMS10000262')<>IDYES then Abort; //上级原因已存在相关资料,如果增加下级原因,则相关记录会被替换,是否继续?
AUpdateFlag:=True;
end;
inherited;
ADOQuery1.Refresh;
ADOQuery1.Locate('T110_003',AName,[]);
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('select * from TAS110 where T110_003='+''''+AName+'''');
SYSDM.qryQuery.Open;
AClassNo:=SYSDM.qryQuery.FieldByName('T110_001').Value;
AParentNo:=SYSDM.qryQuery.FieldByName('T110_004').Value;
//替换上级原因
if AUpdateFlag then
begin
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('select T530_015 from TAS530 where T530_015 like '+''''+GetLikeMark+'['+IntToStr(AParentNo)+']'+GetLikeMark+'''');
SYSDM.qryQuery.ExecSQL;
while not SYSDM.qryQuery.Eof do
begin
S:=SYSDM.qryQuery.FieldByName('T530_015').AsString;
ReplaceString('['+IntToStr(AParentNo)+']','['+IntToStr(AClassNo)+']',S);
SYSDM.qryQuery.Edit;
SYSDM.qryQuery.FieldByName('T530_015').Value:=S;
SYSDM.qryQuery.Post;
SYSDM.qryQuery.Next;
end;
end;
end;
procedure TTas110_01Form.cbParentKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if (Key=vk_delete) or (key=vk_back) then cbParent.Text:='';
end;
procedure TTas110_01Form.cbParentCloseUp(Sender: TObject; Accept: Boolean);
begin
inherited;
ADOQuery2.Close;
ADOQuery2.Open;
ADOQuery2.Locate('T110_002',cbParent.Text,[loCaseInsensitive]);
end;
procedure TTas110_01Form.ReportGetValue(const ParName: String;
var ParValue: Variant);
begin
inherited;
end;
initialization
RegisterClass(TTas110_01Form);
finalization
UnRegisterClass(TTas110_01Form);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -