線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:663
推到 Plurk!
推到 Facebook!

問一個簡單的交易問題~~~

尚未結案
a0485nan
一般會員


發表:1
回覆:2
積分:0
註冊:2005-03-08

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-03-08 08:42:40 IP:203.204.xxx.xxx 未訂閱
~~~~~~數量~~~單價~~~庫存~~~ 產品1 產品2 . . . . ~~~~~~~~~~~~~~~進貨~~~出貨~~~ 數量處要輸入數字~~~做進貨出貨交易~ 進貨.庫存處要加~~出貨.要減 庫存處~用檔案儲存~不用用SQL之類的資料庫~用純文字檔或DAT就好~ 數量處用EDIT~如何讓它的初值都是0?~還有如何讀寫資料~ 拜託請教一下~謝謝~~~
P.D.
版主


發表:603
回覆:4038
積分:3874
註冊:2006-10-31

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-03-12 00:29:28 IP:61.71.xxx.xxx 未訂閱
引言: ~~~~~~數量~~~單價~~~庫存~~~ 產品1 產品2 . . . . ~~~~~~~~~~~~~~~進貨~~~出貨~~~ 數量處要輸入數字~~~做進貨出貨交易~ 進貨.庫存處要加~~出貨.要減 庫存處~用檔案儲存~不用用SQL之類的資料庫~用純文字檔或DAT就好~ 數量處用EDIT~如何讓它的初值都是0?~還有如何讀寫資料~ 拜託請教一下~謝謝~~~
霧剎剎ㄋㄟ!是否可以將你想要的畫面貼上來
stellos
中階會員


發表:24
回覆:84
積分:51
註冊:2004-06-08

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-03-12 10:51:50 IP:61.60.xxx.xxx 未訂閱
用純文字檔或DAT會不會太費工夫啦 資料庫元件這麼多好用又方便    不過還是說明你要的方式 1.先規劃好你的資料格式,假設每欄資料用分號隔開 2.寫一個副程式解讀此檔(得知每筆各欄資料)   我會用結構存它,結構長度=每筆資料長度!!才不會錯 3.你要讀寫它必須要有個變數紀錄Index(不然你怎知修改哪筆) 4.數量處用初值是0,那是在新增一筆資料時吧   你只要在[新增資料]時在數量處填0就好啦    你將來一定會問搜尋資料怎麼做
nnn0918k
一般會員


發表:12
回覆:33
積分:14
註冊:2003-05-12

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-03-13 20:37:48 IP:163.28.xxx.xxx 未訂閱
這種不用資料庫會出人命的哦 建議用資料庫啦.. 即使只是用dbf而已@@" 火舞精靈 - 蘇
a0485nan
一般會員


發表:1
回覆:2
積分:0
註冊:2005-03-08

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-03-13 20:53:49 IP:203.204.xxx.xxx 未訂閱
引言: 用純文字檔或DAT會不會太費工夫啦 資料庫元件這麼多好用又方便 不過還是說明你要的方式 1.先規劃好你的資料格式,假設每欄資料用分號隔開 2.寫一個副程式解讀此檔(得知每筆各欄資料) 我會用結構存它,結構長度=每筆資料長度!!才不會錯 3.你要讀寫它必須要有個變數紀錄Index(不然你怎知修改哪筆) 4.數量處用初值是0,那是在新增一筆資料時吧 你只要在[新增資料]時在數量處填0就好啦 你將來一定會問搜尋資料怎麼做 < face="Verdana, Arial, Helvetica"> 因為我是這學期才接觸delphi的~所以連基本語法都不會~我只有學過c~ 可以弄一個簡單的結構範例寫法給我看看嗎? 只要存產品名稱&庫存~
a0485nan
一般會員


發表:1
回覆:2
積分:0
註冊:2005-03-08

發送簡訊給我
#6 引用回覆 回覆 發表時間:2005-03-13 20:57:45 IP:203.204.xxx.xxx 未訂閱
引言: 這種不用資料庫會出人命的哦 建議用資料庫啦.. 即使只是用dbf而已@@" 火舞精靈 - 蘇
用資料庫比較好搜尋后~ 要怎麼寫語法~去讀取SQL?
nnn0918k
一般會員


發表:12
回覆:33
積分:14
註冊:2003-05-12

發送簡訊給我
#7 引用回覆 回覆 發表時間:2005-03-13 21:51:12 IP:163.28.xxx.xxx 未訂閱
產品物件  
  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

發送簡訊給我
#8 引用回覆 回覆 發表時間:2005-03-13 22:02:03 IP:163.28.xxx.xxx 未訂閱
在上面先幫你規劃了兩個物件: 產品、昌庫, 進貨出貨就是對昌庫進行存取而已, 然後在程式執行時要先從檔案中把資料讀到昌庫裡(LoadFromFile) 而在程式結束時,或者隨時,都可以對昌庫進行存檔(SaveToFile) 上面那兩部分就得靠你自己啦.. 火舞精靈 - 蘇
stellos
中階會員


發表:24
回覆:84
積分:51
註冊:2004-06-08

發送簡訊給我
#9 引用回覆 回覆 發表時間:2005-03-15 00:45:53 IP:220.138.xxx.xxx 未訂閱
a0485nan我不太會Delphi 不過我都是用BCB寫程式 如果你要BCB的範例我可以寫段範例
系統時間:2024-06-02 1:33:55
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!