📄 un_applicant.~pas
字号:
unit un_applicant;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DB, ADODB, DBTables, ExtCtrls;
type
Tfm_applicant = class(TForm)
Label1: TLabel;
BitBtn1: TBitBtn;
BitBtn3: TBitBtn;
BitBtn2: TBitBtn;
BitBtn4: TBitBtn;
Panel1: TPanel;
Label24: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label6: TLabel;
Label7: TLabel;
Label9: TLabel;
ed_name: TEdit;
ed_account: TEdit;
ed_code: TEdit;
ed_tel: TEdit;
ed_addr: TEdit;
ed_rep: TEdit;
ed_account_bank: TEdit;
Label5: TLabel;
ed_tax_no: TEdit;
Label8: TLabel;
ed_relation: TEdit;
Database1: TDatabase;
ADOConnection1: TADOConnection;
select_company: TADOQuery;
insert_client: TADOQuery;
Label10: TLabel;
ed_mail: TEdit;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure ed_telKeyPress(Sender: TObject; var Key: Char);
procedure ed_accountKeyPress(Sender: TObject; var Key: Char);
procedure ed_codeKeyPress(Sender: TObject; var Key: Char);
procedure ed_tax_noKeyPress(Sender: TObject; var Key: Char);
procedure FormCreate(Sender: TObject);
procedure ed_repKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
fm_applicant: Tfm_applicant;
com_id:integer;
function NumMask(var key:char):char;
function DoubleNumMask(var key:char):char;
function TelNumMask(var key:char):char;
function AccNumMask(var key:char):char;
function num_str(ls: Variant): string; //转换大写(包含单位)
function num_str1(ls: Variant; spacenum: integer): string; //转换大写(不包含单位)
implementation
uses un_companyselect;
{$R *.dfm}
procedure Tfm_applicant.BitBtn1Click(Sender: TObject);
var
Com_name:string; // 单位名称
Com_account:string; // 帐号
Com_code:string; // 邮编
Com_tel:string; // 电话
Com_addr:string; // 地址
Com_rep:string; // 法人代表
Com_account_bank:string; // 开户银行
com_relation:string; //联系人
com_tax_no:string; //税号
com_mail:string;//e_mail
i:double;
code:integer;
xx:string;
begin
Com_name:=ed_name.Text ;//单位名称
if trim(Com_name)='' then
begin
Application.MessageBox('单位名称不能为空!','提示', mb_ok);
exit;
end;
Com_addr:=ed_addr.Text ; //单位地址
com_tel:=ed_tel.Text ; //电话
Com_rep:=ed_rep.Text ; //法人代表
com_relation:=ed_relation.Text ;//联系人
Com_account_bank:=ed_account_bank.Text ; //开户银行
if com_addr='' then com_addr:=' ';
if com_tel='' then com_tel:=' ';
if com_addr='' then com_addr:=' ';
if Com_rep='' then Com_rep:=' ';
if com_relation='' then com_relation:=' ';
if Com_account_bank='' then Com_account_bank:=' ';
if trim(ed_code.Text )='' then
Com_code:=' '
else
begin
val(ed_code.Text,i,code);
if code<>0 then
begin
Application.MessageBox('邮编输入不正确!','提示', mb_ok);
exit;
end;
Com_code:=ed_code.Text ;//邮编
end;
if trim(ed_account.Text )='' then
Com_account:=' '
else
begin
{ val(ed_account.Text,i,code);
if code<>0 then
begin
Application.MessageBox('账号输入不正确!','提示', mb_ok);
exit;
end;}
Com_account:=ed_account.Text ; //账号
end;
if trim(ed_tax_no.Text )='' then
com_tax_no:=' '
else
begin
{ val(ed_tax_no.Text,i,code);
if code<>0 then
begin
Application.MessageBox('税号输入不正确!','提示', mb_ok);
exit;
end; }
com_tax_no:=ed_tax_no.Text ; //税号
end;
if trim(ed_code.Text )='' then
Com_code:=' '
else
begin
val(ed_code.Text,i,code);
if code<>0 then
begin
Application.MessageBox('邮编输入不正确!','提示', mb_ok);
exit;
end;
Com_code:=ed_code.Text ;//邮编
end;
com_mail:=ed_mail.text;
if com_mail='' then com_mail:=' ';
{
if not((copy(ed_grzh.Text,1,4)='4580') or (copy(ed_grzh.Text,1,4)='5309') or (copy(ed_grzh.Text,1,5)='12020')) then
begin
application.MessageBox('帐号不对!','提示', mb_ok);
exit;
end;
if (copy(ed_grzh.Text,1,4)='4580') or (copy(ed_grzh.Text,1,4)='5309') then
if length(ed_grzh.Text)<>16 then
begin
application.MessageBox('帐号长度不对!','提示', mb_ok);
exit;
end;
if copy(ed_grzh.Text,1,5)='12020' then
if length(ed_grzh.Text)<>19 then
begin
application.MessageBox('帐号长度不对!','提示', mb_ok);
exit;
end;
}
with select_company do
begin
Close ;
sql.clear;
sql.Add('select * from client where com_name=:@com_name ');
Parameters.ParamByName('@com_name').value :=com_name;
prepared:=true;
open;
if not eof then
begin
xx:='客户名称:'+com_name+'已经存在!';
Application.MessageBox(pchar(xx),'提示', MB_ok);
exit;
end;
end ;
with insert_client do
begin
close;
sql.clear;
sql.add('insert into client(Com_name,Com_account,Com_code,Com_tel,Com_addr,Com_rep,Com_account_bank,com_relation,com_tax_no,com_mail) ');
sql.add('values(:@Com_name,:@Com_account,:@Com_code,:@Com_tel,:@Com_addr,:@Com_rep,:@Com_account_bank,:@com_relation,:@com_tax_no,:@com_mail) ');
Parameters.ParamByName('@Com_name').value :=Com_name;//单位名称
Parameters.ParamByName('@Com_account').value :=Com_account;//帐号
Parameters.ParamByName('@Com_code').value :=Com_code;//邮编
Parameters.ParamByName('@Com_tel').value :=Com_tel;//电话
Parameters.ParamByName('@Com_addr').value :=Com_addr;//地址
Parameters.ParamByName('@Com_rep').value :=Com_rep;//法人代表
Parameters.ParamByName('@Com_account_bank').value :=Com_account_bank;//开户银行
Parameters.ParamByName('@com_relation').value :=com_relation;//联系人
Parameters.ParamByName('@com_tax_no').value :=com_tax_no;//税号
Parameters.ParamByName('@com_mail').value :=com_mail;//e_mail
prepared:=true;
Execsql;
Application.MessageBox('客户信息已保存.','客户信息', mb_ok);
bitbtn4.Enabled :=false;
ed_name.text:='';
ed_account.text:='';
ed_code.text:='';
ed_rep.text:='';
ed_tel.text:='';
ed_addr.text:='';
ed_mail.text:='';
ed_tax_no.text:='';
ed_relation.text:='';
ed_account_bank.text:='';
end;
end;
procedure Tfm_applicant.BitBtn2Click(Sender: TObject);
begin
Application.CreateForm(Tfm_companyselect, fm_companyselect);
with fm_companyselect do
begin
with select_client do
begin
close;
sql.Clear ;
sql.Add('select client_id,Com_name as 客户名称,Com_addr as 客户地址,');
sql.add('Com_tel as 联系电话,com_relation as 联系人,com_mail as e_mail,Com_rep as 传真,');
sql.add('Com_account_bank as 开户银行,Com_account as 账号,com_tax_no as 税号,Com_code as 邮编');
sql.Add(' from client');
prepared:=true;
Open ;
end;
dbgrid1.Columns[0].Visible :=false;
dbgrid1.Columns[1].Width :=200;
dbgrid1.Columns[2].Width :=200;
dbgrid1.Columns[3].Width :=100;
dbgrid1.Columns[4].Width :=100;
dbgrid1.Columns[5].Width :=100;
dbgrid1.Columns[6].Width :=100;
dbgrid1.Columns[7].Width :=120;
dbgrid1.Columns[8].Width :=120;
dbgrid1.Columns[9].Width :=120;
dbgrid1.Columns[10].Width :=100;
showmodal;
free;
end;
end;
procedure Tfm_applicant.BitBtn4Click(Sender: TObject);
var
Com_name:string; // 单位名称
Com_account:string; // 帐号
Com_code:string; // 邮编
Com_tel:string; // 电话
Com_addr:string; // 地址
Com_rep:string; // 法人代表
Com_account_bank:string; // 开户银行
com_relation:string; //联系人
com_tax_no:string; //税号
com_mail:string;//e_mail
i:double;
code:integer;
xx:string;
begin
Com_name:=ed_name.Text ;//单位名称
if trim(Com_name)='' then
begin
Application.MessageBox('单位名称不能为空!','提示', mb_ok);
exit;
end;
Com_addr:=ed_addr.Text ; //单位地址
com_tel:=ed_tel.Text ; //电话
Com_rep:=ed_rep.Text ; //法人代表
com_relation:=ed_relation.Text ;//联系人
Com_account_bank:=ed_account_bank.Text ; //开户银行
if com_addr='' then com_addr:=' ';
if com_tel='' then com_tel:=' ';
if com_addr='' then com_addr:=' ';
if Com_rep='' then Com_rep:=' ';
if com_relation='' then com_relation:=' ';
if Com_account_bank='' then Com_account_bank:=' ';
if trim(ed_code.Text )='' then
Com_code:=' '
else
begin
val(ed_code.Text,i,code);
if code<>0 then
begin
Application.MessageBox('邮编输入不正确!','提示', mb_ok);
exit;
end;
Com_code:=ed_code.Text ;//邮编
end;
if trim(ed_account.Text )='' then
Com_account:=' '
else
begin
{ val(ed_account.Text,i,code);
if code<>0 then
begin
Application.MessageBox('账号输入不正确!','提示', mb_ok);
exit;
end;}
Com_account:=ed_account.Text ; //账号
end;
if trim(ed_tax_no.Text )='' then
com_tax_no:=' '
else
begin
{ val(ed_tax_no.Text,i,code);
if code<>0 then
begin
Application.MessageBox('税号输入不正确!','提示', mb_ok);
exit;
end;}
com_tax_no:=ed_tax_no.Text ; //税号
end;
if trim(ed_code.Text )='' then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -