client/Graficas/Monto.vb

169 lines
6.0 KiB
VB.net
Raw Blame History

Imports System.Data.SqlClient
Public Class Monto
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Chart1 As SoftwareFX.ChartFX.Chart
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.Button1 = New System.Windows.Forms.Button
Me.Chart1 = New SoftwareFX.ChartFX.Chart
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'DataGrid1
'
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(0, 48)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(664, 96)
Me.DataGrid1.TabIndex = 0
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(64, 8)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 24)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
'
'Chart1
'
Me.Chart1.DesignTimeData = "C:\Program Files\ChartFX for .NET 6.2\Wizard\MulltiSeries.txt"
Me.Chart1.Gallery = SoftwareFX.ChartFX.Gallery.Lines
Me.Chart1.Location = New System.Drawing.Point(96, 192)
Me.Chart1.MarkerSize = CType(4, Short)
Me.Chart1.Name = "Chart1"
Me.Chart1.NSeries = 3
Me.Chart1.NValues = 10
Me.Chart1.TabIndex = 2
'
'Monto
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(808, 645)
Me.Controls.Add(Me.Chart1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.DataGrid1)
Me.Name = "Monto"
Me.Text = "Monto"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Dim dap1 As SqlDataAdapter = New SqlDataAdapter
Dim cnn1 As SqlConnection
Dim cmd1 As SqlCommand
Dim das1 As DataSet
Dim i As Integer
Dim clCmp As clsComplejo = New clsComplejo
Private Sub Monto_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conectar_BD()
End Sub
Public Sub conectar_BD()
' Defino mi cadena de conexion (el servidor, la BD el usuario y la contrase<73>a
Dim cadena_conexion As String = "data source=CMAMXDFPR;" & _
"initial catalog=COMERICANET12092009;" & _
"user id = Administrador" & _
";password= 123456"
'Declaro mi Objeto de conexion y le asigno la cadena de conexion que usara para
'Conectarse a la base de datos
cnn1 = New SqlConnection(cadena_conexion)
Cadenas_Select()
Try
cnn1.Open() 'Abro la conexion a la base de datos
'MsgBox("base Abierta")
Llenar_Dataset()
Catch e As System.Data.SqlClient.SqlException
MessageBox.Show(e.Message & " Contacta al Administrador del Servidor", "Error al Conectar con el servidor", MessageBoxButtons.OK, MessageBoxIcon.Stop)
MessageBox.Show("Se cerrar<61> esta Ventana")
Me.Close()
Finally
cnn1.Close() 'cierra la conexion a la base de datos
End Try
End Sub
Private Sub confChart()
With Chart1
'Configuracion del CHART
.ToolBar = True
.SerLegBox = True
.AllowDrag = False
.AllowEdit = False
.ContextMenus = False
.ShowTips = True
.Scrollable = True
End With
'Configuro los ejes del chart
Chart1.Axis(2).AutoScale = True
'Chart1.Axis(0).AutoScale = True
'Chart1.BottomGap = 20
Chart1.Grid = SoftwareFX.ChartFX.ChartGrid.Horz Or SoftwareFX.ChartFX.ChartGrid.Vert
End Sub
Private Sub cadenas_select()
'Defino mi comando para recuperara atributos de una tabla
'Defino el objeto de conexion que se utilizara
cmd1 = New SqlCommand("select * from graficamonto", cnn1)
dap1.SelectCommand = cmd1
End Sub
Private Sub Llenar_Dataset()
'Rellena conjunto d datos (das1) con el adapatdor de datos dap1
' el metodo Fill rellena el conjunto de datos con la tabla Empleados
das1 = New DataSet
dap1.Fill(das1, "graficamonto")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
confChart()
Try
'DataGrid1.SetDataBinding(das1, "graficamonto")
' Chart1.DataSourceSettings.DataSource = das1.Tables("graficamonto")
clCmp.fdDataReader("select * from graficamonto")
Chart1.DataSourceSettings.DataSource = clCmp.dr
'chart1.ge
Catch er As Exception
MessageBox.Show(er.Message)
End Try
End Sub
End Class