Wednesday, March 7, 2007

Form Inherited

Do you experience with delphi form identically many time? If you do, you need to make it simple with inherited.
Actually this method is not something new, because delphi is OOP (Object Oriented Programming) and form is class. If you understanding class very well, you will not find serious trouble with this methode.
However this method doesn't need understanding of class, because this is very simple.
OK, let starting with :
-new application at your delphi and you would have form1 for default
-place one button and save your new application as project1 and form1 as form1
-click File->New->Other->project1->form1
-notice what happen :)
-place another button on your form
-Now you have Form2 identically with Form1, but you added with one button

it's simple, right?

In any complex form with code inside, this would help much without coding same things many times :)

Saturday, March 3, 2007

Getting Up Level

Getting Up Level

Leveling Database structure, is maight be not awkward for many programmer. I got problem when getting the up/upper level of some code. At last I found this way :


Suppose you have a data structure like this:

code varchar(10)
name varchar(100)
parent varchar(10)
level integer

code name parent level
------------------------------------
A1 AOne 1
A10 AOnezero A1 2
A11 AOneOne A1 2
A110 AOneOnezero A11 3


what is the up level 1 code of A110?

answer:
make the sql like this:
select * from table where level=1 and 'A110' like concat(code,'%')