Database Query and other components inside complex Delphi component

Hi!

I am trying to develop Delphi DB component for displaying and editing customer data. Many tables (like, carts) in my database references customer using foreign key (like carts.fk_customer) and users want to see a lot of data about customer in diferent forms. So - I am planning to make the component (apparently - derived from TPanel) with the usual properties - DataSource, DataField (for FK_CUSTOMER) and this component should process the changes of its data field (usually fk_customer) by reading addional d
ata from the query (component has DataSource property, so, this is possible to find the transaction of the DataSource.DataSet and assign this transaction to the component's query) inside this component and displaying in additional fields on this component.

I just wanted to chek whether this is the right solution?

Actually I am also confused which component - DB component (maybe TDataLink is not necessary in this case) or the usual non-DB component (apparently TDataLink is required in this case) - should I use for displaying and providing editing capabilities to the DataField. For the remaining fields in my component (for data from the customers table - like first_name, middle_name, last_name, contact information (multiple addresses) I can certainly use the usual database components, I guess...
0
Tom
5/7/2012 2:23:19 PM
public.delphi.vcl.writing 510 articles. 0 followers. Follow

3 Replies
910 Views

Similar Articles

[PageSpeed] 37

Tom Rhodes wrote:

> Hi!
> 
> I am trying to develop Delphi DB component for displaying and editing
> customer data. Many tables (like, carts) in my database references
> customer using foreign key (like carts.fk_customer) and users want to
> see a lot of data about customer in diferent forms. So - I am
> planning to make the component (apparently - derived from TPanel)
> with the usual properties - DataSource, DataField (for FK_CUSTOMER)
> and this component should process the changes of its data field
> (usually fk_customer) by reading addional d ata from the query
> (component has DataSource property, so, this is possible to find the
> transaction of the DataSource.DataSet and assign this transaction to
> the component's query) inside this component and displaying in
> additional fields on this component.
> 
> I just wanted to chek whether this is the right solution?


I would design this customer display as a TFrame with one additional
pubilc property that takes the customer's primary key as value. The
property would have a setter method that would retrieve the customer
data from the database when the primary key is changed. The frame would
contain whatever database access components it needs to get the data.
The form hosting the frame instance (you would have different forms
using this frame if I understand you correctly) would assign the
foreign key from its dataset to the frame's key property in a suitable
event of its dataset, perhaps AfterScroll.

This way the frame itself is independent of the form that uses it, and
different instances of the frame would also be independent of each
other. You could design the frame with data-aware controls as usual.
The downside is that each frame uses a separate query or dataset, but
they can all share the same database connection contained in some data
module.

-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://codenewsfast.com
http://groups.google.com
0
Peter
5/8/2012 10:06:47 AM
This may work but data binding remains in need for some improvement - e.g. one is required to call the Frame.Id assigment from the FK_CUSTOMERChanged event of the frame's host form (or datamodule) and one is required to assign FK_CUSTOMER field to frame as well - so that Frame can change the value of FK_CUSTOMER (it is not bad idea to display the customer data along the buttons and other components that let's to search and select another customer).

That leads to the idea about using TFieldDataLink as TCustomerFrame variable as it would be used it TCustomerFrame would be made as DB aware component. Apparently - The lifecycles of Frame and Component are different and TFieldDataLink perhaps is not appropriate in both cases. Is it good practice to use TFieldDataLink in frames?

Edited by: Tom Rhodes on May 8, 2012 12:34 PM
0
Tom
5/8/2012 7:35:16 PM
Tom Rhodes wrote:

> This may work but data binding remains in need for some improvement -
> e.g. one is required to call the Frame.Id assigment from the
> FK_CUSTOMERChanged event of the frame's host form (or datamodule) and
> one is required to assign FK_CUSTOMER field to frame as well - so
> that Frame can change the value of FK_CUSTOMER (it is not bad idea to
> display the customer data along the buttons and other components that
> let's to search and select another customer).
> 
> That leads to the idea about using TFieldDataLink as TCustomerFrame
> variable as it would be used it TCustomerFrame would be made as DB
> aware component. Apparently - The lifecycles of Frame and Component
> are different and TFieldDataLink perhaps is not appropriate in both
> cases. Is it good practice to use TFieldDataLink in frames?

Never tried that so cannot comment on it.

My solution would be to add a published event property to the frame
class that the host form could add a handler for. The frame would fire
the event when the user changes the customer displayed in the frame,
e.g. by searching or by adding a new customer. The event handler on the
host form would then take care of setting the new customer's key as
foreign key in its dataset.

This way reduces the coupling between frame and host form, the frame
needs to know absolutely nothing about the host form to work, and that
is what you aim for if you build reusable modules.



-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://codenewsfast.com
http://groups.google.com
0
Peter
5/9/2012 6:19:40 PM
Reply:

Similar Artilces:

.net component to Delphi component ?
Hello, Is there a way to use .net component inside Delphi ? Thanks On Tue, 18 Nov 2008 13:16:37 -0800, isaac sam wrote: > Is there a way to use .net component inside Delphi ? http://www.managed-vcl.com/ has some libraries for this. -- Marc Rohloff [TeamB] marc -at- marc rohloff -dot- com Marc Rohloff wrote: > On Tue, 18 Nov 2008 13:16:37 -0800, isaac sam wrote: > >> Is there a way to use .net component inside Delphi ? > > http://www.managed-vcl.com/ has some libraries for this. > I was hoping for a free tool but thanks On Tue, 18 Nov 2008...

SEPA components for Delphi with Source Code (Delphi 5
Hi all, in the european union change next year the Bankingformat to the SEPA Format. All peoples and companies must change the bankingssoftware and the costumer data form acountnummers in the new IBAN and BIC numbers. See: http://www.arma-it.de/shop/artikelueber.php?wgruppeid=211&wgruppe_offen=211 Functions: - generate SEPA XML'S - Calc IBAN - BIC Database (DE,AT and CH) Questions: vertrieb@arma-it.de PS: Bankinssoftware for Develpoers (Germany only) http://www.arma-it.de/shop/artikelueber.php?wgruppeid=212&wgruppe_offen=212 El 26/10/13 21:38, A...

ANN: Bricksoft IM VCL Component v8.2 released. All components support Delphi 2009!
All components support Delphi 2009! Please download the trial version(http://www.imcomponents.com/bsimtrial.zip) if you like. -- Bricksoft Support Bricksoft IM(MSN+YAHOO+AIM+ICQ+Jabber/GTalk) SDK For NET/VCL/COM/SOAP - http://www.imcomponents.com/ "Jianmin Wu" <nospam@nospam.com> wrote in message news:72535@forums.codegear.com... > All components support Delphi 2009! with D2009 support, do you still require TNT controls for unicode ? Also do you have any plans to support emoticons ? Regards, Danny Component and demo for D2009 don't need TNT cont...

Component toolbar in Delphi XE4 missing tabs and components
I installed my custom components package in the RAD Studio XE4 "personality" (both Delphi and C++Builder). It seemed to work fine and I could create a VCL test app for both Delphi and C++Builder with one of the components dropped on a form. But now I am investigating this further and I find that a lot of components are missing.. :-( I managed to get the components displayed as a tabbed ribbon across the top similar to in Delphi7 by going to View/Toolbars/Components. Then I could also drag it to a place on the screen where it could use the full width of the IDE. I then...

Delphi XE6 How to link FastReport components to FireDAC components?
Hi to all. I'm wondering on how to link FastReport componets to FireDAC components. A Delphi XE article "Creating Reports with FastReport (FireDAC)" tells about some misterious component called "TfrxComponents" that is used to do de job but I can't find it nowhere. FastReport demos uses ADOTables and ADOQuerys but no FDQueys neither FDTables. Is there any source code example for doing this? I'll appreciate any link than can help me to best understand my trouble. Regards, Hernando. First of all, FastReports has a propensity to uninstall itself. S...

Delphi XE6 How to link FastReport components to FireDAC components?
Hi to all. I'm wondering on how to link FastReport componets to FireDAC components. A Delphi XE article "Creating Reports with FastReport (FireDAC)" tells about some misterious component called "TfrxComponents" that is used to do de job but I can't find it nowhere. FastReport demos uses ADOTables and ADOQuerys but no FDQueys neither FDTables. Is there any source code example for doing this? I'll appreciate any link than can help me to best understand my trouble. Regards, Hernando. Please, contact FastReports company regarding FireDAC / FastRepor...

DesignIDE package and porting Delphi 7 components to Delphi XE2
HI I am porting components from Delphi7 to Delphi XE2, and started run in problems regarding MaskProp.dcu, some of the components uses this, and is looking for TMaskProperty class. After a lot of browsing on the net i figured out that all these units is packaged in the designide.dcp. So i have the design time component in a package that requires the designide.dcp and then the runtime component package that reguires the designtime package for the component. In the runtime component package i get errors regarding the MaskProp.dcu and the TMaskProperty class. I dont know what to do from ...

How to uninstall a VCL Component in Delphi 2007?
Guys How do I uninstall a VCL Component in Delphi 2007? Mark Moss Nevermind I figured out how to do it. Mark Moss "Mark Moss" <markemoss@comcast.net> wrote in message news:245205@forums.embarcadero.com... > Guys > > > How do I uninstall a VCL Component in Delphi 2007? > > > Mark Moss ...

Components in Components
I'm finishing up on a component that I've been creating at run-time but thought I'd go ahead and compile it and add it to my palette. The component contains a number of TPersistent components and a couple of TComponents. It's working well, and it compiles OK, but in the Object Inspector each of the TComponent properties has a drop-down control next to it, as if I was supposed to pick a component from a list. What is going on with this? Do I need to define the owner differently, or specify a parent-lik e object? I'd rather it just list the name of the class, like how i...

Spreadsheet component for use in Delphi VCL 2010
Good day I have been using the Flexcel component for reading and writing Excel spreadsheets in my Delphi VCL projects for some while and have been very happy. Unfortunately, though, a version for use with Excel 2007 format files (.XLSX) has been promised for years now but just never arrives and I have reached a stage where I just have to update some of my software. Can any body suggest alternatives and comment on their experience with these? I have no objection to buying a component although all my programs are for academic use by myself and colleagues/friends so cheaper would...

Delphi VCL components properties history articles
Hi, i would like to know where i can found Delphi VCL components properties history information because i need to know from wich Delphi version a property exists or from wich version a protected procedure was marcked with "virtual" command from a standard component. Thanks, Maurício "Julio Pião" <=?Utf-8?Q?Julio_Pi=C3=A3o?=> wrote in message news:292952@forums.embarcadero.com... > i would like to know where i can found Delphi VCL components > properties history information AFAIK, that kind of list does not exist anywhere. > i ...

Which VCL components are (not) included in Delphi XE5 starter?
I currently own RAD Studio 2010 Professional with which I have developed a few Delphi applications, mainly for personal use. I only develop for Windows 32-bit platform and do NOT use Database components, I consider switching from Delphi 2010 Professional to Delphi XE5 Starter Edition and would like to know if my current applications can be compiled with Delphi XE5 Starter. Is there a way to check this _before_ buying Delphi XE5 ? My main concern is that some VCL components from Delphi 2010 Professional are not included in Delphi XE5 Starter Edition, but I cannot find a list which components...

MAC OS-style VCL components for Delphi?
Hi all, I saw an application that I am interested in porting from C to Delphi (http://thirdcog.eu/apps/cfxr) and found it comes with a win32 version, using IMHO yucky controls, and a nice shiny native MAC version (Coca, etc). I really like the look, of the Mac port...I was wondering if there are any VCL controls (preferably free) that can make nice buttons, sliders, etc. like in that MAC screenshot? I'm not worried if they don't operate exactly like MAC ones, I mainly like the look :) I have tried googling but no luck so far :( cheers, Paul www.alphaskins...

skin component for VCL.NET Delphi 2007 ?
I'm trying to find out a component which skin forms automatically. It needs to be VCL.Net component for Delphi 2007. I tried to find one on the web with no success. There are many for VCL but not for VCL.Net. Thanks, Rumen ...

Web resources about - Database Query and other components inside complex Delphi component - public.delphi.vcl.writing

Component - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Spent on specs: are smartphone component wars overrated?
... made, or at least a few dozen? Ironically, many of the games that are recommended tend to be those that don't require blazing hardware components ...

Teardown of iPad Pro reveals revamped component layout
... Apple device teardown on the iPad Pro on Wednesday, revealing a reworked internal design dominated by massive batteries and bespoke audio components. ...

Corvette Stingray gets optional Z06 components
Filed under: Chevrolet , Coupe , Performance Chevrolet announces a series of upgrades available for the Corvette Stingray derived from the equipment ...

Crew, faulty component caused AirAsia crash
Indonesian investigators said crew action and a faulty component caused the AirAsia jet crash in the Java Sea last year, killing 162 passengers. ...

IDG Contributor Network: Four critical patches for November Patch Tuesday update core Windows and Office ...
Microsoft's November Patch Tuesday brings us four critical updates and eight important patches that attempt to resolve 54 reported vulnerabilities ...

DeBoer makes no excuses for components Sharks are missing
... 58° Navigation Home Giants A's Sharks Warriors Kings 49ers Raiders Quakes Insiders More Tickets Shop Watch DeBoer makes no excuses for components ...

Immigration Law Enforcement: A Vital Component Of National Security And Counterterrorism
While the administration claims that these refugees are being vetted, there is no way to actually screen these people

Pneumatic component maker Taiwan Chelic debuts on TSE
Shares of pneumatic automation component maker Taiwan Chelic started trading on the Taiwan Stock Exchange (TSE) on October 27 with an initial ...

Teflon Component Tied to Kids' Weight Gain
PFOA, a main component of Teflon, has been linked to increased body fat and faster weight gain in children.

Resources last updated: 12/1/2015 1:15:11 PM