I'm coming from the desktop side so I'm having a tough time getting into the paradigm of the web side. So here is my scenario that I need to solve:
I have two tables; clients and loans. There is a one to one relationship between clients and loans (yes I know that seems illogical but in this application each client can only have one loan). Not every client has a loan. I only want to create a record in the loan table if the client does indeed have a loan. So this is how I would like for this to work:
1. I have a grid that list all of the clients. The grid works great. We will call this ClientGrid.
2. I have built a dialogue for the loan table. This dialogue works great. We will call is LoanDg.
3. The unique key between the clients and loans table is client_id.
4. I have added a button called Loan to the ClientGrid as one of the grid columns (fields) and on the onClick Javascript I have added an open dialogue action that opens LoanDg.
Here comes my problem. For every client I only want one record in the loan table. So when the user clicks on the Loan button it should do one of two things; open LoanDg and populate it with the values of the already existing record, OR it should open to a blank dialogue with the primary key of client_id already filled in and not editable by the user. When the user clicks on Submit on LoanDg it would add the record to the loans table and from that point forward the user would simply be editing the existing record if they clicked on the Loan button again.
On the desktop side I would simply test for the existence of a record in the loan table that had the same client_id as the client table and if it did not exist I would create the record first before I opened a form or dialogue to allow the user to edit the loan record. However, on the web side this may be unnecessary (given the tools that are available) or at the very least I don't know how to do it.
I hope my explanation can be followed and I appreciate any one's help on my question.
CPGood
I have two tables; clients and loans. There is a one to one relationship between clients and loans (yes I know that seems illogical but in this application each client can only have one loan). Not every client has a loan. I only want to create a record in the loan table if the client does indeed have a loan. So this is how I would like for this to work:
1. I have a grid that list all of the clients. The grid works great. We will call this ClientGrid.
2. I have built a dialogue for the loan table. This dialogue works great. We will call is LoanDg.
3. The unique key between the clients and loans table is client_id.
4. I have added a button called Loan to the ClientGrid as one of the grid columns (fields) and on the onClick Javascript I have added an open dialogue action that opens LoanDg.
Here comes my problem. For every client I only want one record in the loan table. So when the user clicks on the Loan button it should do one of two things; open LoanDg and populate it with the values of the already existing record, OR it should open to a blank dialogue with the primary key of client_id already filled in and not editable by the user. When the user clicks on Submit on LoanDg it would add the record to the loans table and from that point forward the user would simply be editing the existing record if they clicked on the Loan button again.
On the desktop side I would simply test for the existence of a record in the loan table that had the same client_id as the client table and if it did not exist I would create the record first before I opened a form or dialogue to allow the user to edit the loan record. However, on the web side this may be unnecessary (given the tools that are available) or at the very least I don't know how to do it.
I hope my explanation can be followed and I appreciate any one's help on my question.
CPGood
Comment