Wednesday, April 14, 2010

Tips & Trick on SS Classes

Tips & Tricks # 1: Using SSCAL on acquiring transactions for the day

- click on the image to see it in its real size -

When I first decided to create the Editing module, I decided to utilize my SSCAL in acquiring the transactions for that day. So user will simply click on the day shown on SSCAL or navigate to the appropriate one. To do that, I have to tap into the Opgday Object of my SSCAL, Click event and place these:

DODEFAULT()
thisform._gridrefresh()
thisform.grid1.AfterRowColChange()


We will break the above one by one.

As you can see, DODEFAULT() is necessary to instruct SSCAL to perform whatever it is assigned to do then do some more which is calling a method for grid refreshing and calling also the grid's AfterRowColChange event which is basically needed to update display of other objects.

What I am doing now is moving away from SAFE SELECT approach, not that it is not working properly but I am trying to avoid too much record movements between cursors. All we need to do, to avoid Grid Reconstruction is simply something like this:

Thisform._GridRefresh Method:

* Reset RecordSource first
Thisform.grid1.RecordSource =''


* Perform the necessary SQL Select command

Select vchrno, liter, mreading, Alltrim(assets.assetno)+'-'+Alltrim(assets.xdescript) As xasset, fuelpk From fuelvchr ;

LEFT Outer Join assets On fuelvchr.assetfk = assets.assetpk;

WHERE xdate == Thisform.sscal1._value Into Cursor junkgrid Readwrite


* Bind the grid to the cursor and refresh

Thisform.grid1.RecordSourceType= 1

Thisform.grid1.RecordSource = "junkgrid"

Thisform.grid1.Refresh


That is fast, compact and easier. Same result. What is more, it won't reconstruct a grid.



Thisform.Grid1.AfterRowColChange() Event:

I use this event instead of creating a separate method as we can also call this from anywhere inside the form. The result is basically the same. I am using this to update other objects such as textboxes, comboboxes, etc. Basically what it does is simply something like these:

Thisform.txtXdate.Value = fuelvchr.xdate
Thisform.txtVchrno.Value = fuelvchr.vchrno
Thisform.txtliter.Value = fuelvchr.liter
Thisform.txtMreading.Value = fuelvchr.mreading
Thisform.edtRemarks.Value = fuelvchr.remarks



... and some more...

And so what it does, basically, as I have said is showing the transactions keyed in for the day using SSCAL. Check again the image above so you can visualize how it is done.

That trick can be used both on the per subscription and free version. Hope this will be useful to you. Next Trick is utilizing two SSCALs at the same time. Enjoy!





No comments:

Post a Comment