📄 tas130_01.pas.svn-base
字号:
unit Tas130_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
TTas130_01Form = class(TBas200_04Form)
lblName: TLabel;
edtName: TDBEdit;
lblParent: TLabel;
lblPriority: TLabel;
udPriority: TUpDown;
edtPriority: TEdit;
cbParent: TdxTreeViewEdit;
ADOQuery2: TADOQuery;
cbProduct: TCheckBox;
ADOQuery1T130_001: TAutoIncField;
ADOQuery1T130_002: TWideStringField;
ADOQuery1T130_003: TIntegerField;
ADOQuery1T130_004: TSmallintField;
ADOQuery1T130_005: TBooleanField;
ADOQuery1T130_006: TBooleanField;
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);
procedure edtPriorityKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
procedure SetInterface; override;
procedure ReportGetValue(const ParName: String; var ParValue: Variant); override;
{ Public declarations }
end;
var
Tas130_01Form: TTas130_01Form;
implementation
uses SYSDATA, CommFun;
{$R *.dfm}
procedure TTas130_01Form.SetInterface;
var
S:string;
begin
inherited;
Caption:=GetDBString('TAS13001001'); //项目类别维护
lblName.Caption:=GetDBString('TAS13001002'); //类别名称
lblPriority.Caption:=GetDBString('TAS13001003'); //优先级别
lblParent.Caption:=GetDBString('TAS13001004'); //上级类别
ADOQuery1T130_002.DisplayLabel:=GetDBString('TAS13001002'); //类别名称
ADOQuery1T130_003.DisplayLabel:=GetDBString('TAS13001004'); //上级类别
ADOQuery1T130_004.DisplayLabel:=GetDBString('TAS13001003'); //优先级别
cbProduct.Caption:=GetDBString('TAS13001005'); //项目计划中必须录入产品信息
//最高优先级别
S:=GetSysParams('TAS0006');
if S<>'' then udPriority.Min:=StrToInt(S);
//最低优先级别
S:=GetSysParams('TAS0007');
if S<>'' then udPriority.Max:=StrToInt(S);
end;
procedure TTas130_01Form.FormCreate(Sender: TObject);
begin
inherited;
SetInterface;
end;
procedure TTas130_01Form.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
//
end;
procedure TTas130_01Form.ActInsertExecute(Sender: TObject);
var
S:String;
begin
inherited;
//新增
cbParent.Items:=dxDBTreeView1.Items;
cbParent.Text:='';
cbParent.Enabled:=True;
//优先级缺省值
S:=GetSysParams('TAS0008');
if S<>'' then edtPriority.Text:=S;
edtName.SetFocus;
end;
procedure TTas130_01Form.ActUpdateExecute(Sender: TObject);
begin
inherited;
//修改
cbParent.Items:=dxDBTreeView1.Items;
if dxDBTreeView1.Selected.Parent<>nil then
cbParent.Text:=dxDBTreeView1.Selected.Parent.Text
else
cbParent.Text:='';
edtPriority.Text:=ADOQuery1T130_004.AsString;
cbProduct.Checked:=ADOQuery1T130_006.Value;
edtName.SetFocus;
//不能修改有子集,不能修改已被使用的任务类别
cbParent.Enabled:=(not dxDBTreeView1.Selected.HasChildren) and
(not IsExists('select 1 from TAS500 where T500_004='+ADOQuery1T130_001.AsString));
end;
procedure TTas130_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 TAS500 where T500_004='+IntToStr(ADOQuery1T130_001.Value));
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;
ADOQuery1T130_005.Value:=True;
ADOQuery1.Post;
end;
end;
procedure TTas130_01Form.ActSaveExecute(Sender: TObject);
var
AUpdateFlag:Boolean;
AName:string;
AClassNo, AParentNo:Integer;
begin
//保存
AUpdateFlag:=False;
//设置上级类别编号
if cbParent.Text='' then
ADOQuery1T130_003.Value:=0
else
begin
ADOQuery2.Close;
ADOQuery2.Open;
if ADOQuery2.Locate('T130_002',cbParent.Text,[loCaseInsensitive]) then
begin
ADOQuery2.Edit;
ADOQuery2.FieldByName('T130_005').Value:=False;
ADOQuery2.Post;
ADOQuery1T130_003.Value:=ADOQuery2.FieldByName('T130_001').Value;
ADOQuery1T130_005.Value:=True;
end;
end;
ADOQuery1T130_004.AsString:=edtPriority.Text;
ADOQuery1T130_005.Value:=True;
ADOQuery1T130_006.Value:=cbProduct.Checked;
AName:=trim(edtName.Text);
if AName='' then
begin
ShowMsg('UMS10000259'); //任务类别名称不能为空
edtName.SetFocus;
Abort;
end;
//检查上级类别是否已在使用
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('select 1 from TAS500 where T500_004='+IntToStr(ADOQuery1T130_003.Value));
SYSDM.qryQuery.Open;
if not SYSDM.qryQuery.IsEmpty then
begin
if ShowDialog('UMS10000260')<>IDYES then Abort; //上级类别已存在相关资料,如果增加下级类别,则相关记录会被替换,是否继续?
AUpdateFlag:=True;
end;
inherited;
ADOQuery1.Refresh;
ADOQuery1.Locate('T100_002',AName,[loCaseInsensitive]);
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('select * from TAS130 where T130_002='+''''+AName+'''');
SYSDM.qryQuery.Open;
AClassNo:=SYSDM.qryQuery.FieldByName('T130_001').Value;
AParentNo:=SYSDM.qryQuery.FieldByName('T130_003').Value;
//替换上级类别
if AUpdateFlag then
begin
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('update TAS500 set T500_004='+IntToStr(AClassNo)+' where T500_004='+IntToStr(AParentNo));
SYSDM.qryQuery.ExecSQL;
end;
end;
procedure TTas130_01Form.cbParentKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
if (Key=vk_delete) or (key=vk_back) then cbParent.Text:='';
end;
procedure TTas130_01Form.cbParentCloseUp(Sender: TObject;
Accept: Boolean);
begin
inherited;
ADOQuery2.Close;
ADOQuery2.Open;
ADOQuery2.Locate('T130_002',cbParent.Text,[loCaseInsensitive]);
end;
procedure TTas130_01Form.edtPriorityKeyPress(Sender: TObject; var Key: Char);
begin
inherited;
ValidInteger(Sender,Key);
end;
procedure TTas130_01Form.ReportGetValue(const ParName: String;
var ParValue: Variant);
begin
inherited;
end;
initialization
RegisterClass(TTas130_01Form);
finalization
UnRegisterClass(TTas130_01Form);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -