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

📄 chaxun.pas

📁 delphi阿涛印花厂,有关于打印的印花厂源码
💻 PAS
字号:
unit chaxun;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,login, DB, Grids, DBGrids, ADODB, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    Label6: TLabel;
    Label1: TLabel;
    ComboBox3: TComboBox;
    dt1: TDateTimePicker;
    dt2: TDateTimePicker;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    ADOQuery2: TADOQuery;
    DBGrid1: TDBGrid;
    ADOQuery1: TADOQuery;
    DataSource1: TDataSource;
    Label2: TLabel;
    DBGrid2: TDBGrid;
    ADOQuery3: TADOQuery;
    DataSource2: TDataSource;
    procedure Button1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
uses unit2;
procedure TForm1.Button1Click(Sender: TObject);
begin
adoquery2.Close;
if combobox3.ItemIndex<>0 then
 adoquery2.SQL.Text:=format('insert into temp select khh,khm,rq,hy,dj,sl,ze,yf,ze-yf as jq from chb where khh='+'''%s'''+' and rq between #%s# and #%s# order by rq',[trim(copy(combobox3.text,1,3)),datetostr(dt1.Date),datetostr(dt2.Date)])
else
adoquery2.SQL.Text:=format('insert into temp select khh,khm,rq,hy,dj,sl,ze,yf,ze-yf as jq from chb where rq between #%s# and #%s# order by rq',[datetostr(dt1.Date),datetostr(dt2.Date)]);
adoquery2.ExecSQL;
adoquery1.close;
adoquery1.Open;
adoquery2.Close;
adoquery2.SQL.Text:='delete from temp';
adoquery2.ExecSQL;
dbgrid1.Visible:=true;
dbgrid2.Visible:=false;
end;

procedure TForm1.FormShow(Sender: TObject);
var i:integer;
begin
adoquery2.Close;
adoquery2.SQL.Text:='select khid,khname from khb order by khid';
adoquery2.Open;
combobox3.Clear;
combobox3.Items.Append('全部客户');
for i:=1 to adoquery2.RecordCount do
  begin
    combobox3.Items.Append(adoquery2.Recordset.Fields[0].value+'    '+adoquery2.Recordset.Fields[1].value);
    adoquery2.Next;
  end;
combobox3.ItemIndex:=0;
dt1.Date:=date();
dt2.Date:=date();
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
adoquery2.Close;
if combobox3.ItemIndex<>0 then
 adoquery2.SQL.Text:=format('insert into temp select khh,khm,rq,hy,dj,sl,ze,yf,ze-yf as jq from chb where khh='+'''%s'''+' and rq between #%s# and #%s# order by rq',[trim(copy(combobox3.text,1,3)),datetostr(dt1.Date),datetostr(dt2.Date)])
else
adoquery2.SQL.Text:=format('insert into temp select khh,khm,rq,hy,dj,sl,ze,yf,ze-yf as jq from chb where rq between #%s# and #%s# order by rq',[datetostr(dt1.Date),datetostr(dt2.Date)]);
adoquery2.ExecSQL;
adoquery2.close;
if combobox3.ItemIndex<>0 then
 adoquery2.SQL.Text:=format('insert into temp1 select khh,khm,sum(sl)as sl1,sum(ze)as ze1,sum(yf)as yf1,sum(jq)as jq1 from temp group by khh,khm having khh='+'''%s''',[trim(copy(combobox3.text,1,3))])
else
 adoquery2.SQL.Text:='insert into temp1 select khh,khm,sum(sl)as sl1,sum(ze)as ze1,sum(yf)as yf1,sum(jq)as jq1 from temp group by khh,khm ';
adoquery2.ExecSQL;
adoquery3.close;
adoquery3.Open;
adoquery2.Close;
adoquery2.SQL.Text:='delete from temp1';
adoquery2.ExecSQL;
adoquery2.Close;
adoquery2.SQL.Text:='delete from temp';
adoquery2.ExecSQL;
dbgrid2.Visible:=true;
dbgrid1.Visible:=false;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
if dbgrid1.Visible then
begin
form2.ADOQuery1.Clone(adoquery1);
form2.QRLabel4.Caption:=combobox3.Text;
form2.QRLabel5.Caption:=datetostr(dt1.Date);
form2.QRLabel16.Caption:=datetostr(dt2.Date);
form2.QuickRep1.Preview;
end
else
begin
form2.ADOQuery1.Clone(adoquery3);
form2.QRLabel27.Caption:=combobox3.Text;
form2.QRLabel28.Caption:=datetostr(dt1.Date);
form2.QRLabel30.Caption:=datetostr(dt2.Date);
form2.QuickRep2.Preview;
end;
end;

end.

⌨️ 快捷键说明

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