Lab activity

Views:
 
Category: Education
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

Laboratory activity 1:

Laboratory activity 1 Relational database

Create a table:

Create a table Sitem1. dbf SSales1.dbf Field type icode char 2 Icode char 2 qty num 8 Descri char 20 Price num 8 2

Another table:

Another table SStocks1.dbf Field type Icode char 2 Qtysold num 8 2

Tasks:

T asks Create a GUI like below

Type the following on the keypress event of text 1:

Type the following on the keypress event of text 1 IF nkeycode =13 .or. nkeycode =9 then USE sitem1 INDEX sitem1 PUBLIC cIcode cIcode = SPACE(2) cIcode = ALLTRIM( this.Value ) SEEK cIcode IF FOUND() thisform.text2.Value=sitem1-> descri thisform.text3.Value= str (sitem1->price) thisform.text2.Enabled=.f. thisform.text3.Enabled=.f. thisform.command2.enabled=.f. ELSE MESSAGEBOX('item code does not exist!') thisform.command2.Enabled=.f. ENDIF thisform.Refresh ENDIF

Type the following codes in the keypress event of text 4:

Type the following codes in the keypress event of text 4 IF nkeycode =13 .or. nkeycode =9 USE sstocks1 SET ORDER TO icode LOCATE FOR icode =thisform.text1.Value IF FOUND() IF val ( this.Value )< (sstocks1.qtyohand) MESSAGEBOX('not enough stocks') ELSE ENDIF ENDIF thisform.Refresh endif

Type the following codes in the interactivechange event of text 4:

Type the following codes in the interactivechange event of text 4 PUBLIC nAmount nAmount =0 nAmount =sitem1->price*VAL(thisform.text4.Value) thisform.text5.Value=STR( nAmount ) thisform.text5.Enabled=.f. thisform.Refresh

Type the following codes in the keypress event of text 7:

Type the following codes in the keypress event of text 7 PRIVATE nCash,nChange,nCustomer nCash =0 nChange =0 nCash =VAL(thisform.text7.Value) IF nkeycode =13 .or. nkeycode =9 IF nCash >= nBill nChange = nCash-nBill thisform.text8.Value=STR( nChange ) thisform.command2.Enabled=.t. USE sgraph1 SHARED nCustomer =sgraph1->customer nCustomer =nCustomer+1 GO top RLOCK() nBill =sgraph1-> Bill+nBill replace sgraph1->Bill with nBill replace sgraph1->Customer WITH nCustomer UNLOCK ELSE MESSAGEBOX('not enough!') thisform.text7.SetFocus ENDIF ENDIF thisform.Refresh

Type the following codes in the click event of add item button:

Type the following codes in the click event of add item button PRIVATE cIcode,cDescri,nPrice,nQty cIcode =space(2) cDescri =SPACE(15) nQty =0 thisform.list1.RowSourceType= 1 thisform.list1.AddItem(thisform.text1.Value) thisform.list2.AddItem(thisform.text2.Value) thisform.list3.AddItem(thisform.text3.Value) thisform.list4.AddItem(thisform.text4.Value) thisform.list5.AddItem(thisform.text5.Value) nBill = nBill + VAL(thisform.text5.Value) thisform.text6.Value=STR( nBill ) nPrice =0 nAmount2=0

Type the following codes in the click event of add item button cont…:

Type the following codes in the click event of add item button cont… USE ssales1 EXCLUSIVE APPEND BLANK nQty =VAL(thisform.text4.Value) cIcode =thisform.text1.Value replace icode WITH cIcode ,; qty WITH nQty USE sstocks1 SET ORDER TO icode SEEK(thisform.text1.Value) IF FOUND() replace qtysold WITH VAL(thisform.text4.Value) replace qtyohand WITH qtyohand-qtysold ENDIF cIcode =' ' thisform.text1.Value= cIcode thisform.text2.Value= cDescri thisform.text3.Value= nPrice thisform.text5.Value=nAmount2 thisform.list1.Refresh thisform.list2.Refresh In the INIT event of additem button, type the following PUBLIC nBill nBill =0

Type the following codes in the click event of new transaction button:

Type the following codes in the click event of new transaction button thisform.list1.Clear thisform.list2.Clear thisform.list3.Clear thisform.list4.Clear thisform.list5.Clear nCash =0 nBill =0 nChange =0 thisform.text6.Value=STR( nBill ) thisform.text7.Value=STR( nCash ) thisform.text8.Value=STR( nChange ) thisform.text4.Value=' '

Run your program:

Run your program Deliverables (Quiz 1) create a simple point of sales program based on what you have just finished Email it to iamtribe@gmail.com set default to c:\DBMS2

authorStream Live Help