troubleshooting Question

asp.net / array

Avatar of Webboy2008
Webboy2008 asked on
ASP.NETASPC#
1 Comment1 Solution178 ViewsLast Modified:
Hi Experts!

Please review attached classic asp codes. I would like to do the following two items and see any experts can help.

1. Convert classic asp to aspx/c#
2. Once the Save Button is clicked, Save all of the record into MS SQL Server.
Last Five Columns (TTL PCS,TTL FT,TTL LM,MFBM, MFSM,CBM) are not necessary to save if it is too difficult to achieve this one.

Thanks,
<html>
<head>
<script type="text/javascript" language ="javascript" >
    function UpdateRow(x) {
        var _total = 0;
        var _totalFt = 0;
        var _totalLm = 0;
        for (var i = 0; i < 18; i++) {
            //===========================================================
            var _v = parseInt(document.getElementById(x + "_" + i).value);
            if (!isNaN(_v)) {
                _total += _v
            }
            //============================================================
            //Lm Calculation
            if (i == 0) {
                var _v2 = parseInt(document.getElementById(x + "_" + i).value * 995);
            }
            else if (i == 1) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 1220);
            }
            else if (i == 2) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 1530);
            }
            else if (i == 3) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 1830);
            }
            else if (i == 4) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 2130);
            }
            else if (i == 5) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 2440);
            }
            else if (i == 6) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 2740);
            }
            else if (i == 7) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 3050);
            }
            else if (i == 8) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 3350);
            }
            else if (i == 9) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 3660);
            }
            else if (i == 10) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 3960);
            }
            else if (i == 11) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 4270);
            }
            else if (i == 12) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 4570);
            }
            else if (i == 13) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 4880);
            }
            else if (i == 14) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 5180);
            }
            else if (i == 15) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 5490);
            }
            else if (i == 16) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 5790);
            }
            else if (i == 17) {
            var _v2 = parseInt(document.getElementById(x + "_" + i).value * 6100);
            }
            else {
                var _v2 = parseInt(document.getElementById(x + "_" + i).value);
            }
            if (!isNaN(_v2)) {
                _totalLm += _v2
            }
            
            //============================================================
            //Ft Calculation
            if (i == 0) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 3);
            }
            else if (i == 1) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 4);
            }
            else if (i == 2) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 5);
            }
            else if (i == 3) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 6);
            }
            else if (i == 4) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 7);
            }
            else if (i == 5) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 8);
            }
            else if (i == 6) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 9);
            }
            else if (i == 7) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 10);
            }
            else if (i == 8) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 11);
            }
            else if (i == 9) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 12);
            }
            else if (i == 10) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 13);
            }
            else if (i == 11) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 14);
            }
            else if (i == 12) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 15);
            }
            else if (i == 13) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 16);
            }
            else if (i == 14) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 17);
            }
            else if (i == 15) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 18);
            }
            else if (i == 16) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 19);
            }
            else if (i == 17) {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value * 20);
            }
            else {
                var _v1 = parseInt(document.getElementById(x + "_" + i).value);
            }
            if (!isNaN(_v1)) {
                _totalFt += _v1
            }
            //=============================================================
        }
        //========================================================
        //Final Formula:
        document.getElementById("Total_" + x).value = _total;
        document.getElementById("TotalFt_" + x).value = _totalFt;
        document.getElementById("TotalLm_" + x).value = Math.round(_totalLm/1000);
        //========================================================
    }    
    </script>
</head>
<body>
<%
with response
.Write "<form action=""testing101.asp"" method=""post"" name=""frmPost"">"
.Write "<table>"
.Write "<tr><td>How many PKG#:</td><td><input name=""TxtPkg"" value=" & request.Form("TxtPkg") & ">&nbsp;<input type=""Submit"" name=""Btn_PkgRequest""></td></tr>"
.Write "</table>"
.Write "</form>"
end with

Row=Request.Form("TxtPkg")
 If Row <> "" Then
    Row = cint(Row)
    Column = Cint(17)
    ReDim Tatty(Column,Row) 
 Else
    ReDim Tatty(17,1) '=18 columns, 3 rows 
 End If
response.Write "<form action=""testing101.asp"" method=""post"" name=""frmPostData"">"
response.Write "<table>"
Response.Write "<tr><td>Column:</td><td>" & UBound(Tatty,1)+1 & "</td></tr>"
Response.Write "<tr><td>Row:</td><td>" & UBound(Tatty,2) & "</td></tr>"
response.Write "</table>"
response.Write "<table border=""0"">"
response.Write "<tr valign=""bottom""><td colspan=""19"">QuoteId: 1000</td><td><b>TTL PCS</b></td><td><b>TTL FT</b></td><td><b>TTL LM</b></td><td><b>MFBM<br>MFSM</b></td><td><b>CBM</b></td></tr>"
response.Write "<tr align=""right""><td><br></td><td>995</td><td>1220</td><td>1530</td><td>1830</td>"
response.Write "<td>2130</td><td>2440</td><td>2740</td><td>3050</td>"
response.Write "<td>3350</td><td>3660</td><td>3960</td><td>4270</td><td>4570</td>"
response.Write "<td>4880</td><td>5180</td><td>5490</td><td>5790</td><td>6100</td>"
response.Write "</tr>"
response.Write "<tr align=""right"">"
Response.Write "<td><b>PKG#</b></td>"
For i = 3 to 20
Response.Write "<td>" & i & "</td>"
Next
response.Write "</tr>"
For I=0 to UBound(Tatty,2) - 1'read the rows
        response.Write "<tr>"
        response.Write "<td>"
        response.Write "<input size=4 name=Ddl" & i & ">"
        response.Write "</td>"
        For X = 0 To UBound(Tatty,1) 'read the columns
        TmpUse = I & X
        Response.Write "<td>"
        Response.Write "<input onkeyup=""this.value=this.value.replace(/\D/gi,'');"" maxlength=""4"" onblur =""UpdateRow(" & I & ")"" name=" & I & "_" & X & " id=" & I & "_" & X & " size=1>"
        Response.Write "</td>" 
        Next
        If Right(TmpUse,2) = 17 Then
                Response.Write "<td><input readonly  size=4 id=Total_" & Left(TmpUse,1) & " name=Total_"   & Left(TmpUse,1) & "></td>"
                Response.Write "<td><input readonly  size=4 id=TotalFt_" & Left(TmpUse,1) & " name=TotalFt_" & Left(TmpUse,1) & "></td>"
                Response.Write "<td><input readonly  size=4 id=TotalLm_" & Left(TmpUse,1) & " name=TotalLm_" & Left(TmpUse,1) & "></td>"
                Response.Write "<td><input readonly  size=4 id=TotalMfbm_" & Left(TmpUse,1) & " name=TotalMfbm_" & Left(TmpUse,1) & "></td>"
                Response.Write "<td><input readonly  size=4 id=TotalCbm_" & Left(TmpUse,1) & " name=TotalCbm_" & Left(TmpUse,1) & "></td>"
        End If
        response.Write "</tr>"
Next
Response.Write "</table>"
Response.Write "<table>"
response.Write "<td><input type=""Submit"" name=""Btn_Save"" Value=""Save All""></td></tr>"
response.Write "</table>"
%>
</body>
</html>
ASKER CERTIFIED SOLUTION
SStory

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros