can LlblGenPro generate code that will improve on the code that I have written here

Posts   
 
    
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 25-Jan-2006 16:06:50   

hiya,

I have a piece of messy code that I wrote that I hope can be improved by using llblGenPro.

The code assigns a value to a label, depending on the quantity of stock avaliable.


if (products.qty<= 0) {
            tdAmountOnHand.BgColor = "Red";    //inadequate stock levels 
                    
} else if (products.qty<= 5) {
            tdAmountOnHand.BgColor = "Green";   //adequate stock levels
        }

I can improve on this code slightly myself, but I was wondering, could LlbGenPro generate this logic if I created the correct objects in my database?

eg,could I add a "minimumAdequateStockLevel" field to my database so that I would not have to hard-code the numbers "0" and "5"?

ideally, I'd also like to be able to simply pass a "quantity" arg to an LlbGenPro generated object and have the correct "string" colour returned.

Is any of the above possible?

i hope the question made sense :-)

cheers,

yogi

gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 25-Jan-2006 17:18:00   

Hi,

IMHO this is seems the way to go.. You might create a property on the Products class returning a Color value, which could make it like:

tdAmountOnHand.BgColor = Products.StockColor;

But is the code LLBL based? If, then: Is Products a instance of collection or entityclass (based on the product"S" i would guess collection)

Do you have to retrieve the color value on more places than this?

Just trying to help,

Greets, Gab

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Jan-2006 06:28:12   

Just as Gabriel has suggested you might use own property on the Products generated Entity Class, inside the "CustomEntityCode" user code region .

Please refer to LLBLGen Pro documentation "Using the generated code - Adding your own code to the generated classes"

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 26-Jan-2006 11:59:09   

thanks folks,

I had hoped as much. I'll look into it.

cheers, yogi