4
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace ALM!"S # pu$lic partial class %rmAlumnos & Form # 'AS(DAT"S D' ) new 'AS(DAT"S*+; string S,L; pu$lic %rmAlumnos*+ # -nitiali eComponent*+; / pri0ate 0oid %rmAlumnos1Load*o$2ect sender3 (0entArgs e+ # D'.-niciarConexion*4C&5sers5Dell5Documents56ractica5ALM!"1D'.accd$4+; dg0Alumnos.DataMem$er ) 4Alumnos4; / pri0ate ALM!"S asig1alum1text*+ # string ncuenta3 nom$re3 apellidop3 apellidom; int edad ) 73 semestre; ncuenta ) txt!oCuenta.Text; nom$re ) txt!om$re.Text; apellidop ) txtAp8.Text; apellidom ) txtAp9.Text; try # edad ) Con0ert.To-nt:9*txt(dad.Text+; / catc # 55(2emplo de 0alidacion Message'ox.S ow* 4-ngrese un 0alor num<rico para la edad4+; txt(dad.Focus*+; txt(dad.SelectionStart ) 7; txt(dad.SelectionLengt ) txt(dad.TextLengt ; / semestre ) Con0ert.To-nt:9*txtSemestre.Text+; ALM!"S A ) new ALM!"S*ncuenta3 nom$re3 apellidop3 apellidom3 edad3 semestre+; return A; / pri0ate 0oid $utton81Clic=*o$2ect sender3 (0entArgs e+ # ALM!"S a ) asig1alum1text*+;
CodigoConeccDB
Embed Size (px)
DESCRIPTION
Cadena de conexion de base de datos
Citation preview
using System; using System.Collections.Generic;
using System.ComponentModel; using System.Data;
using System.Drawing; using System.Text;
using System.Windows.Forms;
namespace ALM!"S #
pu$lic partial class %rmAlumnos & Form
# 'AS(DAT"S D' ) new 'AS(DAT"S*+;
string S,L;
pu$lic %rmAlumnos*+ # -nitialieComponent*+;
/
D'.-niciarConexion*4C&5sers5Dell5Documents56ractica5ALM!"1D'.accd$4+;
dg0Alumnos.DataMem$er ) 4Alumnos4;
pri0ate ALM!"S asig1alum1text*+ #
string ncuenta3 nom$re3 apellidop3 apellidom;
int edad ) 73 semestre; ncuenta ) txt!oCuenta.Text;
nom$re ) txt!om$re.Text;
apellidop ) txtAp8.Text; apellidom ) txtAp9.Text; try
# edad ) Con0ert.To-nt:9*txt(dad.Text+; /
catc # 55(2emplo de 0alidacion
Message'ox.Sow*4-ngrese un 0alor num<rico para la edad4+;
txt(dad.Focus*+; txt(dad.SelectionStart ) 7;
txt(dad.SelectionLengt ) txt(dad.TextLengt; /
semestre ) Con0ert.To-nt:9*txtSemestre.Text+; ALM!"S A
) new ALM!"S*ncuenta3 nom$re3 apellidop3 apellidom3 edad3
semestre+; return A; /
pri0ate 0oid $utton81Clic=*o$2ect sender3
(0entArgs e+ #
ALM!"S a ) asig1alum1text*+;
S,L ) 4-!S(>T -!T"
alumnos*ncuenta3nom$re3apellidop3apellidom3edad3semestre+4;
S,L ?) 4@AL(S*4 ? a.ncuenta ? 44 ? 434 ? a.nom$re ?
434 ? a.apellidop ? 44; S,L ?) 434 ? a.apellidom ?
434 ? a.edad ? 43 4 ? a.semestre ? 4+4;
int insert ) D'.e2ecutar1sBl*sBl+;
i% *insert )) 8+ 55Si se logro la insercion limpio el
%ormulario # Message'ox.Sow*4Se insertaron
correctamente sus datos4+; txt!oCuenta.Text ) 44;
txt!om$re.Text ) 44; txtAp8.Text ) 44; txtAp9.Text )
44; txt(dad.Text ) 44; txtSemestre.Text ) 44;
txtCuenta.Text ) 44; txt!oCuenta.(na$led ) true;
$tn-nsertar.(na$led ) true;
D'.-niciarConexion*4C&5sers5Dell5Documents56ractica5ALM!"1D'.accd$4+;
/
pri0ate 0oid $utton91Clic=*o$2ect sender3
(0entArgs e+ # ALM!"S a ) asig1alum1text*+;
S,L ) 46DAT( alumnos S(T nom$re)4 ? a.nom$re ? 434;
S,L ?) 4 apellidop)4 ? a.apellidop ?
43apellidom)4 ? a.apellidom ? 434; S,L ?) 4
edad)4 ? a.edad ? 43 semestre)4 ? a.semestre ? 44;
S,L ?) 4 W(>( ncuenta)4 ? a.ncuenta ? 44;
int update ) D'.e2ecutar1sBl*sBl+;
i% *update )) 8+ 55Si se logro la actualiacin limpio el
%ormulario # Message'ox.Sow*4Se actualiaron
correctamente sus datos4+;
txt!oCuenta.Text ) 44; txt!om$re.Text ) 44;
txtAp8.Text ) 44; txtAp9.Text ) 44; txt(dad.Text )
44; txtSemestre.Text ) 44; txtCuenta.Text ) 44;
txt!oCuenta.(na$led ) true; $tn-nsertar.(na$led )
true;
D'.-niciarConexion*4C&5sers5Dell5Documents56ractica5ALM!"S1D'.accd$4+;
/ else Message'ox.Sow*4u$o un error al
actualiar los datos4+;
/
/
/
/
/