unit U_TaxSet;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics,
  cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit,
  dxSkinsCore, dxSkinWXI, Vcl.ComCtrls, Vcl.ToolWin, cxLabel, cxTextEdit,
  U_DataLink, Data.DB, Data.Win.ADODB;

type
  TfrmTaxSet = class(TForm)
    CGDSL: TcxTextEdit;
    CRate: TcxTextEdit;
    COrtherRate: TcxTextEdit;
    cxLabel1: TcxLabel;
    cxLabel2: TcxLabel;
    cxLabel3: TcxLabel;
    ToolBar1: TToolBar;
    ToolButton3: TToolButton;
    TBClose: TToolButton;
    ADOQuery1: TADOQuery;
    procedure ToolButton3Click(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmTaxSet: TfrmTaxSet;

implementation

{$R *.dfm}

procedure TfrmTaxSet.TBCloseClick(Sender: TObject);
begin
  close;
end;

procedure TfrmTaxSet.ToolButton3Click(Sender: TObject);
var
  value: Double;
begin
  with ADOQuery1 do
  begin
    Close;
    sql.Clear;

    for var i := 0 to ControlCount - 1 do
    begin
      if Controls[i] is TcxTextEdit then
      begin
        if TcxTextEdit(Controls[i]).Text <> '' then
        begin
          if not TryStrToFloat(TcxTextEdit(Controls[i]).Text, value) then
          begin
            Application.MessageBox('请输入有效的数字', '提示', 0);
            Exit;
          end;
        end;

        SQL.Add(' update sy_tax set value=' + QuotedStr(TcxTextEdit(Controls[i]).Text) + ' where type =' + QuotedStr(TcxTextEdit(Controls[i]).Name));
      end;
    end;
    ExecSQL;
  end;
  ModalResult := 1;
end;

end.

