⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customersinfo.pas

📁 企业客户关系管理系统
💻 PAS
字号:
unit customersinfo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Mask, DBCtrls, ExtCtrls, Buttons;

type
  TF_customersinfo = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    btn_Add: TBitBtn;
    btn_Delete: TBitBtn;
    btn_Update: TBitBtn;
    btn_Out: TBitBtn;
    Memo1: TMemo;
    btn_Clear: TBitBtn;
    btn_Search: TBitBtn;
    procedure btn_AddClick(Sender: TObject);
    procedure btn_OutClick(Sender: TObject);
    procedure btn_ClearClick(Sender: TObject);
    procedure btn_DeleteClick(Sender: TObject);
    procedure btn_UpdateClick(Sender: TObject);
    procedure btn_SearchClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  F_customersinfo: TF_customersinfo;
  strSQL:String;
implementation
uses datamodule;
{$R *.dfm}

procedure TF_customersinfo.btn_AddClick(Sender: TObject);
begin
strSQL:='insert into CustomersInfo values(:f1,:f2,:f3,:f4,:f5,:f6)';
with DM_datamodule do
begin
if crmDB.Connected then
begin
if trim(edit1.Text)<>'' then
begin
with qry_CustomersInfo do
begin
create(nil);
sql.Add('select * from CustomersInfo where 客户编号=:f1');
Parambyname('f1').AsString:=edit1.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:=Memo1.Text;
ExecSQL;
Close;
messagedlg('新增成功!',mtinformation,[mbok],0);
end
else
begin
messagedlg('已经存在该客户编号!新增失败!',mtinformation,[mbok],0);
close;
end;
end;
end;
end
else
messagedlg('请先登陆!',mtinformation,[mbok],0);
end;
end;

procedure TF_customersinfo.btn_OutClick(Sender: TObject);
begin
edit1.Clear;
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit5.Clear;
Memo1.Clear;
close;
end;

procedure TF_customersinfo.btn_ClearClick(Sender: TObject);
begin
edit1.Clear;
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit5.Clear;
Memo1.Clear;
end;

procedure TF_customersinfo.btn_DeleteClick(Sender: TObject);
begin
strSQL:='delete from CustomersInfo where 客户编号=:f1';
with DM_datamodule do
begin
if crmDB.Connected then
begin
if trim(edit1.Text)<>'' then
begin
with qry_CustomersInfo do
begin
create(nil);
sql.Add('select * from CustomersInfo where 客户编号=:f1');
Parambyname('f1').AsString:=edit1.Text;
open;
if Recordcount<>0 then
begin
sql.Add(strSQL);
ExecSQL;
Close;
messagedlg('删除成功!',mtinformation,[mbok],0);
edit1.Clear;
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit5.Clear;
Memo1.Clear;
end
else
begin
messagedlg('不存在该客户!删除失败!',mtinformation,[mbok],0);
close;
end;
end;
end;
end
else
messagedlg('请先登陆!',mtinformation,[mbok],0);
end;
end;

procedure TF_customersinfo.btn_UpdateClick(Sender: TObject);
begin
strSQL:='update CustomersInfo set 客户名称=:f2,客户电话=:f3,公司地址=:f4,邮编=:f5,备注=:f6 where 客户编号=:f1';
with DM_datamodule do
begin
if crmDB.Connected then
begin
if trim(edit1.Text)<>'' then
begin
with qry_CustomersInfo do
begin
create(nil);
sql.Add('select * from CustomersInfo where 客户编号=:f1');
Parambyname('f1').AsString:=edit1.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:=Memo1.Text;
ExecSQL;
Close;
messagedlg('修改成功!',mtinformation,[mbok],0);
end
else
begin
messagedlg('不存在该客户编号!修改失败!',mtinformation,[mbok],0);
close;
end;
end;
end;
end
else
messagedlg('请先登陆!',mtinformation,[mbok],0);
end;
end;

procedure TF_customersinfo.btn_SearchClick(Sender: TObject);
begin
with DM_datamodule do
begin
if crmDB.Connected then
begin
if trim(edit1.Text)<>'' then
begin
with qry_CustomersInfo do
begin
create(nil);
sql.Add('select * from CustomersInfo where 客户编号=:f1');
Parambyname('f1').AsString:=edit1.Text;
prepare;
open;
if Recordcount<>0 then
begin
edit2.Text:=fieldbyname('客户名称').AsString;
edit3.Text:=fieldbyname('客户电话').AsString;
edit4.Text:=fieldbyname('公司地址').AsString;
edit5.Text:=fieldbyname('邮编').AsString;
Memo1.Text:=fieldbyname('备注').AsString;
Close;
end
else
begin
messagedlg('不存在该客户编号!查找失败!',mtinformation,[mbok],0);
close;
end;
end;
end;
end
else
messagedlg('请先登陆!',mtinformation,[mbok],0);
end;
end;

procedure TF_customersinfo.FormShow(Sender: TObject);
begin
memo1.Text:='';
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -