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

📄 fhd_cx.pas

📁 省级集邮品管理ERP
💻 PAS
📖 第 1 页 / 共 2 页
字号:
procedure TFrm_FHD_CX.BBt_CZFHDClick(Sender: TObject);
begin
  if DataSource1.DataSet.IsEmpty then Exit;
  if DataSource1.DataSet.FieldByName('ORD').AsString <> '2' then Exit;
  if CHQMsgBox('确实要冲正此发货单吗?', 2) = IDNO then Exit;
  CZBill(DataSource1.DataSet.FieldByName('FHDH').AsString);
  DataSource1.DataSet.Close;
  DataSource1.DataSet.Open;
end;

procedure TFrm_FHD_CX.Button1Click(Sender: TObject);
var
  V_Count, i: Integer;
  V_PPDM, v_date, YW_SQL, YW_INIT_SQL, YW_REFRASH_SQL: string;
  V_HZDTJ: string;

  procedure SetTS(APPDM, TS: string);
  var
    StrSQL: string;
  begin
    with Qry_Static2, RPT_FHSH do
    begin
      Close;
      SQL.Clear;
      StrSQL := '';
      case Fio_type of
        io_jyp:
          StrSQL := 'select a.PPDM, sum(a.SL) TS, b.QXDW DWDM '#13 +
            'from TKS_JYCKPP a, TKS_JYFHD b where a.FHDH=b.FHDH '#13 +
            'and ' + V_HZDTJ +
            'and a.PPDM=''' + APPDM + '''group by a.PPDM, b.QXDW';
        io_yp:
          StrSQL := 'select a.PPDM, sum(a.SL) TS, b.QXDW DWDM '#13 +
            'from TKS_YPCKPP a, TKS_YPFHD b where a.FHDH=b.FHDH '#13 +
            'and ' + V_HZDTJ +
            'and a.PPDM=''' + APPDM + '''group by a.PPDM, b.QXDW';
        io_grp:
          StrSQL := 'select a.PPDM, sum(a.SL) TS, b.QXDW DWDM '#13 +
            'from TKS_GRPCKPP a, TKS_GRPFHD b where a.FHDH=b.FHDH '#13 +
            'and ' + V_HZDTJ +
            'and a.PPDM=''' + APPDM + '''group by a.PPDM, b.QXDW';
        io_txp:
          StrSQL := 'select a.TUDM PPDM, sum(a.SL) TS, b.QXDW DWDM '#13 +
            'from TKS_TXCKPP a, TKS_TXFHD b where a.FHDH=b.FHDH '#13 +
            'and ' + V_HZDTJ +
            'and a.TUDM=''' + APPDM + '''group by a.TUDM, b.QXDW';
      end;
      SQL.Add(StrSQL);
      Open;
      while not Eof do
      begin
        if Qry_Print.Locate('DWDM', FieldByName('DWDM').AsString, []) then
        begin
          Qry_Print.Edit;
          Qry_Print.FieldByName(TS).AsInteger := FieldByName('TS').AsInteger;
          Qry_Print.Post;
        end;
        Next;
      end;
      Close;
    end;
  end;

begin
  v_date := SpinEdit1.Text + formatfloat('00', SpinEdit2.Value);
  case TButton(Sender).Tag of
    11: //当月
      V_HZDTJ := ' to_char(KDRQ, ''YYYYMM'')=''' + v_date + ''' ';
    22: //依据单
      V_HZDTJ := ' YJDH=''' + FQuery.FieldByName('YJDH').AsString + ''' ';
  end;

  with Qry_Static do
  begin
    Close;
    SQL.Clear;
    case Fio_type of
      io_jyp:
        YW_SQL := 'select count(distinct a.PPDM) from TKS_JYCKPP a, TKS_JYFHD b '#13 +
          'where a.FHDH=b.FHDH and b.JSZT<>''1'' and ' + V_HZDTJ;
      io_yp:
        YW_SQL := 'select count(distinct a.PPDM) from TKS_YPCKPP a, TKS_YPFHD b '#13 +
          'where a.FHDH=b.FHDH and b.JSZT<>''1'' and ' + V_HZDTJ;
      io_grp:
        YW_SQL := 'select count(distinct a.PPDM) from TKS_GRPCKPP a, TKS_GRPFHD b '#13 +
          'where a.FHDH=b.FHDH and b.JSZT<>''1'' and ' + V_HZDTJ;
      io_txp:
        YW_SQL := 'select count(distinct a.TUDM) from TKS_TXCKPP a, TKS_TXFHD b '#13 +
          'where a.FHDH=b.FHDH and b.JSZT<>''1'' and ' + V_HZDTJ;
    end;
    SQL.Add(YW_SQL);
    Open;
    if not Eof then
      V_Count := Fields[0].AsInteger
    else
      V_Count := 0;
    Close;
  end;
  if not (v_count > 0) then Exit;
  V_Count := Ceil(V_Count / 5);
  V_PPDM := '0';
  for i := 1 to V_Count do
  begin
    RPT_FHSH := TRPT_FHSH.Create(nil);
    //初始化
    with RPT_FHSH do
    begin
      L_NDYF.Caption := SpinEdit1.Text + '年度  ' + SpinEdit2.Text + ' 月份';
      L_YS.Caption := ' 共 ' + IntToStr(V_Count) + ' 页 /第 ' + IntToStr(i) + ' 页';
      QRL_MZ1.Caption := '';
      QRL_MZ2.Caption := '';
      QRL_MZ3.Caption := '';
      QRL_MZ4.Caption := '';
      QRL_MZ5.Caption := '';

      QRT_TS1.Enabled := False;
      QRT_TS2.Enabled := False;
      QRT_TS3.Enabled := False;
      QRT_TS4.Enabled := False;
      QRT_TS5.Enabled := False;

      QRE_TS1.Enabled := False;
      QRE_TS2.Enabled := False;
      QRE_TS3.Enabled := False;
      QRE_TS4.Enabled := False;
      QRE_TS5.Enabled := False;

      Qry_Print.Open;
      Qry_Print.Delete;
    end;

    with Qry_Static, RPT_FHSH do
    begin
      Close;
      SQL.Clear;
      case Fio_type of
        io_jyp:
          YW_INIT_SQL := 'select distinct a.QXDW DWDM, b.DWJC DWMC, b.PXM '#13 +
            'from TKS_JYFHD a, TGS_GXDWSJB b where a.QXDW=b.DWDM and a.JSZT<>''1'''#13 +
            'and ' + V_HZDTJ + ' order by b.PXM';
        io_yp:
          YW_INIT_SQL := 'select distinct a.QXDW DWDM, b.DWJC DWMC, b.PXM '#13 +
            'from TKS_YPFHD a, TGS_GXDWSJB b where a.QXDW=b.DWDM and a.JSZT<>''1'''#13 +
            'and ' + V_HZDTJ + ' order by b.PXM';
        io_grp:
          YW_INIT_SQL := 'select distinct a.QXDW DWDM, b.DWJC DWMC, b.PXM '#13 +
            'from TKS_GRPFHD a, TGS_GXDWSJB b where a.QXDW=b.DWDM and a.JSZT<>''1'''#13 +
            'and ' + V_HZDTJ + ' order by b.PXM';
        io_txp:
          YW_INIT_SQL := 'select distinct a.QXDW DWDM, b.DWJC DWMC, b.PXM '#13 +
            'from TKS_TXFHD a, TGS_GXDWSJB b where a.QXDW=b.DWDM and a.JSZT<>''1'''#13 +
            'and ' + V_HZDTJ + ' order by b.PXM';
      end;
      SQL.Add(YW_INIT_SQL);
      Open;
      while not Eof do
      begin
        Qry_Print.Append;
        Qry_Print.FieldByName('DWDM').AsString := FieldByName('DWDM').AsString;
        Qry_Print.FieldByName('DWMC').AsString := FieldByName('DWMC').AsString;
        Qry_Print.Post;
        Next;
      end;

    //刷新标题
      with Qry_Static, RPT_FHSH do
      begin
        Close;
        SQL.Clear;
        case Fio_type of
          io_jyp:
            YW_REFRASH_SQL := 'select distinct a.PPDM, c.ZH, c.TMC '#13 +
              'from TKS_JYCKPP a, TKS_JYFHD b, TB_YZPPTXXB c '#13 +
              'where a.FHDH=b.FHDH and a.PPDM=c.TDM and b.JSZT<>''1'''#13 +
              'and ' + V_HZDTJ + ' and a.PPDM>' + V_PPDM + ' order by a.PPDM';
          io_yp:
            YW_REFRASH_SQL := 'select distinct a.PPDM, c.ZH, c.TMC '#13 +
              'from TKS_YPCKPP a, TKS_YPFHD b, TB_YZPPXXB c '#13 +
              'where a.FHDH=b.FHDH and a.PPDM=c.TDM and b.JSZT<>''1'''#13 +
              'and ' + V_HZDTJ + ' and a.PPDM>' + V_PPDM + ' order by a.PPDM';
          io_grp:
            YW_REFRASH_SQL := 'select distinct a.PPDM, c.ZH, c.TMC '#13 +
              'from TKS_GRPCKPP a, TKS_GRPFHD b, TB_YZPPXXB c '#13 +
              'where a.FHDH=b.FHDH and a.PPDM=c.TDM and b.JSZT<>''1'''#13 +
              'and ' + V_HZDTJ + ' and a.PPDM>' + V_PPDM + ' order by a.PPDM';
          io_txp:
            YW_REFRASH_SQL := 'select distinct a.TUDM PPDM, c.ZH, c.TMC '#13 +
              'from TKS_TXCKPP a, TKS_TXFHD b, TB_YZPPXXB c '#13 +
              'where a.FHDH=b.FHDH and a.TUDM=c.TDM and b.JSZT<>''1'''#13 +
              'and ' + V_HZDTJ + ' and a.TUDM>' + V_PPDM + ' order by a.TUDM';
        end;
        SQL.Add(YW_REFRASH_SQL);
        Open;
        if not eof then
        begin
          QRL_MZ1.Caption := Fields[1].AsString;
          QRL_MC1.Caption := Fields[2].AsString;
          QRT_TS1.Enabled := True;
          QRE_TS1.Enabled := True;
          V_PPDM := Fields[0].AsString;
          SetTS(V_PPDM, 'TS1');
          Next;
        end;
        if not eof then
        begin
          QRL_MZ2.Caption := Fields[1].AsString;
          QRL_MC2.Caption := Fields[2].AsString;
          QRT_TS2.Enabled := True;
          QRE_TS2.Enabled := True;
          V_PPDM := Fields[0].AsString;
          SetTS(V_PPDM, 'TS2');
          Next;
        end;
        if not eof then
        begin
          QRL_MZ3.Caption := Fields[1].AsString;
          QRL_MC3.Caption := Fields[2].AsString;
          QRT_TS3.Enabled := True;
          QRE_TS3.Enabled := True;
          V_PPDM := Fields[0].AsString;
          SetTS(V_PPDM, 'TS3');
          Next;
        end;
        if not eof then
        begin
          QRL_MZ4.Caption := Fields[1].AsString;
          QRL_MC4.Caption := Fields[2].AsString;
          QRT_TS4.Enabled := True;
          QRE_TS4.Enabled := True;
          V_PPDM := Fields[0].AsString;
          SetTS(V_PPDM, 'TS4');
          Next;
        end;
        if not eof then
        begin
          QRL_MZ5.Caption := Fields[1].AsString;
          QRL_MC5.Caption := Fields[2].AsString;
          QRT_TS5.Enabled := True;
          QRE_TS5.Enabled := True;
          V_PPDM := Fields[0].AsString;
          SetTS(V_PPDM, 'TS5');
        end;
        Close;
      end;
    end;
    RPT_FHSH.ReportTitle := pCaption[integer(Fio_Type)] + '出库汇总单';
    RPT_FHSH.ZDRQ.Caption := FormatDateTime('YYYY-MM-DD', Now);
    RPT_FHSH.ZBR.Caption := VG_USERNAME;
    RPT_FHSH.QRLabel3.Caption := '单位:' + VG_UNITNAME;
    RPT_FHSH.Preview;
    RPT_FHSH.Free;
  end;
end;

procedure TFrm_FHD_CX.RxDBG_fhdDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
  if FQuery.FieldByName('ZT').AsString = '被撤消' then
    if (gdselected in state) and (RxDBG_fhd.focused = true) then
      RxDBG_fhd.Canvas.Font.Color := clWhite
    else
      RxDBG_fhd.Canvas.Font.Color := clNavy;
  if FQuery.FieldByName('ZT').AsString = '被冲正' then
    if (gdselected in state) and (RxDBG_fhd.focused = true) then
      RxDBG_fhd.Canvas.Font.Color := clWhite
    else
      RxDBG_fhd.Canvas.Font.Color := clMaroon;
  if FQuery.FieldByName('ZT').AsString = '冲正' then
    if (gdselected in state) and (RxDBG_fhd.focused = true) then
      RxDBG_fhd.Canvas.Font.Color := clWhite
    else
      RxDBG_fhd.Canvas.Font.Color := clMaroon;
  RxDBG_fhd.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;

end.

⌨️ 快捷键说明

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