Sistema Ferreteria
Sistema Ferreteria
Sistema Ferreteria
Use Ferreteria
Create table Productos
(
idprod int primary key,
nomprod varchar(50),
precio int,
idcat int
)
Create table Categorias
(
idcate int primary key,
nomcate varchar(50)
)
Create table Empleados
(
idemp int identity primary key,
nomemp varchar(50),
clave varchar(12)
)
insert into Empleados (nomemp,clave) values ('oscar','12345')
insert into Empleados (nomemp,clave) values ('maria','54321')
Select * From Empleados
Public Class Form9
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
ProgressBar1.Value = ProgressBar1.Value + 1
If ProgressBar1.Value >= 100 Then
Timer1.Enabled = False
Form1.Show()
Me.Hide()
End If
End Sub
End Class
Imports System.Data
Imports System.Data.SqlClient
Menu Principal
End Sub
End Class
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data
Imports System.Data.SqlClient
Public Class Form4
Dim cn As New SqlConnection("Server=(local);Integrated
Security=yes;DataBase=Ferreteria")
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim sql As String
sql = "Select * From Categorias Where idcate=" & TextBox1.Text
Dim cmd As New SqlCommand(sql, cn)
cn.Open()
Dim lector As SqlDataReader 'Sirve para leer la Data del command
lector = cmd.ExecuteReader 'Lee el Select del command
If lector.Read Then
TextBox2.Text = lector(1).ToString
Else
MsgBox("Codigo no Existe", 16, "Aviso")
End If
TextBox1.Clear()
TextBox1.Focus()
cn.Close()
End Sub
End Class
Imports System.Data
Imports System.Data.SqlClient
Public Class Form5
Dim cn As New SqlConnection("Server=(local);Integrated
Security=yes;DataBase=Ferreteria")
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim sql As String
sql = "Select * From Categorias Where idcate=" & TextBox1.Text
Dim cmd As New SqlCommand(sql, cn)
cn.Open()
Dim lector As SqlDataReader
lector = cmd.ExecuteReader
If lector.Read Then
TextBox2.Text = lector(1).ToString
Else
MsgBox("Codigo no Existe", 16, "Aviso")
End If
cn.Close()
activar(True)
End Sub
Sub activar(ByVal x As Boolean)
TextBox1.Enabled = Not x
TextBox2.Enabled = x
Button2.Enabled = Not x
Button1.Enabled = x
Button3.Enabled = Not x
End Sub
Imports System.Data
Imports System.Data.SqlClient
End If
Else
If estado = "Modificar" Then
If MsgBox("Desear Actualizar los cambios del Registro",
MsgBoxStyle.YesNo, "Aviso") = vbYes Then
cn.Open()
dr = ds.Tables("empleados").Rows(fil)
dr(1) = TextBox1.Text
dr(2) = TextBox2.Text
Dim cb As New SqlCommandBuilder(da)
da.Update(ds, "empleados")
ds.Tables(0).AcceptChanges()
botones(True)
textos(True)
limpiar()
cn.Close()
End If
End If
End If
estado = ""
Verdatos2()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
If MsgBox("Desea eliminar el Registro?", MsgBoxStyle.YesNo, "Aviso") =
vbYes Then
dr = ds.Tables("empleados").Rows(fil)
dr.Delete()
Dim del As New DataTable
Dim cb As New SqlCommandBuilder(da)
del = ds.Tables("empleados").GetChanges(DataRowState.Deleted)
da.Update(del)
ds.Tables("empleados").AcceptChanges()
textos(False)
verdatos()
End If
End Sub