?? bm_priu.pas
字號(hào):
unit BM_PRIU;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask, Grids, DBGrids, ExtCtrls, ComCtrls, TabNotBk,
Buttons, DB, ADODB;
type
TBM_PRIF = class(TForm)
TabbedNotebook1: TTabbedNotebook;
Panel1: TPanel;
CB1: TComboBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
CB2: TComboBox;
DP1: TDateTimePicker;
DP2: TDateTimePicker;
Panel2: TPanel;
CheckBox1: TCheckBox;
TabbedNotebook2: TTabbedNotebook;
DBGrid3: TDBGrid;
AQ1: TADOQuery;
DS1: TDataSource;
Panel3: TPanel;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton10: TSpeedButton;
SpeedButton5: TSpeedButton;
Panel4: TPanel;
TabbedNotebook3: TTabbedNotebook;
Label5: TLabel;
cb3: TComboBox;
cb4: TComboBox;
Label6: TLabel;
dp3: TDateTimePicker;
Label7: TLabel;
dp4: TDateTimePicker;
Label8: TLabel;
CheckBox2: TCheckBox;
AQ2: TADOQuery;
DS2: TDataSource;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
DBGrid2: TDBGrid;
DBGrid1: TDBGrid;
DBGrid4: TDBGrid;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure CB1DropDown(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure CB2DropDown(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
procedure DBGrid3DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
procedure DBGrid2DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
procedure DBGrid3DblClick(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
procedure SpeedButton10Click(Sender: TObject);
procedure SpeedButton8Click(Sender: TObject);
procedure SpeedButton7Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton9Click(Sender: TObject);
procedure cb3DropDown(Sender: TObject);
procedure cb4DropDown(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure DBGrid4DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
canmodify:boolean;
end;
var
BM_PRIF: TBM_PRIF;
sqltext,sqltext2:string;
implementation
uses BM_DMU, BM_PRIU_ADDU, BM_OFICEU;
{$R *.dfm}
function caldate(ndate:tdatetime):tdate;
var
yy,mm,dd:word;
begin
ndate:=date;
decodedate(ndate,yy,mm,dd);
if mm=1 then
begin
mm:=12;
yy:=yy-1;
end
else
mm:=mm-1;
result:=encodedate(yy,mm,dd);
end;
procedure TBM_PRIF.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=cafree;
end;
procedure TBM_PRIF.CB1DropDown(Sender: TObject);
var i:integer;
begin
CB1.Items.Clear ;
WITH DM.QALL do
begin
close;
sql.Clear ;
sql.Add('select DISTINCT 部門名稱 from 部門');
open;
first;
end;
for i:=0 to DM.QALL.RecordCount-1 do
begin
CB1.Items.Add(DM.QALL.Fields[0].asstring);
DM.QALL.next;
end;
end;
procedure TBM_PRIF.FormCreate(Sender: TObject);
begin
dp1.DateTime := caldate(date);
dp3.DateTime := caldate(date);
//dp1.Text :=datetostr(caldate(date));
dp2.DateTime :=date;
dp4.DateTime :=date;
dm.DAYINZHI.Open ;
canmodify :=false;
end;
procedure TBM_PRIF.CB2DropDown(Sender: TObject);
var i:integer;
begin
CB2.Items.Clear ;
WITH DM.QALL do
begin
close;
sql.Clear ;
sql.Add('select distinct 型號(hào) from 打印紙');
open;
first;
end;
for i:=0 to DM.QALL.RecordCount-1 do
begin
CB2.Items.Add(DM.QALL.Fields[0].asstring);
DM.QALL.next;
end;
end;
procedure TBM_PRIF.BitBtn1Click(Sender: TObject);
var
date1,date2:tdate;
begin
SpeedButton8.Enabled :=false;
sqltext:='select * from 打印紙支出 ';
sqltext2:='select 型號(hào),sum(支出數(shù)量) as AA from 打印紙支出';
if cb1.Text <>'' then
begin
sqltext:=sqltext+ ' where 支出部門="'+CB1.Text +'"';
sqltext2:=sqltext2+ ' where 支出部門="'+CB1.Text +'"';
if cb2.Text <>'' then
begin
sqltext:=sqltext+ ' And 型號(hào)="'+CB2.Text +'"';
sqltext2:=sqltext2+ ' And 型號(hào)="'+CB2.Text +'"';
end;
if checkbox1.Checked then
begin
sqltext:=sqltext+' And 支出時(shí)間 >=:date1 and 支出時(shí)間<=:date2';
sqltext2:=sqltext2+' And 支出時(shí)間 >=:date1 and 支出時(shí)間<=:date2';
end;
end
else
if cb2.Text <>'' then
begin
sqltext:=sqltext+ ' where 型號(hào)="'+CB2.Text +'"';
sqltext2:=sqltext2+ ' where 型號(hào)="'+CB2.Text +'"';
if checkbox1.Checked then
begin
sqltext:=sqltext+' And 支出時(shí)間 >=:date1 and 支出時(shí)間<=:date2';
sqltext2:=sqltext2+' And 支出時(shí)間 >=:date1 and 支出時(shí)間<=:date2';
end;
end
else
begin
if checkbox1.Checked then
begin
sqltext:=sqltext+' where 支出時(shí)間 >=:date1 and 支出時(shí)間<=:date2';
sqltext2:=sqltext2+' where 支出時(shí)間 >=:date1 and 支出時(shí)間<=:date2';
end;
end;
sqltext:=sqltext+' order by 型號(hào)';
with AQ1 do
begin
with sql do
begin
close;
clear;
add(sqltext);
if checkbox1.Checked then
begin
Parameters.parambyname('Date1').value:=dp1.datetime;//strtodate(MaskEdit1.Text);
Parameters.parambyname('Date2').value:=dp2.DateTime;//(MaskEdit2.Text);
end;
end;
open;
if aq1.RecordCount >0 then SpeedButton8.Enabled :=true;
end;
///////////////////
sqltext2:=sqltext2+' group by 型號(hào)';
with DM.QALL2 do
begin
with sql do
begin
close;
clear;
add(sqltext2);
if checkbox1.Checked then
begin
Parameters.parambyname('Date1').value:=dp1.datetime;//strtodate(MaskEdit1.Text);
Parameters.parambyname('Date2').value:=dp2.DateTime;//(MaskEdit2.Text);
end;
end;
open;
if DM.QALL2.RecordCount >0 then SpeedButton8.Enabled :=true;
end;
BM_OFFICEF.StatusBar1.Panels[0].TEXT :='系統(tǒng)提示:符合條件記錄為'+inttostr(AQ1.RecordCount)+'條!';
end;
procedure TBM_PRIF.BitBtn2Click(Sender: TObject);
begin
try
canmodify:=false;
BM_PRIF_ADDF := TBM_PRIF_ADDF.Create(Application);
BM_PRIF_ADDF.Caption :='打印紙?zhí)砑?#039;;
BM_PRIF_ADDF.SHOW;
except
MessageBox(0, '窗體創(chuàng)建錯(cuò)誤', '產(chǎn)生嚴(yán)重例外錯(cuò)誤', MB_OK +
MB_ICONSTOP);
end;
end;
procedure TBM_PRIF.CheckBox1Click(Sender: TObject);
begin
Dp1.Enabled := CheckBox1.Checked;
dp2.Enabled := CheckBox1.Checked;
end;
procedure TBM_PRIF.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
inherited;
With DbGrid1 do
begin
if ((State = [gdSelected]) or (State = [gdSelected,gdFocused])) then
begin
Canvas.Font.Color := clYellow;
Canvas.Brush.Color :=clNavy;
end
else
begin
if DataCol mod 2 <> 0 then Canvas.Brush.Color := clWhite
else Canvas.Brush.Color := $00EAEAEA;
end;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
END;
procedure TBM_PRIF.DBGrid3DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
inherited;
With DbGrid3 do
begin
if ((State = [gdSelected]) or (State = [gdSelected,gdFocused])) then
begin
Canvas.Font.Color := clYellow;
Canvas.Brush.Color := clNavy;
end
else
begin
if DataCol mod 2 <> 0 then Canvas.Brush.Color := clWhite
else Canvas.Brush.Color := $00EAEAEA;
end;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;
procedure TBM_PRIF.DBGrid2DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
inherited;
With DbGrid2 do
begin
if ((State = [gdSelected]) or (State = [gdSelected,gdFocused])) then
begin
Canvas.Font.Color := clYellow;
Canvas.Brush.Color := clNavy;
end
else
begin
if DataCol mod 2 <> 0 then Canvas.Brush.Color := clWhite
else Canvas.Brush.Color := $00EAEAEA;
end;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -