View Single Post
  #5 (permalink)  
Old January 20th, 2005, 12:10 PM
pjmair pjmair is offline
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is the whole thing... on the repeater control my alternating and normal templates have different code to try to call that Delete_Click function, neither works of course...

Thanks!

Code:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<head>
<title>Direct Costs Administration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<Link REL="stylesheet" Type="text/css" HREF="/apps/styles/ows.css">
<Link REL="stylesheet" Type="text/css" HREF="/apps/styles/env.css">
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-image: url(/apps/images/main_bg.jpg);
}
-->
</style>
<Script Runat="Server">
Dim Amount As Decimal
Dim Total As Decimal = 0
Dim BDate As String

Sub Page_Load
        If Not Page.IsPostBack Then
            Dim conTSE as SqlConnection
            Dim project_number

            project_number = Request.QueryString("proj_num")
            txtProjectNumber.Text = project_number

            conTSE = New SqlConnection("server=ENVWDB;uid=web;pwd=xzalr62yyp;database=TimesheetExpress;")
            conTSE.Open()

            Dim    cmdOldCosts    As SqlCommand
            Dim dtrOldCosts As SqlDataReader

            cmdOldCosts = New SqlCommand( "SELECT * FROM direct_costs WHERE proj_no = '" & project_number & "' ORDER BY cost_date DESC", conTSE )
            dtrOldCosts = cmdOldCosts.ExecuteReader()

            rptOldCosts.DataSource = dtrOldCosts
            rptOldCosts.DataBind()

            dtrOldCosts.Close()
            conTSE.Close()
        End If
End Sub

Function Delete_Click(string env_id)
    Dim strTest
    strTest = env_id
    Response.Write( "I want to delete record: " & strTest)
End Function


Function GetTotal()
  Return FormatCurrency(Total)
End Function

Function FormatDate(ADate as String)
  BDate = ADate
  Return BDate
End Function

Function AddBling(Cost As Decimal)
  Total += Cost
  Return FormatCurrency(Cost)
End Function

Function Format2Decs(x As String)
  If Len(x)=0 Then
      Return ""
  Else
    Return Decimal.Parse(x).ToString( "f" )
  End If
End Function


</SCRIPT>
</head>
<%
dim project_number
project_number = Request.QueryString("proj_num")
%>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="ms-main">
  <tr height="31">
    <td width="150" valign="top" background="/apps/images/top_blue_gold_bar.jpg"><img src="/apps/images/top_left_sp_icon.jpg"></td>
    <td valign="middle" align="right" style="padding-right: 7px" class="ms-banner" background="/apps/images/top_blue_gold_bar.jpg"><a href="http:\\envwdb\hr\">Up to Environics HR Web</a></td>
  </tr>
  <tr>
    <td><img src="/apps/images/tse_icon.jpg"></td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <tr><td width='6'><img src="/apps/images/spacer.gif" height="1" width="6"></td><td class="ms-titlearea">Environics HR Web</td></tr>
        <tr><td width='6'><img src="/apps/images/spacer.gif" height="1" width="6"></td><td class="ms-pagetitle">Direct Costs Administration</td></tr>
      </table>
    </td>
  </tr>
  <tr height="1">
    <td background="/apps/images/gold_bar_1x1.jpg" colspan="2"><img src="/apps/images/spacer.gif" height="1" width="1"></td>
  </tr>
  <tr>
    <td colspan="2">
      <table class="ql-header" cellpadding="4">
        <tr height="1"><td colspan="2"><img src="/apps/images/spacer.gif" height="1" width="1"></td></tr>
        <tr>
          <td width='5'>&nbsp;</td>
          <td><a href="add_costs.aspx">Add Cost Item</a></td>
        </tr>
        <tr>
          <td width='4'>&nbsp;</td>
          <td><a href="edit_costs_pick.aspx">Edit Cost Item</a></td>
        </tr>
        <tr>
          <td width='4'>&nbsp;</td>
          <td><a href="delete_costs_pick.aspx">Delete Cost Item</a></td>
        </tr>
      </table>
    </td>
  </tr>
</table>

<div id="gohome" style="position:absolute;left:30px;top:9px">
<p class="ms-banner"><a href="http:\\envwdb">Intranet Home</a></p>
</div>

<div id="main" style="position:absolute;left:157px;top:93px">
<table width="800" class="ms-vb" cellpadding="0" cellspacing="0" border="0">
  <tr height="17">
    <td valign="middle" background="../images/title_shading.jpg" class="ql-header">&nbsp;Delete Costs For <%=project_number%></td>
  </tr>
</table>
<form runat="server">
<table width="800" class="ms-vb" cellpadding="5" cellspacing="0" border="0">
  <tr>
    <td colspan="3">A full listing of current costs associated with this project is shown below.  Click the 'Delete' link beside any cost to edit it.</td>
  </tr>
  <tr>
    <td colspan="3" align="left">
        <asp:Repeater ID="rptOldCosts" runat="server">
                    <headertemplate>
                      <table border="1" style="border-collapse:collapse" font-name="verdana" Font-Size="8pt">
                        <tr style="background-color:#E1EDFD; color:#FFFFFF">
                          <th class="ql-header" align="center" width="80" height="17">Delete Cost</th>
                          <th class="ql-header" align="center" width="100">Cost Date</th>
                          <th class="ql-header" align="center" width="100">Expense Code</th>
                          <th class="ql-header" align="center" width="250">Description</th>
                          <th class="ql-header" align="center" width="80">Hours</th>
                          <th class="ql-header" align="center" width="80">Cost/Hour</th>
                          <th class="ql-header" align="center" width="80">Cost</th>

                        </tr>
                      </HeaderTemplate>

                    <itemtemplate>
                      <tr>
                        <td height="17"><div align="center"><a href='<%# "edit_this_cost.aspx?project=" & txtProjectNumber.Text & "id=" & Container.DataItem( "env_id" ) %>'><img src="../images/delete.GIF" border="0"></a></div></td>
                        <td><div align="center"><%# FormatDate(Container.DataItem( "cost_date" )) %></div></td>
                        <td><div align="center"><%# Container.DataItem( "task_desc_env" ) %></div></td>
                        <td><div align="left"><%# Container.DataItem( "description" ) %></div></td>
                        <td><div align="center"><%# Format2Decs(Container.DataItem( "units" ).ToString()) %></div></td>
                        <td><div align="center"><%# Format2Decs(Container.DataItem( "cost_per" ).ToString()) %></div></td>
                        <td><div align="right"><%# AddBling(Container.DataItem( "cost" )) %></div></td>

                      </tr>
                    </itemtemplate>

                    <AlternatingItemTemplate>
                      <tr style="background-color:#F0F0F0">
                        <td height="17"><div align="center"><img src="../images/delete.GIF" border="0" onClick="Delete_Click(<%# Container.DataItem( "env_id" )%>);"></div></td>
                        <td><div align="center"><%# FormatDate(Container.DataItem( "cost_date" )) %></div></td>
                        <td><div align="center"><%# Container.DataItem( "task_desc_env" ) %></div></td>
                        <td><div align="left"><%# Container.DataItem( "description" ) %></div></td>
                        <td><div align="center"><%# Format2Decs(Container.DataItem( "units" ).ToString()) %></div></td>
                        <td><div align="center"><%# Format2Decs(Container.DataItem( "cost_per" ).ToString()) %></div></td>
                        <td><div align="right"><%# AddBling(Container.DataItem( "cost" )) %></div></td>

                      </tr>
                    </AlternatingItemTemplate>

                    <FooterTemplate>
                      <tr align="right">
                        <th colspan="6" style="background-color:#F0F0F0; color:#333333" height="17">Total:</th>
                        <td><b><%# GetTotal() %></b></td>
                      </tr>
                    </table>
                    </FooterTemplate>
                    </asp:Repeater>
    </td>
  </tr>
</table> 
<asp:TextBox ID="txtProjectNumber" runat="server" visible="false"/> 
</form>
</div>
</body>
</html>