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

📄 frmpitpw.~pas

📁 发票系统 发票系统 发票系统
💻 ~PAS
字号:
unit FrmPitPw;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, Buttons, ToolWin, Menus, ExtCtrls, ImgList, ActnList,
  StdCtrls, Printers;

type
  TPitPw = class(TForm)
    ScrollBox1: TScrollBox;
    sbarMain: TStatusBar;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    Panel1: TPanel;
    PageEdit: TEdit;
    PageLabel: TPanel;
    ToolButton10: TToolButton;
    ToolButton11: TToolButton;
    ToolButton12: TToolButton;
    ToolButton13: TToolButton;
    ToolButton14: TToolButton;
    Panel3: TPanel;
    ZoomEdit: TEdit;
    Panel2: TPanel;
    ToolButton9: TToolButton;
    ToolButton15: TToolButton;
    ilstActions: TImageList;
    dlogOpen: TOpenDialog;
    dlogSave: TSaveDialog;
    PreviewTimer: TTimer;
    MainMenu1: TMainMenu;
    File1: TMenuItem;
    Open1: TMenuItem;
    SaveAs1: TMenuItem;
    Print1: TMenuItem;
    N1: TMenuItem;
    Exit1: TMenuItem;
    Page1: TMenuItem;
    First1: TMenuItem;
    Previous1: TMenuItem;
    Next1: TMenuItem;
    Last1: TMenuItem;
    N2: TMenuItem;
    GotoPage1: TMenuItem;
    Zoom1: TMenuItem;
    In1: TMenuItem;
    Out1: TMenuItem;
    N3: TMenuItem;
    Page2: TMenuItem;
    PageWidth1: TMenuItem;
    PopupMenu1: TPopupMenu;
    In2: TMenuItem;
    Out2: TMenuItem;
    Image1: TImage;
    PrintDialog1: TPrintDialog;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure SaveAs1Click(Sender: TObject);
    procedure ToolButton15Click(Sender: TObject);
    procedure ToolButton11Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
  private
    procedure PrintFP01;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  PitPw: TPitPw;

implementation

uses
  FrmCustom, FrmMain;

{$R *.dfm}

procedure TPitPw.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure TPitPw.ToolButton2Click(Sender: TObject);
begin
  if dlogSave.Execute then
  begin
    if dlogSave.FileName<>'' then
    begin
      Image1.Picture.SaveToFile(dlogSave.FileName);
    end;
  end;
end;

procedure TPitPw.ToolButton1Click(Sender: TObject);
begin
  if dlogOpen.Execute then
  begin
    if dlogOpen.FileName<>'' then
    begin
      Image1.Canvas.Brush.Style:=bsClear;
      Image1.Picture.LoadFromFile(dlogOpen.FileName);
    end;
  end;
end;

procedure TPitPw.SaveAs1Click(Sender: TObject);
begin
  ToolButton2.Click;
end;

procedure TPitPw.ToolButton15Click(Sender: TObject);
begin
  Close;
end;

procedure TPitPw.ToolButton11Click(Sender: TObject);
var
  ScaleX,ScaleY :Integer;
  R :TRect;
begin
  if Printer.Printers.Count=0 then
  begin
    ShowMessage('请首先安装打印机');
    Exit;          //跳出N11Click
  end;
  if not dlogOpen.Execute then Exit
  else
  begin
    with Printer do
    begin
      BeginDoc;
      ScaleX :=GetDeviceCaps(Handle,LogPixelsX) div PixelsPerInch;
      ScaleY :=GetDeviceCaps(Handle,LogPixelsY) div PixelsPerInch;
      R :=Rect(0,0,Image1.Width*ScaleX,Image1.Height*ScaleY);
      Canvas.StretchDraw(R,Image1.Picture.Graphic);
      EndDoc;
    end;
  end;
end;


procedure TPitPw.PrintFP01;
var
  CurrentIndex: Integer;
  aTmpFont: TFont;
  DrawMoneyCp,DrawMoney, DrawOne: string;
  i, j, THeight, TWidth: Integer;
begin
  Printer.Orientation:=poPortrait;
  with Printer do
  begin
    THeight := Canvas.TextHeight('1');
    aTmpFont := Canvas.Font;
    with Canvas do
    begin
      TextOut(500, 20, BKString);
      Font.Size := 14;
      Font.Name := '宋体';
      Font.Style := [fsBold];
      TextOut(250, 20, '租 赁 业 发 票');
      Font.Size := 10;
      Font.Name := '宋体';
      Font.Color := $004080FF;
      Font.Style := Font.Style - [fsBold];
    //////////////////////////////////////////////
