主要代码如下。帮忙看看不合理的地方,谢谢。
procedure TForm1.SavePicture(ParentIDD: Integer; node: TTreeNode; //保存图片
fn: string);
var
query:TADOQuery;
begin
query:=TADOquery.Create(self);
try
with query do
begin
Connection:=ADOConnection1;
close;
sql.Clear;
sql.Add('select * from zhiyuan');
open;
Append;
FieldByName('IDD').AsInteger:=nodeData(node.Data).idd;
FieldByName('PID').AsInteger:=ParentIDD ;
FieldByName('FName').AsString:=nodeData(node.Data).caption;
FieldByName('Ext').AsString:=LowerCase(ExtractFileExt(fn));
FieldByName('Folder').AsInteger:=0;
FieldByName('BMark').AsBoolean:=false;
FieldByName('Pass').AsString:='';
FieldByName('路径一').AsString:=copy(fn,length(extractfilepath(copy(fn,1,LastDelimiter('/',fn)-1)))+1,length(fn));
FieldByName('路径二').AsString:=Edit9.text;
FieldByName('路径三').AsString:=Edit9.text;
FieldByName('系统类别').AsInteger:=nodeData(node.Data).idd;
FieldByName('违章车号').AsInteger:=nodeData(node.Data).idd;
FieldByName('系统编码').AsString:=Edit1.text;
FieldByName('通知书编号').AsString:=Edit2.text;
FieldByName('违章车型').AsString:=Edit3.text;
FieldByName('处理结果').AsString:=Edit4.text;
FieldByName('处罚种类').AsString:=Edit5.text;
FieldByName('发案方式').AsString:=Edit6.text;
FieldByName('违章时间').AsString:=Edit7.text;
FieldByName('编辑输入').AsString:=Edit8.text;
FieldByName('违章车号1').AsString:=Edit10.text;
Post;
end;
finally
query.Free;
end;
end;
procedure TForm1.AddPicMenuClick(Sender: TObject);
var
i :integer;
PNode :NodeData;
Node :TTreeNode;
NodeCaption:string;
begin
if PageControl1.ActivePage<>TreeTab then PageControl1.ActivePage:=TreeTab;
if Treeview1.Selected=nil then begin
messagedlg('必须先选择一个目录,以便添加图片!',mtError,[mbOK],0);
Exit;
end;
if TreeView1.Selected.ImageIndex=0 then
TreeView1.Selected.Parent.Selected:=true;
Node:=nil;
OpenPictureDialog1.Title:='添加图片:';
openpictureDialog1.Options:=[ofHideReadOnly,ofAllowMultiSelect,ofPathMustExist,ofFileMustExist,ofEnableSizing,ofDontAddToRecent,ofForceShowHidden];
if not openpicturedialog1.Execute then exit;
AviForm:=TAviForm.Create(self);
AviForm.Caption:='正在添加图片,请等待...';
AviForm.Label1.Caption:='';
aviform.Label1.Visible:=true;
AviForm.Button1.Enabled:=True;
AviForm.stop:=false;
AviForm.Animate1.CommonAVI:=aviCopyFiles;
AviForm.Animate1.Active:=True;
AviForm.Show;
Screen.Cursor:=crHourGlass;
TreeView1.Items.BeginUpdate;
Try
for i:=0 to OpenPictureDialog1.Files.Count-1 do
begin
application.ProcessMessages;
if AviForm.stop then break;
NodeCaption:=ExtractFileName(OpenPictureDialog1.Files.Strings);
AviForm.Label1.Caption:=NodeCaption;
NodeCaption:=Copy(NodeCaption,1,length(NodeCaption)-4);
new(PNode);
PNode.idd:=GetMaxIDD+1;
PNode.caption:=NodeCaption;
Pnode.Password:='';
Node:=TreeView1.Items.AddChildObject(TreeView1.Selected,NodeCaption,PNode);
Node.SelectedIndex:=0;
Node.ImageIndex:=0;
SavePicture(NodeData(Node.Parent.Data).idd,Node,OpenPictureDialog1.Files.Strings);
end;
Node.Selected:=True;
//showPic(NodeData(Node.Data).idd);
finally
TreeView1.Items.EndUpdate;
AviForm.Close;
AviForm.Free;
Screen.Cursor:=crDefault;
end;
Statusbar1.Panels[2].Text:=intToStr(GetPicOrFolderCount(1));
Statusbar1.Panels[4].Text:=intToStr(GetPicOrFolderCount(0));
end;