pro yec todai
Post on 17-Sep-2015
255 Views
Preview:
DESCRIPTION
TRANSCRIPT
-
Proyecto Final de
Curso DAI
-
Indice
Introduccin
Tecnologas usadas
Bibliografa
Seguimiento del proyecto
Planificacin de la base de datos
Estructuracion del programa
Archivo nuevo
Archivo pedidos
Consulta actualizar
Consulta mostrar
Estadisicas
Configuracin
Acerca de
Datos tecnicos
Problemas resueltos
CODIGO ANEXADO
Form1
Cliente_insert
Producto_insert
Proveedor_insert
Servicio_insert
Categora_insert
Factura_pedir
Servicio_pedir
Actualizar_cliente
Actualizar_producto
Actualizar_proveedor
Actualizar_servicio
Ver_cliente
Ver_factura
Ver_producto
Ver_proveedor
-
Ver_servicio
Dashboard
Grafclipro
Grafacano
Grafacmes
Grafingreano
Grafingremes
Grafprodcate
Reportclipro
Reportfacano
Reportfacmes
Reportingresoanual
Reportingresomensual
Reportprocate
Confi
Variables
Acercade
-
Introduccin
En este proyecto tratamos de simular una empresa comercial que se dedica a
vender productos informticos y servicios. Estos productos nos los
proporcionan unos proveedores.
Hemos creado una aplicacin que permita gestionar los proveedores, clientes,
productos, facturas, servicios etc. Facilitando as la gestin de los datos de nuestra empresa.
Esta aplicacin esta destinada a los empleados para manejar los datos recibidos
por medios como fax, telfono etc.
A nivel personal para la empresa se ha aadido unos mdulos de reporting
grficos para facilitar el anlisis de las ventas de nuestra empresa.
Para desarrollar la aplicacin hemos escogido la plataforma de programacin
Visual Estudio .NET con el lenguaje visual Basic ya que por el tiempo destinado
al proyecto necesitbamos un lenguaje potente para las necesidades de nuestro
trabajo, verstil y fcil (sobre todo grficamente).
-
Tecnologas usadas
Visual Basic .NET
SQL Server
Netadventage 6.1 (Grficos y Grid)
Crystal Reports
Office Project 2003
Cdigos Postales (aplicacin que facilitaba la bsqueda de cdigos)
Fast Help
Photo Express 4.0
-
Bibliografa
Paginas Web:
http://www.programar.net/directory/category.aspx?id=11
http://www.buayacorp.com/archivos/exportar-reportes-crystal-reports-
en-aspnet
http://www.microsoft.com/spanish/msdn/comunidad/mtj.net/voices/a
rt11.asp
http://www.elguille.info/vb/vb_crystal.htm
http://www.microsoft.com/spanish/msdn/comunidad/mtj.net/voices/a
rt192.asp
http://www.elguille.info/colabora/puntoNET/newhang_DatagridComboBox.htm
http://www.forosdelweb.com/showthread.php?t=392026
http://www.netaweb.com.do/articulos/datagridcombo1.asp
http://www.netaweb.com.do/datagridcombo.asp
http://es.gotdotnet.com/quickstart/winforms/doc/WinFormsData.aspx
http://asp.net.do/foros/ShowPost.aspx?PostID=1355
http://www.elguruprogramador.com.ar/foros/mensaje.asp?id=3460
http://www.microsoft.com/spanish/msdn/articulos/archivo/140305/voices/datagr
idcolumnstyle2.asp
http://www.infragistics.com/downloads/default.aspx
http://www.programar.net/directory/category.aspx?id=3
http://www.elguille.info/colabora/puntoNET/yosall_datagrid.htm
http://www.configuracionesintegrales.com/miguele/responder.asp?idfor
o=2&idPregunta=143
http://www.vb-helper.com/index_database.html
http://www.wikipedia.org/
-
Seguimiento del Proyecto
-
Planificacin de la Base de Datos
Para este proyecto hemos decidido la creacin de las siguientes tablas, para
centralizar los datos:
Factura: En esta tabla guardamos un identificador para factura nico y
no repetible, tambin guardamos la fecha en la que se efectu la compra,
el identificador del cliente que realiza la compra y tambin tenemos
cortados el mes y el ao para poder hacer las estadsticas y los grficos.
Ordenar: Esta tabla sirve solo para establecer un orden lgico a la hora de
visualizar los meses en las graficas e estadsticas, ya que si no en vez del 2
vendra el 11.
Relacional: Esta tabla es capaz de relacionar una misma factura con
diferentes productos gracias a un identificador de factura, uno de
producto y la cantidad que se ha comprado.
Producto: En esta tabla se almacena la informacin relacionada con el
producto, con informacin tal como el proveedor, categora a la que
pertenece gracias a los identificadores de la tabla categora, tambin hay
un campo precio unidad para poder elaborar la factura junto con la tabla
relacional. Tambin dispone de un campo donde se guarda el ao del
producto para poder gestionar las graficas mejor.
Categora: Esta tabla el identificador de categora junto con el nombre de
la misma para poder agrupar los productos mejor.
Proveedor: Tabla que guarda informacin de nuestros proveedores, en la
cual hay informacin como el nombre de la empresa, contacto, telfono,
direccin, cif etc. Y la categora a la que pertenece, relacionado con la
tabla categora.
Cliente: Contiene toda la informacin relacionada con los clientes de la
empresa ya sea nombre, direccin, telfono, CIF, numero de cuenta,
cdigo postal etc. Y el ao en que se dio de alta este cliente para poder
utilizarla en las graficas.
-
Servicios: Esta tabla guarda la informacin acerca de los servicios que
pueden contratar nuestros clientes que esta relacionada con la tabla
SER_CLIE.
Ser_clie: Esta tabla es empleada para relacionar cliente y servicio, para
que un cliente pueda disponer de ms de un servicio contratado.
Provincia: En esta tabla se almacenan las provincias espaolas junto con
un identificador nico.
Poblacin: En esta tabla se almacenan las poblaciones espaolas junto
con su propio identificador mas un identificador para conocer a que
provincia pertenece.
Ubicacin_cp: Esta tabla guarda todos los cdigos postales y los
relaciona con las poblaciones que como ya hemos mencionado
anteriormente esta relacionado con la provincia, de esta manera con solo
saber un cdigo postal podemos conocer su poblacin y provincia.
Tambin podemos agrupar los clientes por provincia tal como hemos
hecho en las graficas.
-
Visin de las tablas
Bloque facturas.
Bloque Producto / Categora
-
Bloque Cliente / Proveedor
Bloque Servicios
-
Bloque Cdigo postales.
-
Vista General.
Tal como se ve en esta vista se puede observar la relacin establecida en las
tablas.
Una vez terminada la estructura procedemos a la insercin de datos en ella, lo
cual lleva un tiempo.
-
Estructuracin del programa
Al ser una aplicacin e Visual Basic .Net se basa en formularios que
interactuaran con el usuario, para ello hemos creado un men que facilitara la
navegacin por el programa.
Tal como se puede ver en las siguientes imgenes:
Dentro de archivo, Nuevo:
En este apartado podemos insertar nuevos registros en cada una de sus
categoras del men.
Cliente:
-
Producto:
Proveedor:
-
Servicio:
Categora:
-
Como podemos observar todos estos formularios sirven para ingresar nuevos
registros en la base de datos.
Dentro de Archivo, Pedidos:
En pedidos los clientes pueden realizar compras de productos o servicios.
Factura (compra):
-
Servicio:
Dentro de Consulta Actualizar:
Aqu podremos actualizar informacin sobre clientes o proveedores que
cambien de direccin, cuenta bancaria etc. se puede modificar directamente
desde grid.
-
Cliente:
Producto:
-
Proveedor:
Servicio:
-
Como podemos observar permitimos editar los campos lgicos ya que la fecha o
el identificador seguirn siendo nicos y no modificables.
Dentro de Consulta Mostrar:
Aqu podremos visualizar toda la informacin sobre un registro de cualquier
tabla ya sea por nombre o identificador.
Cliente:
-
Producto:
Proveedor:
-
Servicio:
Factura:
-
Dentro de Estadsticas:
Aqu podremos ver un cuadro de mandos donde salen estadsticas actualizadas
sobre nuestros datos.
Si clickeamos sobre alguna de ellas, podemos ver una grafica grande y un report
de los datos.
Dashboard:
-
Ejemplo de Productos por categora:
Dentro de Configuracin:
Aqu se abrir un nuevo formulario en el cual podremos configurar la conexin
a nuestro servidor SQL.
-
En el momento de la instalacin este formulario aparece, para poder realizar la
primera configuracin.
Dentro de Acerca de:
Men donde se podr encontrar informacin acerca de los programadores,
compaa, versin del programa y un archivo de ayuda.
Acerca de Chacha:
Versin:
-
Ayuda:
-
Datos Tcnicos
Conexiones:
En este programa hemos utilizado para las conexiones sqlconnection y para
guardar y poder leer la informacin hemos empleado sqldataadapters y
Datasets, con los cuales nos facilitaba la conexin e extraccin de informacin
de la base de datos.
Tambin hemos empleado StoredsProcedures para recuperar informacin
especfica de la base de datos.
Para guardar la configuracin de la conexin creamos un fichero *.def en el cual
se guarda el connectionstring que usaran los sqlconnection y el Cristal report.
Componentes:
En principio usamos componentes .Net que incluye Visual Basic.
Al tener problemas con el Gris ya que no nos permita editarlo como queramos
tuvimos que buscar uno que pudiera satisfacer nuestras necesidades.
Buscando y preguntando encontramos NetAdvantage el cual es un paquete que
incluye diferentes componentes incluyendo un Gris con mucha mas
funcionalidad.
Para la realizacin de las graficas y reporting usamos:
Cristal Reports para realizar los reporting con la informacin relevante de la
empresa.
NeTAdvantage para la realizacin de las graficas.
-
Programas:
Fast Help nos ayudo a la creacin de un archivo *.chm el cual es el formato
estndar de la ayuda de Windows, con el creamos una ayuda para nuestro
programa, facilitando as el uso a los usuarios.
Cdigo Postal , es una pequea aplicacin que nos ayudo a encontrar una serie
de cdigos postales para poder emplearlos en nuestra base de datos para darle
mas realismo.
-
Problemas Resueltos
1. Al empezar la aplicacin nos dimos cuenta que era muy incomodo limitar
la aplicacin a nico servidor ya bien sea para testearlo nosotros o como
producto final, por ello agregamos el modulo de configuracin de la
conexin de esta manera el programa puede atacar a cualquier servidor
SQL mientras este tenga la BD, para ello guardamos la cadena de
conexin en un archivo *.def que al iniciar cada formulario verifica si
existe y copia la cadena en la conexin actual.
2. Cuando iniciamos la seccin de actualizar observamos el bajo
rendimiento que nos ofreca el componente gratis de Microsoft, en este
caso estamos hablando del Grid empleado en mostrar. Despus de probar
diferentes maneras de hacerlo mas verstil decimos desistir y buscar una
alternativa, para ello encontramos un paquete de pago que
proporcionaba diferentes herramientas que nos serian de utilidad, como
poda ser el UltraGrid que utilizamos en la seccin de actualizar.
3. Al mismo tiempo que editbamos con el nuevo grid observamos que era
muy incomodo seleccionar el cdigo postal manualmente, para ello nos
intereso poner un combobox dentro del grid, de manera que el usuario
pudiera elegir el cdigo postal de la base de datos, sin crear as errores o
confusiones.
4. Al realizar las primeras graficas nos costo bastante asimilar la relacin
entre la Query que nosotros hacamos con la informacin mostrada por la
grafica, finalmente sacamos toda la informacin de los storedsprocedures
y los cargbamos en un dataset y la grafica se encargaba de visualizar los
datos incluidos en el.
5. Al utilizar el crystal report tuvimos una limitacin desde el comienzo, la
cadena de conexin no se poda editar, lo cual nos obligaba a atacar
siempre al mismo servidor, tras buscar cdigo e informacin en Internet
conseguimos encontrar una alternativa para poder lanzar el reporte en
cualquier servidor, usando as nuestro archivo de conexin.
6. En Crystal report una vez compilas un instalador, es necesario incluir una
serie de archivos ensamblados donde se guarda la informacin del
numero de la licencia que emplea, el problema es que como no poseemos
-
esta licencia no podemos incluirla en el instalador. No obstante en todas
las maquinas que utilizan visual Basic .net existe esta licencia de prueba,
permitiendo as trabajar y ver los reportes que hace nuestro programa.
7. Como ultimo pero no menos importante tuvimos que controlar que los
datos que se insertan son compatibles con la base de datos, para evitar
as errores.
-
Cdigo Anexado
Form1:
Imports System.Drawing.Printing Imports System.Drawing.Graphics Imports System.Drawing.Imaging Imports System.Runtime.InteropServices Public Class Proyecto Inherits System.Windows.Forms.Form
#Region " Cdigo generado por el Diseador de Windows Forms "
Private Sub Proyecto_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AddHandler Proyecto.Closed, AddressOf z_Closed
Dim control As Integer If fitxer_conexio() = False Then
Dim xy As New confi control_configurcion = 1 xy.Text = "Editar Configuracion" xy.Show() xy.WindowState = FormWindowState.Normal MsgBox("Debe configurar la conexion al Servidor",MsgBoxStyle.Information) control = 1 Dim x As Integer
For x = 0 To MainMenu1.MenuItems.Count - 1
If x 3 Then
MainMenu1.MenuItems.Item(x).Enabled = False
End If
Next
End If
MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False
Try If control = 0 Then
fitxer_conexio() SqlConnection1.ConnectionString = cadena_connection
SqlConnection1.Open()
SqlConnection1.Close() End If
-
Catch ex As Exception
MsgBox("No hay conexion con el servidor, verifique la configuracion y pongase en contacto con un administrador", MsgBoxStyle.Critical)
Dim i As Integer
For i = 0 To MainMenu1.MenuItems.Count - 1
If i 3 Then
MainMenu1.MenuItems.Item(i).Enabled = False
End If
Next
End Try
'lemos el fichero
End Sub Private Sub z_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
End Sub
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New cliente_insert crear_from(x, "Nuevo Cliente")
End Sub Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem6.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New servicio_insert crear_from(x, "Nuevo Servicio") End Sub Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New proveedor_insert crear_from(x, "Nuevo proveedor") End Sub Private Sub MenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem7.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New categoria_insert crear_from(x, "Nueva Categora") End Sub
-
Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New producto_insert crear_from(x, "Nueva Producto")
End Sub Private Sub MenuItem11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem11.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New servicio_pedir crear_from(x, "Pedir Servico") End Sub
Private Sub MenuItem27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem27.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New ver_cliente crear_from(x, "Cliente") End Sub
Private Sub MenuItem10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem10.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New factura_pedir crear_from(x, "Pedido Factura") End Sub
Private Sub MenuItem28_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem28.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New ver_producto crear_from(x, "Ver Producto")
End Sub Private Sub MenuItem29_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem29.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New ver_proveedor crear_from(x, "Ver Producto")
End Sub
Private Sub MenuItem30_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem30.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New ver_servicio crear_from(x, "Ver Servicio")
End Sub Private Sub MenuItem43_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem43.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form()
-
Dim x As New ver_factura crear_from(x, "Ver Factura") MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = True
End Sub
Private Sub MenuItem20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem20.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New actualizar_servicio crear_from(x, "Actualizar Servicio")
End Sub
Private Sub MenuItem17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem17.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New actualizar_cliente crear_from(x, "Actualizar Cliente")
End Sub
Private Sub MenuItem18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem18.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New actualizar_producto crear_from(x, "Actualizar Producto")
End Sub
Private Sub MenuItem19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem19.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New actualizar_proveedor crear_from(x, "Actualizar Proveedor")
End Sub
Private Sub MenuItem33_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem33.Click MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False cerrar_form() Dim x As New Dashboard crear_from(x, "Dashboard")
End Sub
Public Function crear_from(ByVal nombre As Form, ByVal texto As String)
nombre.MdiParent = Me nombre.Text = texto
-
nombre.Show() nombre.WindowState = FormWindowState.Maximized 'con esta funcion podemos llamar a todos los form desde el principal
End Function Public Function cerrar_form()
'funcion de cerrar formulario Try Me.ActiveMdiChild.Close()
Catch ex As Exception
End Try
End Function
Private Sub MenuItem39_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem39.Click
MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False If control_configurcion = 0 Then
Dim xy As New confi control_configurcion = 1 xy.Text = "Editar Configuracion" xy.Show() xy.WindowState = FormWindowState.Normal
Else
MsgBox("Hay en ejecucion una ventana de configuracion", MsgBoxStyle.Exclamation)
End If
End Sub
Private Sub MenuItem12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem12.Click 'Dim prd As PrintDocument 'prd = New PrintDocument
'AddHandler prd.PrintPage, AddressOf OnPrintPage
AddHandler PrintDocument1.PrintPage, AddressOf OnPrintPage
Try PrintDialog1.ShowDialog() 'prd.Print() PrintDocument1.Print()
Catch ex As Exception
-
End Try
End Sub
Private Sub OnPrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Dim hwndForm As IntPtr hwndForm = Me.Handle
Dim hdcDIBSection As IntPtr Dim hdcRef As IntPtr Dim hbmDIBSection As IntPtr Dim hbmDIBSectionOld As IntPtr Dim BMPheader As Win32APICall.BITMAPINFOHEADER
hdcRef = Win32APICall.GetDC(IntPtr.Zero) hdcDIBSection = Win32APICall.CreateCompatibleDC(hdcRef) Win32APICall.ReleaseDC(IntPtr.Zero, hdcRef)
BMPheader.biBitCount = 24 BMPheader.biClrImportant = 0 BMPheader.biClrUsed = 0 BMPheader.biCompression = Win32APICall.BI_RGB BMPheader.biSize = 40 BMPheader.biHeight = Me.Height BMPheader.biPlanes = 1 BMPheader.biSizeImage = 0 BMPheader.biWidth = Me.Width BMPheader.biXPelsPerMeter = 0 BMPheader.biYPelsPerMeter = 0
hbmDIBSection = Win32APICall.CreateDIBSection(hdcDIBSection, BMPheader, Win32APICall.DIB_RGB_COLORS, _ IntPtr.Zero, IntPtr.Zero, 0)
hbmDIBSectionOld = Win32APICall.SelectObject(hdcDIBSection, hbmDIBSection) Win32APICall.PatBlt(hdcDIBSection, 0, 0, Me.Width, Me.Height, Win32APICall.WHITENESS) Win32APICall.PrintWindow(hwndForm, hdcDIBSection, 0) Win32APICall.SelectObject(hdcDIBSection, hbmDIBSectionOld)
Dim imageFrm As Bitmap imageFrm = Image.FromHbitmap(hbmDIBSection) e.Graphics.DrawImage(imageFrm, 0, 0)
Win32APICall.DeleteDC(hdcDIBSection) Win32APICall.DeleteObject(hbmDIBSection) End Sub
Private Sub MenuItem37_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem37.Click
Help.ShowHelpIndex(Me, "HelpChacha.chm")
End Sub Private Sub MenuItem35_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem35.Click
-
MainMenu1.MenuItems(0).MenuItems.Item(2).Enabled = False
If control_acerca = 0 Then
Dim x As New Acerca control_acerca = 1 x.Text = "Acerca de .... CHACHA" x.Show() x.WindowState = FormWindowState.Normal
End If
End Sub
Private Sub MenuItem36_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem36.Click MsgBox("Chacha Manager Version 1.0", MsgBoxStyle.Information, "Chacha Developer") End Sub End Class
Public Class Win32APICall
Public Const DIB_RGB_COLORS = 0 Public Const BI_RGB = 0 Public Const WHITENESS = 16711778
_ Public Shared Function PrintWindow(ByVal hWnd As IntPtr, ByVal hDC As IntPtr, ByVal dwFlags As Integer) As UInt32 End Function
_ Structure BITMAPINFOHEADER Dim biSize As Int32 Dim biWidth As Int32 Dim biHeight As Int32 Dim biPlanes As Int16 Dim biBitCount As Int16 Dim biCompression As Int32 Dim biSizeImage As Int32 Dim biXPelsPerMeter As Int32 Dim biYPelsPerMeter As Int32 Dim biClrUsed As Int32 Dim biClrImportant As Int32 End Structure
_ Public Shared Function CreateDIBSection(ByVal hdc As IntPtr, ByRef pbmi As BITMAPINFOHEADER, _
-
ByVal iUsage As Int32, ByVal ppvBits As IntPtr, ByVal hSection As IntPtr, _ ByVal dwOffset As Int32) As IntPtr End Function
_ Public Shared Function PatBlt(ByVal hDC As IntPtr, ByVal nXLeft As Int32, _ ByVal nYLeft As Int32, ByVal nWidth As Int32, ByVal nHeight As Int32, _ ByVal dwRop As Int32) As Boolean End Function
_ Public Shared Function SelectObject(ByVal hDC As IntPtr, ByVal hObj As IntPtr) As IntPtr End Function
_ Public Shared Function CreateCompatibleDC(ByVal hRefDC As IntPtr) As IntPtr End Function
_ Public Shared Function DeleteDC(ByVal hDC As IntPtr) As Boolean End Function
_ Public Shared Function DeleteObject(ByVal hObj As IntPtr) As Boolean End Function
_ Public Shared Function ReleaseDC(ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As Boolean End Function _ Public Shared Function GetDC(ByVal hWnd As IntPtr) As IntPtr End Function End Class
-
Clientes_insert:
Public Class cliente_insert Inherits System.Windows.Forms.Form
Private Sub cliente_insert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try fitxer_conexio() SqlConnection1.ConnectionString = cadena_connection
Dim Ds_cliente As New Data_cliente SqlConnection1.Open() SqlDataAdapter2.Fill(Ds_cliente.Ubicacion_cp)
ComboBox1.DataSource = Ds_cliente.Ubicacion_cp ComboBox1.ValueMember = Ds_cliente.Ubicacion_cp.ID_cpColumn.ToString
SqlConnection1.Close()
Catch ex As Exception
MsgBox("Base de datos no operatiba", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text "" And TextBox2.Text "" And TextBox3.Text "" And TextBox4.Text _ "" And TextBox5.Text "" And TextBox6.Text "" And ComboBox1.Text "" Then
Dim p As String = TextBox5.Text
If p.Length() > 10 Then
Label1.Text = "NIF incorrecto" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End If
Try
Long.Parse(TextBox6.Text) Catch ex As Exception
Label1.Text = "Numero de cuenta no es de caracter numerico" Update()
-
System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End Try
p = TextBox6.Text
If p.Length() > 25 Then
Label1.Text = "Numero de cuenta Incorrecto" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End If
If ingresar_usuario() Then
Label1.Text = " REGISTRO INTRODUCIDO CON EXITO"
TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" TextBox6.Text = "" ComboBox1.SelectedIndex = 0 Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Else
Label1.Text = " REGISTRO NO INTRODUCIDO" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
End If
Else
Label1.Text = "Debe rellenar todos los campos especificados" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
End If
End Sub
-
Private Function ingresar_usuario() As Boolean
Dim ret As Boolean = False
Try
Dim Ds_cliente As New Data_cliente Dim userr As Data_cliente.ClienteRow
SqlConnection1.Open() SqlDataAdapter1.Fill(Ds_cliente.Cliente)
userr = Ds_cliente.Cliente.NewRow
userr.cli_empresa = TextBox1.Text userr.cli_nombre = TextBox2.Text userr.cli_apellido = TextBox3.Text userr.cli_direccion = TextBox4.Text userr.cli_cif_nif = TextBox5.Text userr.cli_cuenta = TextBox6.Text userr.cli_ID_codigo = ComboBox1.Text userr.cli_fecna = System.DateTime.Now() userr.cli_esta_ano = System.DateTime.Now.Year.ToString()
Ds_cliente.Cliente.AddClienteRow(userr) SqlDataAdapter1.Update(Ds_cliente.Cliente) Ds_cliente.Cliente.AcceptChanges() SqlConnection1.Close()
ret = True
Catch ex As Exception
Return ret End Try
Return ret
End Function End Class
-
Producto_insert:
Imports System.Data.SqlClient Public Class producto_insert Inherits System.Windows.Forms.Form
Dim cont As Integer Private Sub producto_insert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try fitxer_conexio() SqlConnection1.ConnectionString = cadena_connection Dim Ds_pro As New Data_producto
SqlConnection1.Open() SqlDataAdapter2.Fill(Ds_pro.Categoria)
ComboBox1.DataSource = Ds_pro.Categoria ComboBox1.DisplayMember = Ds_pro.Categoria.cate_nombreColumn.ToString ComboBox1.ValueMember = Ds_pro.Categoria.ID_categoriaColumn.ToString
SqlConnection1.Close()
Catch ex As Exception
MsgBox("Base de datos no operatiba")
End Try
End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
cont += 1 If cont > 2 Then
Try SqlConnection1.Open() Dim com As New SqlCommand Dim p1 As New SqlParameter
com.CommandType = CommandType.StoredProcedure
p1.DbType = DbType.Int32 p1.Value = Integer.Parse(ComboBox1.SelectedValue.ToString) p1.ParameterName = "@id_cate"
com.Parameters.Add(p1) com.CommandText = "Fynd_provee"
-
com.Connection = SqlConnection1
SqlDataAdapter3.SelectCommand = com 'Dim adapter As New SqlDataAdapter(com) Dim Ds_povee As New Data_producto SqlDataAdapter3.Fill(Ds_povee.Proveedor)
ComboBox2.DataSource = Ds_povee.Proveedor ComboBox2.DisplayMember = Ds_povee.Proveedor.provee_nombreColumn.ToString ComboBox2.ValueMember = Ds_povee.Proveedor.ID_proveedorColumn.ToString
com.Parameters.Clear()
SqlConnection1.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text "" And TextBox2.Text "" And ComboBox1.Text "" And ComboBox1.Text "" Then
Try
Double.Parse(TextBox2.Text) Catch ex As Exception
Label1.Text = "Debe introducir una cantidad numerica en el campo precio/unidad" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
End Try
If Double.Parse(TextBox2.Text) < 0 Then
Label1.Text = "Debe introducir una cantidad superior a 0" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Exit Sub
End If
-
If ingresar_producto() Then
TextBox1.Text = "" TextBox2.Text = "" ComboBox1.SelectedIndex = 0
Label1.Text = " REGISTRO INTRODUCIDO CON EXITO" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Else
Label1.Text = " REGISTRO NO INTRODUCIDO" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" End If
Else
Label1.Text = " Introducir todos los campos" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
End If End Sub Private Function ingresar_producto() As Boolean
Dim ret As Boolean = False
Try
Dim Ds_producto As New Data_producto Dim producc As Data_producto.ProductoRow
SqlConnection1.Open() SqlDataAdapter1.Fill(Ds_producto.Producto)
producc = Ds_producto.Producto.NewRow
producc.pro_nombre = TextBox1.Text producc.pro_preciounidad = TextBox2.Text producc.pro_ID_cate = ComboBox1.SelectedValue.ToString producc.pro_ID_provee = ComboBox2.SelectedValue.ToString producc.pro_fecna = System.DateTime.Now() producc.pro_esta = System.DateTime.Now.Year()
Ds_producto.Producto.AddProductoRow(producc) SqlDataAdapter1.Update(Ds_producto.Producto) Ds_producto.Producto.AcceptChanges() SqlConnection1.Close()
ret = True
-
Catch ex As Exception Return ret
End Try
Return ret
End Function
End Class
-
Proveedor_insert:
Public Class proveedor_insert Inherits System.Windows.Forms.Form
Private Sub proveedor_insert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try
fitxer_conexio() SqlConnection1.ConnectionString = cadena_connection Dim Ds_cate As New Data_Categoria
SqlConnection1.Open() SqlDataAdapter2.Fill(Ds_cate.Categoria) SqlDataAdapter3.Fill(Ds_cate.Ubicacion_cp)
ComboBox2.DataSource = Ds_cate.Categoria ComboBox2.DisplayMember = Ds_cate.Categoria.cate_nombreColumn.ToString ComboBox2.ValueMember = Ds_cate.Categoria.ID_categoriaColumn.ToString
ComboBox1.DataSource = Ds_cate.Ubicacion_cp ComboBox1.DisplayMember = Ds_cate.Ubicacion_cp.ID_cpColumn.ToString ComboBox1.ValueMember = Ds_cate.Ubicacion_cp.ID_cpColumn.ToString
SqlConnection1.Close()
Catch ex As Exception
MsgBox("Base de datos no operatiba")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text "" And TextBox2.Text "" And TextBox3.Text "" And TextBox4.Text _ "" And TextBox5.Text "" And ComboBox1.Text "" Then
Dim p As String = TextBox3.Text
If p.Length() > 10 Then
Label1.Text = "NIF incorrecto" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End If
-
Try
Long.Parse(TextBox4.Text) Catch ex As Exception
Label1.Text = "Telefono es de tipo numerico" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End Try
p = TextBox4.Text
If p.Length() > 9 Then
Label1.Text = "Numero de telefono incorrecto" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End If
Try
Long.Parse(TextBox5.Text) Catch ex As Exception
Label1.Text = "Numero de cuenta no es de caracter numerico" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End Try
p = TextBox5.Text
If p.Length() > 25 Then
Label1.Text = "Numero de cuenta Incorrecto" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End If
If ingresar_proveedor() Then
Label1.Text = " REGISTRO INTRODUCIDO CON EXITO"
TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = ""
-
TextBox4.Text = "" TextBox5.Text = ""
ComboBox1.SelectedIndex = 0 ComboBox2.SelectedIndex = 0 Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Else
Label1.Text = " REGISTRO NO INTRODUCIDO" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
End If
Else Label1.Text = "Debe rellenar todos los campos especificados" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
End If
End Sub
Private Function ingresar_proveedor() As Boolean
Dim ret As Boolean = False
Try
Dim Ds_provee As New Data_proveedor Dim provee As Data_proveedor.ProveedorRow
SqlConnection1.Open() SqlDataAdapter1.Fill(Ds_provee.Proveedor)
provee = Ds_provee.Proveedor.NewRow
provee.provee_nombre = TextBox1.Text provee.provee_direccion = TextBox2.Text provee.provee_cif = TextBox3.Text provee.provee_tlf = TextBox4.Text provee.provee_cuenta = TextBox5.Text provee.provee_ID_cp = ComboBox1.SelectedValue.ToString provee.provee_ID_cate = ComboBox2.SelectedValue.ToString provee.provee_fecna = System.DateTime.Now()
Ds_provee.Proveedor.AddProveedorRow(provee) SqlDataAdapter1.Update(Ds_provee.Proveedor) Ds_provee.Proveedor.AcceptChanges()
-
SqlConnection1.Close()
ret = True
Catch ex As Exception
Return ret End Try
Return ret
End Function End Class
-
Servicio_insert:
Public Class servicio_insert Inherits System.Windows.Forms.Form
Private Function ingresar_serv() As Boolean
Dim ret As Boolean = False
Try
Dim Ds_servicio As New Data_servicio Dim userr As Data_servicio.ServiciosRow
SqlConnection1.Open() SqlDataAdapter1.Fill(Ds_servicio.Servicios)
userr = Ds_servicio.Servicios.NewRow
userr.ser_servicio = TextBox1.Text userr.ser_comentario = TextBox2.Text userr.ser_precio = TextBox3.Text userr.ser_horas = TextBox4.Text
Ds_servicio.Servicios.AddServiciosRow(userr) SqlDataAdapter1.Update(Ds_servicio.Servicios) Ds_servicio.Servicios.AcceptChanges() SqlConnection1.Close()
ret = True
Catch ex As Exception
MsgBox(ex.ToString) Return ret End Try
Return ret
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text "" And TextBox2.Text "" And TextBox3.Text "" And TextBox4.Text "" Then
Try
Integer.Parse(TextBox4.Text) Catch ex As Exception
Label1.Text = "Debe introducir una cantidad numerica en el campo horas" Update() System.Threading.Thread.Sleep(2000)
-
Label1.Text = ""
End Try
Try
Double.Parse(TextBox3.Text) Catch ex As Exception
Label1.Text = "Debe introducir una cantidad numerica en el campo precio" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
End Try
If Integer.Parse(TextBox4.Text) < 0 Then
Label1.Text = "Debe introducir una cantidad numerica en el campo Horas" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End If
If Integer.Parse(TextBox3.Text) < 0 Then
Label1.Text = "Debe introducir una cantidad numerica en el campo Precio" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End If
If ingresar_serv() Then Label1.Text = " REGISTRO INTRODUCIDO CON EXITO" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" Else Label1.Text = " REGISTRO NO INTRODUCIDO" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" End If Else Label1.Text = " Introducir el nombre de la categoria"
-
Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" End If End Sub
Private Sub servicio_insert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load fitxer_conexio() SqlConnection1.ConnectionString = cadena_connection End Sub End Class
-
Categora_insert:
Public Class categoria_insert Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text "" Then If ingresar_cate() Then Label1.Text = " REGISTRO INTRODUCIDO CON EXITO" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" TextBox1.Text = "" Else Label1.Text = " REGISTRO NO INTRODUCIDO" End If Else Label1.Text = " Introducir el nombre de la categoria" End If End Sub Private Function ingresar_cate() As Boolean
Dim ret As Boolean = False
Try
Dim Ds_categoria As New Data_Categoria Dim userr As Data_Categoria.CategoriaRow
SqlConnection1.Open() SqlDataAdapter1.Fill(Ds_categoria.Categoria)
userr = Ds_categoria.Categoria.NewRow
userr.cate_nombre = TextBox1.Text
Ds_categoria.Categoria.AddCategoriaRow(userr) SqlDataAdapter1.Update(Ds_categoria.Categoria) Ds_categoria.Categoria.AcceptChanges() SqlConnection1.Close()
ret = True
Catch ex As Exception
Return ret End Try
Return ret
End Function
-
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub categoria_insert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load fitxer_conexio() SqlConnection1.ConnectionString = cadena_connection End Sub End Class
-
Factura_pedir:
Imports System.Data.SqlClient Public Class factura_pedir Inherits System.Windows.Forms.Form
Dim xxx As Integer Dim controlador, controlar_grid As Integer Dim i As Integer = 1 Dim cont As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Enabled = False System.Threading.Thread.Sleep(1500) Button1.Enabled = True If CheckedListBox1.CheckedIndices.Count > 0 Then
Dim x As Integer
For x = 0 To CheckedListBox1.Items.Count() - 1
If CheckedListBox1.GetItemChecked(x) Then
AxMSFlexGrid1.Rows = AxMSFlexGrid1.Rows + 1 AxMSFlexGrid1.set_TextMatrix(i, 0, CheckedListBox1.Items.Item(x).row(0).ToString) AxMSFlexGrid1.set_TextMatrix(i, 1, CheckedListBox1.Items.Item(x).row(3).ToString) AxMSFlexGrid1.set_TextMatrix(i, 2, 1) controlar_grid = 1 i += 1
End If
Next
If controlador = 0 Then
AxMSFlexGrid1.Rows = AxMSFlexGrid1.Rows - 1 controlador = 1
End If
Else
Label1.Text = "Debe escojer un producto para poder aadirlo" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
'MsgBox("pepe") End If
-
End Sub Private Sub factura_pedir_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ToolTip1.SetToolTip(Me.Button1, "Double Click en Grid para aadir cantidad")
Try
fitxer_conexio() SqlConnection1.ConnectionString = cadena_connection
Dim Ds_fact As New Data_factura
SqlConnection1.Open() SqlDataAdapter2.Fill(Ds_fact.Cliente)
ComboBox1.DataSource = Ds_fact.Cliente ComboBox1.DisplayMember = Ds_fact.Cliente.cli_empresaColumn.ToString ComboBox1.ValueMember = Ds_fact.Cliente.ID_clienteColumn.ToString
SqlDataAdapter3.Fill(Ds_fact.Categoria) ComboBox2.DataSource = Ds_fact.Categoria ComboBox2.DisplayMember = Ds_fact.Categoria.cate_nombreColumn.ToString ComboBox2.ValueMember = Ds_fact.Categoria.ID_categoriaColumn.ToString
SqlConnection1.Close()
Catch ex As Exception
MsgBox("Base de datos no operatiba")
End Try prepara_grid()
End Sub Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged cont += 1 If cont > 2 Then
'CheckedListBox1.Items.Clear()
Try SqlConnection1.Open() Dim com As New SqlCommand Dim p1 As New SqlParameter
com.CommandType = CommandType.StoredProcedure
-
p1.DbType = DbType.Int32 p1.Value = Integer.Parse(ComboBox2.SelectedValue.ToString) p1.ParameterName = "@id_cate"
com.Parameters.Add(p1) com.CommandText = "Fynd_productos" com.Connection = SqlConnection1
SqlDataAdapter4.SelectCommand = com 'Dim adapter As New SqlDataAdapter(com) Dim Ds_prodaa As New Data_factura SqlDataAdapter4.Fill(Ds_prodaa.Producto)
CheckedListBox1.DataSource = Ds_prodaa.Producto
CheckedListBox1.DisplayMember = Ds_prodaa.Producto.pro_nombreColumn.ToString CheckedListBox1.ValueMember = Ds_prodaa.Producto.ID_productoColumn.ToString
com.Parameters.Clear()
SqlConnection1.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If End Sub Private Sub AxMSFlexGrid1_DblClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxMSFlexGrid1.DblClick
With AxMSFlexGrid1
row_selecionado = .RowSel ComboBox3.Visible = True
End With End Sub Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged With AxMSFlexGrid1
.set_TextMatrix(row_selecionado, 2, ComboBox3.Text) Update()
End With
ComboBox3.Visible = False
End Sub
-
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If controlar_grid = 1 Then
If fer_factura() Then Label1.Text = "REGISTRO INTRODUCIDO CON EXITO (ID factura = " & xxx & ")" Update() System.Threading.Thread.Sleep(3000) AxMSFlexGrid1.Clear() prepara_grid() Label1.Text = "" i = 1 controlador = 0 controlar_grid = 0 Else Label1.Text = "REGISTRO NO INTRODUCIDO" Update() System.Threading.Thread.Sleep(2000) AxMSFlexGrid1.Clear() prepara_grid() Label1.Text = "" i = 1 controlador = 0 End If
Else Label1.Text = "Debe agregar algun producto" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
End If End Sub Private Function fer_factura() As Boolean Dim ret = False
Try
Dim Ds_fact As New Data_factura
With AxMSFlexGrid1 Dim q, t As Integer For q = 1 To .Rows - 1 For t = 1 To .Rows - 1 If .get_TextMatrix(t, 0) = .get_TextMatrix(q, 0) And t q Then Label1.Text = "Hay registros duplicados" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Exit Function
End If
Next Next
-
End With
SqlConnection1.Open()
Dim cmd As New SqlCommand cmd.CommandType = CommandType.Text cmd.CommandText = "SELECT ID_factura, fac_ID_cli, fac_fecna, fac_cobro,fac_esta_ano,fac_esta_mes FROM Factura" cmd.Connection = SqlConnection1 SqlDataAdapter6.SelectCommand = cmd
SqlDataAdapter6.Fill(Ds_fact.Factura) Dim fact As Data_factura.FacturaRow
fact = Ds_fact.Factura.NewRow
fact.fac_cobro = 1 fact.fac_fecna = System.DateTime.Now fact.fac_ID_cli = ComboBox1.SelectedValue.ToString fact.fac_esta_ano = System.DateTime.Now.Year fact.fac_esta_mes = System.DateTime.Now.Month.ToString
Ds_fact.Factura.AddFacturaRow(fact) SqlDataAdapter6.Update(Ds_fact.Factura) Ds_fact.Factura.AcceptChanges()
'encontrar factura mia
Dim com As New SqlCommand Dim p1 As New SqlParameter Dim p2 As New SqlParameter Dim p3 As New SqlParameter
com.CommandType = CommandType.StoredProcedure
p1.DbType = DbType.DateTime p1.Value = fact.fac_fecna p1.ParameterName = "@date"
p2.DbType = DbType.Int32 p2.Value = ComboBox1.SelectedValue.ToString p2.ParameterName = "@clien"
p3.DbType = DbType.Int32 p3.Direction = ParameterDirection.Output p3.ParameterName = "@id_fact"
com.Parameters.Add(p1) com.Parameters.Add(p2) com.Parameters.Add(p3)
com.CommandText = "Fynd_fact" com.Connection = SqlConnection1
SqlDataAdapter6.SelectCommand = com
com.ExecuteNonQuery()
-
xxx = p3.Value
'MsgBox(xxx) 'Dim adapter As New SqlDataAdapter(com)
com.Parameters.Clear()
With AxMSFlexGrid1 Dim q As Integer For q = 1 To .Rows - 1 If .get_TextMatrix(q, 2) "None" Then
SqlDataAdapter7.Fill(Ds_fact.Relacional) Dim factrela As Data_factura.RelacionalRow factrela = Ds_fact.Relacional.NewRow factrela.rela_ID_fac = xxx factrela.rela_ID_pro = .get_TextMatrix(q, 0) factrela.rela_cantidad = .get_TextMatrix(q, 2) Ds_fact.Relacional.AddRelacionalRow(factrela) SqlDataAdapter7.Update(Ds_fact.Relacional) Ds_fact.Relacional.AcceptChanges() End If Next End With 'SqlDataAdapter7.Dispose() 'SqlDataAdapter6.Dispose()
SqlConnection1.Close()
CheckedListBox1.DataSource = Nothing ret = True
Catch ex As Exception
MsgBox(ex.ToString)
End Try Return ret End Function Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged AxMSFlexGrid1.Clear() prepara_grid() i = 1 controlador = 0 'CheckedListBox1.da End Sub Private Function prepara_grid()
With AxMSFlexGrid1
.Rows = 2
-
.set_ColWidth(0, 1400) .set_ColWidth(1, 2200) .set_ColWidth(2, 982) .set_ColAlignment(2, 3) .set_ColAlignment(0, 3) .set_TextMatrix(0, 0, "ID Producto") .set_TextMatrix(0, 1, "Producto") .set_TextMatrix(0, 2, "Cantidad") .FixedCols = 0 .FixedRows = 1
End With
Dim se As Integer
ComboBox3.Items.Add("None") For se = 1 To 300
ComboBox3.Items.Add(se)
Next End Function End Class
-
Servicio_pedir:
Imports System.Data.SqlClient Public Class servicio_pedir Inherits System.Windows.Forms.Form
Dim var As Integer
Private Sub servicio_pedir_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try fitxer_conexio() SqlConnection1.ConnectionString = cadena_connection Dim Ds_ser As New Data_servicio Dim Ds_cli As New Data_cliente
Dim com As New SqlCommand Dim p1 As New SqlParameter
SqlConnection1.Open() SqlDataAdapter2.Fill(Ds_ser.Servicios)
com.CommandType = CommandType.StoredProcedure com.CommandText = "ordena_cliente" com.Connection = SqlConnection1
SqlDataAdapter1.SelectCommand = com
SqlDataAdapter1.Fill(Ds_cli.Cliente)
ComboBox1.DataSource = Ds_cli.Cliente ComboBox1.DisplayMember = Ds_cli.Cliente.cli_empresaColumn.ToString ComboBox1.ValueMember = Ds_cli.Cliente.ID_clienteColumn.ToString
ComboBox2.DataSource = Ds_ser.Servicios ComboBox2.DisplayMember = Ds_ser.Servicios.ser_servicioColumn.ToString ComboBox2.ValueMember = Ds_ser.Servicios.ID_servicioColumn.ToString
SqlConnection1.Close()
Catch ex As Exception
MsgBox("Base de datos no operatiba")
End Try End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ComboBox1.Text "" And ComboBox2.Text "" Then
-
If realizar_pedido() Then
Label1.Text = " REGISTRO INTRODUCIDO CON EXITO"
ComboBox2.SelectedIndex = 0 ComboBox1.SelectedIndex = 0 Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Else
Label1.Text = " REGISTRO NO INTRODUCIDO" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
End If
End If
End Sub
Private Function realizar_pedido() As Boolean
Dim ret As Boolean = False
Try
Dim Ds_servico As New Data_servicio Dim servc As Data_servicio.ServiciosRow
Dim Ds_ser As New Data_servicio Dim servv As Data_servicio.Ser_ClieRow
SqlDataAdapter2.Fill(Ds_servico)
servc = Ds_servico.Servicios.FindByID_servicio(ComboBox2.SelectedValue.ToString)
SqlConnection1.Open() SqlDataAdapter3.Fill(Ds_ser.Ser_Clie)
servv = Ds_ser.Ser_Clie.NewRow
servv.ser_cli_ID_cli = ComboBox1.SelectedValue.ToString servv.ser_cli_ID_ser = ComboBox2.SelectedValue.ToString servv.ser_cli_fecna = System.DateTime.Now() servv.ser_cli_Horas = servc.ser_horas
-
Ds_ser.Ser_Clie.AddSer_ClieRow(servv) SqlDataAdapter3.Update(Ds_ser.Ser_Clie) Ds_ser.Ser_Clie.AcceptChanges() SqlConnection1.Close()
ret = True Catch ex As Exception Return ret
End Try
Return ret
End Function
End Class
-
Actualizar_cliente: Imports System.Data.SqlClient Public Class actualizar_cliente Inherits System.Windows.Forms.Form Dim cont, contt As Integer Dim var As Integer
Private Sub actualizar_cliente_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try fitxer_conexio() SqlConnection1.ConnectionString = cadena_connection Dim Ds_cli As New Data_cliente 'Dim Ds_cli_e As New Data_cliente
SqlConnection1.Open() SqlDataAdapter1.Fill(Ds_cli.Cliente) 'SqlDataAdapter2.Fill(Ds_cli_e.Cliente)
ComboBox1.DataSource = Ds_cli.Cliente
ComboBox1.DisplayMember = Ds_cli.Cliente.cli_empresaColumn.ToString ComboBox1.ValueMember = Ds_cli.Cliente.ID_clienteColumn.ToString
ComboBox2.DataSource = Ds_cli.Cliente
ComboBox2.DisplayMember = Ds_cli.Cliente.ID_clienteColumn.ToString ComboBox2.ValueMember = Ds_cli.Cliente.ID_clienteColumn.ToString
SqlConnection1.Close()
Catch ex As Exception
'MsgBox("Base de datos no operatiba") MsgBox(ex.ToString)
End Try End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
cont += 1 If cont > 2 Then
cargar_grid(Integer.Parse(ComboBox1.SelectedValue.ToString)) var = Integer.Parse(ComboBox1.SelectedValue.ToString)
End If
-
End Sub
Private Function cargar_grid(ByVal lol As Integer)
Try
Dim Ds_clie As New DataSet
SqlConnection1.Open()
Dim com As New SqlCommand Dim p1 As New SqlParameter com.CommandType = CommandType.StoredProcedure com.CommandText = "act_cliente" com.Connection = SqlConnection1
p1.DbType = DbType.Int32 p1.Value = lol p1.ParameterName = "@id_cli"
com.Parameters.Add(p1)
SqlDataAdapter2.SelectCommand = com
SqlDataAdapter2.Fill(Ds_clie)
UltraGrid1.DataSource = Ds_clie.Tables("cliente")
'aqui en este punto crearemos un combobox ^^
Dim setw As New Data_cliente
SqlDataAdapter3.Fill(setw.Ubicacion_cp) If UltraGrid1.DisplayLayout.ValueLists.Exists("test1") Then UltraGrid1.DisplayLayout.ValueLists.Remove("test1") End If UltraGrid1.DisplayLayout.ValueLists.Add("test1")
With UltraGrid1.DisplayLayout.ValueLists("test1").ValueListItems Dim r As DataRow Dim t As DataTable
t = setw.Ubicacion_cp
For Each r In t.Rows
.Add(r(0).ToString, r(0).ToString)
Next
End With
UltraGrid1.DisplayLayout.Bands(0).Columns(6).ValueList _ = UltraGrid1.DisplayLayout.ValueLists("test1") UltraGrid1.DisplayLayout.Bands(0).Columns(6).Style _
-
=
Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownValidate.DropDownList
com.Parameters.Clear()
SqlConnection1.Close()
Catch ex As Exception
'MsgBox("Base de datos no operatiba") MsgBox(ex.ToString)
End Try
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try
Dim Ds_client As New Data_cliente
'UltraGrid1.Update() 'UltraGrid1.DataBind() Dim Dt As DataTable = UltraGrid1.DataSource
Dt.TableName = "cliente"
Dim r As DataRow
For Each r In Dt.Rows
'MsgBox(r(0) & " " & r(1) & " " & r(2) & " " & r(3) & " " & r(4))
Next
'Verificamos que la informacion sea correcta
If r(4).ToString.Length > 10 Then
Label1.Text = "NIF incorrecto" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End If
Try
Long.Parse(r(5).ToString) Catch ex As Exception
Label1.Text = "Numero de cuenta no es de caracter numerico"
-
Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End Try
If r(5).ToString.Length() > 25 Then
Label1.Text = "Numero de cuenta Incorrecto" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End If
SqlConnection1.Open()
Dim com As New SqlCommand Dim p1 As New SqlParameter Dim p2 As New SqlParameter Dim p3 As New SqlParameter Dim p4 As New SqlParameter Dim p5 As New SqlParameter Dim p6 As New SqlParameter Dim p7 As New SqlParameter Dim p8 As New SqlParameter com.CommandType = CommandType.StoredProcedure com.CommandText = "Actualizar_Cliente" com.Connection = SqlConnection1
p1.DbType = DbType.Int32 p1.Value = var p1.ParameterName = "@id_cli"
p2.DbType = DbType.AnsiString p2.Value = r(0).ToString p2.ParameterName = "@nombreemp"
p3.DbType = DbType.AnsiString p3.Value = r(1).ToString p3.ParameterName = "@nomcontact"
p4.DbType = DbType.AnsiString p4.Value = r(2).ToString p4.ParameterName = "@ape"
p5.DbType = DbType.AnsiString p5.Value = r(3).ToString p5.ParameterName = "@direccion"
p6.DbType = DbType.AnsiString p6.Value = r(4).ToString p6.ParameterName = "@cif"
p7.DbType = DbType.AnsiString p7.Value = r(5).ToString p7.ParameterName = "@cuenta"
-
p8.DbType = DbType.Int32 p8.Value = r(6).ToString p8.ParameterName = "@cp"
com.Parameters.Add(p1) com.Parameters.Add(p2) com.Parameters.Add(p3) com.Parameters.Add(p4) com.Parameters.Add(p5) com.Parameters.Add(p6) com.Parameters.Add(p7) com.Parameters.Add(p8)
com.ExecuteNonQuery() com.Parameters.Clear()
SqlConnection1.Close()
UltraGrid1.Update() UltraGrid1.DataBind()
Label1.Text = "Registro actualizado correctamente" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Catch ex As Exception
Label1.Text = "Registro NO actualizado" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Try
Catch es As Exception
SqlConnection1.Close() End Try
End Try End Sub
End Class
-
Actualizar_producto: Imports System.Data.SqlClient
Public Class actualizar_producto Inherits System.Windows.Forms.Form Dim cont, contt As Integer Dim var As Integer
Private Sub actualizar_producto_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try fitxer_conexio() SqlConnection1.ConnectionString = cadena_connection Dim Ds_pro As New Data_producto 'Dim Ds_cli_e As New Data_cliente
SqlConnection1.Open() SqlDataAdapter1.Fill(Ds_pro.Producto) 'SqlDataAdapter2.Fill(Ds_cli_e.Cliente)
ComboBox1.DataSource = Ds_pro.Producto
ComboBox1.DisplayMember = Ds_pro.Producto.pro_nombreColumn.ToString ComboBox1.ValueMember = Ds_pro.Producto.ID_productoColumn.ToString
ComboBox2.DataSource = Ds_pro.Producto
ComboBox2.DisplayMember = Ds_pro.Producto.ID_productoColumn.ToString ComboBox2.ValueMember = Ds_pro.Producto.ID_productoColumn.ToString
SqlConnection1.Close()
Catch ex As Exception
MsgBox("Base de datos no operatiba")
End Try End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
cont += 1 If cont > 2 Then
cargar_grid(Integer.Parse(ComboBox1.SelectedValue.ToString)) var = Integer.Parse(ComboBox1.SelectedValue.ToString)
End If
End Sub
Private Function cargar_grid(ByVal lol As Integer)
-
Try
Dim Ds_ser As New DataSet
SqlConnection1.Open()
Dim com As New SqlCommand Dim p1 As New SqlParameter com.CommandType = CommandType.StoredProcedure com.CommandText = "act_producto" com.Connection = SqlConnection1
p1.DbType = DbType.Int32 p1.Value = lol p1.ParameterName = "@id_pro"
com.Parameters.Add(p1)
SqlDataAdapter2.SelectCommand = com
SqlDataAdapter2.Fill(Ds_ser)
'DataGrid1.DataSource = Ds_cli
'codigo para hacer chhuminadas
UltraGrid1.DataSource = Ds_ser.Tables("producto")
'insertamos combobox lol
com.Parameters.Clear()
SqlConnection1.Close()
Catch ex As Exception
MsgBox("Base de datos no operatiba")
End Try
End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim Ds_prod As New Data_producto
'UltraGrid1.Update() 'UltraGrid1.DataBind() Dim Dt As DataTable = UltraGrid1.DataSource
Dt.TableName = "producto"
-
Dim r As DataRow
'Ds_prod.Merge(Dt)
For Each r In Dt.Rows
'MsgBox(r(0) & " " & r(1) & " " & r(2) & " " & r(3) & " " & r(4))
Next
Try
Double.Parse(r(1).ToString) Catch ex As Exception
Label1.Text = "Debe introducir una cantidad numerica en el campo precio/unidad" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
End Try
If Double.Parse(r(1).ToString) < 0 Then
Label1.Text = "Debe introducir una cantidad superior a 0" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Exit Sub
End If
SqlConnection1.Open()
Dim com As New SqlCommand Dim p1 As New SqlParameter Dim p2 As New SqlParameter Dim p3 As New SqlParameter Dim p4 As New SqlParameter Dim p5 As New SqlParameter com.CommandType = CommandType.StoredProcedure com.CommandText = "Actualizar_Producto" com.Connection = SqlConnection1
p1.DbType = DbType.Int32 p1.Value = var p1.ParameterName = "@id_pro"
p2.DbType = DbType.AnsiString p2.Value = r(0).ToString p2.ParameterName = "@producto"
p3.DbType = DbType.Int32
-
p3.Value = r(1).ToString p3.ParameterName = "@precio"
com.Parameters.Add(p1) com.Parameters.Add(p2) com.Parameters.Add(p3)
com.ExecuteNonQuery() com.Parameters.Clear()
SqlConnection1.Close()
UltraGrid1.Update() UltraGrid1.DataBind()
Label1.Text = "Registro actualizado correctamente" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Catch ex As Exception
Label1.Text = "Registro NO actualizado" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Try
Catch es As Exception
SqlConnection1.Close() End Try
End Try End Sub End Class
-
Actualizar_proveedor: Imports System.Data.SqlClient
Public Class actualizar_proveedor Inherits System.Windows.Forms.Form Dim cont, contt As Integer Dim var As Integer
Private Sub actualizar_proveedor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
fitxer_conexio() SqlConnection1.ConnectionString = cadena_connection Dim Ds_prove As New Data_proveedor 'Dim Ds_cli_e As New Data_cliente
SqlConnection1.Open() SqlDataAdapter1.Fill(Ds_prove.Proveedor) 'SqlDataAdapter2.Fill(Ds_cli_e.Cliente)
ComboBox1.DataSource = Ds_prove.Proveedor
ComboBox1.DisplayMember = Ds_prove.Proveedor.provee_nombreColumn.ToString ComboBox1.ValueMember = Ds_prove.Proveedor.ID_proveedorColumn.ToString
ComboBox2.DataSource = Ds_prove.Proveedor
ComboBox2.DisplayMember = Ds_prove.Proveedor.ID_proveedorColumn.ToString ComboBox2.ValueMember = Ds_prove.Proveedor.ID_proveedorColumn.ToString
SqlConnection1.Close()
Catch ex As Exception
MsgBox("Base de datos no operatiba")
End Try
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
cont += 1 If cont > 2 Then
cargar_grid(Integer.Parse(ComboBox1.SelectedValue.ToString)) var = Integer.Parse(ComboBox1.SelectedValue.ToString)
-
End If
End Sub
Private Function cargar_grid(ByVal lol As Integer)
Try
Dim Ds_proved As New DataSet
SqlConnection1.Open()
Dim com As New SqlCommand Dim p1 As New SqlParameter com.CommandType = CommandType.StoredProcedure com.CommandText = "act_proveedor" com.Connection = SqlConnection1
p1.DbType = DbType.Int32 p1.Value = lol p1.ParameterName = "@id_pro"
com.Parameters.Add(p1)
SqlDataAdapter2.SelectCommand = com
SqlDataAdapter2.Fill(Ds_proved)
'DataGrid1.DataSource = Ds_cli
'codigo para hacer chhuminadas
UltraGrid1.DataSource = Ds_proved.Tables("proveedor")
Dim setw As New Data_cliente
SqlDataAdapter3.Fill(setw.Ubicacion_cp) If UltraGrid1.DisplayLayout.ValueLists.Exists("test1") Then UltraGrid1.DisplayLayout.ValueLists.Remove("test1") End If UltraGrid1.DisplayLayout.ValueLists.Add("test1")
With UltraGrid1.DisplayLayout.ValueLists("test1").ValueListItems Dim r As DataRow Dim t As DataTable
t = setw.Ubicacion_cp
For Each r In t.Rows
.Add(r(0).ToString, r(0).ToString)
-
Next
End With
UltraGrid1.DisplayLayout.Bands(0).Columns(5).ValueList _ = UltraGrid1.DisplayLayout.ValueLists("test1") UltraGrid1.DisplayLayout.Bands(0).Columns(5).Style _ =
Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownValidate.DropDownList
com.Parameters.Clear()
SqlConnection1.Close()
Catch ex As Exception
MsgBox("Base de datos no operatiba")
End Try
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try
Dim Ds_prov As New Data_proveedor
'UltraGrid1.Update() 'UltraGrid1.DataBind() Dim Dt As DataTable = UltraGrid1.DataSource
Dt.TableName = "proveedor"
Dim r As DataRow
'Ds_prov.Merge(Dt)
For Each r In Dt.Rows
'MsgBox(r(0) & " " & r(1) & " " & r(2) & " " & r(3) & " " & r(4))
Next
If r(2).ToString.Length() > 10 Then
Label1.Text = "NIF incorrecto" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
-
End If
Try
Long.Parse(r(3).ToString) Catch ex As Exception
Label1.Text = "Telefono es de tipo numerico" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End Try
If r(3).ToString.Length() > 9 Then
Label1.Text = "Numero de telefono incorrecto" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End If
Try
Long.Parse(r(4).ToString) Catch ex As Exception
Label1.Text = "Numero de cuenta no es de caracter numerico" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End Try
If r(4).ToString.Length() > 25 Then
Label1.Text = "Numero de cuenta Incorrecto" Update() System.Threading.Thread.Sleep(2000) Label1.Text = "" Exit Sub
End If
SqlConnection1.Open()
Dim com As New SqlCommand Dim p1 As New SqlParameter Dim p2 As New SqlParameter Dim p3 As New SqlParameter Dim p4 As New SqlParameter
-
Dim p5 As New SqlParameter Dim p6 As New SqlParameter Dim p7 As New SqlParameter com.CommandType = CommandType.StoredProcedure com.CommandText = "Actualizar_Proveedor" com.Connection = SqlConnection1
p1.DbType = DbType.Int32 p1.Value = var p1.ParameterName = "@id_prov"
p2.DbType = DbType.AnsiString p2.Value = r(0).ToString p2.ParameterName = "@nombre"
p3.DbType = DbType.AnsiString p3.Value = r(1).ToString p3.ParameterName = "@direccion"
p4.DbType = DbType.AnsiString p4.Value = r(2).ToString p4.ParameterName = "@cif"
p5.DbType = DbType.AnsiString p5.Value = r(3).ToString p5.ParameterName = "@telefono"
p6.DbType = DbType.AnsiString p6.Value = r(4).ToString p6.ParameterName = "@cuenta"
p7.DbType = DbType.Int32 p7.Value = r(5).ToString p7.ParameterName = "@cp"
com.Parameters.Add(p1) com.Parameters.Add(p2) com.Parameters.Add(p3) com.Parameters.Add(p4) com.Parameters.Add(p5) com.Parameters.Add(p6) com.Parameters.Add(p7)
com.ExecuteNonQuery() com.Parameters.Clear()
SqlConnection1.Close()
UltraGrid1.Update() UltraGrid1.DataBind()
Label1.Text = "Registro actualizado correctamente" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Catch ex As Exception
Label1.Text = "Registro NO actualizado"
-
Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
Try
Catch es As Exception
SqlConnection1.Close() End Try
End Try End Sub End Class
-
Actualizar_servicio: Imports System.Data.SqlClient Public Class actualizar_servicio Inherits System.Windows.Forms.Form Dim cont, contt As Integer Dim var As Integer
Private Sub actualizar_servicio_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try
Dim Ds_ser As New Data_servicio fitxer_conexio() SqlConnection1.ConnectionString = cadena_connection
'Dim Ds_cli_e As New Data_cliente
SqlConnection1.Open() SqlDataAdapter1.Fill(Ds_ser.Servicios) 'SqlDataAdapter2.Fill(Ds_cli_e.Cliente)
ComboBox1.DataSource = Ds_ser.Servicios
ComboBox1.DisplayMember = Ds_ser.Servicios.ser_servicioColumn.ToString ComboBox1.ValueMember = Ds_ser.Servicios.ID_servicioColumn.ToString
ComboBox2.DataSource = Ds_ser.Servicios
ComboBox2.DisplayMember = Ds_ser.Servicios.ID_servicioColumn.ToString ComboBox2.ValueMember = Ds_ser.Servicios.ID_servicioColumn.ToString
SqlConnection1.Close()
Catch ex As Exception
MsgBox("Base de datos no operatiba")
End Try End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
cont += 1 If cont > 2 Then
cargar_grid(Integer.Parse(ComboBox1.SelectedValue.ToString)) var = Integer.Parse(ComboBox1.SelectedValue.ToString)
End If
-
End Sub Private Function cargar_grid(ByVal lol As Integer)
Try Dim Ds_serr As New DataSet
SqlConnection1.Open()
Dim com As New SqlCommand Dim p1 As New SqlParameter com.CommandType = CommandType.StoredProcedure com.CommandText = "act_servicio" com.Connection = SqlConnection1
p1.DbType = DbType.Int32 p1.Value = lol p1.ParameterName = "@id_pro"
com.Parameters.Add(p1)
SqlDataAdapter2.SelectCommand = com
SqlDataAdapter2.Fill(Ds_serr)
'DataGrid1.DataSource = Ds_cli
'codigo para hacer chhuminadas
UltraGrid1.DataSource = Ds_serr.Tables("servicios")
com.Parameters.Clear()
SqlConnection1.Close()
Catch ex As Exception
MsgBox("Base de datos no operatiba")
End Try
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim servi As New Data_servicio 'UltraGrid1.Update() 'UltraGrid1.DataBind()
SqlDataAdapter3.Fill(servi.Servicios)
-
Dim Dt As DataTable = UltraGrid1.DataSource
Dt.TableName = "servicios"
Dim r As DataRow
For Each r In Dt.Rows
'MsgBox(r(0) & " " & r(1) & " " & r(2) & " " & r(3) & " " & r(4))
Next
Try
Integer.Parse(r(3).ToString) Catch ex As Exception
Label1.Text = "Debe introducir una cantidad numerica en el campo horas" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
End Try
Try
Double.Parse(r(2).ToString) Catch ex As Exception
Label1.Text = "Debe introducir una cantidad numerica en el campo precio" Update() System.Threading.Thread.Sleep(2000) Label1.Text = ""
End Try
If Integer.Parse(r(3).ToString) < 0 Then
Label1.Text = "Debe introducir una cantidad numerica en el campo Horas" Update() System.Threading.Thread.Sleep(2000)
top related