KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

GridView: Order Entry

 
Post new topic   Reply to topic    KiXforms Forum Index -> Script Archive
View previous topic :: View next topic  
Author Message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Thu Jan 13, 2005 3:43 pm    Post subject: GridView: Order Entry Reply with quote

If anyone wants to grab the latest dev build, and give this script a try - its kinda where were "heading" with gridview, in terms of it being a very core and versitile part of Kixforms...

Note: This script requires the most recent dev. build.

Code:

break on

$system = createobject("kixtart.system")

$form = $system.form()
$form.clientsize = 640,480
$form.text = "Order Form"
$form.font = $system.font("verdana",10)
$form.cellpadding = 10

$categories = $system.listitemcollection()
$= $categories.add("Markers")
$= $categories.add("Pens")
$= $categories.add("")

$pens = $system.listitemcollection()
$= $pens.add("Flexgrip highlighter",1.00)
$= $pens.add("Gripper ball",0.50)
$= $pens.add("Retractable",0.50)
$= $pens.add("Roundedge stick pens",0.50)
$= $pens.add("Rubber grip",0.75)
$= $pens.add("Rubberstik",1.00)
$= $pens.add("Stainless steel ballpoint",1.00)
$= $pens.add("Stick pen",0.50)
$= $pens.add("Twist erase pencil",0.75)

$markers = $system.listitemcollection()
$= $markers.add("Gold",2.00)
$= $markers.add("Permanent",1.50)
$= $markers.add("Silver",1.75)
$= $markers.add("White paint",1.25)

$heading = $form.richtextbox()
$heading.font = $system.font("verdana",16)
$heading.height = 70
$heading.dock = "top"
$heading.locked = 1
$heading.html = "
<body bgcolor=lightblue><font size=4 color=blue><center><b>Order Entry Form</b></center></font>
<font size=2>
Select a <b>Category</b>, then a <b>Description</b>. The <b>Unit Cost</b> is extracted for you. Enter
the number of <b>Units</b> purchased, the <b>Total</b> is calculated <i>automatically</i>.
</font>
"

$gridview = $form.gridview()
$gridview.dock = "fill"
$gridview.oncellvaluechanged = "cellvaluechanged()"
$gridview.allowsorting = 0

$gridview.gridlinecolor = $system.color("black")

$column = $gridview.columns.add("Category")
$column.celltype = "combobox"
$column.items = $categories
;$column.backcolor = $system.color("khaki")

$column = $gridview.columns.add("Description")
$column.celltype = "combobox"
$column.width = 200
;$column.backcolor = $system.color("khaki")

$column = $gridview.columns.add("Unit Cost")
$column.celltype = "textbox"
$column.valuetype = "currency"
$column.locked = 1
$column.backcolor = $system.color("khaki")

$column = $gridview.columns.add("Units")
$column.celltype = "textbox"
$column.valuetype = "number"
;$column.backcolor = $system.color("khaki")

$column = $gridview.columns.add("Total")
$column.celltype = "textbox"
$column.valuetype = "currency"
$column.celltype = $system.textboxcelltype()
$column.locked = 1
$column.backcolor = $system.color("khaki")

$gridview.rowcount = 20

$gridview.cells(16,3).text = "SUBTOTAL"
$gridview.cells(16,3).locked = 1
$gridview.cells(16,4).value = 0

$gridview.cells(17,2).text = "PST"
$gridview.cells(17,2).locked = 1
$gridview.cells(17,3).text = 0.07
$gridview.cells(17,3).format = "0%"
$gridview.cells(17,4).value = 0

$gridview.cells(18,2).text = "GST"
$gridview.cells(18,2).locked = 1
$gridview.cells(18,3).text = 0.08
$gridview.cells(18,3).format = "0%"
$gridview.cells(18,4).value = 0

$gridview.cells(19,3).text = "TOTAL"
$gridview.cells(19,3).locked = 1
$gridview.cells(19,4).value = 0

;; cache some row indexes

$subtotalrow = $gridview.columns("units").find("subtotal",,2)
$pstrow = $gridview.columns("unit cost").find("pst")
$gstrow = $gridview.columns("unit cost").find("gst")
$totalrow = $gridview.columns("units").find("total",,2)

$gridview.currentrowindex = 0
$gridview.currentcolumnindex = 0

$form.center()
$form.show()
$gridview.focus

while $form.visible
 $= execute($form.doevents())
loop

exit 1

function gridclick()

endfunction

function cellvaluechanged()

 dim $subtotal

 $col = $gridview.eventargs.changedcolumnindex
 $row = $gridview.eventargs.changedrowindex

 select

  case $col = 0 ;; category

   select

    case $gridview.cells($row,0).text = ""

     $gridview.rows($row).cells(0).text = ""
     $gridview.rows($row).cells(1).text = ""
     $gridview.rows($row).cells(1).items = 0

    case $gridview.cells($row,0).text = "pens"

     $gridview.rows($row).cells(1).items = $pens

    case $gridview.cells($row,0).text = "markers"

     $gridview.rows($row).cells(1).items = $markers

   endselect

   $gridview.rows($row).cells(2).text = ""
   $gridview.rows($row).cells(3).text = ""
   $gridview.rows($row).cells(4).text = ""

  case $col = 1 ;; description

   $gridview.rows($row).cells(2).text = $gridview.rows($row).cells(1).value
   $gridview.rows($row).cells(3).value = 1

 endselect

 if $gridview.rows($row).cells(1).text <> ""
  $gridview.rows($row).cells(4).text = $gridview.rows($row).cells(2).value * $gridview.rows($row).cells(3).value
 endif

 $subtotal = 0.0

 for $i = 0 to $subtotalrow - 1

  $subtotal = $subtotal + $gridview.rows($i).cells(4).value

 next

 $pst = $subtotal * $gridview.rows($pstrow).cells(3).value
 $gst = $subtotal * $gridview.rows($gstrow).cells(3).value

 $gridview.rows($subtotalrow).cells(4).value = $subtotal
 $gridview.rows($pstrow).cells(4).value = $pst
 $gridview.rows($gstrow).cells(4).value = $gst
 $gridview.rows($totalrow).cells(4).value = $subtotal + $pst + $gst

endfunction   
Back to top
View user's profile Send private message
masken
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 14 Mar 2003
Posts: 202
Location: Gothenburg, Sweden

PostPosted: Fri Jan 14, 2005 10:55 am    Post subject: Reply with quote

Besides that the Cost column doesnt work (doesnt display cost) it looks slick Smile

ps, when a drop down isn't selectable, shouldn't it be grayed out?
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Script Archive All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group