xqin
|
Posted: 05/11/2003, 1:39 PM |
|
Hi,
There is a multi-selection Checkbox implementation in the Example Pack
coming with CCS 2.0. It's in ASP and works just fine. Could anyone convert
it to PHP?
*****populate the CheckBox*****
Function employees_record_BeforeShow() 'employees_record_BeforeShow
@14-4429F99B
'Custom Code @34-73254650
'Declare variables
Dim ProjectConnection
Dim ProjectRecordSet
Dim ArraySize
Dim ArrayProject()
'Populate the multi-select project CheckBox list
If employees_record.EditMode Then
ArraySize = 1:
ReDim ArrayProject(0)
'Create a new database connection object
Set ProjectConnection = New clsDBIntranetDB
ProjectConnection.Open
Set ProjectRecordSet = ProjectConnection.Execute("SELECT project_id FROM
projects_employees WHERE emp_id =" &
ProjectConnection.ToSQL(CCGetParam("emp_id", ""),ccsInteger ) )
While NOT ProjectRecordSet.EOF
ReDim Preserve ArrayProject(ArraySize)
ArrayProject(ArraySize) = ProjectRecordSet("project_id")
ProjectRecordSet.MoveNext
ArraySize = ArraySize + 1
Wend
employees_record.ProjectList.IsMultiple = True
employees_record.ProjectList.MultipleValues = ArrayProject
'Close and destroy the recordset
ProjectRecordSet.Close
Set ProjectRecordSet = Nothing
'Close and destroy the database connection object
ProjectConnection.Close
Set ProjectConnection = Nothing
End If
'End Custom Code
End Function 'Close employees_record_BeforeShow @14-54C34B28
****Customer insert/update/delete*****
Function ProjectEmployeesModify(Actions)
Dim EmpProjectConn
Dim EmpID
Dim ProjectID
Dim ProjectList
Dim GetLastInsKey
'Create a new database connection object
Set EmpProjectConn = New clsDBIntranetDB
EmpProjectConn.Open
'Retrieve current project
EmpID = Request.QueryString("emp_id")
ProjectList = Split(Request.Form("ProjectList"),",")
If Actions = "Insert" Then
'Retrieve the last inserted key
'Use MS SQL method (disabled below)
' GetLastInsKey = CCDLookup("@@IDENTITY","employees","",DBIntranetDB)
'Use a method compatible with all databases (unsafe when multiple users
insert records at the same time)
GetLastInsKey = CCDLookup("max(emp_id)", "employees", "", DBIntranetDB)
'Insert New links
For Each ProjectID In ProjectList
EmpProjectConn.Execute("INSERT INTO projects_employees (project_id,
emp_id) VALUES (" & EmpProjectConn.ToSQL(ProjectID,ccsInteger) & "," &
EmpProjectConn.ToSQL(GetLastInsKey,ccsInteger) & ")")
Next
End If
If EmpID > 0 Then
If Actions = "Delete" Or Actions = "Update" Then
'Delete project employees links
EmpProjectConn.Execute("DELETE FROM projects_employees WHERE emp_id="
& EmpProjectConn.ToSQL(EmpID,ccsInteger))
End If
If Actions = "Update" Then
'Insert assigned employees
For Each ProjectID In ProjectList
EmpProjectConn.Execute("INSERT INTO projects_employees (project_id,
emp_id) VALUES (" & EmpProjectConn.ToSQL(ProjectID,ccsInteger) & "," &
EmpProjectConn.ToSQL(EmpID,ccsInteger) & ")")
Next
End If
End If
'Close and destroy the database connection object
EmpProjectConn.Close
Set EmpProjectConn = Nothing
End Function
thanks
xiaoming
|
|
|
|