📄 unit6.pas
字号:
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, DB, ADODB, Buttons, jpeg;
type
TForm6 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
StaticText1: TStaticText;
ComboBox1: TComboBox;
StaticText2: TStaticText;
Edit1: TEdit;
StaticText3: TStaticText;
Edit2: TEdit;
Panel1: TPanel;
Button1: TButton;
Panel2: TPanel;
StaticText4: TStaticText;
StaticText5: TStaticText;
StaticText6: TStaticText;
StaticText7: TStaticText;
ADOQuery1: TADOQuery;
ADOStoredProc1: TADOStoredProc;
StaticText8: TStaticText;
ComboBox2: TComboBox;
StaticText9: TStaticText;
Edit3: TEdit;
Button2: TButton;
Panel3: TPanel;
StaticText11: TStaticText;
StaticText12: TStaticText;
StaticText13: TStaticText;
Edit5: TEdit;
Panel4: TPanel;
StaticText10: TStaticText;
Edit4: TEdit;
Edit6: TEdit;
StaticText14: TStaticText;
BitBtn1: TBitBtn;
StaticText15: TStaticText;
StaticText16: TStaticText;
StaticText17: TStaticText;
Image1: TImage;
ADOQuery2: TADOQuery;
Image2: TImage;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Image1Click(Sender: TObject);
procedure Image2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form6: TForm6;
card_type:char;
implementation
uses unit3, Unit8, Unit1;
{$R *.dfm}
procedure TForm6.FormCreate(Sender: TObject);
begin
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from Bank where Card_type=:a');
ADOQuery1.Parameters[0].Value:='中国工商银行';
ADOQuery1.Active:=true;
ADOQuery1.Open;
if(ADOQuery1.RecordCount>0)then begin combobox1.Items.Add('中国工商银行');combobox2.Items.Add('中国工商银行');end;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from Bank where Card_type=:a');
ADOQuery1.Parameters[0].Value:='中国招商银行';
ADOQuery1.Open;
if(ADOQuery1.RecordCount>0)then begin combobox1.Items.Add('中国招商银行');combobox2.Items.Add('中国招商银行');end;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from Bank where Card_type=:a');
ADOQuery1.Parameters[0].Value:='中国农业银行';
ADOQuery1.Open;
if(ADOQuery1.RecordCount>0)then begin combobox1.Items.Add('中国农业银行');combobox2.Items.Add('中国农业银行');end;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from Bank where Card_type=:a');
ADOQuery1.Parameters[0].Value:='中信银行';
ADOQuery1.Open;
if(ADOQuery1.RecordCount>0)then begin combobox1.Items.Add('中信银行');combobox2.Items.Add('中信银行');end;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from Bank where Card_type=:a');
ADOQuery1.Parameters[0].Value:='中国光大银行';
ADOQuery1.Open;
if(ADOQuery1.RecordCount>0)then begin combobox1.Items.Add('中国光大银行');combobox2.Items.Add('中国光大银行');end;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from Bank where Card_type=:a');
ADOQuery1.Parameters[0].Value:='中国建设银行';
ADOQuery1.Open;
if(ADOQuery1.RecordCount>0)then begin combobox1.Items.Add('中国建设银行');combobox2.Items.Add('中国建设银行');end;
Panel2.Visible:=false;
end;
procedure TForm6.Button1Click(Sender: TObject);
var
mon:double;
id:string;
tt:string;
dd:integer;
flag:string;
zhj:double;
riqi:integer;
begin
//判断是否透支
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select amount as tto from overdraft where (card_type=:a and card_no=:b)');
adoquery1.Parameters[0].Value:=trim(combobox1.Text);
adoquery1.Parameters[1].Value:=Edit1.Text;
adoquery1.Open;
//---没有透支---
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select customer_id as ss from customer_fund where (card_type=:a and card_no=:b)');
adoquery2.Parameters[0].Value:=trim(combobox1.Text);
adoquery2.Parameters[1].Value:=Edit1.Text;
adoquery2.Open;
id:=adoquery2.FieldByName('ss').Value;
if(adoquery1.RecordCount<=0)then begin
tt:='存款';
//--------计算存款前的利息----
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select datediff(day,Deposit_date,getdate()) as ttot, fortune_amount as ss from Fund_bill where (Card_type=:a and Card_no=:b)');
adoquery1.Parameters[0].Value:=combobox1.Text;
adoquery1.Parameters[1].Value:=Edit1.Text;
adoquery1.Open;
mon:=Adoquery1.FieldByName('ss').Value;
dd:=Adoquery1.FieldByName('ttot').Value;
mon:=mon+mon*0.005*dd;
showmessage('你有本金和利息'+floattostr(mon)+'将作为此次的本金');
//adoquery1.SQL.Clear;
//adoquery1.SQL.Add('select datediff(day,Deposit_date,getdate()) as ttot from fund_bill where (card_type=:a and card_no=:b)');
//adoquery1.SQL.Clear;
//adoquery1.SQL.Add('select amount as tto from overdraft where (Card_type=:a and Card_no=:b)');
// adoquery1.Parameters[0].Value:=combobox1.Text;
// adoquery1.Parameters[1].Value:=Edit1.Text;
// adoquery1.Open;
// if(Adoquery1.FieldByName('tto').Value=null)then
// begin
ADOStoredProc1.ProcedureName:='Deposit_t_w';
ADOStoredProc1.Parameters.Refresh;
adostoredProc1.Parameters.ParamByName('@type').Value:=trim(combobox1.Text);
adostoredProc1.Parameters.ParamByName('@Number').Value:=Edit1.Text;
adostoredProc1.Parameters.ParamByName('@date').Value:=Now();
adostoredProc1.Parameters.ParamByName('@money1').Value:=strtofloat(Edit2.Text);
adostoredProc1.Parameters.ParamByName('@id').Value:=id;
adostoredProc1.Parameters.ParamByName('@TT').Value:=tt;
adostoredProc1.ExecProc;
Application.MessageBox('存款成功!!!','提示',0+64);
adoquery1.SQL.Clear;
adoquery1.sql.Add('select Fortune_amount as ss from Fund_bill where (Card_type=:a and Card_no=:b)');
adoquery1.Parameters[0].Value:=trim(combobox1.Text);
adoquery1.Parameters[1].Value:=Edit1.Text;
adoquery1.Open;
mon:=adoquery1.fieldByName('ss').AsFloat;
StaticText5.Caption:=floattostr(mon);
StaticText7.Caption:='%0.5';
if(trim(combobox1.Text)='中国工商银行')then begin StaticText12.Caption:='欢迎使用中国工商银行'; end;
if(trim(combobox1.Text)='中国招商银行')then begin StaticText12.Caption:='欢迎使用中国招商银行'; end;
if(trim(combobox1.Text)='中国农业银行')then begin StaticText12.Caption:='欢迎使用中国农业银行'; end;
if(trim(combobox1.Text)='中信银行')then begin StaticText12.Caption:='欢迎使用中信银行'; end;
if(trim(combobox1.Text)='中国光大银行')then begin StaticText12.Caption:='欢迎使用中国光大银行'; end;
if(trim(combobox1.Text)='中国建设银行')then begin StaticText12.Caption:='欢迎使用中国建设银行'; end;
Panel2.Visible:=true;
Exit;
end;
//----有透支---
if(adoquery1.RecordCount>0)then begin
zhj:=Adoquery1.FieldByName('tto').Value;
showmessage('你有透支金额'+floattostr(zhj));
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select datediff(day,dat,getdate()) as ttot from overdraft where (Card_type=:a and Card_no=:b)');
adoquery1.Parameters[0].Value:=combobox1.Text;
adoquery1.Parameters[1].Value:=Edit1.Text;
adoquery1.Open;
riqi:=adoquery1.fieldbyname('ttot').Value;
if(zhj<=strtofloat(Edit2.Text))then //透支额小于存款额
begin
tt:='存款';
ADOStoredProc1.ProcedureName:='Deposit_t_d';
ADOStoredProc1.Parameters.Refresh;
adostoredProc1.Parameters.ParamByName('@type').Value:=trim(combobox1.Text);
adostoredProc1.Parameters.ParamByName('@Number').Value:=Edit1.Text;
adostoredProc1.Parameters.ParamByName('@date').Value:=Now();
adostoredProc1.Parameters.ParamByName('@amount').Value:=strtofloat(Edit2.Text)-zhj;
adostoredProc1.Parameters.ParamByName('@id').Value:=id;
adostoredProc1.Parameters.ParamByName('@TT').Value:=tt;
adostoredProc1.Parameters.ParamByName('@riqi').Value:=riqi;
adostoredProc1.ExecProc;
showmessage('去了透支额,你还有'+floattostr(strtofloat(Edit2.Text)-zhj)+'存款');
//Exit;
end;
if(zhj>strtofloat(Edit2.Text))then
begin
ADOStoredProc1.ProcedureName:='Deposit_t_x';
ADOStoredProc1.Parameters.Refresh;
adostoredProc1.Parameters.ParamByName('@type').Value:=trim(combobox1.Text);
adostoredProc1.Parameters.ParamByName('@Number').Value:=Edit1.Text;
adostoredProc1.Parameters.ParamByName('@date').Value:=Now();
adostoredProc1.Parameters.ParamByName('@money1').Value:=strtofloat(Edit2.Text);
adostoredProc1.Parameters.ParamByName('@id').Value:=id;
adostoredProc1.Parameters.ParamByName('@riqi').Value:=riqi;
adostoredProc1.ExecProc;
showmessage('支还透支额');
Exit;
end;
end;
//---------end-------
adoquery1.SQL.Clear;
adoquery1.sql.Add('select Fortune_amount as ss from Fund_bill where (Card_type=:a and Card_no=:b)');
adoquery1.Parameters[0].Value:=trim(combobox1.Text);
adoquery1.Parameters[1].Value:=Edit1.Text;
adoquery1.Open;
mon:=adoquery1.fieldByName('ss').AsFloat;
StaticText5.Caption:=floattostr(mon);
StaticText7.Caption:='%0.5';
if(trim(combobox1.Text)='中国工商银行')then begin StaticText12.Caption:='欢迎使用中国工商银行'; end;
if(trim(combobox1.Text)='中国招商银行')then begin StaticText12.Caption:='欢迎使用中国招商银行'; end;
if(trim(combobox1.Text)='中国农业银行')then begin StaticText12.Caption:='欢迎使用中国农业银行'; end;
if(trim(combobox1.Text)='中信银行')then begin StaticText12.Caption:='欢迎使用中信银行'; end;
if(trim(combobox1.Text)='中国光大银行')then begin StaticText12.Caption:='欢迎使用中国光大银行'; end;
if(trim(combobox1.Text)='中国建设银行')then begin StaticText12.Caption:='欢迎使用中国建设银行'; end;
Panel2.Visible:=true;
end;
procedure TForm6.Button2Click(Sender: TObject);
var
day:integer;
mo:double;
begin
if(Edit5.Text='')then begin showmessage('请输入卡号');Edit5.SetFocus;Exit;end;
if(Edit3.Text='')then begin showmessage('请输入密码');Edit3.SetFocus;Exit;end;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select fortune_amount as ss from Fund_bill where (Card_type=:a and Card_no=:b and Keyword=:c)');
adoquery1.Parameters[0].Value:=comboBox2.Text;
adoquery1.Parameters[1].Value:=Edit5.Text;
adoquery1.Parameters[2].Value:=Edit3.Text;
adoquery1.Open;
if(adoquery1.RecordCount<=0)then begin showmessage('请确保你输入的卡号,密码正确');Edit3.SetFocus;Exit;end;
mo:=Adoquery1.FieldByName('ss').Value;
//-------计算利息------
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select datediff(day,Deposit_date,getdate()) as ttot from fund_bill where (card_type=:a and card_no=:b)');
adoquery1.Parameters[0].Value:=comboBox2.Text;
adoquery1.Parameters[1].Value:=Edit5.Text;
adoquery1.Open;
day:=Adoquery1.FieldByName('ttot').Value;
mo:=mo+mo*0.005*day;
Edit4.Text:=floattostr(mo);
form8.Edit3.Text:=Edit4.Text;
Panel4.Visible:=true;
Edit6.SetFocus;
end;
procedure TForm6.BitBtn1Click(Sender: TObject);
var
id:string;
begin
if(strtofloat(Edit4.Text)<strtofloat(Edit6.Text))then //透支
begin
//-----检查上次的透支是否还清--------
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from overdraft where (card_type=:a and card_no=:b)');
adoquery1.Parameters[0].Value:=comboBox2.Text;
adoquery1.Parameters[1].Value:=Edit5.Text;
adoquery1.Open;
if(adoquery1.RecordCount>0) then
begin
showmessage('你上次的透支额还没还,不能透支,请尽快还清上次的透支额');
exit;
end;
//-----------end----------------
if(comboBox2.Text='中国工商银行')then begin staticText17.Caption:='欢迎使用中国工商银行透支服务';end;
if(comboBox2.Text='中国招商银行')then begin staticText17.Caption:='欢迎使用中国招商银行透支服务';end;
if(comboBox2.Text='中国农业银行')then begin staticText17.Caption:='欢迎使用中国农业银行透支服务';end;
if(comboBox2.Text='中信银行')then begin staticText17.Caption:='欢迎使用中信银行透支服务';end;
if(comboBox2.Text='中国光大银行')then begin staticText17.Caption:='欢迎使用中国光大银行透支服务';end;
if(comboBox2.Text='中国建设银行')then begin staticText17.Caption:='欢迎使用中国建设银行透支服务';end;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select Customer.trust_abi as ss,fortune_amount as dd from Customer,Customer_Fund,Fund_bill where Customer.customer_id=Customer_fund.Customer_id and customer_fund.card_no=Fund_bill.card_no and fund_bill.card_type=:a and fund_bill.Card_no=:b');
adoquery1.Parameters[0].Value:=comboBox2.Text;
adoquery1.Parameters[1].Value:=Edit5.Text;
adoquery1.Open;
form8.StaticText3.Caption:=comboBox2.Text;
form8.Edit2.Text:=Edit5.Text;
form8.StaticText4.Caption:=inttostr(adoquery1.fieldbyname('ss').Value*1000+adoquery1.fieldbyname('dd').Value);
//form8.Edit3.Text:=floattostr(adoquery1.fieldbyname('dd').Value);
form8.Show;
self.Hide;
Exit;
end;
if((strtofloat(Edit4.Text))>(strtofloat(Edit6.Text)))then
begin
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select customer_id as ss from customer_fund where (card_type=:a and card_no=:b)');
adoquery1.Parameters[0].Value:=combobox2.Text;
adoquery1.Parameters[1].Value:=Edit5.Text;
adoquery1.Open;
id:=adoquery1.fieldbyname('ss').Value;
ADOStoredProc1.ProcedureName:='fecth1';
ADOStoredProc1.Parameters.Refresh;
adostoredProc1.Parameters.ParamByName('@type').Value:=comboBox2.Text;
adostoredProc1.Parameters.ParamByName('@no').Value:=edit5.Text;
adostoredProc1.Parameters.ParamByName('@date').Value:=now();
adostoredProc1.Parameters.ParamByName('@id').Value:=id;
adostoredProc1.Parameters.ParamByName('@TT').Value:='取款';
adostoredProc1.Parameters.ParamByName('@sub1').Value:=strtofloat(Edit6.Text);
ADOStoredProc1.ExecProc;
Application.messagebox('取款成功','提示',0+64);
end;
end;
procedure TForm6.Image1Click(Sender: TObject);
begin
form1.Show;
self.Hide;
end;
procedure TForm6.Image2Click(Sender: TObject);
begin
form1.Show;
self.Hide;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -