Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Decimal
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Imaging.ImageFormat

Partial Class TestingNewTopHome
    Inherits System.Web.UI.Page
    Dim sel_val As String
    Dim ret_user As String
    Dim ds As DataSet
    Dim dt As DataTable
    Dim i As Integer
    Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
        If Not Page.IsPostBack Then

            TextBox1.Text = "Enter First Name"
            TextBox2.Text = "Enter City Name"
            TextBox2.Attributes.Add("onfocus", "javascript:checkdata(this,'Enter City Name')")
            TextBox1.Attributes.Add("onfocus", "javascript:checkdata(this,'Enter First Name')")

            TextBox1.Attributes.Add("onblur", "javascript:checkdata1(this,'Enter First Name')")
            TextBox2.Attributes.Add("onblur", "javascript:checkdata1(this,'Enter City Name')")

            Button1.Attributes.Add("onclick", "alert('hello')")
            Button2.Attributes.Add("onclick", "javascript:ask()")

            Image1.Attributes.Add("onMouseOver", "javascript:imgover(this)")
            Image1.Attributes.Add("onMouseOut", "javascript:imgover1(this)")

            Image2.Attributes.Add("onMouseOver", "javascript:imgmove(this)")
            Image2.Attributes.Add("onMouseOut", "javascript:imgmove1(this)")

          
        End If


    End Sub
   


 
    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        If FileUpload1.HasFile Then
            Label1.Text = FileUpload1.FileName
            Label2.Text = Path.GetExtension(FileUpload1.FileName)
        End If
    End Sub

    Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim aMonths As ArrayList = New ArrayList()
        Dim aProfits As ArrayList = New ArrayList()

        'aMonths.Add("January")
        'aMonths.Add("February")
        'aMonths.Add("March")
        'aMonths.Add("April")
        'aMonths.Add("May")
        'aMonths.Add("June")
        'aMonths.Add("July")
        'aMonths.Add("August")
        'aMonths.Add("September")
        'aMonths.Add("October")
        'aMonths.Add("November")
        'aMonths.Add("December")

        'aProfits.Add(240500)
        'aProfits.Add(220950)
        'aProfits.Add(283500)
        'aProfits.Add(340000)
        'aProfits.Add(325750)
        'aProfits.Add(123456)
        'aProfits.Add(235621)
        'aProfits.Add(345235)
        'aProfits.Add(290451)
        'aProfits.Add(152345)
        'aProfits.Add(653456)
        'aProfits.Add(785620)
        Dim dt As DataTable = ReturnDataTable("SELECT DISTINCT Supplier_Master.Supplier_KId FROM         Supplier_Master INNER JOIN                       Product_Master ON Supplier_Master.Supplier_Kid = Product_Master.Product_SupplierId WHERE     (Supplier_Master.Supplier_IsDeleted = '0') AND (Product_Master.Product_IsDeleted = '0')")
        Dim i As Integer
        For i = 0 To 9
            aMonths.Add(dt.Rows(i).Item(0).ToString)
        Next

        Dim dt1 As DataTable = ReturnDataTable("SELECT  top(10)   COUNT(Product_Master.Product_Kid) AS Expr1, Supplier_Master.Supplier_Name FROM         Product_Master INNER JOIN   Supplier_Master ON Product_Master.Product_SupplierId = Supplier_Master.Supplier_Kid GROUP BY Product_Master.Product_SupplierId, Supplier_Master.Supplier_Name ")
        For i = 0 To dt1.Rows.Count - 1
            aProfits.Add(CType(dt1.Rows(i).Item(0).ToString, Integer))
        Next

        'Dim dk As String = ReturnValue("Select count(supplier_Kid) from Supplier_master where supplier_isdeleted='0'")
        'Dim dk1 As String = ReturnValue("Select count(BuyerRegister_Kid) from BuyerRegister where BuyerRegister_IsDeleted='0'")
        'Dim ik As Integer = CType(dk, Integer)
        'Dim ik1 As Integer = CType(dk1, Integer)
        'aProfits.Add(ik1)
        'aProfits.Add(ik)

        DrawBarGraph("Product wise Suppliers!", aMonths, aProfits)

        'Dim dr As DataReader
        'Dim con As New SqlConnection
        'con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
        'Dim str As String
        'str = "SELECT count(AdminUserLog_Kid) as Entry,AdminUserLog_UserName as Users FROM AdminUserLog"
        'Dim cmd As New SqlCommand
        'cmd = New SqlCommand(str, con)
        'Dim dr As SqlDataReader
        'con.Open()
        'dr = cmd.ExecuteReader


        'Do While dr.Read()
        '   drawing.Graphic .FillRectangle(New SolidBrush(Color.Blue, (i * 35) + 15, 200 - ReaderObj(itemtotal), 20, ReaderObj(itemtotal) + 5)
        '    objGraphics.DrawRectangle(Pens.Black, (i * 35) + 15, 200 - ReaderObj(itemtotal), 20, ReaderObj(itemtotal) + 5)
        'Loop

        ''Close objects
        'dr.Close()
        'con.Close()
    End Sub
    Sub DrawBarGraph(ByVal strTitle As String, _
        ByVal aX As ArrayList, ByVal aY As ArrayList)
        Const iColWidth As Integer = 60, iColSpace As Integer = 25, _
              iMaxHeight As Integer = 400, iHeightSpace As Integer = 25, _
              iXLegendSpace As Integer = 30, iTitleSpace As Integer = 50
        Dim iMaxWidth As Integer = (iColWidth + iColSpace) * aX.Count + iColSpace, _
              iMaxColHeight As Integer = 0, _
              iTotalHeight As Integer = iMaxHeight + iXLegendSpace + iTitleSpace

        Dim objBitmap As Bitmap = New Bitmap(iMaxWidth, iTotalHeight)
        Dim objGraphics As Graphics = Graphics.FromImage(objBitmap)

        objGraphics.FillRectangle(New SolidBrush(Color.White), _
                    0, 0, iMaxWidth, iTotalHeight)
        objGraphics.FillRectangle(New SolidBrush(Color.Ivory), _
                    0, 0, iMaxWidth, iMaxHeight)

        ' find the maximum value
        Dim iValue As Integer
        For Each iValue In aY
            If iValue > iMaxColHeight Then iMaxColHeight = iValue
        Next

        Dim iBarX As Integer = iColSpace, iCurrentHeight As Integer
        Dim objBrush As SolidBrush = New SolidBrush(Color.FromArgb(70, 20, 20))
        Dim fontLegend As Font = New Font("Arial", 11), _
            fontValues As Font = New Font("Arial", 8), _
            fontTitle As Font = New Font("Arial", 24)

        ' loop through and draw each bar
        Dim iLoop As Integer
        For iLoop = 0 To aX.Count - 1
            iCurrentHeight = ((Convert.ToDouble(aY(iLoop)) / _
                   Convert.ToDouble(iMaxColHeight)) * _
                   Convert.ToDouble(iMaxHeight - iHeightSpace))
            objGraphics.FillRectangle(objBrush, iBarX, _
            iMaxHeight - iCurrentHeight, iColWidth, iCurrentHeight)
            objGraphics.DrawString(aX(iLoop), fontLegend, _
               objBrush, iBarX, iMaxHeight)
            objGraphics.DrawString(Format(aY(iLoop), "#,###"), _
               fontValues, objBrush, iBarX, iMaxHeight - iCurrentHeight - 15)
            iBarX += (iColSpace + iColWidth)
        Next
        objGraphics.DrawString(strTitle, fontTitle, objBrush, _
              (iMaxWidth / 2) - strTitle.Length * 6, iMaxHeight + iXLegendSpace)
        'objBitmap.Save("C:\inetpub\wwwroot\graph.gif", ImageFormat.GIF) 
        ' Dim gif As Drawing.Imaging.ImageFormat
        objBitmap.Save(Server.MapPath("images/graph1.gif"))
        objGraphics.Dispose()
        objBitmap.Dispose()

        Image3.ImageUrl = Page.ResolveUrl("images/graph1.gif")

    End Sub

    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim d As Boolean = CreateMessageConfirm(Me, "Are You Sure want to register ?", "strkeyVal")


    End Sub
End Class
