uclientset.~pas
来自「DELPHI编程入门篇.从基础入手,浅显易懂,一定物有所值.」· ~PAS 代码 · 共 256 行
~PAS
256 行
unit Uclientset;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, ComCtrls, StdCtrls, ExtCtrls, Buttons, DB, ADODB, RpCon,
RpConDS, RpDefine, RpRave,RvCsRpt,RVProj,RVClass,RVCsStd;
type
Tfrmclientset = class(TForm)
SpeedButton4: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton1: TSpeedButton;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
ComboBox1: TComboBox;
CheckBox1: TCheckBox;
DatePicker: TDateTimePicker;
StringGrid1: TStringGrid;
Label6: TLabel;
Label5: TLabel;
Label4: TLabel;
Label3: TLabel;
ADOQuery1: TADOQuery;
RvProject1: TRvProject;
clientsetConnection1: TRvDataSetConnection;
procedure FormCreate(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure ComboBox1Select(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmclientset: Tfrmclientset;
implementation
uses Udatamodule, Usettlecharge;
{$R *.dfm}
procedure Tfrmclientset.FormCreate(Sender: TObject);
var
sdate,syear,smonth:word;
begin
decodedate(date,syear,smonth,sdate);
if smonth > 1 then dec(smonth)
else begin
smonth:=12;
dec(syear);
end;
datepicker.Date:=encodedate(syear,smonth,sdate);
checkbox1.Checked:=false;
datepicker.Enabled:=false;
adoquery1.SQL.Text:='select clientname from clients';
adoquery1.Open;
while not adoquery1.Eof do
begin
combobox1.Items.Add(adoquery1.fields[0].AsString);
adoquery1.Next;
end;
adoquery1.Close;
combobox1.ItemIndex:=-1;
stringgrid1.Cells[0,0]:='业务日期';
stringgrid1.Cells[1,0]:='业务类型';
stringgrid1.Cells[2,0]:='单号';
stringgrid1.Cells[3,0]:='经手人';
stringgrid1.Cells[4,0]:='应付金额';
stringgrid1.Cells[5,0]:='已付金额';
end;
procedure Tfrmclientset.CheckBox1Click(Sender: TObject);
begin
if datepicker.Enabled then
datepicker.Enabled:=false
else
datepicker.Enabled:=true;
end;
procedure Tfrmclientset.SpeedButton1Click(Sender: TObject);
var
i,arow:integer;
allpay,allpayed:real;
begin
if edit1.Text = '' then
begin
showmessage('请选择客户!');
exit;
end;
for i:=1 to stringgrid1.RowCount-1 do
stringgrid1.Rows[i].Clear;
stringgrid1.RowCount:=2;
adoquery1.SQL.Text:='select saledate,wholesaleid,handleman,accounts from '
+'wholesale where clientid = '''+edit1.Text+'''';
if datepicker.Enabled then
adoquery1.SQL.Add('and saledate >=#'+datetostr(datepicker.Date)+'#');
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
arow:=1;
stringgrid1.RowCount:=adoquery1.RecordCount+1;
while not adoquery1.Eof do
begin
stringgrid1.Cells[0,arow]:=adoquery1.Fields[0].AsString;
stringgrid1.Cells[1,arow]:='销售';
stringgrid1.Cells[2,arow]:=adoquery1.Fields[1].AsString;
stringgrid1.Cells[3,arow]:=adoquery1.Fields[2].AsString;
stringgrid1.Cells[4,arow]:=adoquery1.Fields[3].AsString;
stringgrid1.Cells[5,arow]:='0';
adoquery1.Next;
inc(arow);
end;
end;
adoquery1.Close;
adoquery1.SQL.Text:='select refdate,wrefid,handleman,accounts '
+'from whrefund where clientid = '''+edit1.Text+'''';
if not datepicker.Enabled then
adoquery1.SQL.Add('and refdate >=#'+datetostr(datepicker.Date)+'#');
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
while not adoquery1.Eof do
begin
if stringgrid1.Cells[0,stringgrid1.RowCount-1] <> '' then
stringgrid1.RowCount:=stringgrid1.RowCount+1;
arow:=stringgrid1.RowCount-1;
stringgrid1.Cells[0,arow]:=adoquery1.Fields[0].AsString;
stringgrid1.Cells[1,arow]:='退货';
stringgrid1.Cells[2,arow]:=adoquery1.Fields[1].AsString;
stringgrid1.Cells[3,arow]:=adoquery1.Fields[2].AsString;
stringgrid1.Cells[4,arow]:='-'+adoquery1.Fields[3].AsString;
stringgrid1.Cells[5,arow]:='0';
adoquery1.Next;
end;
end;
adoquery1.Close;
adoquery1.SQL.Text:='select settledate,settleid,handleman,payed from'
+' clisettle where clientid = '''+edit1.Text+'''';
if datepicker.enabled then
adoquery1.SQL.add('and settledate >=#'+datetostr(datepicker.Date)+'#');
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
while not adoquery1.Eof do
begin
if stringgrid1.Cells[0,stringgrid1.RowCount-1] <> '' then
stringgrid1.RowCount:=stringgrid1.RowCount+1;
arow:=stringgrid1.RowCount-1;
stringgrid1.Cells[0,arow]:=adoquery1.Fields[0].AsString;
stringgrid1.Cells[1,arow]:='结算';
stringgrid1.Cells[2,arow]:=adoquery1.Fields[1].AsString;
stringgrid1.Cells[3,arow]:=adoquery1.Fields[2].AsString;
stringgrid1.Cells[4,arow]:='0';
stringgrid1.Cells[5,arow]:=adoquery1.Fields[3].AsString;
adoquery1.Next;
end;
end;
adoquery1.Close;
if stringgrid1.Cells[1,1] = '' then
begin
label5.Caption:='0.00';
label6.Caption:='0.00';
end
else begin
allpay:=0;
allpayed:=0;
for i:=1 to stringgrid1.RowCount-1 do
begin
allpay:=allpay+strtocurr(stringgrid1.Cells[4,i]);
allpayed:=allpayed+strtocurr(stringgrid1.Cells[5,i]);
end;
label5.Caption:=floattostr(allpay)+' ';
label6.Caption:=floattostr(allpayed)+' ';
end;
end;
procedure Tfrmclientset.SpeedButton3Click(Sender: TObject);
begin
Application.CreateForm(Tfrmsettlecharge, frmsettlecharge);
frmsettlecharge.ShowModal;
frmsettlecharge.Release;
end;
procedure Tfrmclientset.ComboBox1Select(Sender: TObject);
begin
adoquery1.SQL.Text:='select clientid from clients where clientname = '''+combobox1.Text+'''';
adoquery1.Open;
edit1.Text:=adoquery1.Fields[0].AsString;
adoquery1.Close;
end;
procedure Tfrmclientset.SpeedButton4Click(Sender: TObject);
begin
modalresult:=mrcancel;
end;
procedure Tfrmclientset.SpeedButton2Click(Sender: TObject);
var
i:integer;
mypage:travepage;
mytext:travetext;
begin
rvproject1.Open;
with rvproject1.ProjMan do
begin
mypage:=findravecomponent('report1.page1',nil) as travepage;
mytext:=findravecomponent('text3',mypage) as travetext;
mytext.Text:=combobox1.Text;
mytext:=findravecomponent('text12',mypage) as travetext;
mytext.Text:=label5.Caption;
mytext:=findravecomponent('text13',mypage) as travetext;
mytext.Text:=label6.Caption;
end;
if stringgrid1.Cells[0,1] <> '' then
begin
adoquery1.SQL.Text:='create table tbclientset (operdate date not null,'+
'operkind char(20),tabid char(12),handleman char(20),shpay float,payed float)';
adoquery1.ExecSQL;
adoquery1.Close;
for i:=1 to stringgrid1.RowCount-1 do
begin
adoquery1.SQL.Text:='insert into tbclientset values(#'+stringgrid1.Cells[0,i]+
'#,'''+stringgrid1.Cells[1,i]+''','''+stringgrid1.Cells[2,i]+''','''+
stringgrid1.Cells[3,i]+''','+stringgrid1.Cells[4,i]+','+stringgrid1.Cells[5,i]+')';
adoquery1.ExecSQL;
adoquery1.Close;
end;
adoquery1.SQL.Text:='select * from tbclientset';
adoquery1.Open;
try
rvproject1.Execute;
finally
rvproject1.Close;
adoquery1.Close;
adoquery1.SQL.Text:='drop table tbclientset';
adoquery1.ExecSQL;
adoquery1.Close;
end;
end
else
showmessage('请先查询数据');
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?