unit auxipnt;

interface

uses
  Windows, SysUtils, Classes, Controls, Forms, Dialogs, Grids, Printers, uss;

procedure UT0801_P01(PACKFIELDS: TBuffer; soutComm: TsoutComm);
procedure UT0804_P01(PACKFIELDS: TBuffer; soutComm: TsoutComm);
procedure UT0901_P01(PACKFIELDS: TBuffer; soutComm: TsoutComm);

function FillSpaces(Src: String; MaxSize:Integer; Alignment: Integer):String;

implementation

procedure UT0804_P01(PACKFIELDS: TBuffer; soutComm: TsoutComm);
var
   tmpStr: String;
   midX, curX, curY: Integer;
   tagX1,tagX2: Integer;
   SpaceLine: Integer;
   MaxChar, MaxCharPixel: Integer;
begin
  If MessageDlg('请准备好打印纸，然后按[OK]开始打印。',mtInformation,[mbOK, mbCancel],0) = mrOK then
  begin
    with Printer do
    begin
      BeginDoc;

      Canvas.Font.Name := 'MS Sans Serif';
      Canvas.Font.Size := 8;

      Title := '管理柜员开户信息档案';
      SpaceLine := Canvas.TextHeight('Yy');
      MaxChar := 60;
      MaxCharPixel := Canvas.TextWidth('我') * MaxChar;

      curX := 0;  curY := 0;
      midX := Trunc(PageWidth div 2) - Trunc(MaxCharPixel div 2);

      //  Print Report Title
      tmpStr := Title;
      curX := PageWidth div 2 - Canvas.TextWidth(tmpStr) div 2;
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + SpaceLine;

      curX := midX;
      tmpStr := Format(StringOfChar(' ', 2)+'交易代码：%s'+
                       StringOfChar(' ', 4)+'交易名称：%s'+
                       StringOfChar(' ', 4)+'交易流水号：%s'+
                       StringOfChar(' ', 10)+'交易日期：%s',
                       [FillSpaceS(soutComm.SOFIELD01, 4, 1),
                        FillSpaceS(soutComm.SOFIELD02, 24, -1),
                        FillSpaceS(soutComm.SOFIELD03, 4, 1),
                        FillSpaceS(soutComm.SOFIELD04, 10, -1)
                        ]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := midX;
      Canvas.Rectangle(curX, curY, curX + MaxCharPixel, curY + Trunc(SpaceLine * 6.5));
      curY := curY + Trunc(SpaceLine * 0.5);

      curX := midX;
      tmpStr := Format(StringOfChar(' ', 2)+'柜员编号：%s',[FillSpaceS(soutComm.SOFIELD00, 4, 1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curX := curX + Canvas.TextWidth(tmpStr) + Canvas.TextWidth('空格');
      tagX1 := curX;
      tmpStr := Format('柜员姓名：%s',[FillSpaces(PACKFIELDS.FIELD01,16, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curX := curX + Canvas.TextWidth(tmpStr) + Canvas.TextWidth('空格');
      tagX2 := curX;
      tmpStr := Format('身份证号：%s',[FillSpaces(PACKFIELDS.FIELD03, 64, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := tagX1;
      tmpStr := Format('柜员级别：%s',[FillSpaces('管理柜员', 16, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := midX;
      tmpStr := Format(StringOfChar(' ', 2)+'网点编号：%s',[FillSpaceS(soutComm.SOFIELD08, 4, 1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curX := curX + Canvas.TextWidth(tmpStr) + Canvas.TextWidth('空格');
      curX := tagX1;
      tmpStr := Format('网点名称：%s',[FillSpaces(soutComm.SOFIELD07,48, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := tagX1;
      tmpStr := Format('备注信息：%s',[FillSpaces(PACKFIELDS.FIELD04, 64, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);
      curY := curY + Trunc(SpaceLine * 0.5);

      curX := midX;
      tmpStr := Format(StringOfChar(' ', 2)+'经办员：%s'+
                       StringOfChar(' ', 6)+'经办网点：%s',
                       [soutComm.SOFIELD05, soutComm.SOFIELD06]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      EndDoc;
     end;
   end;
end;

procedure UT0801_P01(PACKFIELDS: TBuffer; soutComm: TsoutComm);
var
   tmpStr: String;
   midX, curX, curY: Integer;
   tagX1,tagX2: Integer;
   SpaceLine: Integer;
   MaxChar, MaxCharPixel: Integer;
begin
  If MessageDlg('请准备好打印纸，然后按[OK]开始打印。',mtInformation,[mbOK, mbCancel],0) = mrOK then
  begin
    with Printer do
    begin
      BeginDoc;

      Canvas.Font.Name := 'MS Sans Serif';
      Canvas.Font.Size := 8;

      Title := '网点开户信息档案';
      SpaceLine := Canvas.TextHeight('Yy');
      MaxChar := 60;
      MaxCharPixel := Canvas.TextWidth('我') * MaxChar;

      curX := 0;  curY := 0;
      midX := Trunc(PageWidth div 2) - Trunc(MaxCharPixel div 2);

      //  Print Report Title
      tmpStr := Title;
      curX := PageWidth div 2 - Canvas.TextWidth(tmpStr) div 2;
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + SpaceLine;

      curX := midX;
      tmpStr := Format(StringOfChar(' ', 2)+'交易代码：%s'+
                       StringOfChar(' ', 4)+'交易名称：%s'+
                       StringOfChar(' ', 4)+'交易流水号：%s'+
                       StringOfChar(' ', 10)+'交易日期：%s',
                       [FillSpaceS(soutComm.SOFIELD01, 4, 1),
                        FillSpaceS(soutComm.SOFIELD02, 24, -1),
                        FillSpaceS(soutComm.SOFIELD03, 4, 1),
                        FillSpaceS(soutComm.SOFIELD04, 10, -1)
                        ]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := midX;
      Canvas.Rectangle(curX, curY, curX + MaxCharPixel, curY + Trunc(SpaceLine * 9.5));
      curY := curY + Trunc(SpaceLine * 0.5);

      curX := midX;
      tmpStr := Format(StringOfChar(' ', 2)+'网点编号：%s',[FillSpaceS(soutComm.SOFIELD00, 4, 1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curX := curX + Canvas.TextWidth(tmpStr) + Canvas.TextWidth('空格');
      tagX1 := curX;
      tmpStr := Format('网点名称：%s',[FillSpaces(PACKFIELDS.FIELD00,36, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curX := curX + Canvas.TextWidth(tmpStr) + Canvas.TextWidth('空格');
      tagX2 := curX;
      tmpStr := Format('网点简称：%s',[FillSpaces(PACKFIELDS.FIELD01,16, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := tagX1;
      tmpStr := Format('网点地址：%s',[FillSpaces(PACKFIELDS.FIELD02, 64, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := tagX1;
      tmpStr := Format('联系电话：%s',[FillSpaces(PACKFIELDS.FIELD03, 38, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curX := tagX2;
      tmpStr := Format('传真号码：%s',[FillSpaces(PACKFIELDS.FIELD04, 38, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := tagX1;
      tmpStr := Format('负责经理：%s',[FillSpaces(PACKFIELDS.FIELD05, 38, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curX := tagX2;
      tmpStr := Format('经理电话：%s',[FillSpaces(PACKFIELDS.FIELD06, 38, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := tagX1;
      tmpStr := Format('身份证号：%s',[FillSpaces(PACKFIELDS.FIELD07, 38, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := tagX1;
      tmpStr := Format('备注信息：%s',[FillSpaces(PACKFIELDS.FIELD08, 64, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);
      curY := curY + Trunc(SpaceLine * 0.5);

      curX := midX;
      tmpStr := Format(StringOfChar(' ', 2)+'经办员：%s'+
                       StringOfChar(' ', 6)+'经办网点：%s',
                       [soutComm.SOFIELD05, soutComm.SOFIELD06]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      EndDoc;
     end;
   end;
end;

procedure UT0901_P01(PACKFIELDS: TBuffer; soutComm: TsoutComm);
var
   tmpStr: String;
   midX, curX, curY: Integer;
   tagX1,tagX2: Integer;
   SpaceLine: Integer;
   MaxChar, MaxCharPixel: Integer;
begin
  If MessageDlg('请准备好打印纸，然后按[OK]开始打印。',mtInformation,[mbOK, mbCancel],0) = mrOK then
  begin
    with Printer do
    begin
      BeginDoc;

      Canvas.Font.Name := 'MS Sans Serif';
      Canvas.Font.Size := 8;

      Title := '本网点柜员开户信息档案';
      SpaceLine := Canvas.TextHeight('Yy');
      MaxChar := 60;
      MaxCharPixel := Canvas.TextWidth('我') * MaxChar;

      curX := 0;  curY := 0;
      midX := Trunc(PageWidth div 2) - Trunc(MaxCharPixel div 2);

      //  Print Report Title
      tmpStr := Title;
      curX := PageWidth div 2 - Canvas.TextWidth(tmpStr) div 2;
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + SpaceLine;

      curX := midX;
      tmpStr := Format(StringOfChar(' ', 2)+'交易代码：%s'+
                       StringOfChar(' ', 4)+'交易名称：%s'+
                       StringOfChar(' ', 4)+'交易流水号：%s'+
                       StringOfChar(' ', 10)+'交易日期：%s',
                       [FillSpaceS(soutComm.SOFIELD01, 4, 1),
                        FillSpaceS(soutComm.SOFIELD02, 24, -1),
                        FillSpaceS(soutComm.SOFIELD03, 4, 1),
                        FillSpaceS(soutComm.SOFIELD04, 10, -1)
                        ]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := midX;
      Canvas.Rectangle(curX, curY, curX + MaxCharPixel, curY + Trunc(SpaceLine * 6.5));
      curY := curY + Trunc(SpaceLine * 0.5);

      curX := midX;
      tmpStr := Format(StringOfChar(' ', 2)+'柜员编号：%s',[FillSpaceS(soutComm.SOFIELD00, 4, 1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curX := curX + Canvas.TextWidth(tmpStr) + Canvas.TextWidth('空格');
      tagX1 := curX;
      tmpStr := Format('柜员姓名：%s',[FillSpaces(PACKFIELDS.FIELD00,16, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curX := curX + Canvas.TextWidth(tmpStr) + Canvas.TextWidth('空格');
      tagX2 := curX;
      tmpStr := Format('身份证号：%s',[FillSpaces(PACKFIELDS.FIELD02, 38, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := tagX1;
      tmpStr := Format('柜员级别：%s',[FillSpaces('业务柜员', 16, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := midX;
      tmpStr := Format(StringOfChar(' ', 2)+'网点编号：%s',[FillSpaceS(soutComm.SOFIELD08, 4, 1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curX := curX + Canvas.TextWidth(tmpStr) + Canvas.TextWidth('空格');
      curX := tagX1;
      tmpStr := Format('网点名称：%s',[FillSpaces(soutComm.SOFIELD07,48, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      curX := tagX1;
      tmpStr := Format('备注信息：%s',[FillSpaces(PACKFIELDS.FIELD03, 64, -1)]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);
      curY := curY + Trunc(SpaceLine * 0.5);

      curX := midX;
      tmpStr := Format(StringOfChar(' ', 2)+'经办员：%s'+
                       StringOfChar(' ', 6)+'经办网点：%s',
                       [soutComm.SOFIELD05, soutComm.SOFIELD06]);
      Canvas.TextOut(curX, curY, PChar(tmpStr));
      curY := curY + Canvas.TextHeight(tmpStr);

      curY := curY + Trunc(SpaceLine * 0.5);

      EndDoc;
     end;
   end;
end;

function FillSpaces(Src: String; MaxSize:Integer; Alignment: Integer):String;
var
   n: Integer;
begin
   n := Length(Src);
   If n > MaxSize then
      Result := Copy(Src, 1, MaxSize)
   else
     Case Alignment of
       -1:  Result := Src + StringOfChar(' ', MaxSize - n);
        0:  Result := StringOfChar(' ', Trunc(MaxSize - n) div 2) +
                      Src +
                      StringOfChar(' ', Trunc(MaxSize - n) div 2);
        1:  Result := StringOfChar(' ', MaxSize - n) + Src;
     else
        Result := Copy(Src, 1, MaxSize)
     end;
end;

end.
