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

📄 frmmain.~pas

📁 发票管理系统其中包括: 1.租凭业发票 2.建筑业发票 3.固定资产发票 4.服务行业发票 5.无形资产发票
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
              FieldByName('金额合计').AsCurrency := StrToCurr(InVoiceTable.Cells[9,
                6]);
            if InVoiceTable.Cells[6, 9] <> '' then
              FieldByName('开票人').AsString := InVoiceTable.Cells[6, 9];
            if InVoiceTable.Cells[10, 9] <> '' then
              FieldByName('收款人').AsString := InVoiceTable.Cells[10, 9];
            if InVoiceTable.Cells[2, 7] <> '' then
              FieldByName('备注').AsString := InVoiceTable.Cells[2, 7];
            Post;
          end;
        end;
      end;
      if s = 3 then
        Application.MessageBox('数据只能填写三行!!', '贝壳提示', MB_OK +
          MB_ICONINFORMATION + MB_DEFBUTTON3 + MB_TOPMOST)
      else
      begin
        if WorksFlags <> 3 then //因为已经更新会弹出更新成功,
                                   //所以不必再保存成功
          Application.MessageBox('保存成功!', '贝壳提示', MB_OK +
            MB_ICONINFORMATION + MB_DEFBUTTON3 + MB_TOPMOST);
        ADOTableTax.Close;
        SpeedButton15.Enabled := False;
        SpeedButton20.Enabled := True;
        //SpeedButton4.Click;
        //ClearEdit; //清空
      end;
    except
      Application.MessageBox('保存错误!', '贝壳提示', MB_OK + MB_ICONSTOP +
        MB_DEFBUTTON3 + MB_TOPMOST);
      ADOTableTax.Close;            
    end;
  end;
end;

procedure TMain.ShowInitialization;
var
  aStr: string;
begin
  WorksFlags := 1;
  AppPath := ExtractFilePath(ParamStr(0));
//  aStr := AppPath + 'web\left.htm';
  MainBrower.Navigate(HttpURL+'web/left.htm');
//  MainBrower.Navigate(aStr);
  Application.ProcessMessages;
  CurrentFP := 'FP01';
  NowDate := Now;
  cxDateEdit1.Date := NowDate;
  SpeedButton4.Enabled := True;
  SpeedButton6.Enabled := True;
  SpeedButton15.Enabled := True;
  InVoiceTable.Col := 5;
  InVoiceTable.Row := 5;
  StatusBar1.Panels[3].Text:=CurrenUser;
  DrawFP01;
  AdvEdit1.Text:='100000001';
  cxButton5.Click;
end;

procedure TMain.SpeedButton15Click(Sender: TObject);
begin
  if CurrentFP = 'FP01' then
  begin
    if not CheckOut then //查检数据是否合格
    else
      if WorksFlags = 3 then
      begin
        UpdateFP('TaxZly'); //开始更新
      end
      else
      begin
        SaveFP01; //开始保存
        SpeedButton20.Enabled := False;
      end;
    WorksFlags := 1;
    TaxPubReadOnly := True;
  end;
  if CurrentFP = 'FP02' then
  begin
    if not CheckOut then //查检数据是否合格
    else
      if WorksFlags = 3 then
      begin
        UpdateFP('TaxJzy'); //开始更新
      end
      else
      begin
        SaveFP02; //开始保存
        SpeedButton20.Enabled := False;
      end;
    WorksFlags := 1;
    TaxPubReadOnly := True;
  end;
  if CurrentFP = 'FP03' then
  begin
    if not CheckOut then //查检数据是否合格
    else
      if WorksFlags = 3 then
      begin
        UpdateFP('TaxGdzc'); //开始更新
      end
      else
      begin
        SaveFP03; //开始保存
        SpeedButton20.Enabled := False;
      end;
    WorksFlags := 1;
    TaxPubReadOnly := True;
  end;
  if CurrentFP = 'FP04' then
  begin
    if not CheckOut then //查检数据是否合格
    else
      if WorksFlags = 3 then
      begin
        UpdateFP('TaxFwhy'); //开始更新
      end
      else
      begin
        SaveFP04; //开始保存
        SpeedButton20.Enabled := False;
      end;
    WorksFlags := 1;
    TaxPubReadOnly := True;
  end;
  if CurrentFP = 'FP05' then
  begin
    if not CheckOut then //查检数据是否合格
    else
      if WorksFlags = 3 then
      begin
        UpdateFP('TaxWxzc'); //开始更新
      end
      else
      begin
        SaveFP05; //开始保存
        SpeedButton20.Enabled := False;
      end;
    WorksFlags := 1;
    TaxPubReadOnly := True;
  end;  
