Thread View: cn.bbs.comp.program
1 messages
1 total messages
Started by ���ܵ�Сʨ
Sat, 18 Apr 1998 00:00
DataWindow����ݻ�����
Author: ���ܵ�Сʨ
Date: Sat, 18 Apr 1998 00:00
Date: Sat, 18 Apr 1998 00:00
125 lines
9255 bytes
9255 bytes
DATAWINDOW���ĸ���վ��
��PowerBuilder��,DataWindow���û�ǰ�������洢���������
�Ķ�����ÿһ��Data Window��������4����ά����Ϊ��ݻ�����,
�����洢��ѯ������ݡ��û���DataWindow�ж���ݴ���ϵͳ�ڲ���
����ʵ���϶��ǽ�������⼸���������н��е��ĺ��ƶ�,�����
�û��ύ��ݿ�ʱ,ϵͳ������ĸ��������е���Ϣ�γ�SQL��IN-SER
T,UPDATE,DELETE����䡣���ĸ���������:
Primary Buffer
����������Ǵ����䴰����DataWindow�ؼ�����ݵ�,����Dat
aWindow��Retrieve() �����InsertRow()������Խ�����������
�������С���ʹ���й�DataWindowɾ����˺���ʱ,��Ӧ��¼����
��һ��������ɾ�����ִ��DataWindow��Update()����ʱ,PowerBu
ilder���鿴��һ�������еļ�¼,���γ�SQL INSERT��UPDATE���
��
Delete Buffer
���������������DeleteRow()�����Primary Buffer��ɾ
��ļ�¼,ִ��Update( )����ʱ,ϵͳ�����һ������ļ�¼�γ�DEL
ETE��䡣
Filter Buffer
���������洢���Ǵ�Original Bufferʹ��Filter()�������
��Primary Buffer�к�ʣ��ļ�¼��
Original Buffer
��һ������洢����DataWindow���ִ��retrieve()����ʱ�õ�
��ȫ����¼�����ύ��ݿ�ʱ,���Primary Buffer��ɵ�UPDATE��
����Delete Buffer��ɵ�DELETE��䶼Ҫ������һ����������
����ЩSQL����е�Where�Ӿ䡣
Original Buffer��PowerBuilder�ڲ�ά��,Power-Builder����
�����κκ������ı����ֵ,����ͨ��PowerBuilder���ṩ��Get
Item��ϵ�еĺ�����Զ���DataWindow�������ݿ��в鵽��ԭʼֵ
��ͨ����Щ�������ǿ��Ա��ʵ����ν��"Undo"����,���ҵõ���ʹ
���ֹ���ʱ�γ��ύ��ݿ��WHERE�Ӿ䡣
�����ǰʹ�õ�DataWindowû�������ĵ�Ȩ��,���ܶ�D
elete�������Origin al������в���,���ҵ�����Update()ʱҲ��
����ϵͳ����
��ݻ������״ֵ̬
Primary Buffer��Delete Buffer�����м����м���״ֵ̬,���
״ֵ̬��һ��ö�����͡����ύʱ�ɸ��е�״ֵ̬�������Ƿ�Ҫ����
SQL���,����Primary Buffer�������IN-SE RT��UPDATE���,��Del
ete Buffer�������DELETE��䡣������GetItemStatus()�����Se
tItemStatus()������Զ���һ״ֵ̬�����ݡ���һö��״̬������
����:
��NotModified!���������л��е�ֵΪ��ѯ���,û�з���ı�
��
��DataModified!���������л��е�ֵΪ��ѯ���,�����˸ı䡣
��New!���������л���Ϊһ���������,���û�з���ı�(���
Ϊ�ջ�ȱʡֵ)��
��NewModified!���������л���Ϊһ���������,��ݷ���ı�
���ı���ͨ���û���������������SetItem()����
����������������һʵ��:
����������һ�ű�,����������ֶ�,����ITEM������
ITEM CHAR(5);
NAME CHAR(20);
QUANTITY INT��
��Script�����Dz�ѯ���ű�ļ�¼,�õ�������Щ��Ϣ�洢����P
rimary��OrigianalBu ffer��,���е��к��ǻ�������ϵġ�
��1
�ڴ�����,���DZ�̹��˵�����Ϊ0����,���Ҽ���һ������:
dw_1.SetFilter("quantity=0")
dw_1.Filter()
dw_1.InsertRow()
��ʱPrimary Buffer��״̬Ϊ:
��2
��Filter Buffer�еļ�¼Ϊ:
��3
�û����²��������������,ɾ���˵�3�����,�����˵�2����
�ݡ������뿪���Dat aWindowʱ,Primary��Delete�������״̬��
��:
��4
��ʱִ��dw_1.update()����,ϵͳ���������������������SQL
��䡣��5
��Primary Buffer��,״̬ΪNotModified��New!���н������Զ�
������SQL��䡣״̬ΪDataModified���н�����UPDATE���,״̬Ϊ
NewModified�������INSERT���,��Dele te������������D
ELETE��䡣
�ĸ��������ڱ���е�����
ijЩDataWindow�ؼ��ĺ�����ָ��DataWindow������Ĺ��ܡ���
��ȱʡ,���ʾPrimar y�����������ǿ���ָ��������ĺ���:
��GetItemStatus()
��GetNextModified()
��GetUpdateStatus()
��SetItemStatus()
�����GetItem��ϵ�еĺ���,���Բ�ѯDataWindow�е�ֵ����
������:
��GetItemDate()
��GetItemDataTime()
��GetItemDecimal()
��GetItemNumber()
��GetItemString()
��GetItemTime()
GetItem��ϵ�к���Ҳ����ָ��������,���ҿ���������ָ����ѯ
���ǵ�ǰֵ����ԭʼֵ(�������ݿ��в鵽��ֵ)����:
dw_1.GetItemString(1,"name",Primary!,TRUE)
ʹ��DataWindow��Reset()�����Retrieve()�����Լ��ı�DataO
bject����ʱ,ϵͳ�������⼸��������
���û�����һ������ʱ,���������Ҫ�Զ����²������е�ijЩ
���в���һЩȱʡ�����ֵ����ʱ,�û���û�ж�������κ��ġ�
�������û�Ҫ�ر���һ����ʱ,�����CloseQu ery�¼�����Modified
Count()����鿴����Ƿ���,�õ��Ľ����Ȼ������ı䡣�û���
�õ�һ����ʾ��Ϣ��:"�Ƿ���㱣����������?��/��/ȡ��"������
����Ȼ�Dz��ʺϵ�:��������û�ѡ����DZ���ʱ,��ЩԭӦ�ǿռ�¼
����Ҳ��Ϊ�������ݵ���,ϵͳ�����γ�SQL ��INSERT����ύ���
��,����Ľ���Ϊ���ӡ�Ϊ�ı���һ״��,���ǿ�����SetItemStat
us()������е�״̬��ΪNew!�����������в��벢��������ȱʡֵ
֮��,���е�״ֵ̬ΪNew!������ij���Ϳ��Եõ����ϵĹ��ܡ�
��Insert a new row in dw_1
long 1_Row
1_Row=dw_1,InsertRow(dw_1,GetRow())
dw_1,SetItem(1_Row,"discount_pct",0,10)
��Set th row status to New! so that the CloseQuery check
will only detectus er entries.
dw_1.SetItemStatus(1_Row,0,Primary!,New!)
ʹ��SetItemStatus����ʱ��һЩ״̬ת��������,�±�����ʾ��
�ǽ�ԭ����״̬�ı�Ϊ��һ״̬ʱ,������Ӱ�졣������ΪNo,��˵
������һ������������������Ч;�����и���˲�ͬ��״̬,���״
̬�Ƕ���ָ����״̬������6
��һ��״̬�ĸı䲻������ʱ,���Զ�ε���SetItemStatus�Ե�
�������״̬������, ��New!״̬���ܸij�NotModified!״̬,�ɽ�
��ij�DataModified!״̬,Ȼ���ٸij�NotMod ified!״̬��
--
[m[1;37m�� ��Դ:���ϴ�С�ٺ���Ϣ����վ bbs.nju.edu.cn��[FROM: hsia.nju.edu.cn][m
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads