關于DBGrid的問題,能否不用临时表 (100分)

  • 主题发起人 主题发起人 lsyhql
  • 开始时间 开始时间
L

lsyhql

Unregistered / Unconfirmed
GUEST, unregistred user!
請教各位大蝦:(我使用的是paradox数据库)
出库单,在一個DBGrid中直接錄入數據,然后保存至Table中.如何實現:
1.當按下一'新增'Button時(設Table1.append),DBGrid中不顯示記錄,就像與其關聯的Table
是個無記錄的空表一樣(因為當Table中有記錄時,令Table1.Active:=true;時,DBGrid中會
出現Table中已有之全部記錄).而且录入的商品批号后,系统先判断该批号是否存在,如果
不存在,则发出警告。当录入完该记录的相关数据:出库件数,系统能自动显示该批号还剩
余几件,自动显示当前出库公斤数等。
2.當在DBGrid中輸入多條後,按'OK'按鈕才將其真正存入數據庫中,而此時如果按下'Cancel'
按鈕後,數據不寫入數據庫中(放棄).好像在Table的方法中,無論Append,insert,edit,即
使不在數據錄入後不寫Post,而離開當前記錄後(如錄入完第一條到第二條記錄時,第一條
自動Post了)記錄像便寫入數據庫.我如何限制其自動Post,而執行一'確認'動作呢?
我尝试过使用临时表,但很琐碎,而且程序也很大。有更好的办法吗?
100分奉上
 
1. In OnButtonClick event, firstly show a seperate form for inquire data and
only execute Table1.AppendRecord(...) after user clicked OK button. And
before insert, you can do more things, such as search if it is duplicated,
or else.
2. You may set the CachedUpdate property of TTable or TQuery to true, and the
modifies will be made only in the memory before you call ApplyUpdates. And
you may cancel all actions by calling CancelUpdates.
 
可以换一个方法试试看,一定能够解决你的问题,而且效率绝对比table组件的高,
那就是使用query和updatesql控件合作,看看delphi5demo里面的例子就知道那!
 
用事务管理
 
接受答案了
 
后退
顶部