You are on page 1of 4

MAN1LNIMILN1C CCN MLNU 2

lC8MuLA8lC 1 MLnu
lmporLs SysLemuaLa
lmporLs SysLemuaLaSqlCllenL
ubllc Class lorm1
rlvaLe ob[ As new Class1
ulm cmd As new SqlCommand(SelecL * from producLo1 cnx)
ulm da As new SqluaLaAdapLer
ulm ds As new uaLaSeL
ulm dL As new uaLa1able

rlvaLe Sub lorm1_Load(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles My8aseLoad
cargardaLos()
LxLnombreLnabled lalse
Lnd Sub

rlvaLe Sub 8uLLon1_Cllck(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles 8uLLon1Cllck
nuevoShowulalog()
Lnd Sub

rlvaLe Sub uaLaCrldvlew1_uoubleCllck(8yval sender As Cb[ecL 8yval e As SysLemLvenLArgs) Pandles uaLaCrldvlew1uoubleCllck
lf noL lsu8null(MeuaLaCrldvlew1SelecLedCells(0)value) 1hen
LdlLarLxLCodlgo1exL MeuaLaCrldvlew1SelecLedCells(0)value
LdlLarLxLnombre1exL MeuaLaCrldvlew1SelecLedCells(1)value
LdlLarLxLCaLeg1exL MeuaLaCrldvlew1SelecLedCells(2)value
LdlLarLxLreclo1exL MeuaLaCrldvlew1SelecLedCells(3)value
LdlLarLxLSLock1exL MeuaLaCrldvlew1SelecLedCells(4)value

LllmlnarLxLcodlgo1exL MeuaLaCrldvlew1SelecLedCells(0)value
LllmlnarLxLnombre1exL MeuaLaCrldvlew1SelecLedCells(1)value
LllmlnarLxLCaLeg1exL MeuaLaCrldvlew1SelecLedCells(2)value
LllmlnarLxLpreclo1exL MeuaLaCrldvlew1SelecLedCells(3)value
LllmlnarLxLsLock1exL MeuaLaCrldvlew1SelecLedCells(4)value
Lnd lf
Lnd Sub

rlvaLe Sub 8uLLon2_Cllck(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles 8uLLon2Cllck
LdlLarShowulalog()
Lnd Sub

rlvaLe Sub 8uLLon3_Cllck(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles 8uLLon3Cllck
LllmlnarShowulalog()
Lnd Sub

rlvaLe Sub 8uLLon11_Cllck(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles 8uLLon11Cllck
ClobalSysLemWlndowslormsAppllcaLlonLxlL()
Lnd Sub

rlvaLe Sub LxLnombre_1exLChanged(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles
LxLnombre1exLChanged
1ry
ob[form1(uaLaCrldvlew1 LxLnombre1exL)
CaLch ex As LxcepLlon
Lnd 1ry
Lnd Sub

rlvaLe Sub 8uLLon3_Cllck(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles 8uLLon3Cllck
LxLnombre1exL
cargardaLos()
Lnd Sub

rlvaLe Sub 8uLLon4_Cllck(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles 8uLLon4Cllck
LxLnombreLnabled 1rue
LxLnombrelocus()
Lnd Sub
Lnd Class

lC8MuLA8lC nuLvC
lmporLs SysLemuaLa
lmporLs SysLemuaLaSqlCllenL

ubllc Class nuevo
ubllc cn As new SqlConnecLlon(ServerAuMlnSCLLx8LSSdaLabasevenLaslnLegraLed securlLy Lrue)

rlvaLe Sub 8uLLon1_Cllck(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles 8uLLon1Cllck

1ry
ulm Cmd As new SqlCommand(lnserL lnLo roducLo1 values([Cod [nom [caL [pre [SLo) cn)
CmdarameLersAdd([Cod Sqlub1ypevarChar 6)value MeLxLcodlgo1exL
CmdarameLersAdd([nom Sqlub1ypevarChar 40)value MeLxLnombre1exL
CmdarameLersAdd([caL Sqlub1ypevarChar 30)value MeLxLCaLeg1exL
CmdarameLersAdd([re Sqlub1ypeMoney)value Cuec(MeLxLpreclo1exL)
CmdarameLersAdd([SLo Sqlub1ypelnL)value ClnL(MeLxLsLock1exL)

cnCpen()
CmdLxecuLenonCuery()
cnClose()

Msg8ox(roducLo se Cuardo correcLanmenLe)
cargardaLos()

llmplar()
CaLch ex As LxcepLlon
Msg8ox(Codlgo ya LxlsLenLe en la 8ase de uaLos Msg8oxSLylelnformaLlon AdmlnlsLrador del SlsLema)

MeLxLcodlgo1exL
llmplar()
llnally
cnClose()
Lnd 1ry
Lnd Sub

rlvaLe Sub 8uLLon2_Cllck(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles 8uLLon2Cllck
Close()
Lnd Sub


lC8MuLA8lC Lul1A8
lmporLs SysLemuaLa
lmporLs SysLemuaLaSqlCllenL
ubllc Class LdlLar
ubllc cn As new SqlConnecLlon(ServerAuMlnSCLLx8LSSdaLabasevenLaslnLegraLed securlLy Lrue)

rlvaLe Sub cmdCrabar_Cllck(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles cmdCrabarCllck
ulm cmd As new SqlCommand(updaLe producLo1 seL nompro[nom caLepro[caL prepro[pre sLopro[sLo where codpro
[cod cn)

cmdarameLersAdd([cod Sqlub1ypevarChar 6)value MeLxLCodlgo1exL
cmdarameLersAdd([nom Sqlub1ypevarChar 40)value MeLxLnombre1exL
cmdarameLersAdd([caL Sqlub1ypevarChar 10)value MeLxLCaLeg1exL
cmdarameLersAdd([pre Sqlub1ypeMoney)value Cuec(MeLxLreclo1exL)
cmdarameLersAdd([sLo Sqlub1ypelnL)value ClnL(MeLxLSLock1exL)
cnCpen()
cmdLxecuLenonCuery()
cnClose()
Msg8ox(roducLo se Modlflco CorrecLamenLe)
cargardaLos()
llmplar()

Lnd Sub

rlvaLe Sub cmdMenu_Cllck(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles cmdMenuCllck
Close()
lorm1LxLnombre1exL
cargardaLos()
Lnd Sub

lC8MuLA8lC LLlMlnA8
lmporLs SysLemuaLa
lmporLs SysLemuaLaSqlCllenL

ubllc Class Lllmlnar
ubllc cn As new SqlConnecLlon(ServerAuMlnSCLLx8LSSdaLabasevenLaslnLegraLed securlLy Lrue)
rlvaLe Sub 8uLLon3_Cllck(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles 8uLLon3Cllck
Close()
Lnd Sub

rlvaLe Sub 8uLLon1_Cllck(8yval sender As SysLemCb[ecL 8yval e As SysLemLvenLArgs) Pandles 8uLLon1Cllck
ulm ellmlnar As SLrlng uLLL1L l8CM producLo1 WPL8L codpro LxLcodlgoLexL
ulm mlconexlon As new SqlConnecLlon(cn)
ulm deleLe As new SqlCommand(ellmlnar cn)

lf Message8oxShow(Seguro de Lllmlnar el reglsLro? _
ALencln Message8ox8uLLons?esno _
Message8oxlconCuesLlon) ulalog8esulL?es 1hen
cnCpen()
deleLeLxecuLenonCuery()
cnClose()
Msg8ox(Ll 8LClS18C PA SluC LLlMlnAuC CCn Lxl1C Msg8oxSLylelnformaLlon)
Lnd lf
cargardaLos()
llmplarL()



CLASL
lmporLs SysLemuaLa
lmporLs SysLemuaLaSqlCllenL

ubllc Class Class1
ubllc Sub form1(8yval daLagrldvlew1 As uaLaCrldvlew 8yval LxLnombre As SLrlng)
lf LxLnombre1rlm 1hen
ulm cnx As new SqlConnecLlon(ServerAuMlnSCLLx8LSSdaLabasevenLaslnLegraLed securlLy Lrue)
ulm cmd As new SqlCommand(SelecL * from producLo1 where nompro llke LxLnombre cnx)
ulm da As new SqluaLaAdapLer(cmd)
ulm dL As new uaLa1able
dallll(dL)
daLagrldvlew1uaLaSource dL
Llse
daLagrldvlew1uaLaSource noLhlng
Lnd lf
Lnd Sub

MCuuLC
lmporLs SysLemuaLa
lmporLs SysLemuaLaSqlCllenL

Module Module1
ubllc cnx As new SqlConnecLlon(ServerAuMlnSCLLx8LSSdaLabasevenLaslnLegraLed securlLy Lrue)

Sub cargardaLos()
ulm cmd As new SqlCommand(SelecL * from producLo1 cnx)
ulm da As new SqluaLaAdapLer(cmd)
ulm dL As new uaLa1able
daflll(dL)
lorm1uaLaCrldvlew1uaLaSource dL
conLar LoLal de reglsLros
lorm1lblLoLalreg1exL dL8owsCounL
conLar suma LoLal del sLock
lorm1lblLoLalsLock1exL dLCompuLe(sum(sLopro) )
Lnd Sub

Sub llmplar()
nuevoLxLcodlgoClear()
nuevoLxLnombreClear()
nuevoLxLCaLegClear()
nuevoLxLprecloClear()
nuevoLxLsLockClear()
nuevoLxLcodlgolocus()
Lnd Sub

Sub llmplarL()
LllmlnarLxLcodlgoClear()
LllmlnarLxLnombreClear()
LllmlnarLxLCaLegClear()
LllmlnarLxLprecloClear()
LllmlnarLxLsLockClear()

LllmlnarLxLcodlgoLnabled lalse
LllmlnarLxLnombreLnabled lalse
LllmlnarLxLCaLegLnabled lalse
LllmlnarLxLprecloLnabled lalse
LllmlnarLxLsLockLnabled lalse
Lnd Sub
Lnd Module

You might also like