//      TextOut(370, 60, '开票日期:'); //
//      TextOut(430, 60, DateToStr(Main.cxDateEdit1.Date));
//      TextOut(510, 60, '发票号码:'); //
//      TextOut(570, 60, Main.AdvEdit3.Text);
//      TextOut(20, 80, '承租方:'); //
//      TextOut(65, 80,  Main.AdvEdit4.Text);
//      TextOut(280, 80, '客户名称:'); //
//      TextOut(340, 80, Main.AdvEdit5.Text);
//      TextOut(510, 80, '发票号码:'); //
//      TextOut(570, 80, Main.AdvEdit6.Text);
//
//      Pen.Color := clBackground;
//      MoveTo(430, 60 + THeight); //TextHeigth('1') 1只是个代表,计算它的高度
//      LineTo(500, 60 + THeight);
//
//      MoveTo(570, 60 + THeight);
//      LineTo(570 + TextWidth(Main.AdvEdit3.Text), 60 + THeight);
//
//      MoveTo(65, 80 + THeight);
//      LineTo(65 + TextWidth(Main.AdvEdit4.Text), 80 + THeight);
//
//      MoveTo(340, 80 + THeight);
//      LineTo(500, 80 + THeight);
//
//      MoveTo(570, 80 + THeight);
//      LineTo(570 + TextWidth(Main.AdvEdit3.Text), 80 + THeight);

    ////////////////////////////////////////////////
      MoveTo(20, 100); LineTo(650, 100); //第一根横线
      MoveTo(20, 100); LineTo(20, 290); //第一根竖线
      MoveTo(650, 100); LineTo(650, 290); //最后一根竖线
      MoveTo(20, 160); LineTo(650, 160);
      MoveTo(110, 120); LineTo(300, 120);
      MoveTo(110, 140); LineTo(260, 140);
      MoveTo(430, 120); LineTo(650, 120);

      MoveTo(110, 100); LineTo(110, 270);
      MoveTo(185, 120); LineTo(185, 220);
      MoveTo(260, 120); LineTo(260, 220);
      MoveTo(300, 100); LineTo(300, 220);
      MoveTo(340, 100); LineTo(340, 220);
      MoveTo(380, 100); LineTo(380, 220);
      MoveTo(430, 100); LineTo(430, 220);

      MoveTo(20, 240); LineTo(650, 240);
      MoveTo(20, 270); LineTo(650, 270);
      MoveTo(20, 290); LineTo(650, 290);

      MoveTo(160, 270); LineTo(160, 290);
      MoveTo(280, 270); LineTo(280, 290);
      MoveTo(410, 270); LineTo(410, 290);
      MoveTo(530, 270); LineTo(530, 290);

      for i := 1 to 3 do
      begin
        MoveTo(20, 160 + i * 20); LineTo(650, 160 + i * 20);
      end;
//      *******************************
//      TextOut(30, 125, '租 赁 项 目');
//      TextOut(158, 105, '租 赁 日 期');
//      TextOut(135, 125, '起');
//      TextOut(195, 125, '止');
//      TextOut(115, 145, '年 月 日');
//      TextOut(195, 145, '年 月 日');
//      TextOut(265, 135, '天 数');
//      TextOut(302, 125, '单 位');
//      TextOut(345, 125, '数 量');
//      TextOut(390, 120, '收 费');
//      TextOut(390, 135, '标 准');
//      TextOut(510, 105, '金    额');
//      for i := 1 to 11 do
//      begin
//        if i = 2 then
//          Pen.Color := clRed
//        else
//          Pen.Color := clBackground;
//        MoveTo(650 - 20 * I, 120); LineTo(650 - I * 20, 240);
//        CurrentIndex := (12 - i + 1);
//        DrawMoneyCp := Copy(MoneyCaStr, CurrentIndex * 2 - 1, 2);
//        TextOut(650 - (20 * i - 5), 135, DrawMoneyCp);
//      end;
     ////////////////////////////////
//
//      for i:=0 to 3 do
//      begin
//        if i<>3 then
//        begin
//          TWidth:=20+(110-20-(TextWidth('杨') * Length(Main.InVoiceTable.Cells[0,3+i])div 2)) div 2;
//          TextOut(TWidth,165+i*20,Main.InVoiceTable.Cells[0,3+i] );
//          TWidth:=110+(185-110-(TextWidth('杨') * Length(Main.InVoiceTable.Cells[2,3+i])div 2)) div 2;
//          TextOut(TWidth,165+i*20,Main.InVoiceTable.Cells[2,3+i] );
//          TWidth:=185-2+(260-185-(TextWidth('杨') * Length(Main.InVoiceTable.Cells[4,3+i])div 2)) div 2;
//          TextOut(TWidth,165+i*20,Main.InVoiceTable.Cells[4,3+i] );
//          TWidth:=260-2+(300-260-(TextWidth('杨') * Length(Main.InVoiceTable.Cells[5,3+i])div 2)) div 2;
//          TextOut(TWidth,165+i*20,Main.InVoiceTable.Cells[5,3+i] );
//          TWidth:=300-2+(340-300-(TextWidth('杨') * Length(Main.InVoiceTable.Cells[6,3+i])div 2)) div 2;
//          TextOut(TWidth,165+i*20,Main.InVoiceTable.Cells[6,3+i] );
//          TWidth:=340-2+(380-340-(TextWidth('杨') * Length(Main.InVoiceTable.Cells[7,3+i])div 2)) div 2;
//          TextOut(TWidth,165+i*20,Main.InVoiceTable.Cells[7,3+i] );
//          TWidth:=380-2+(430-380-(TextWidth('杨') * Length(Main.InVoiceTable.Cells[8,3+i])div 2)) div 2;
//          TextOut(TWidth,165+i*20,Main.InVoiceTable.Cells[8,3+i] );
//        end;
//        DrawMoney := Main.InVoiceTable.Cells[9, 3+i];
//        if DrawMoney <> '' then
//          DrawMoney := FormatFloat('0.00', StrToFloat(DrawMoney));
//        DrawMoney := StringReplace(DrawMoney, '.', '', []);
//        for J := 1 to 12 do
//        begin
//          TWidth := TextWidth('1') + 8;
//          if J > Length(DrawMoney) then
//            DrawOne := ''
//          else
//            DrawOne := Copy(DrawMoney, Length(DrawMoney) - J + 1, 1);
//            TextOut(650 - (20 * j - 5), 165+i*20, DrawOne);
//        end;
//      end;
//      TextOut(23,225,'金额合计|大写');
//      TextOut(130,225,Main.InVoiceTable.Cells[2,6]);
//      TextOut(35,250,'备    注');
//      TextOut(130,250,Main.InVoiceTable.Cells[2,7]);
//      TextOut(38,275,'出租方(盖章有效)');
//      TextOut(230,275,'开票人:');
//      TextOut(290,275,Main.InVoiceTable.Cells[6,9]);
//      TextOut(480,275,'收款人:');
//      TextOut(540,275,Main.InVoiceTable.Cells[10,9]);
//      Font.Color:=clBackground;
//      TextOut(50,300,' 按照《中华人民共和国企业所得税暂行条例》的规定,这种车贴属于工资的组成部分,只能');
//      TextOut(50,315,'在企业所得税前限额扣除,超过部分要做纳税调整。而且按照《中华人民共和国个人所得税法》');
//      TextOut(50,330,'的规定,这种车贴也是要征收个人所得税的。如果允许编造这样一个虚假的合同到税务机关代开');
//      TextOut(50,345,'发票,企业不仅可以在缴纳所得税前全额扣除,作为员工个人还可以少缴或不缴个人所得税。');
    end;
  end;
end;
procedure TPitPw.ToolButton3Click(Sender: TObject);
var
  ScaleX,ScaleY :Integer;
  R :TRect;
begin
  with Printer do
  begin
    BeginDoc;
    ScaleX :=GetDeviceCaps(Handle,LogPixelsX) div PixelsPerInch;
    ScaleY :=GetDeviceCaps(Handle,LogPixelsY) div PixelsPerInch;
    R :=Rect(0,0,Image1.Width*ScaleX,Image1.Height*ScaleY);
    Canvas.StretchDraw(R,Image1.Picture.Graphic);
    EndDoc;
  end;
end;

end.

⌨️ 快捷键说明

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