全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1499
推到 Plurk!
推到 Facebook!

如何改寫以 case 印出適當報表

缺席
u86210779
一般會員


發表:16
回覆:41
積分:16
註冊:2004-06-08

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-05-01 18:52:08 IP:218.169.xxx.xxx 訂閱
請問各位先進:

<textarea class="delphi" rows="10" cols="60" name="code"> procedure TfmPrint.Master; begin with RadioGroup1 do case ItemIndex of 0: SetCust;//客戶資料表 1: SetSply;//廠商 end; end; procedure TfmPrint.SetCust; begin ptCust := TptCust.Create(Self); SetReport(ptCust, RadioGroup3.ItemIndex=1); end; procedure TfmPrint.SetSply; begin ptSply := TptSply.Create(Self); SetReport(ptSply, RadioGroup3.ItemIndex=1); end; ........ //如何改寫為 procedure TfmPrint.Master; begin with RadioGroup1 do case ItemIndex of 0: SetPrint(ptCust);//客戶資料表 1: SetPrint(ptSply);//廠商 end; end; procedure TfmPrint.SetPrint(ptPrint:???); begin ptPrint := TptPrint.Create(Self); SetReport(ptPrint, RadioGroup3.ItemIndex=1); end; procedure SetReport(vReport: TQuickRep; vPreView: boolean); var i: integer; begin with vReport do try Prepare; for i := 1 to ComponentCount - 1 do if Components[i] is TQRLabel then with (Components[i] as TQRLabel) do if name = 'QRLabelTotPage' then Caption := IntToStr(QRPrinter.PageCount); if vPreView then Print else Preview; finally Free; QRPrinter := nil; end; end; </textarea> 感謝你撥空看我的問題.
bruce
中階會員


發表:19
回覆:121
積分:83
註冊:2002-04-16

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-05-02 09:06:53 IP:203.70.xxx.xxx 訂閱
//如何改寫為
  • procedure TfmPrint.Master;
  • begin
  • with RadioGroup1 do
  • case ItemIndex of
  • 0: SetPrint(ptCust);//客戶資料表
  • 1: SetPrint(ptSply);//廠商
  • end;
  • end;
  • procedure TfmPrint.SetPrint(ptPrint:???);
  • begin
  • ptPrint := TptPrint.Create(Self);
  • SetReport(ptPrint, RadioGroup3.ItemIndex=1);
  • end;

    更改如下:

  • procedure TfmPrint.SetPrint(ptPrint:Tptint);
  • begin
  • SetReport(ptPrint, RadioGroup3.ItemIndex=1);
  • end;

    您的問題應該是,如何傳遞物件至一個程序,把物件當成變數型態的一種就對了。
  • u86210779
    一般會員


    發表:16
    回覆:41
    積分:16
    註冊:2004-06-08

    發送簡訊給我
    #3 引用回覆 回覆 發表時間:2007-05-07 10:09:38 IP:218.169.xxx.xxx 訂閱
    感謝你的回覆, 經測試後還是無法修改.
    我是使用 Dephi V7, QuickRep.
    系統時間:2024-04-26 16:23:59
    聯絡我們 | Delphi K.Top討論版
    本站聲明
    1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
    2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
    3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!