CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 Master/Detail Tables in one Form

Print topic Send  topic

Author Message
Andres Rormoser
Posted: 11/18/2005, 6:52 AM

I manage to put a Master/Detail tables in one form, to submit both tables at the same
time. Here is the tutorial:

+ Add an Editable Grid for the Detail Table
+ Add Master Fields outside Begin/End Row Section
+ Change the properties of the Editable Grid:
Custom Insert Type: Table
Custom Insert: All the fields from the Detail table and the field with reference to the
master table get it from a session variable (x ej cve_id)
+ Add a BeforeShow Event to read the data of the Master Table from the database an
populate it to textboxes in the form

'Custom Code @85-73254650
' -------------------------
' declaro variables
dim cve_id, cve_fechaingreso, cve_cli_id, cve_bonificacion, cve_vco_id, cve_ven_id,
cve_vli_id, cve_vai_id, cve_mon_id, cve_vct_id
Dim SQL
Dim RecordSet
Dim UserId
Dim UserName
Dim WorkPhone
cve_id = CCGetParam("cve_id",0)
if cve_id<>0 then
' it's an update
' save id into session variable
Session("cve_id") = cve_id
' get data from database
SQL = "SELECT * FROM ComprobanteVenta WHERE cve_id="&cve_id
' Open the recordset
Set RecordSet = DBConnection1.Execute(SQL)
If DBConnection1.Errors.Count = 0 Then
If NOT RecordSet.EOF then
ComprobanteVentaDetalle.cve_fechaingreso.value = CCGetValue(RecordSet,
"cve_fechaingreso")
ComprobanteVentaDetalle.cve_cli_id.value = CCGetValue(RecordSet, "cve_cli_id")
ComprobanteVentaDetalle.cve_bonificacion.value = CCGetValue(RecordSet,
"cve_bonificacion")
ComprobanteVentaDetalle.cve_vco_id.value = CCGetValue(RecordSet, "cve_vco_id")
ComprobanteVentaDetalle.cve_ven_id.value = CCGetValue(RecordSet, "cve_ven_id")
ComprobanteVentaDetalle.cve_vli_id.value = CCGetValue(RecordSet, "cve_vli_id")
ComprobanteVentaDetalle.cve_vai_id.value = CCGetValue(RecordSet, "cve_vai_id")
ComprobanteVentaDetalle.cve_mon_id.value = CCGetValue(RecordSet, "cve_mon_id")
ComprobanteVentaDetalle.cve_vct_id.value = CCGetValue(RecordSet, "cve_vct_id")
End if
' Close the recordset
RecordSet.Close
Set RecordSet = Nothing
Else
DBConnection1.Errors.Clear
End If
end if

' -------------------------
'End Custom Code

+ Add a BeforeSubmit Event to read the Textboxes of the Master Fields in the Form and
update/insert into the table Master an get the id inserted

Function ComprobanteVentaDetalle_BeforeSubmit(Sender)
'ComprobanteVentaDetalle_BeforeSubmit @20-FC746084

'Custom Code @84-73254650
' -------------------------
' declare variables
dim cve_id, cve_fechaingreso, cve_cli_id, cve_bonificacion, cve_vco_id, cve_ven_id,
cve_vli_id, cve_vai_id, cve_mon_id, cve_vct_id, cve_emp_id
' read textboxes of master table
cve_id = CCGetParam("cve_id",0)
cve_fechaingreso = chr(34) & CCGetParam("cve_fechaingreso", Empty) & chr(34)
cve_cli_id = CCGetParam("cve_cli_id", Empty)
cve_bonificacion = CCGetParam("cve_bonificacion", Empty)

' declare variables
Dim SQL, rsGroups

' execute procedure to update/insert Master Field
SQL = "EXEC cve_ins_upd " & cve_id & "," & cve_fechaingreso & "," & cve_cli_id & "," &
cve_bonificacion
Set rsGroups = DBConnection1.Execute(SQL)
if not rsGroups.EOF and cve_id=0 then
' if it's an insert put the id inserted into cve_id session variable
Session("cve_id") = rsGroups("cve_id")
SQL = CCDLookup(Session("cve_id"),"","",DBConnection1)
end if
' -------------------------
'End Custom Code

%>

Regards, Andres Rormoser.


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.