📄 customersrelationerinfo.pas
字号:
unit customersrelationerinfo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type
TF_customersrelationerinfo = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Label4: TLabel;
Edit4: TEdit;
Label5: TLabel;
Edit5: TEdit;
Label6: TLabel;
Edit6: TEdit;
Label7: TLabel;
Edit7: TEdit;
Label8: TLabel;
Edit8: TEdit;
Label9: TLabel;
Edit9: TEdit;
Label10: TLabel;
Edit10: TEdit;
Label11: TLabel;
Edit11: TEdit;
Label12: TLabel;
Edit12: TEdit;
Label13: TLabel;
Memo1: TMemo;
btn_Search: TBitBtn;
btn_Update: TBitBtn;
btn_Add: TBitBtn;
btn_Delete: TBitBtn;
btn_Clear: TBitBtn;
btn_Out: TBitBtn;
ComboBox1: TComboBox;
procedure btn_SearchClick(Sender: TObject);
procedure btn_UpdateClick(Sender: TObject);
procedure btn_AddClick(Sender: TObject);
procedure btn_DeleteClick(Sender: TObject);
procedure btn_ClearClick(Sender: TObject);
procedure btn_OutClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
F_customersrelationerinfo: TF_customersrelationerinfo;
strSQL:String;
implementation
uses datamodule;
{$R *.dfm}
procedure TF_customersrelationerinfo.btn_SearchClick(Sender: TObject);
begin
with DM_datamodule do
begin
if crmDB.Connected then
begin
with qry_CustomersRelationerInfo do
begin
create(nil);
sql.Add('select * from CustomersRelationerInfo where 客户编号=:f1');
Parambyname('f1').AsString:=combobox1.Text;
prepare;
open;
if Recordcount<>0 then
begin
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('部门').AsString;
edit9.Text:=fieldbyname('业余爱好').AsString;
edit10.Text:=fieldbyname('性格特点').AsString;
edit11.Text:=fieldbyname('家庭住址').AsString;
edit12.Text:=fieldbyname('邮编').AsString;
Memo1.Text:=fieldbyname('备注').AsString;
Close;
end
else
begin
messagedlg('不存在该客户编号!查找失败!',mtinformation,[mbok],0);
close;
end;
end;
end
else
messagedlg('请先登陆!',mtinformation,[mbok],0);
end;
end;
procedure TF_customersrelationerinfo.btn_UpdateClick(Sender: TObject);
begin
strSQL:='update CustomersRelationerInfo set 联系人姓名=:f2,称谓=:f3,职务=:f4,办公电话=:f5,电子邮件=:f6,'+
'移动电话=:f7,部门=:f8,业余爱好=:f9,性格特点=:f10,家庭住址=:f11,邮编=:f12,备注=:f13 where 客户编号=:f1';
with DM_datamodule do
begin
if crmDB.Connected then
begin
with qry_CustomersRelationerInfo do
begin
create(nil);
sql.Add('select * from CustomersRelationerInfo where 客户编号=:f1');
Parambyname('f1').AsString:=combobox1.Text;
open;
if Recordcount<>0 then
begin
sql.Add(strSQL);
Parambyname('f2').AsString:=edit2.Text;
Parambyname('f3').AsString:=edit3.Text;
Parambyname('f4').AsString:=edit4.Text;
Parambyname('f5').AsString:=edit5.Text;
Parambyname('f6').AsString:=edit6.Text;
Parambyname('f7').AsString:=edit7.Text;
Parambyname('f8').AsString:=edit8.Text;
Parambyname('f9').AsString:=edit9.Text;
Parambyname('f10').AsString:=edit10.Text;
Parambyname('f11').AsString:=edit11.Text;
Parambyname('f12').AsString:=edit12.Text;
Parambyname('f13').AsString:=Memo1.Text;
ExecSQL;
Close;
messagedlg('修改成功!',mtinformation,[mbok],0);
end
else
begin
messagedlg('不存在该客户编号!修改失败!',mtinformation,[mbok],0);
close;
end;
end;
end
else
messagedlg('请先登陆!',mtinformation,[mbok],0);
end;
end;
procedure TF_customersrelationerinfo.btn_AddClick(Sender: TObject);
begin
strSQL:='insert into CustomersRelationerInfo values(:f1,:f2,:f3,:f4,:f5,:f6,:f7,:f8,:f9,:f10,:f11,:f12,:f13)';
with DM_datamodule do
begin
if crmDB.Connected then
begin
with qry_CustomersRelationerInfo do
begin
create(nil);
sql.Add('select * from CustomersRelationerInfo where 客户编号=:f1');
Parambyname('f1').AsString:=combobox1.Text;
open;
if Recordcount=0 then
begin
sql.Add(strSQL);
Parambyname('f2').AsString:=edit2.Text;
Parambyname('f3').AsString:=edit3.Text;
Parambyname('f4').AsString:=edit4.Text;
Parambyname('f5').AsString:=edit5.Text;
Parambyname('f6').AsString:=edit6.Text;
Parambyname('f7').AsString:=edit7.Text;
Parambyname('f8').AsString:=edit8.Text;
Parambyname('f9').AsString:=edit9.Text;
Parambyname('f10').AsString:=edit10.Text;
Parambyname('f11').AsString:=edit11.Text;
Parambyname('f12').AsString:=edit12.Text;
Parambyname('f13').AsString:=Memo1.Text;
ExecSQL;
Close;
messagedlg('新增成功!',mtinformation,[mbok],0);
end
else
begin
messagedlg('已经存在该客户编号!新增失败!',mtinformation,[mbok],0);
close;
end;
end;
end
else
messagedlg('请先登陆!',mtinformation,[mbok],0);
end;
end;
procedure TF_customersrelationerinfo.btn_DeleteClick(Sender: TObject);
begin
strSQL:='delete from CustomersRelationerInfo where 客户编号=:f1';
with DM_datamodule do
begin
if crmDB.Connected then
begin
if messagedlg('确定要删除吗?',mtinformation,[mbyes,mbno],0)=mrYes then
begin
with qry_CustomersRelationerInfo do
begin
create(nil);
sql.Add('select * from CustomersRelationerInfo where 客户编号=:f1');
Parambyname('f1').AsString:=combobox1.Text;
open;
if Recordcount<>0 then
begin
sql.Add(strSQL);
ExecSQL;
Close;
messagedlg('删除成功!',mtinformation,[mbok],0);
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit5.Clear;
edit6.Clear;
edit7.Clear;
edit8.Clear;
edit9.Clear;
edit10.Clear;
edit11.Clear;
edit12.Clear;
Memo1.Clear;
end
else
begin
messagedlg('不存在该客户!删除失败!',mtinformation,[mbok],0);
close;
end;
end;
end;
end
else
messagedlg('请先登陆!',mtinformation,[mbok],0);
end;
end;
procedure TF_customersrelationerinfo.btn_ClearClick(Sender: TObject);
begin
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit5.Clear;
edit6.Clear;
edit7.Clear;
edit8.Clear;
edit9.Clear;
edit10.Clear;
edit11.Clear;
edit12.Clear;
Memo1.Clear;
end;
procedure TF_customersrelationerinfo.btn_OutClick(Sender: TObject);
begin
combobox1.Clear;
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit5.Clear;
edit6.Clear;
edit7.Clear;
edit8.Clear;
edit9.Clear;
edit10.Clear;
edit11.Clear;
edit12.Clear;
Memo1.Clear;
close;
end;
procedure TF_customersrelationerinfo.FormShow(Sender: TObject);
begin
with DM_datamodule.qry_CustomersInfo do
begin
close;
sql.Clear;
sql.Add('select 客户编号 from CustomersInfo');
try
prepare;
execsql;
open;
first;
while not eof do
begin
combobox1.Items.Add(fieldbyname('客户编号').AsString);
next;
end;
finally
close;
end;
end;
combobox1.Text:=combobox1.Items.Text;
combobox1.ItemIndex:=0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -