📄 un_companyselect.~pas
字号:
unit un_companyselect;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Grids, DBGrids, StdCtrls, Buttons, ADODB;
type
Tfm_companyselect = class(TForm)
BitBtn1: TBitBtn;
DBGrid1: TDBGrid;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
GroupBox1: TGroupBox;
Label24: TLabel;
ed_name: TEdit;
Label6: TLabel;
ed_addr: TEdit;
Label3: TLabel;
ed_code: TEdit;
Label7: TLabel;
Label8: TLabel;
ed_rep: TEdit;
ed_relation: TEdit;
ed_tel: TEdit;
Label4: TLabel;
Label9: TLabel;
ed_account_bank: TEdit;
Label2: TLabel;
ed_account: TEdit;
Label5: TLabel;
ed_tax_no: TEdit;
BitBtn4: TBitBtn;
DataSource1: TDataSource;
select_client: TADOQuery;
delete_company: TADOQuery;
Label10: TLabel;
ed_mail: TEdit;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure ed_telKeyPress(Sender: TObject; var Key: Char);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure ed_accountKeyPress(Sender: TObject; var Key: Char);
procedure ed_codeKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
fm_companyselect: Tfm_companyselect;
implementation
uses un_applicant;
{$R *.dfm}
procedure Tfm_companyselect.BitBtn1Click(Sender: TObject);
var i:integer;
begin
if DBGrid1.SelectedIndex>=0 then
with DBGrid1.DataSource.DataSet do
begin
GotoBookmark(pointer(DBGrid1.SelectedIndex));
com_id:=Fields[0].Asinteger;
fm_applicant.ed_name.text:=Fields[1].asstring;
fm_applicant.ed_addr.text:=Fields[2].asstring;
fm_applicant.ed_tel.text:=Fields[3].asstring;
fm_applicant.ed_relation.text:=Fields[4].asstring;
fm_applicant.ed_mail.text:=Fields[5].asstring;
fm_applicant.ed_rep.text:=Fields[6].asstring;
fm_applicant.ed_account_bank.text:=Fields[7].asstring;
fm_applicant.ed_account.text:=Fields[8].asstring;
fm_applicant.ed_tax_no.text:=Fields[9].asstring;
fm_applicant.ed_code.text:=Fields[10].asstring;
fm_companyselect.close;
// fm_applicant.show;
fm_applicant.bitbtn4.Enabled :=true;
end;
end;
procedure Tfm_companyselect.BitBtn3Click(Sender: TObject);
begin
if DBGrid1.SelectedIndex>=0 then
with DBGrid1.DataSource.DataSet do
begin
GotoBookmark(pointer(DBGrid1.SelectedIndex));
com_id:=Fields[0].Asinteger;
end;
with delete_company do
begin
Close ;
sql.clear;
sql.add('delete * from client where client_id=:@com_id');
Parameters.ParamByName('@com_id').value:=com_id;
prepared:=true;
Execsql;
Application.MessageBox('记录已删除!','提示', MB_ok);
select_client.close;
select_client.prepared:=true;
select_client.Open ;
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;
end;
end;
procedure Tfm_companyselect.ed_telKeyPress(Sender: TObject; var Key: Char);
begin
key:=TELNumMask(key);
end;
procedure Tfm_companyselect.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;
begin
if trim(ed_name.Text)<>'' then
com_name:=ed_name.Text
else
com_name:='';
if trim(ed_account.Text)<>'' then
Com_account:=ed_account.Text
else
Com_account:='';
if trim(ed_code.Text)<>'' then
Com_code:=ed_code.Text
else
Com_code:='';
if trim(ed_addr.Text)<>'' then
Com_addr:=ed_addr.Text
else
Com_addr:='';
if trim(ed_tel.Text)<>'' then
com_tel:=ed_tel.Text
else
com_tel:='';
if trim(ed_rep.Text)<>'' then
com_rep:=ed_rep.Text
else
com_rep:='';
if trim(ed_account_bank.Text)<>'' then
Com_account_bank:=ed_account_bank.Text
else
Com_account_bank:='';
if trim(ed_relation.Text)<>'' then
com_relation:=ed_relation.Text
else
com_relation:='';
if trim(ed_tax_no.Text)<>'' then
com_tax_no:=ed_tax_no.Text
else
com_tax_no:='';
if trim(ed_mail.Text)<>'' then
com_mail:=ed_mail.Text
else
com_mail:='';
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 where 1=1 ');
if Com_name<>'' then sql.Add('and Com_name like ''%'+Com_name+'%''');
if Com_account<>'' then sql.Add('and Com_account=:@Com_account');
if Com_code<>'' then sql.Add(' and Com_code=:@Com_code');
if Com_tel<>'' then sql.add(' and Com_tel like ''%'+Com_tel+'%''');
if Com_addr<>'' then sql.add(' and Com_addr like ''%'+Com_addr+'%''');
if Com_rep<>'' then sql.add(' and Com_rep like ''%'+Com_rep+'%''');
if Com_account_bank<>'' then sql.add(' and Com_account_bank like ''%'+Com_account_bank+'%''');
if com_relation<>'' then sql.add(' and com_relation like ''%'+ com_relation+'%''');
if com_tax_no<>'' then sql.add(' and com_tax_no=:@com_tax_no');
if com_mail<>'' then sql.add(' and com_mail like ''%'+com_mail+'%''');
if Com_account<>'' then Parameters.ParamByName('@Com_account').value:=Com_account;
if Com_code<>'' then Parameters.ParamByName('@Com_code').value:=Com_code;
if com_tax_no<>'' then Parameters.ParamByName('@com_tax_no').value:=com_tax_no;
prepared:=true;
open;
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;
end;
end;
procedure Tfm_companyselect.FormKeyPress(Sender: TObject; var Key: Char);
var
sClassName:string;
begin
if Key = #13 then
begin
sClassName := TForm(Sender).ActiveControl.ClassName;
if (sClassName <> 'TDBMemo')
And (sClassName <> 'TMemo') then
begin
Key := #0;
Perform(WM_NEXTDLGCTL, 0, 0);
end;
end;
end;
procedure Tfm_companyselect.ed_accountKeyPress(Sender: TObject;
var Key: Char);
begin
key:=telNumMask(key);
end;
procedure Tfm_companyselect.ed_codeKeyPress(Sender: TObject;
var Key: Char);
begin
key:=telNumMask(key);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -