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

📄 frmmain.~pas

📁 发票管理系统其中包括: 1.租凭业发票 2.建筑业发票 3.固定资产发票 4.服务行业发票 5.无形资产发票
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
          MoneyTop := Rect.Top + (Rect.Bottom - Rect.Top - MoneyWidth) div 2;
          Canvas.TextOut(MoneyLeft - 5, MoneyTop, DrawOne);
          if i <> 1 then
          begin
            Canvas.MoveTo(aLineTop - 4, Rect.Top);
            Canvas.LineTo(aLineTop - 4, Rect.Bottom);
          end;
        end;
      end;
    end;
  end;
 if CurrentFP = 'FP05' then
  begin
    if (ARow = 5) and (ACol = 9) then
    begin
      with InVoiceTable do
      begin
        MoneyDiv := Length(MoneyCaStr) div 2;
        for i := 1 to MoneyDiv do
        begin
          CurrentIndex := (MoneyDiv - i + 1);
          DrawMoneyCp := Copy(MoneyCaStr, CurrentIndex * 2 - 1, 2);
          MoneyWidth := Canvas.TextWidth('4') + 8;
          if I = 3 then
            Canvas.Pen.Color := 3637448
          else
            Canvas.Pen.Color := 8684164;
          aLineTop := Rect.Right - (MoneyWidth * i) + 12;
          MoneyLeft := aLineTop - (MoneyWidth);
          MoneyTop := Rect.Top + (Rect.Bottom - Rect.Top - MoneyWidth) div 2;
          Canvas.TextOut(MoneyLeft, MoneyTop, DrawMoneyCp);
          if i <> 1 then
          begin
            Canvas.MoveTo(aLineTop - 2, Rect.Top);
            Canvas.LineTo(aLineTop - 2, Rect.Bottom);
          end;
        end;
      end;
    end;
    if (ACol >= 9) and (ACol <= 12) and ((ARow >= 6) and (ARow <= 9)) then
    begin
      with InVoiceTable do
      begin
        DrawMoney := InVoiceTable.Cells[ACol, ARow];
        if DrawMoney <> '' then
          DrawMoney := FormatFloat('0.00', StrToFloat(DrawMoney));
        DrawMoney := StringReplace(DrawMoney, '.', '', []);
        Canvas.FillRect(Rect);
        for i := 1 to 12 do
        begin
          case i of
            3:
              Canvas.Pen.Color := clGreen;
            1, 5, 9:
              Canvas.Pen.Color := clGreen;
          else
            Canvas.Pen.Color := 8684164;
          end;
          MoneyWidth := Canvas.TextWidth('4') + 8;
          if i > Length(DrawMoney) then
            DrawOne := ''
          else
            DrawOne := Copy(DrawMoney, Length(DrawMoney) - i + 1, 1);
          if I = 3 then
            Canvas.Pen.Color := 3637448
          else
            Canvas.Pen.Color := 8684164;
          aLineTop := Rect.Right - MoneyWidth * (i - 1);
          MoneyLeft := aLineTop - MoneyWidth + 6;
          MoneyTop := Rect.Top + (Rect.Bottom - Rect.Top - MoneyWidth) div 2;
          Canvas.TextOut(MoneyLeft - 5, MoneyTop, DrawOne);
          if i <> 1 then
          begin
            Canvas.MoveTo(aLineTop - 4, Rect.Top);
            Canvas.LineTo(aLineTop - 4, Rect.Bottom);
          end;
        end;
      end;
    end;
  end;
end;

procedure TMain.InVoiceTableGetEditMask(Sender: TObject; ACol,
  ARow: Integer; var Value: string);
begin
  if CurrentFP = 'FP01' then
  begin
    if (((ARow >= 3) and (ARow <= 5)) and ((ACol = 2) or (ACol = 4))) then
      Value := '!9999/99/00;1;_';
  end;
end;

procedure TMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if Application.MessageBox('你是否真的要退出', '提示', MB_YESNO + MB_ICONWARNING + MB_DEFBUTTON3 + MB_TOPMOST) = IDYES then
  begin
    Action := caFree;
    Application.Terminate;
  end
  else
    Action := caNone;
end;

procedure TMain.InVoiceTableEditingDone(Sender: TObject);
var
  i: Integer;
  aDxCell, aHjCell, aBeginCell: TCustomCell;
begin
  if CurrentFP = 'FP01' then
  begin
    if (((PubARow >= 3) and (PubARow <= 5)) and ((PubACol = 2) or (PubACol = 4))) then
      if InVoiceTable.Cells[PubACol, PubARow] = '    -  -  ' then
        InVoiceTable.Cells[PubACol, PubARow] := ''
      else
      begin
        try
          if (PubACol = 2) and (PubARow >= 3) and (PubARow <= 5) then
          begin
            InVoiceTable.Cells[2, PubARow] := FormatDateTime('YYYY-MM-DD',
              StrToDate(InVoiceTable.Cells[2, PubARow]));
            StrToDate(InVoiceTable.Cells[2, PubARow]);
          end;
          if (PubACol = 4) and (PubARow >= 3) and (PubARow <= 5) then
          begin
            InVoiceTable.Cells[4, PubARow] := FormatDateTime('YYYY-MM-DD',
              StrToDate(InVoiceTable.Cells[4, PubARow]));
            StrToDate(InVoiceTable.Cells[4, PubARow]);
          end;
        except
          if i = 1 then Exit;
          InVoiceTable.Cells[PubACol, PubARow] := '';
          inc(i);
          Application.MessageBox('日期填写错误!     ', '贝壳提示', MB_OK +
            MB_ICONWARNING + MB_DEFBUTTON3 + MB_TOPMOST);
        end;
      end;
    if (PubACol >= 9) and ((PubARow >= 3) and (PubARow <= 5)) then
    begin
      aDxCell.aRow := 6;
      aDxCell.aCol := 2;
      aHjCell.aRow := 6;
      aHjCell.aCol := 9;
      aBeginCell.aRow := 3;
      aBeginCell.aCol := 9;
      AutoComputer(aDxCell, aHjCell, aBeginCell, 3);
    end;
  end;
  if CurrentFP = 'FP02' then
    if (PubACol >= 8) and ((PubARow >= 3) and (PubARow <= 6)) then
    begin
      aDxCell.aRow := 7;
      aDxCell.aCol := 2;
      aHjCell.aRow := 7;
      aHjCell.aCol := 8;
      aBeginCell.aRow := 3;
      aBeginCell.aCol := 8;
      AutoComputer(aDxCell, aHjCell, aBeginCell, 3);
    end;
  if CurrentFP = 'FP03' then
    if (PubACol >= 7) and (PubACol <= 10) and ((PubARow >= 3) and (PubARow <= 6)) then
    begin
      aDxCell.aRow := 6;
      aDxCell.aCol := 3;
      aHjCell.aRow := 6;
      aHjCell.aCol := 7;
      aBeginCell.aRow := 3;
      aBeginCell.aCol := 7;
      AutoComputer(aDxCell, aHjCell, aBeginCell, 3);
    end;
  if CurrentFP = 'FP04' then
    if (PubACol >= 9) and (PubACol <= 12) and ((PubARow >= 2) and (PubARow <= 4)) then
    begin
      aDxCell.aRow := 5;
      aDxCell.aCol := 3;
      aHjCell.aRow := 5;
      aHjCell.aCol := 9;
      aBeginCell.aRow := 2;
      aBeginCell.aCol := 9;
      AutoComputer(aDxCell, aHjCell, aBeginCell, 3);
    end;
  if CurrentFP = 'FP05' then
    if (PubACol >= 9) and (PubACol <= 12) and ((PubARow >= 6) and (PubARow <= 8)) then
    begin
      aDxCell.aRow := 9;
      aDxCell.aCol := 3;
      aHjCell.aRow := 9;
      aHjCell.aCol := 9;
      aBeginCell.aRow := 6;
      aBeginCell.aCol := 9;
      AutoComputer(aDxCell, aHjCell, aBeginCell, 3);
    end;
end;

procedure TMain.InVoiceTableKeyPress(Sender: TObject; var Key: Char);
var
  aStr: string;
  aPos: Integer;
  aDxCell, aHjCell, aBeginCell: TCustomCell;
begin
  if CurrentFP = 'FP01' then
  begin
    if (PubACol >= 9) and ((PubARow >= 3) and (PubARow <= 5)) then
    begin
      aPos := Pos('.', InVoiceTable.Cells[PubACol, PubARow]);
      if aPos > 0 then
        if not (Key in ['0'..'9', #9, #13]) then Key := #0
        else
          if not (Key in ['0'..'9', #9, #13, '.']) then Key := #0;
    end;
    if (Key = #13) then
    begin
      if (PubACol >= 9) and ((PubARow >= 3) and (PubARow <= 5)) then
      begin
        aDxCell.aRow := 6;
        aDxCell.aCol := 2;
        aHjCell.aRow := 6;
        aHjCell.aCol := 9;
        aBeginCell.aRow := 3;
        aBeginCell.aCol := 9;
        AutoComputer(aDxCell, aHjCell, aBeginCell, 3);
      end;
      SendMessage(InVoiceTable.Handle, VK_RIGHT, VK_TAB, 0);
    end;
  end;
  if CurrentFP = 'FP02' then
  begin
    if (PubACol >= 8) and ((PubARow >= 3) and (PubARow <= 6)) then
    begin
      aPos := Pos('.', InVoiceTable.Cells[PubACol, PubARow]);
      if aPos > 0 then
        if not (Key in ['0'..'9', #9, #13]) then Key := #0
        else
          if not (Key in ['0'..'9', #9, #13, '.']) then Key := #0;
    end;
    if (Key = #13) then
    begin
      if (PubACol >= 8) and ((PubARow >= 3) and (PubARow <= 6)) then
      begin
        aDxCell.aRow := 7;
        aDxCell.aCol := 2;
        aHjCell.aRow := 7;
        aHjCell.aCol := 8;
        aBeginCell.aRow := 3;
        aBeginCell.aCol := 8;
        AutoComputer(aDxCell, aHjCell, aBeginCell, 3);
      end;
      SendMessage(InVoiceTable.Handle, VK_RIGHT, VK_TAB, 0);
    end;
  end;
  if CurrentFP = 'FP03' then
  begin
    if (PubACol >= 7) and ((PubARow >= 3) and (PubARow <= 6)) then
    begin
      aPos := Pos('.', InVoiceTable.Cells[PubACol, PubARow]);
      if aPos > 0 then
        if not (Key in ['0'..'9', #9, #13]) then Key := #0
        else
          if not (Key in ['0'..'9', #9, #13, '.']) then Key := #0;
    end;
    if (Key = #13) then
    begin
      if (PubACol >= 7) and (PubACol <= 10) and ((PubARow >= 3) and (PubARow <= 6)) then
      begin
        aDxCell.aRow := 6;
        aDxCell.aCol := 3;
        aHjCell.aRow := 6;
        aHjCell.aCol := 7;
        aBeginCell.aRow := 3;
        aBeginCell.aCol := 7;
        AutoComputer(aDxCell, aHjCell, aBeginCell, 3);
      end;
      SendMessage(InVoiceTable.Handle, VK_RIGHT, VK_TAB, 0);
    end;
  end;
  if CurrentFP = 'FP04' then
  begin
      if (PubACol >= 9) and (PubACol <= 12) and ((PubARow >= 2) and (PubARow <=4)) then
    begin                             
      aPos := Pos('.', InVoiceTable.Cells[PubACol, PubARow]);
      if aPos > 0 then
        if not (Key in ['0'..'9', #9, #13]) then Key := #0
        else
          if not (Key in ['0'..'9', #9, #13, '.']) then Key := #0;
    end;
    if (Key = #13) then
    begin
      if (PubACol >= 9) and (PubACol <= 12) and ((PubARow >= 2) and (PubARow <=4)) then
      begin
        aDxCell.aRow := 5;
        aDxCell.aCol := 3;
        aHjCell.aRow := 5;
        aHjCell.aCol := 9;
        aBeginCell.aRow := 2;
        aBeginCell.aCol := 9;
        AutoComputer(aDxCell, aHjCell, aBeginCell, 3);
      end;
      SendMessage(InVoiceTable.Handle, VK_RIGHT, VK_TAB, 0);
    end;
  end;
  if CurrentFP = 'FP05' then
  begin
    if (PubACol >= 9) and (PubACol <= 12) and ((PubARow >= 6) and (PubARow <=8)) then
    begin                             
      aPos := Pos('.', InVoiceTable.Cells[PubACol, PubARow]);
      if aPos > 0 then
        if not (Key in ['0'..'9', #9, #13]) then Key := #0
        else
          if not (Key in ['0'..'9', #9, #13, '.']) then Key := #0;
    end;
    if (Key = #13) then
    begin
      if (PubACol >= 9) and (PubACol <= 12) and ((PubARow >= 6) and (PubARow <=8)) then
      begin
        aDxCell.aRow := 9;
        aDxCell.aCol := 3;
        aHjCell.aRow := 9;
        aHjCell.aCol := 9;
        aBeginCell.aRow := 6;
        aBeginCell.aCol := 9;
        AutoComputer(aDxCell, aHjCell, aBeginCell, 3);
      end;
      SendMessage(InVoiceTable.Handle, VK_RIGHT, VK_TAB, 0);
    end;
  end;
end;

procedure TMain.InVoiceTableGetEditorType(Sender: TObject; ACol,
  ARow: Integer; var AEditor: TEditorType);
begin
  if CurrentFP = 'FP01' then
  begin
    if ((ACol = 5) or (ACol = 7) or (ACol = 8)) and ((ARow >= 3) or (ARow <= 6)) then
      AEditor := edNumeric;
  end;
  if CurrentFP = 'FP02' then
  begin
    if ((ACol = 6) or (ACol = 7)) and ((ARow >= 3) or (ARow <= 6)) then
      AEditor := edNumeric;
  end;
end;

procedure TMain.SaveFP01;
var
  FMax: Integer;
  i, s: integer;
begin
  with DataModule1 do
  begin
    try
      ADOTableTax.TableName := 'TaxZly';
      ADOTableTax.Open;
      ADOTableTax.First;
      for i := 3 to 5 do
      begin
        if InVoiceTable.Cells[0, i] = '' then
        begin
          Inc(s);
          Continue;
        end
        else
        begin
          with ADOTableTax do
          begin
            Append;
            FMax := GetMax('Select Max(ID) From TaxZly');
            FieldByName('ID').AsInteger := FMax + 1;
            FieldByName('发票号码').AsString := AdvEdit3.Text;
            FieldByName('承租方').AsString := AdvEdit4.Text;
            FieldByName('客户名称').AsString := AdvEdit5.Text;
            FieldByName('客户编码').AsString := AdvEdit6.Text;
            FieldByName('开票日期').AsDateTime := cxDateEdit1.Date;
            if InVoiceTable.Cells[0, i] <> '' then
              FieldByName('租赁项目').AsString := InVoiceTable.Cells[0, i];
            if InVoiceTable.Cells[2, i] <> '' then
              FieldByName('开始日期').AsDateTime := StrToDate(InVoiceTable.Cells[
                2, I]);
            if InVoiceTable.Cells[4, i] <> '' then
              FieldByName('停止日期').AsDateTime := StrToDate(InVoiceTable.Cells[
                4, I]);
            if InVoiceTable.Cells[5, i] <> '' then
              FieldByName('天数').AsInteger := StrToInt(InVoiceTable.Cells[5, i]);
            if InVoiceTable.Cells[6, i] <> '' then
              FieldByName('单位').AsString := InVoiceTable.Cells[6, i];
            if InVoiceTable.Cells[7, i] <> '' then
              FieldByName('数量').AsInteger := StrToInt(InVoiceTable.Cells[7, i]);
            if InVoiceTable.Cells[8, i] <> '' then
              FieldByName('收费标准').AsInteger := StrToInt(InVoiceTable.Cells[8,
                i]);
            if InVoiceTable.Cells[9, i] <> '' then
              FieldByName('金额').AsCurrency := StrToCurr(InVoiceTable.Cells[9,
                i]);
            if InVoiceTable.Cells[2, 6] <> '' then
              FieldByName('金额大写').AsString := InVoiceTable.Cells[2, 6];
            if InVoiceTable.Cells[9, 6] <> '' then

⌨️ 快捷键说明

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