📄 data.~pas
字号:
unit data;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls, Buttons,ADODB, ImgList;
type
TdataForm = class(TForm)
hxxmComboBox: TComboBox;
sjnrMemo: TMemo;
dataListView: TListView;
Label1: TLabel;
Label2: TLabel;
Panel1: TPanel;
addBitBtn: TBitBtn;
deleteBitBtn: TBitBtn;
closeBitBtn: TBitBtn;
dataImageList: TImageList;//设置属性数据
procedure ReadyforShow();//设置属性数据
procedure hxxmComboBoxChange(Sender: TObject);
procedure closeBitBtnClick(Sender: TObject);
procedure deleteBitBtnClick(Sender: TObject);
procedure addBitBtnClick(Sender: TObject);
procedure dataListViewSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
dataForm: TdataForm;
implementation
uses main, client, other;
{$R *.dfm}
procedure TdataForm.ReadyforShow();
begin
//清空列表数据
datalistview.Clear;
if self.Caption='数据候选' then
begin
hxxmComboBox.Clear;
hxxmComboBox.AddItem('公司',nil);
hxxmComboBox.AddItem('部门',nil);
hxxmComboBox.AddItem('地址',nil);
end
else if self.Caption='日常用语' then
begin
hxxmComboBox.Clear;
hxxmComboBox.AddItem('日常用语',nil);
hxxmComboBox.AddItem('节日问候',nil);
hxxmComboBox.AddItem('公司信息',nil);
hxxmComboBox.AddItem('真情祝福',nil);
hxxmComboBox.AddItem('商业问候',nil);
hxxmComboBox.AddItem('经典对白',nil);
hxxmComboBox.AddItem('幽默搞笑',nil);
hxxmComboBox.AddItem('保留信息',nil);
end;
end;
procedure TdataForm.hxxmComboBoxChange(Sender: TObject);
begin
// 清除列表中的数据
datalistview.Clear;
// 添加数据到列表中
if hxxmComboBox.Text='地址' then
begin
addressadoquery.First;
while not addressadoquery.Eof do
begin
datalistview.AddItem(addressadoquery.Fields.Fields[0].AsString,nil);
addressadoquery.Next;
end
end
else if hxxmComboBox.Text='公司' then
begin
companyadoquery.First;
while not companyadoquery.Eof do
begin
datalistview.AddItem(companyadoquery.Fields.Fields[0].AsString,nil);
companyadoquery.Next;
end
end
else if hxxmComboBox.Text='部门' then
begin
departmentadoquery.First;
while not departmentadoquery.Eof do
begin
datalistview.AddItem(departmentadoquery.Fields.Fields[0].AsString,nil);
departmentadoquery.Next;
end
end
else if hxxmComboBox.Text='日常用语' then
begin
rcyyadoquery.First;
while not rcyyadoquery.Eof do
begin
datalistview.AddItem(rcyyadoquery.Fields.Fields[0].AsString,nil);
rcyyadoquery.Next;
end
end
else if hxxmComboBox.Text='节日问候' then
begin
jrwhadoquery.First;
while not jrwhadoquery.Eof do
begin
datalistview.AddItem(jrwhadoquery.Fields.Fields[0].AsString,nil);
jrwhadoquery.Next;
end
end
else if hxxmComboBox.Text='公司信息' then
begin
gsxxadoquery.First;
while not gsxxadoquery.Eof do
begin
datalistview.AddItem(gsxxadoquery.Fields.Fields[0].AsString,nil);
gsxxadoquery.Next;
end
end
else if hxxmComboBox.Text='真情祝福' then
begin
zqzfadoquery.First;
while not zqzfadoquery.Eof do
begin
datalistview.AddItem(zqzfadoquery.Fields.Fields[0].AsString,nil);
zqzfadoquery.Next;
end
end
else if hxxmComboBox.Text='商业问候' then
begin
sywhadoquery.First;
while not sywhadoquery.Eof do
begin
datalistview.AddItem(sywhadoquery.Fields.Fields[0].AsString,nil);
sywhadoquery.Next;
end
end
else if hxxmComboBox.Text='经典对白' then
begin
jddbadoquery.First;
while not jddbadoquery.Eof do
begin
datalistview.AddItem(jddbadoquery.Fields.Fields[0].AsString,nil);
jddbadoquery.Next;
end
end
else if hxxmComboBox.Text='幽默搞笑' then
begin
ymgxadoquery.First;
while not ymgxadoquery.Eof do
begin
datalistview.AddItem(ymgxadoquery.Fields.Fields[0].AsString,nil);
ymgxadoquery.Next;
end
end
else if hxxmComboBox.Text='保留信息' then
begin
blxxadoquery.First;
while not blxxadoquery.Eof do
begin
datalistview.AddItem(blxxadoquery.Fields.Fields[0].AsString,nil);
blxxadoquery.Next;
end
end;
end;
procedure TdataForm.closeBitBtnClick(Sender: TObject);
begin
//清空数据
hxxmComboBox.ItemIndex:=-1;
sjnrMemo.Clear;
dataListView.Clear;
close;
end;
procedure TdataForm.deleteBitBtnClick(Sender: TObject);
begin
// 有属性内容被选中
if datalistview.SelCount=1 then
begin
//从address,company,department对象删除数据
if hxxmComboBox.Text='地址' then
try
addressadoquery.RecNo:=dataListView.Selected.Index+1;
addressadoquery.Delete;
except
application.MessageBox('发生错误!','提示',MB_OK)
end
else if hxxmComboBox.Text='公司' then
try
companyadoquery.RecNo:=dataListView.Selected.Index+1;
companyadoquery.Delete;
except
application.MessageBox('发生错误!','提示',MB_OK)
end
else if hxxmComboBox.Text='部门' then
try
departmentadoquery.RecNo:=dataListView.Selected.Index+1;
departmentadoquery.Delete;
except
application.MessageBox('发生错误!','提示',MB_OK)
end
else if hxxmComboBox.Text='日常用语' then
try
rcyyadoquery.RecNo:=dataListView.Selected.Index+1;
rcyyadoquery.Delete;
except
application.MessageBox('发生错误!','提示',MB_OK)
end
else if hxxmComboBox.Text='节日问候' then
try
jrwhadoquery.RecNo:=dataListView.Selected.Index+1;
jrwhadoquery.Delete;
except
application.MessageBox('发生错误!','提示',MB_OK)
end
else if hxxmComboBox.Text='公司信息' then
try
gsxxadoquery.RecNo:=dataListView.Selected.Index+1;
gsxxadoquery.Delete;
except
application.MessageBox('发生错误!','提示',MB_OK)
end
else if hxxmComboBox.Text='真情祝福' then
try
zqzfadoquery.RecNo:=dataListView.Selected.Index+1;
zqzfadoquery.Delete;
except
application.MessageBox('发生错误!','提示',MB_OK)
end
else if hxxmComboBox.Text='商业问候' then
try
sywhadoquery.RecNo:=dataListView.Selected.Index+1;
sywhadoquery.Delete;
except
application.MessageBox('发生错误!','提示',MB_OK)
end
else if hxxmComboBox.Text='经典对白' then
try
jddbadoquery.RecNo:=dataListView.Selected.Index+1;
jddbadoquery.Delete;
except
application.MessageBox('发生错误!','提示',MB_OK)
end
else if hxxmComboBox.Text='幽默搞笑' then
try
ymgxadoquery.RecNo:=dataListView.Selected.Index+1;
ymgxadoquery.Delete;
except
application.MessageBox('发生错误!','提示',MB_OK)
end
else if hxxmComboBox.Text='保留信息' then
try
blxxadoquery.RecNo:=dataListView.Selected.Index+1;
blxxadoquery.Delete;
except
application.MessageBox('发生错误!','提示',MB_OK)
end;
// 删除列表中选中数据
dataListView.DeleteSelected;
end;
end;
procedure TdataForm.addBitBtnClick(Sender: TObject);
begin
//无候选项目
if hxxmComboBox.Text='' then
exit;
//无要添加的数据
if trim(sjnrMemo.Text)='' then
exit;
// 查询要添加的数据是否已在列表中
if datalistview.FindCaption(0,trim(sjnrMemo.Text),false,true,false)=nil then
begin
if hxxmComboBox.Text='地址' then
try
addressadoquery.Append;
addressadoquery.fields.fields[0].AsString:=trim(sjnrMemo.Text);
addressadoquery.Post;
except
application.MessageBox('发生错误!','提示',MB_OK);
exit;
end
else if hxxmComboBox.Text='公司' then
try
companyadoquery.Append;
companyadoquery.fields.fields[0].AsString:=trim(sjnrMemo.Text);
companyadoquery.Post;
except
application.MessageBox('发生错误!','提示',MB_OK);
exit;
end
else if hxxmComboBox.Text='部门' then
try
departmentadoquery.Append;
departmentadoquery.fields.fields[0].AsString:=trim(sjnrMemo.Text);
departmentadoquery.Post;
except
application.MessageBox('发生错误!','提示',MB_OK);
exit;
end
else if hxxmComboBox.Text='日常用语' then
try
rcyyadoquery.Append;
rcyyadoquery.fields.fields[0].AsString:=trim(sjnrMemo.Text);
rcyyadoquery.Post;
except
application.MessageBox('发生错误!','提示',MB_OK);
exit;
end
else if hxxmComboBox.Text='节日问候' then
try
jrwhadoquery.Append;
jrwhadoquery.fields.fields[0].AsString:=trim(sjnrMemo.Text);
jrwhadoquery.Post;
except
application.MessageBox('发生错误!','提示',MB_OK);
exit;
end
else if hxxmComboBox.Text='公司信息' then
try
gsxxadoquery.Append;
gsxxadoquery.fields.fields[0].AsString:=trim(sjnrMemo.Text);
gsxxadoquery.Post;
except
application.MessageBox('发生错误!','提示',MB_OK);
exit;
end
else if hxxmComboBox.Text='真情祝福' then
try
zqzfadoquery.Append;
zqzfadoquery.fields.fields[0].AsString:=trim(sjnrMemo.Text);
zqzfadoquery.Post;
except
application.MessageBox('发生错误!','提示',MB_OK);
exit;
end
else if hxxmComboBox.Text='商业问候' then
try
sywhadoquery.Append;
sywhadoquery.fields.fields[0].AsString:=trim(sjnrMemo.Text);
sywhadoquery.Post;
except
application.MessageBox('发生错误!','提示',MB_OK);
exit;
end
else if hxxmComboBox.Text='经典对白' then
try
jddbadoquery.Append;
jddbadoquery.fields.fields[0].AsString:=trim(sjnrMemo.Text);
jddbadoquery.Post;
except
application.MessageBox('发生错误!','提示',MB_OK);
exit;
end
else if hxxmComboBox.Text='幽默搞笑' then
try
ymgxadoquery.Append;
ymgxadoquery.fields.fields[0].AsString:=trim(sjnrMemo.Text);
ymgxadoquery.Post;
except
application.MessageBox('发生错误!','提示',MB_OK);
exit;
end
else if hxxmComboBox.Text='保留信息' then
try
blxxadoquery.Append;
blxxadoquery.fields.fields[0].AsString:=trim(sjnrMemo.Text);
blxxadoquery.Post;
except
application.MessageBox('发生错误!','提示',MB_OK);
exit;
end;
// 向列表添加数据
dataListView.AddItem(trim(sjnrMemo.Text),nil);
// 删除输入数据
sjnrMemo.Clear;
end;
end;
procedure TdataForm.dataListViewSelectItem(Sender: TObject;
Item: TListItem; Selected: Boolean);
begin
//显示选中的项目内容
if Selected then
sjnrMemo.Text:=item.Caption
//如果没有项目被选中,则删除已显示的内容
else
sjnrMemo.Clear;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -