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

📄 unid_impressao.pas

📁 System for issue quitter of rental immobile.
💻 PAS
字号:
unit Unid_Impressao;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ExtCtrls, StdCtrls, Buttons, VDOBasePrinter, Nelsoft,
  VDOCaPrinter;

type
  TForm_Impressao = class(TForm)
    MEM_Recibo: TMemo;
    BIT_Alterar: TBitBtn;
    BIT_Imprimir: TBitBtn;
    BIT_Cancelar: TBitBtn;
    LED_Vias: TLabeledEdit;
    UPD_Vias: TUpDown;
    VDO_Impressao: TVDOCaPrinter;
    LED_Nome_Impressora: TLabeledEdit;
    procedure FormCreate(Sender: TObject);
    procedure BIT_AlterarClick(Sender: TObject);
    procedure SaidaEdicao(Sender: TObject);
    procedure BIT_ImprimirClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
      function PadCenter(pText: string; pFill: Char; pComp: byte): string;
  end;

var
  Form_Impressao: TForm_Impressao;

implementation

uses Unid_Dados, Unid_Principal;

{$R *.dfm}

procedure TForm_Impressao.FormCreate(Sender: TObject);
var
   stLinhaTracejada, stLinhaAssinatura: String;
   stLinhaBranco, stValorRecibo: String;
   stLin1, stLin2, stLin3, stLin4: String;
   Memo_Aux: TStringList;
   nDias: extended;
begin
   stLinhaTracejada := StringOfChar('-', 70);
   stLinhaAssinatura := StringOfChar('-', 40);
   stLinhaBranco := StringOfChar(' ', 70);
   stLin1 := PadCenter('SOLINO IM覸EIS', ' ', 70);
   stLin2 := PadCenter('Creci 6142', ' ', 70);
   stLin3 := PadCenter('*** RECIBO DE ALUGUEL DE IM覸EL ***', ' ', 70);
   stLin4 := Form_Dados.CDS_ReciboREC_NUM.AsString;
   stLin4 := 'Recibo N鷐ero: ' + stLin4;
   stLin4 := PadCenter(stLin4, ' ', 70);
   Memo_Aux := TStringList.Create;
   Memo_Aux.Add(stLin1);
   Memo_Aux.Add(stLin2);
   Memo_Aux.Add(stLinhaBranco);
   Memo_Aux.Add(stLinhaTracejada);
   Memo_Aux.Add(stLin3);
   Memo_Aux.Add(stLin4);
   Memo_Aux.Add(stLinhaTracejada);
   Memo_Aux.Add(stLinhaBranco);
   Memo_Aux.Add('DADOS DO IM覸EL:');
   stLin1 := Form_Dados.CDS_ReciboEND_LOGRAD.Text;
   stLin2 := Form_Dados.CDS_ReciboEND_NUM.Text;
   stLin3 := Form_Dados.CDS_ReciboEND_COMPL.Text;
   Memo_Aux.Add('Logradouro/N鷐ero.: ' + stLin1 + ' ' + stLin2);
   Memo_Aux.Add('Complemento.......: ' + stLin3);
   Memo_Aux.Add('Bairro............: ' + Form_Dados.CDS_ReciboEND_BAIRRO.Text);
   stLin1 := Copy(Form_Dados.CDS_ReciboEND_CEP.Text, 1, 5);
   stLin2 := Copy(Form_Dados.CDS_ReciboEND_CEP.Text, 6, 3);
   stLin3 := TrimRight(Form_Dados.CDS_ReciboEND_CIDADE.Text);
   stLin4 := '(' + Form_Dados.CDS_ReciboEND_ESTADO.Text + ')';
   Memo_Aux.Add('CEP/Cidade/Estado.: ' + stLin1 + '-' + stLin2 + ' - ' + stLin3 + ' ' + stLin4);
   Memo_Aux.Add(stLinhaBranco);
   Memo_Aux.Add('DADOS DO LOCAT罵IO:');
   stLin1 := Form_Dados.CDS_ReciboLOC_NOME.Text;
   stLin2 := Trim(Form_Dados.CDS_ReciboLOC_CPF.Text);
   stLin3 := '';
   if length (stLin2) = 14 then begin
      stLin3 := stLin3 + Copy(stLin2, 1, 2) + '.';
      stLin3 := stLin3 + Copy(stLin2, 3, 3) + '.';
      stLin3 := stLin3 + Copy(stLin2, 6, 3) + '/';
      stLin3 := stLin3 + Copy(stLin2, 9, 4) + '-';
      stLin3 := stLin3 + Copy(stLin2, 13, 2);
   end;
   if length (stLin2) = 11 then begin
      stLin3 := stLin3 + Copy(stLin2, 1, 3) + '.';
      stLin3 := stLin3 + Copy(stLin2, 4, 3) + '.';
      stLin3 := stLin3 + Copy(stLin2, 7, 3) + '-';
      stLin3 := stLin3 + Copy(stLin2, 10, 2);
   end;
   if ((length (stLin2) <> 14) and (length (stLin2) <> 11)) then begin
      stLin3 := stLin2;
   end;
   stLin4 := Trim(Form_Dados.CDS_ReciboLOC_RG.Text);
   Memo_Aux.Add('Nome..............: ' + stLin1);
   Memo_Aux.Add('N鷐ero CPF/CNPJ...: ' + stLin3);
   Memo_Aux.Add('N鷐ero RG/IE......: ' + stLin4);
   Memo_Aux.Add(stLinhaBranco);
   stValorRecibo := CurrToStrF(Form_Dados.CDS_ReciboREC_VALOR.Value, ffCurrency, 2);
   Memo_Aux.Add('                                        Valor do Recibo - ' + stValorRecibo);
   Memo_Aux.Add(stLinhaBranco);
   stLin1 := '     Recebemos do(a) Sr(a). ';
   stLin2 := Trim(Form_Dados.CDS_ReciboLOC_NOME.Value);
   stLin2 := AnsiUpperCase(stLin2);
   stLin3 := ' a import鈔cia supra de ' + stValorRecibo;
   stLin4 := stLin1 + stLin2 + stLin3;
   stLin1 := Num2Ext(Form_Dados.CDS_ReciboREC_VALOR.Value, 'real', 'reais', 'centavo', 'centavos');
   stLin1 := ' (' + stLin1 + '), proveniente do pagamento de ';
   nDias := Form_Dados.CDS_ReciboREC_DTA_REF2.Value - Form_Dados.CDS_ReciboREC_DTA_REF1.Value;
   stLin2 := FloatToStr(nDias) + ' (' + Num2Ext(nDias, ' ', ' ', ' ', ' ');
   stLin2 := Trim(stLin2) + ') dias de aluguel, referente ao per韔do de: ';
   stLin3 := DateToStr(Form_Dados.CDS_ReciboREC_DTA_REF1.Value);
   stLin3 := stLin3 + ' a ' + DateToStr(Form_Dados.CDS_ReciboREC_DTA_REF2.Value) + '.';
   stLin4 := stLin4 + stLin1 + stLin2 + stLin3;
   stLin4 := WrapText(stLin4, #13#10, ['.',' ',#9,'-'], 70);
   Memo_Aux.Add(stLin4);
   Memo_Aux.Add(stLinhaBranco);
   stLin1 := '     Bras韑ia (DF), ';
   stLin2 := DateToStr(Form_Dados.CDS_ReciboREC_DTA_EMIS.Value) + '.';
   stLin3 := stLin1 + stLin2;
   Memo_Aux.Add(PadCenter(stLin3, ' ', 70));
   Memo_Aux.Add(stLinhaBranco);
   Memo_Aux.Add(stLinhaBranco);
   Memo_Aux.Add(PadCenter(stLinhaAssinatura, ' ', 70));
   MEM_Recibo.Lines := Memo_Aux;
end;

function TForm_Impressao.PadCenter(pText: string; pFill: Char; pComp: byte): string;
var
   nAux, nDif, nMed: byte;
   nDiv: Real;
   sRes, sMed: String;
begin
   nAux := Length (pText);
   if nAux >= pComp then begin
      Result := Copy (pText, 1 , pComp);
   end else begin
      if Odd (nAux) then Inc (nAux, 1);
      nDif := pComp - nAux;
      if Odd (nDif) then Inc (nDif, 1);
      nDiv := nDif / 2;
      sMed := FloatToStr(nDiv);
      nMed := StrToInt(sMed);
      sRes := StringOfChar(pFill, nMed) + pText + StringOfChar(pFill, nMed);
      Result := Copy (sRes, 1, pComp);
   end;
end;

procedure TForm_Impressao.BIT_AlterarClick(Sender: TObject);
begin
   MEM_Recibo.ReadOnly := False;
   BIT_Imprimir.Enabled := False;
   MEM_Recibo.Color := clSkyBlue;
   MEM_Recibo.SetFocus;
end;

procedure TForm_Impressao.SaidaEdicao(Sender: TObject);
begin
   MEM_Recibo.ReadOnly := True;
   MEM_Recibo.Color := clWindow;
   BIT_Imprimir.Enabled := True;
end;

procedure TForm_Impressao.BIT_ImprimirClick(Sender: TObject);
var
   nAux, nLin: byte;
   nQtd, nVia: Integer;
   sAux: String;
begin
   sAux := StringOfChar('=', 70);
   nQtd := Form_Dados.CDS_ReciboREC_QTD_IMPRES.Value + 1;
   Form_Dados.CDS_Recibo.Edit;
   Form_Dados.CDS_ReciboREC_QTD_IMPRES.Value := nQtd;
   Form_Dados.CDS_Recibo.Post;
   VDO_Impressao.BeginDoc;
   VDO_Impressao.PrinterName := LED_Nome_Impressora.Text;
   for nVia := 1 to UPD_Vias.Position do begin
      nAux := MEM_Recibo.Lines.Count;
      VDO_Impressao.NewLine(1);
      for nLin := 0 to nAux do begin
         VDO_Impressao.Print(6, MEM_Recibo.Lines.Strings[nLin], true);
      end;
      if nVia < UPD_Vias.Position then begin
         VDO_Impressao.NewLine(1);
         VDO_Impressao.Print(6, sAux, true);
      end;
   end;
   VDO_Impressao.EndDoc;
end;

end.

⌨️ 快捷键说明

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