問一個簡單的交易問題~~~ |
尚未結案
|
a0485nan
一般會員 發表:1 回覆:2 積分:0 註冊:2005-03-08 發送簡訊給我 |
|
P.D.
版主 發表:603 回覆:4038 積分:3874 註冊:2006-10-31 發送簡訊給我 |
|
stellos
中階會員 發表:24 回覆:84 積分:51 註冊:2004-06-08 發送簡訊給我 |
|
nnn0918k
一般會員 發表:12 回覆:33 積分:14 註冊:2003-05-12 發送簡訊給我 |
|
a0485nan
一般會員 發表:1 回覆:2 積分:0 註冊:2005-03-08 發送簡訊給我 |
引言: 用純文字檔或DAT會不會太費工夫啦 資料庫元件這麼多好用又方便 不過還是說明你要的方式 1.先規劃好你的資料格式,假設每欄資料用分號隔開 2.寫一個副程式解讀此檔(得知每筆各欄資料) 我會用結構存它,結構長度=每筆資料長度!!才不會錯 3.你要讀寫它必須要有個變數紀錄Index(不然你怎知修改哪筆) 4.數量處用初值是0,那是在新增一筆資料時吧 你只要在[新增資料]時在數量處填0就好啦 你將來一定會問搜尋資料怎麼做 >>< face="Verdana, Arial, Helvetica"> 因為我是這學期才接觸delphi的~所以連基本語法都不會~我只有學過c~ 可以弄一個簡單的結構範例寫法給我看看嗎? 只要存產品名稱&庫存~ |
a0485nan
一般會員 發表:1 回覆:2 積分:0 註冊:2005-03-08 發送簡訊給我 |
|
nnn0918k
一般會員 發表:12 回覆:33 積分:14 註冊:2003-05-12 發送簡訊給我 |
產品物件
TProduct = class(TObject) private FId: Cardinal; FName: String; FValue: Cardinal; FCount: Cardinal; protected public constructor Create; destructor Destroy; override; published property Id: Cardinal read FId write FId; property Name: String read FName write FName; property Value: Cardinal read FValue write FValue; property Count: Cardinal read FCount write FCount; end; { TProduct } constructor TProduct.Create; begin inherited Create; FId := 0; FName := ''; FValue := 0; FCount := 0; end; destructor TProduct.Destroy; begin inherited Destroy; end;昌庫物件 TStorage = class(TObject) private FList: TList; function GetList(index: Integer): TProduct; procedure SetList(index: Integer; const Value: TProduct); protected public constructor Create; destructor Destroy; override; procedure Clear; function Add: TProduct; overload; function Add(AProduct: TProduct): Integer; overload; function Count: Integer; property List[index: Integer]: TProduct read GetList write SetList; procedure Delete(AProduct: TProduct); overload; procedure Delete(index: Integer); overload; published end; { TStorage } function TStorage.Add: TProduct; begin result := TProduct.Create; Add(result); end; function TStorage.Add(AProduct: TProduct): Integer; begin result := FList.Add(AProduct); end; procedure TStorage.Clear; var i: Integer; begin for i := 0 to (FList.Count - 1) do begin TProduct(FList.Items[i]).Free; end; FList.Clear; end; function TStorage.Count: Integer; begin result := FList.Count; end; constructor TStorage.Create; begin FList := TList.Create; end; procedure TStorage.Delete(AProduct: TProduct); var i: Integer; begin for i := 0 to (FList.Count - 1) do begin if (TProduct(FList.Items[i]) = AProduct) then Delete(i); end; end; procedure TStorage.Delete(index: Integer); begin TProduct(FList.Items[index]).Free; FList.Delete(index); end; destructor TStorage.Destroy; begin Clear; FreeAndNil(FList); inherited; end; function TStorage.GetList(index: Integer): TProduct; begin result := TProduct(FList.Items[index]); end; procedure TStorage.SetList(index: Integer; const Value: TProduct); begin FList.Items[index] := Value; end;火舞精靈 - 蘇 |
nnn0918k
一般會員 發表:12 回覆:33 積分:14 註冊:2003-05-12 發送簡訊給我 |
|
stellos
中階會員 發表:24 回覆:84 積分:51 註冊:2004-06-08 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |