Morpheusweb.it - Risorse per webmaster: script, ASP.NET, C#, Visual Basic .Net, tutorial, asp, javascript, css, php, html, java, ADO, VBScript, forms, frames, Active Server Pages, Dynamic HTML, database, gratis per webmaster e webdesigner

Percentuals - << C# VERSION >>

Print an html table with graph percentuals


<HTML>
<script language="VB" runat="server">
Sub Page_Load(source As Object, E As EventArgs)
  Dim objConn As New SqlConnection("workstation id=Intranet;packet size=4096; _
        user id=USERID;data source=DATABASE;persist security info=True; _
        initial catalog=DATABASE;password=PASSWORD")
  Dim strSql As String = "Select valore, Nome From Tabella Order By nome"
  Dim da As New SqlDataAdapter(strSql, objConn)
  Dim ds As New DataSet
  da.Fill(ds, "Tabella")

  Dim strHTML As String
  strHTML = "<table width='80%' border='1'>"
  strHTML &= "<tr>"
  strHTML &= "<td>Nome</td><td>Percentuale"
  strHTML &= "</td><td>valore</td>"
  strHTML &= "</tr>"

  Dim dr As DataRow
  Dim intValue, intBlank As Integer
  For Each dr In ds.Tables("Tabella").Rows
    intValue = 100 * (dr("valore") / 125)
    intBlank = 100 - intValue
    strHTML &= "<tr><td width='30%'>" & dr("Nome") & "</td>" & _
        "<td width='60%'><table width='100%'><tr>"
    If intValue < 3 Then
      strHTML &= "<td height=""20px"" width=" & intValue.ToString & "% bgcolor=red>"
    ElseIf intValue > 6 Then
      strHTML &= "<td height=""20px"" width=" & intValue.ToString & "% bgcolor=green>"
    Else
      strHTML &= "<td height=""20px"" width=" & intValue.ToString & "% bgcolor=blue>"
    End If
    strHTML &= " </td>" & _
      "<td width=" & intBlank.ToString & "% </td>" & _
      "</tr></table></td>" & _
      "<td width=10%>" & dr("valore").ToString & "</td></tr>"
    Next

    strHTML &= "</table>"

    ShowTable.Text = strHTML
End Sub
</script>
<body>
<form id="Form1" method="post" runat="server">
<asp:Label id="ShowTable" runat="server"></asp:Label>
</form>
</body>
</HTML>



Download Code...


Print Page


 


Page top

risorse per webmaster