end;

function TMain.CheckOut: Boolean;
begin
  Result := True;
  if Length(Trim(AdvEdit3.Text)) < 8 then
  begin
    Application.MessageBox('发票号码不能小于八位 !   ', '贝壳提示', MB_OK +
      MB_ICONWARNING + MB_DEFBUTTON3 + MB_TOPMOST);
    AdvEdit3.SetFocus;
    Result := False;
    Exit;
  end;
  if Trim(AdvEdit4.Text) = '' then
  begin
    Application.MessageBox(PChar('请输入' + Label9.Caption + ' !   '), '贝壳提示', MB_OK +
      MB_ICONWARNING + MB_DEFBUTTON3 + MB_TOPMOST);
    AdvEdit4.SetFocus;
    Result := False;
    Exit;
  end;
  if Trim(AdvEdit5.Text) = '' then
  begin
    Application.MessageBox('请输入发票号码,且不能重复 !   ', '贝壳提示', MB_OK +
      MB_ICONWARNING + MB_DEFBUTTON3 + MB_TOPMOST);
    AdvEdit5.SetFocus;
    Result := False;
    Exit;
  end;
  if Length(Trim(AdvEdit6.Text)) <> 5 then
  begin
    Application.MessageBox('客户编码为五位 !   ', '贝壳提示', MB_OK +
      MB_ICONWARNING + MB_DEFBUTTON3 + MB_TOPMOST);
    AdvEdit6.SetFocus;
    Result := False;
    Exit;
  end;
  if AdvEdit7.Enabled then
  begin
    Application.MessageBox(Pchar(Label4.caption + '错误!  '), '贝壳提示', MB_OK +
      MB_ICONWARNING + MB_DEFBUTTON3 + MB_TOPMOST);
    AdvEdit7.SetFocus;
    Result := False;
    Exit;
  end;
end;

function TMain.GetMax(aSql: string): Integer;
begin
  with DataModule1.ADOOther do
  begin
    try
      SQL.Clear;
      SQL.Add(aSql);
      Open;
      Result := Fields[0].AsInteger;
    except
      Application.MessageBox('获取数据库最大ID值失败!', '贝壳提示', MB_OK +
        MB_ICONWARNING + MB_DEFBUTTON3 + MB_TOPMOST);
      Result := 0;
    end;
  end;
end;

procedure TMain.AdvEdit3Exit(Sender: TObject);
begin
  if WorksFlags = 3 then
    Exit;
//  if Length(Trim(AdvEdit3.Text))<8 then
//  begin
//    Application.MessageBox('发票号码不能小于八位!', '贝壳提示', MB_OK +
//      MB_ICONWARNING + MB_DEFBUTTON3 + MB_TOPMOST);
//    AdvEdit3.SetFocus;
//    Exit;
//  end;
  with DataModule1 do
  begin
    ADOOther.SQL.Clear;
    ADOOther.SQL.Add('Select * from TaxZly Where 发票号码=' +
      QuotedStr(AdvEdit3.Text));
    ADOOther.Open;
    if not ADOOther.Eof then
    begin
      Application.MessageBox('对不起,数据库中已存在此发票!', '贝壳提示',
        MB_OK + MB_ICONWARNING + MB_DEFBUTTON3 + MB_TOPMOST);
      AdvEdit3.Text := '';
      AdvEdit3.SetFocus;
    end;
  end;
end;

procedure TMain.ClearEdit;
begin
  AdvEdit3.Clear;
  AdvEdit4.Clear;
  AdvEdit5.Clear;
  AdvEdit6.Clear;
  AdvEdit7.Clear;
end;

procedure TMain.AutoComputer(DxCell, HjCell, BeginCell: TCustomCell; aIndex: Integer); //
//自动计算金额
var
  i: Integer;
  aSum: Double;
begin
  for i := BeginCell.aRow to (BeginCell.aRow + aIndex - 1) do
  begin
    if InVoiceTable.Cells[9, i] <> '' then
      aSum := aSum + StrToFloat(InVoiceTable.Cells[9, i]);
  end;
  InVoiceTable.Cells[DxCell.aCol, DxCell.aRow] := NtoC(aSum);
  InVoiceTable.Cells[HjCell.aCol, HjCell.aRow] := FloatToStr(aSum);
end;

procedure TMain.InVoiceTableSelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  PubACol := ACol;
  PubARow := ARow;
end;

function TMain.SelectFP01(aText: string): Boolean;
var
  aSql: string;
  i: Integer;
begin
  i := 3;
  Result := True;
  with DataModule1.ADOSelect do
  begin
    SQL.Clear;
    aSql := 'Select * From TaxZly Where 发票号码=' + QuotedStr(aText);
    SQL.Add(aSql);
    Open;
    if RecordCount <= 0 then
    begin
      Application.MessageBox('数据库中无此发票!  ', '贝壳提示', MB_OK +
        MB_ICONWARNING + MB_DEFBUTTON3 + MB_TOPMOST);
      AdvEdit1.Clear;
      advedit1.SetFocus;
      Result := False;
      Exit;
    end;
    try
      while not Eof do
      begin
        if i > 6 then
          Exit;
        if i = 3 then
        begin
          cxDateEdit1.Date := FieldByName('开票日期').AsDateTime;
          AdvEdit3.Text := FieldByName('发票号码').AsString;
          AdvEdit4.Text := FieldByName('承租方').AsString;
          AdvEdit5.Text := FieldByName('客户名称').AsString;
          AdvEdit6.Text := FieldByName('客户编码').AsString;
          InVoiceTable.Cells[2, 6] := FieldByName('金额大写').AsString;
          InVoiceTable.Cells[9, 6] := CurrToStr(FieldByName('金额合计').AsCurrency);
          InVoiceTable.Cells[6, 9] := FieldByName('开票人').AsString;
          InVoiceTable.Cells[10, 9] := FieldByName('收款人').AsString;
          InVoiceTable.Cells[2, 7] := FieldByName('备注').AsString;
        end;
        InVoiceTable.Cells[0, i] := FieldByName('租赁项目').AsString;
        InVoiceTable.Cells[2, i] := DateToStr(FieldByName('开始日期').AsDateTime);
        InVoiceTable.Cells[4, i] := DateToStr(FieldByName('停止日期').AsDateTime);
        InVoiceTable.Cells[5, i] := IntToStr(FieldByName('天数').AsInteger);
        InVoiceTable.Cells[6, i] := FieldByName('单位').AsString;
        InVoiceTable.Cells[7, i] := IntToStr(FieldByName('数量').AsInteger);
        InVoiceTable.Cells[8, i] := IntToStr(FieldByName('收费标准').AsInteger);
        InVoiceTable.Cells[9, i] := CurrToStr(FieldByName('金额').AsCurrency);
        Inc(i);
        Next;
      end;
    except
      Result:=false;
    end;
  end;
end;

procedure TMain.SpeedButton4Click(Sender: TObject);
var
  i: Integer;
begin
  cxDateEdit1.Date := NowDate;
  for i := 0 to ComponentCount - 1 do
  begin
    if Components[i] is TAdvEdit then
    begin
      TAdvEdit(Components[i]).Clear;
      TAdvEdit(Components[i]).ReadOnly := False;
    end;
  end;
  InVoiceTable.DefaultRowHeight := 21;
  InVoiceTable.DefaultColWidth := 44;
  SpeedButton15.Enabled := True;
  SpeedButton20.Enabled := False;
  TaxPubReadOnly := False;
  InVoiceTable.Clear;
  if CurrentFP = 'FP01' then
  begin
    DrawFP01;
  end;
  if CurrentFP = 'FP02' then
  begin
    DrawFP02;
  end;
  if CurrentFP = 'FP03' then
  begin
    DrawFP03;
  end;
  if CurrentFP = 'FP04' then
  begin
    DrawFP04;
  end;
  if CurrentFP = 'FP05' then
  begin
    DrawFP05;
  end;
end;

procedure TMain.AdvEdit1KeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in ['0'..'9', #13, #8, #22, #24, #9]) then Key := #0;
  if Key = #13 then
    cxButton5.Click;
end;

procedure TMain.SpeedButton20Click(Sender: TObject);
var
  i: Integer;
begin
  cxDateEdit1.Date := NowDate;
  for i := 0 to ComponentCount - 1 do
  begin
    if Components[i] is TAdvEdit then
      TAdvEdit(Components[i]).ReadOnly := False;
  end;
  SpeedButton15.Enabled := True;
  SpeedButton20.Enabled := False;
  AdvEdit3.ReadOnly := True;
  TaxPubReadOnly := False;
  WorksFlags := 3;
end;

procedure TMain.AdvEdit6KeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in ['0'..'9', #13, #8, #22, #9]) then Key := #0;
end;

procedure TMain.AdvEdit3KeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in ['0'..'9', #13, #8, #22, #24, #9]) then Key := #0;
  if Key = #13 then

⌨️ 快捷键说明

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