📄 counselingfrm.pas
字号:
with ManagDM do
begin
if datasource2.State in [dsinsert,dsedit] then
tbl_Counseling.Post;
SqlExec(anyqry,'select * from Counselinginfo where classname='+#39+selnode.Text+#39);
DoInt:=anyqry.fieldbyname('OneLevelNo').AsInteger;
if length(IntToStr(DoInt))=1 then
DoStr:='0'+IntToStr(DoInt)
else
DoStr:=IntToStr(DoInt);
Doint1:=anyqry.fieldbyname('TwoLevelNo').AsInteger;
if length(IntToStr(Doint1))=1 then
DoStr1:='0'+IntToStr(DoInt1)
else
DoStr1:=IntToStr(DoInt1);
SqlExec(ranqry,'select * from counselinginfo where OneLevelNo='+IntToStr(DoInt)+' and TwoLevelNo='+IntToStr(DoInt1));
if length(IntToStr(GetSerialNoQry(ranqry,'ThreeLevelNo')))=1 then
DoStr2:='0'+IntToStr(GetSerialNoQry(ranqry,'ThreeLevelNo'))
else
DoStr2:=IntToStr(GetSerialNoQry(ranqry,'ThreeLevelNo'));
tbl_Counseling.Append;
tbl_Counseling.FieldByName('classno').AsString:=DoStr+DoStr1+DoStr2;
tbl_Counseling.FieldByName('OneLevelNo').AsInteger:=Doint;
tbl_Counseling.FieldByName('TwoLevelNo').AsInteger:=DoInt1;
tbl_Counseling.FieldByName('ThreeLevelNo').AsInteger:=GetSerialNoQry(ranqry,'ThreeLevelNo');
end;
end;
end Else Application.MessageBox('请录入信息名称','提示',MB_OK);
dbedit1.SetFocus;
end;
procedure TForm_Counsetling.Act_deleteExecute(Sender: TObject);
procedure unenabledcom;
begin
label1.Enabled:=false; dbedit1.Enabled:=false;
label2.Enabled:=false;
label3.Enabled:=false; dbcombobox1.Enabled:=false;
label4.Enabled:=false;
label5.Enabled:=false; dbedit4.Enabled:=false;
label8.Enabled:=false; dbedit7.Enabled:=false;
Spd_save.Enabled:=false; Spd_cancel.Enabled:=false;
end;
procedure enabledcompo;
begin
label1.Enabled:=true; dbedit1.Enabled:=true;
label2.Enabled:=true;
label3.Enabled:=true; dbcombobox1.Enabled:=true;
label4.Enabled:=true;
label5.Enabled:=true; dbedit4.Enabled:=true;
label8.Enabled:=true; dbedit7.Enabled:=true;
Spd_save.Enabled:=true; Spd_cancel.Enabled:=true;
end;
var
selnode:TTreeNode;
doint:integer;
begin
flag:=false;
selnode:=Treeview1.Selected;
if (selnode.Level<>0)and(not Selnode.HasChildren) then
if Application.MessageBox('是否删除记录?','警告',mb_iconinformation+mb_okcancel)=idok then
begin
unenabledcom;
case selnode.Level of
1:
begin
with ManagDM do
begin
SqlExec(anyqry,'select * from counselinginfo where classname='+#39+selnode.Text+#39);
doint:=anyqry.fieldbyname('onelevelno').AsInteger;
SqlPerform(ranqry,'delete from counselinginfo where OneLevelNo='+IntToStr(DoInt));
end;
end;
2:
begin
with ManagDM do
begin
SqlExec(anyqry,'select * from Counselinginfo where classname='+#39+selnode.Text+#39);
doint:=anyqry.fieldbyname('twolevelno').AsInteger;
SqlPerform(ranqry,'delete from Counselinginfo where TwoLevelNo='+IntToStr(Doint));
end;
end;
3:
begin
with ManagDM do
begin
SqlPerform(anyqry,'delete from Counselinginfo where classname='+#39+selnode.Text+#39);
end;
end;
end;
enabledcompo;
TreeView1.Items.Delete(TreeView1.Selected);
MessageDlg('删除完毕!',mtinformation,[mbok],0);
exit;
end;
Application.MessageBox('该节点不允许删除,请先将其下层节点删除','提示',MB_OK);
end;
procedure TForm_Counsetling.Act_editExecute(Sender: TObject);
var
selnode:TTreeNode;
begin
fflag:=true;
flag:=false;
selnode:=TreeView1.Selected;
if selnode.Level<>0 then
with ManagDM do
begin
tbl_counseling.Locate('classname',selnode.Text,[locaseinsensitive]);
end;
dbedit1.SetFocus;
dbedit1.SelStart:=0;
dbedit1.SelLength:=Length(trim(ManagDM.Tbl_Counseling.fieldbyname('classname').AsString));
end;
procedure TForm_Counsetling.Spd_cancelClick(Sender: TObject);
begin
ManagDM.Tbl_counseling.cancel;
end;
procedure TForm_Counsetling.Spd_saveClick(Sender: TObject);
var
DoStr:string;
i:integer;
begin
if trim(DBedit1.Text)<>'' then
begin
try
with ManagDM do
begin
if datasource2.State in [dsinsert,dsedit] then
begin
tbl_Counseling.FieldByName('infohost').AsString := Qry_hostconfig.fieldbyname('hostname').AsString;
tbl_Counseling.FieldByName('infovirtualdev').AsString := Qry_hostconfig.fieldbyname('item').AsString;
tbl_Counseling.Post;
end;
end;
if flag then
begin
DoStr:=treeview1.Selected.Text;
Act_refresh.OnExecute(self);
for i:=0 to treeview1.Items.Count-1 do
begin
if treeview1.Items.Item[i].Text=DoStr then
begin
treeview1.Items.Item[i].Expanded:=true;
treeview1.Items.Item[i].Selected:=true;
break;
end;
end;
end;
if fflag then
begin
treeview1.Selected.Text:=ManagDM.Tbl_counseling.fieldbyname('classname').AsString;
fflag:=not fflag;
end;
except
end;
end;
end;
procedure TForm_Counsetling.Act_refreshExecute(Sender: TObject);
begin
try
flag:=false;
FreeNewCounselingOption;
LoadNewCounselingOption;
ShowTreeNode;
TreeView1.SetFocus ;
TreeView1.Items.Item[0].Selected :=True;
except
end;
end;
procedure TForm_Counsetling.DBComboBox1Change(Sender: TObject);
begin
with ManagDM do
begin
if DBComboBox1.ItemIndex=0 then
Qry_hostconfig.Locate('Item','Bmp',[locaseinsensitive])
else
if DBComboBox1.ItemIndex=1 then
Qry_hostconfig.Locate('Item','Html',[locaseinsensitive])
else
if DBComboBox1.ItemIndex=2 then
Qry_hostconfig.Locate('Item','Txt',[locaseinsensitive])
else
if DBComboBox1.ItemIndex=3 then
Qry_hostconfig.Locate('Item','Excel',[locaseinsensitive])
else
Qry_hostconfig.Locate('Item','Word',[locaseinsensitive]);
end;
end;
procedure TForm_Counsetling.SpeedButton1Click(Sender: TObject);
begin
if not Assigned(Form_InfoSeleFile) then Application.CreateForm(TForm_InfoSeleFile,Form_InfoSeleFile);
Form_InfoSeleFile.show;
end;
procedure TForm_Counsetling.FormAssigned;
begin
if Assigned(FHtmlForm) then
begin
FHtmlForm.Free;
FHtmlForm:=nil;
end;
if Assigned(FRichForm) then
begin
FRichForm.free;
FRichForm:=nil;
end;
if Assigned(FTxtForm) then
begin
FTxtForm.free;
FTxtForm:=nil;
end;
if Assigned(FExcelForm) then
begin
//FExcelForm.OleContainer1.free;
//FExcelForm.OleContainer1:=nil;
FExcelForm.free;
FExcelForm:=nil;
end;
end;
procedure TForm_Counsetling.TreeView1Change(Sender: TObject;
Node: TTreeNode);
var
selnode:TTreeNode;
Dostr:string;
begin
try
if flag then
dostr:=managdm.tbl_Counseling.fieldbyname('classno').asstring;
flag:=false;
selnode:=treeview1.Selected;
with ManagDM do
begin
if selnode.Level<>0 then
begin
if (datasource2.State in [dsEdit,dsInsert]) and (trim(tbl_counseling.fieldbyname('classname').AsString)<>'') then
tbl_counseling.post;
tbl_counseling.close;
tbl_counseling.open;
if not tbl_counseling.Locate('classno',dostr,[locaseinsensitive]) then
begin
if not tbl_counseling.Locate('classno',PNewCounselLevelOne(selnode.data)^.OeID,[locaseinsensitive]) then
begin
if not tbl_counseling.Locate('classno',PNewCounselLevelOne(selnode.data)^.OeID,[locaseinsensitive]) then
tbl_counseling.Locate('classno',PNewCounselLevelThree(selnode.data)^.OeID,[locaseinsensitive]);
end;
end;
DBComboBox1.OnChange(self);
if Assigned(FileFrm) then
begin
FileFrm.Free;
FileFrm:=nil;
end;
FileFrm:=TFileFrm.Create;
FileFrm.FInfoType:=Tbl_counseling.fieldbyname('InfoType').AsInteger;
FileFrm.FInfoHost:=Qry_hostconfig.fieldbyname('HostName').AsString; // 1
FileFrm.FInfoVirtualDev:=Qry_hostconfig.fieldbyname('Text').AsString;
FileFrm.FInfoFile:=Tbl_counseling.fieldbyname('InfoFile').AsString;// 3
if (pos(':',FileFrm.FInfoVirtualDev)>0) or (pos(':',FileFrm.FInfoVirtualDev)>0) then
FileFrm.FInfoVirtualDev:=StrReplace(FileFrm.FInfoVirtualDev,':','');//2
case FileFrm.FInfoType of
1:
begin
FormAssigned;
try
if FileFrm.FInfoFile<>'' then
begin
//image1.Visible:=false;
FHtmlForm := TForm_html.Create(Application, Pal_bak);
FHtmlForm.parent:=Pal_bak;
FHtmlForm.Align:=alclient;
FHtmlForm.Show;
FHtmlForm.WebBrowser1.Navigate('\\'+FileFrm.FInfoHost+'\'+FileFrm.FInfoVirtualDev+'\'+FileFrm.FInfoFile);
end else
begin
if Assigned(FHtmlForm) then
begin
FHtmlForm.Free;
FHtmlForm:=nil;
end;
end;
except
ShowMessage('文件名或路径有错误!请检查');
end;
end;
0:
begin
FormAssigned;
FRichForm :=TForm_RichEdit1.Create(Application, Pal_bak);
FRichForm.parent:=Pal_bak;
FRichForm.Align:=alclient;
FRichForm.Show;
try
if FileFrm.FInfoFile<>'' then
FRichForm.Image1.Picture.LoadFromFile('\\'+FileFrm.FInfoHost+'\'+FileFrm.FInfoVirtualDev+'\'+FileFrm.FInfoFile)
else
begin
if Assigned(FRichForm) then
begin
FRichForm.free;
FRichForm:=nil;
end;
end;
except
ShowMessage('文件名或路径有错误!请检查');
end;
end;
2: //Txt
begin
FormAssigned;
FTxtForm :=TForm_RichEdit.Create(Application, Pal_bak);
FTxtForm.parent:=Pal_bak;
FTxtForm.Align:=alclient;
FTxtForm.RichEdit1.Lines.Clear;
FTxtForm.Show;
try
if FileFrm.FInfoFile<>'' then
FTxtForm.RichEdit1.Lines.LoadFromFile('\\'+FileFrm.FInfoHost+'\'+FileFrm.FInfoVirtualDev+'\'+FileFrm.FInfoFile)
else
begin
if Assigned(FTxtForm) then
begin
FTxtForm.free;
FTxtForm:=nil;
end;
end;
except
ShowMessage('文件名或路径有错误!请检查');
end;
end;
3: //Excel
begin
FormAssigned;
FExcelForm :=TForm_Excel.Create(Application, Pal_bak);
FExcelForm.parent:=Pal_bak;
FExcelForm.Align:=alclient;
FExcelForm.Show;
try
if FileFrm.FInfoFile<>'' then
FExcelForm.OleContainer1.CreateObjectFromFile('\\'+FileFrm.FInfoHost+'\'+FileFrm.FInfoVirtualDev+'\'+FileFrm.FInfoFile,false)
else
begin
if Assigned(FExcelForm) then
begin
FExcelForm.OleContainer1.free;
FExcelForm.OleContainer1:=nil;
FExcelForm.free;
FExcelForm:=nil;
end;
end;
except
ShowMessage('文件名或路径有错误!请检查');
end;
end;
4: //word
begin
FormAssigned;
FExcelForm :=TForm_Excel.Create(Application, Pal_bak);
FExcelForm.parent:=Pal_bak;
FExcelForm.Align:=alclient;
FExcelForm.Show;
try
if FileFrm.FInfoFile<>'' then
FExcelForm.OleContainer1.CreateObjectFromFile('\\'+FileFrm.FInfoHost+'\'+FileFrm.FInfoVirtualDev+'\'+FileFrm.FInfoFile,false)
else
begin
if Assigned(FExcelForm) then
begin
FExcelForm.OleContainer1.free;
FExcelForm.OleContainer1:=nil;
FExcelForm.free;
FExcelForm:=nil;
end;
end;
except
ShowMessage('文件名或路径有错误!请检查');
end;
end;
end; // end
end else FormAssigned;
end;
except
Act_refresh.Execute;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -