Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch Insert from a detail page (asp)

Status
Not open for further replies.

ammodog6942

Programmer
Feb 5, 2008
7
US
I am trying to do a batch insert from a detail page. I have a department table, employee table, and a employee financial table. On the detail page I can bring over the employeeid, departmentid, and the financialid and populate the page with all employees and their different accounts:

Example:

Smith, john | IT Department | Account1
Smith, john | IT Department | Account2
Taylor, Suzy | HR | Account 1

I then want to enter in some time sheet number values for all and have it inserted in to the database table tbldepttransactions while bringing over each employeeid, departmentid, and the financialid along with the entered values.

Example:

Smith, john | IT Department | Account1 |25|32|5|
Smith, john | IT Department | Account2| 23|1|3|
Taylor, Suzy | HR | Account 1 |25|32|5|

I can do this one at a time but Im having problems with the multiple entries on one page, I've thought of possibly doing some kind of loop but I am unsure on how to accomplish this. Thank You for your help
 
Here is the code of what I have so far as you can see i get the info from a query based on which department user is logged in by their department ID.

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/time.asp" -->
<%
Dim rsemployeelist__MMColParam
rsemployeelist__MMColParam = "1"
If (Session("MM_departmentid") <> "") Then
rsemployeelist__MMColParam = Session("MM_departmentid")
End If
%>
<%
Dim rsemployeelist
Dim rsemployeelist_cmd
Dim rsemployeelist_numRows

Set rsemployeelist_cmd = Server.CreateObject ("ADODB.Command")
rsemployeelist_cmd.ActiveConnection = MM_time_STRING
rsemployeelist_cmd.CommandText = "SELECT * FROM qryemployeefinancialrecord WHERE departmentid = ?"
rsemployeelist_cmd.Prepared = true
rsemployeelist_cmd.Parameters.Append rsemployeelist_cmd.CreateParameter("param1", 5, 1, -1, rsemployeelist__MMColParam) ' adDouble

Set rsemployeelist = rsemployeelist_cmd.Execute
rsemployeelist_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsemployeelist_numRows = rsemployeelist_numRows + Repeat1__numRows
%><title>Johnson County Payroll Voucher and Time Application</title>
<style type="text/css">
<!--
.style3 {font-size: 9px}
-->
</style>
<p>&nbsp;</p>
<p align="center"><strong><img src="images/money.jpg" width="115" height="121" align="middle" />Johnson County Payroll Voucher and Time Application</strong><img src="images/clock.jpg" width="101" height="121" align="absmiddle" /></p>
<form id="form1" name="form1" method="post" action="">
<table width="1544" border="1">
<tr>
<td width="207"><div align="center"><span class="style3">Employee</span></div></td>
<td width="138"><div align="center"><span class="style3">Approp. #</span></div></td>
<td width="65"><div align="center"><span class="style3">Pay Start</span></div></td>
<td width="57"><div align="center"><span class="style3">Pay End</span></div></td>
<td width="48"><div align="center"><span class="style3">Hours Worked</span></div></td>
<td width="48"><div align="center"><span class="style3">Overtime Hours</span></div></td>
<td width="48"><div align="center"><span class="style3">Comp. Time Earned</span></div></td>
<td width="48"><div align="center"><span class="style3">Holiday</span></div></td>
<td width="48"><div align="center"><span class="style3">Vacation Used</span></div></td>
<td width="48"><div align="center"><span class="style3">Sick Used</span></div></td>
<td width="48"><div align="center"><span class="style3">Personal Used</span></div></td>
<td width="48"><div align="center"><span class="style3">Comp. Time Used</span></div></td>
<td width="48"><div align="center"><span class="style3">Funeral</span></div></td>
<td width="48"><div align="center"><span class="style3">Military</span></div></td>
<td width="48"><div align="center"><span class="style3">Jury Duty</span></div></td>
<td width="48"><div align="center"><span class="style3">Leave W/O pay</span></div></td>
<td width="48"><div align="center"><span class="style3">Family &amp; Med Leave</span></div></td>
<td width="48"><div align="center"><span class="style3">Other (Explain in Notes</span></div></td>
<td width="287"><div align="center"><span class="style3">Notes</span></div></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsemployeelist.EOF))
%>
<tr>
<td height="87"><div align="center"><span class="style3">
<label> <%=(rsemployeelist.Fields.Item("last").Value)%>, <%=(rsemployeelist.Fields.Item("first").Value)%><br />
</label>
</span></div></td>
<td><div align="center"><span class="style3"></span><%=(rsemployeelist.Fields.Item("appropnumber").Value)%></div></td>
<td><div align="center">
<input name="paystart" type="text" id="paystart" size="8" />
</div> <label></label></td>
<td><div align="center">
<input name="payend" type="text" id="payend" size="8" />
</div></td>
<td><div align="center">
<input name="regularhours" type="text" id="regularhours" size="8" />
</div></td>
<td><div align="center">
<input name="overtimehours" type="text" id="overtimehours" size="8" />
</div></td>
<td><div align="center">
<input name="comptimeearned" type="text" id="comptimeearned" size="8" />
</div></td>
<td><div align="center">
<input name="holiday" type="text" id="holiday" size="8" />
</div></td>
<td><div align="center">
<input name="vacationused" type="text" id="vacationused" size="8" />
</div></td>
<td><div align="center">
<input name="sickused" type="text" id="sickused" size="8" />
</div></td>
<td><div align="center">
<input name="personalused" type="text" id="personalused" size="8" />
</div></td>
<td><div align="center">
<input name="comptimeused" type="text" id="comptimeused" size="8" />
</div></td>
<td><div align="center">
<input name="funeral" type="text" id="funeral" size="8" />
</div></td>
<td><div align="center">
<input name="military" type="text" id="military" size="8" />
</div></td>
<td><div align="center">
<input name="juryduty" type="text" id="juryduty" size="8" />
</div></td>
<td><div align="center">
<input name="leavewithoutpay" type="text" id="leavewithoutpay" size="8" />
</div></td>
<td><div align="center">
<input name="familyandmedicalleave" type="text" id="familyandmedicalleave" size="8" />
</div></td>
<td><div align="center">
<input name="otherleave" type="text" id="otherleave" size="8" />
</div></td>
<td><label>
<div align="center">
<textarea name="notes" id="notes" cols="45" rows="5"></textarea>
</div> </label></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsemployeelist.MoveNext()
Wend
%>

</table>
</form>
<p align="center">&nbsp;</p>

<%
rsemployeelist.Close()
Set rsemployeelist = Nothing
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top