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

📄 bm_priu.pas

📁 Delphi办公管理系统
💻 PAS
📖 第 1 页 / 共 2 页
字号:
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 型号 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 型号,sum(支出数量) 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 型号="'+CB2.Text +'"';
                    sqltext2:=sqltext2+ ' And 型号="'+CB2.Text +'"';
                    end;

                  if checkbox1.Checked then
                      begin
                        sqltext:=sqltext+' And 支出时间 >=:date1 and 支出时间<=:date2';
                         sqltext2:=sqltext2+' And 支出时间 >=:date1 and 支出时间<=:date2';
                      end;
     end
     else
     if cb2.Text <>'' then
     begin
                   sqltext:=sqltext+ ' where 型号="'+CB2.Text +'"';
                    sqltext2:=sqltext2+ ' where 型号="'+CB2.Text +'"';
                   if checkbox1.Checked then
                      begin
                        sqltext:=sqltext+' And 支出时间 >=:date1 and 支出时间<=:date2';
                         sqltext2:=sqltext2+' And 支出时间 >=:date1 and 支出时间<=:date2';
                      end;
     end
     else
     begin
      if checkbox1.Checked then
          begin
            sqltext:=sqltext+' where 支出时间 >=:date1 and 支出时间<=:date2';
             sqltext2:=sqltext2+' where 支出时间 >=:date1 and 支出时间<=:date2';
          end;
     end;
sqltext:=sqltext+' order by 型号';
  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 型号';
   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 :='系统提示:符合条件记录为'+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 :='打印纸添加';
 BM_PRIF_ADDF.SHOW;
  except
    MessageBox(0, '窗体创建错误', '产生严重例外错误', 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;

⌨️ 快捷键说明

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