示例#1
0
 private void guardar_Click(object sender, RoutedEventArgs e)
 {
     if (clIdent.Text != "" && nomAc.Text != "" && apPater.Text != "" && apMater.Text != "" && calle.Text != ""
         && colonia.Text != "" && municipio.Text != "" && estado.Text != "")
     {
         if ((int)tipoCl.SelectedValue == 1)
         {
             Table<Alumno> al = conex.GetTable<Alumno>();
             Alumno alm = new Alumno();
             alm.Nombre = nomAc.Text;
             alm.apPater = apPater.Text;
             alm.apMater = apMater.Text;
             alm.calle = calle.Text;
             alm.colonia = colonia.Text;
             alm.num = num.Text;
             alm.municipio = municipio.Text;
             alm.estado = estado.Text;
             alm.telefono = telefono.Text;
             alm.matricula = clIdent.Text;
             al.InsertOnSubmit(alm);
             al.Context.SubmitChanges();
         }
         else if ((int)tipoCl.SelectedValue == 2)
         {
             Table<Empleado> em = conex.GetTable<Empleado>();
             Empleado emp = new Empleado();
             emp.Nombre = nomAc.Text;
             emp.apPater = apPater.Text;
             emp.apMater = apMater.Text;
             emp.calle = calle.Text;
             emp.colonia = colonia.Text;
             emp.num = num.Text;
             emp.municipio = municipio.Text;
             emp.estado = estado.Text;
             emp.telefono = telefono.Text;
             emp.numEmp = Int32.Parse(clIdent.Text);
             em.InsertOnSubmit(emp);
             em.Context.SubmitChanges();
         }
         else if ((int)tipoCl.SelectedValue == 3)
         {
             Table<ClienteExt> ce = conex.GetTable<ClienteExt>();
             ClienteExt cex = new ClienteExt();
             cex.Nombre = nomAc.Text;
             cex.apPater = apPater.Text;
             cex.apMater = apMater.Text;
             cex.calle = calle.Text;
             cex.colonia = colonia.Text;
             cex.num = num.Text;
             cex.municipio = municipio.Text;
             cex.estado = estado.Text;
             cex.telefono = telefono.Text;
             cex.curp_rfc = clIdent.Text;
             ce.InsertOnSubmit(cex);
             ce.Context.SubmitChanges();
         }
         MessageBox.Show("Cliente Agregado", "Correcto", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     else
     {
         MessageBox.Show("Verifique la información. Hacen falta algunos datos., ", "Información", MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
示例#2
0
 private void actualizar_Click(object sender, RoutedEventArgs e)
 {
     if (ident.Text != "" && nomAl.Text != "" && apPater.Text != "" && apMater.Text != "" && calle.Text != ""
         && colonia.Text != "" && municipio.Text != "" && estado.Text != "")
     {
     if (tabAlumno.IsSelected)
     {
         MessageBox.Show("Selecciono Alumno");
         Alumno ren = (from am in db.Alumno
                       where am.matricula == ident.Text
                       select am).SingleOrDefault();
         if (ren == null)
         {
             MessageBox.Show("Hay que insertar");
             Table<Alumno> ca = db.GetTable<Alumno>();
             Alumno a = new Alumno();
             a.matricula = ident.Text;
             a.Nombre = nomAl.Text;
             a.apPater = apPater.Text;
             a.apMater = apMater.Text;
             a.calle = calle.Text;
             a.colonia = colonia.Text;
             a.num = noExt.Text;
             a.municipio = municipio.Text;
             a.estado = estado.Text;
             a.telefono = tel.Text;
             ca.InsertOnSubmit(a);
             ca.Context.SubmitChanges();
             MessageBox.Show("El registro se agrego correctamente");
         }
         else
         {
             MessageBox.Show("Hay que modificar");
             ren.matricula = ident.Text;
             ren.Nombre = nomAl.Text;
             ren.apPater = apPater.Text;
             ren.apMater = apMater.Text;
             ren.calle = calle.Text;
             ren.colonia = colonia.Text;
             ren.num = noExt.Text;
             ren.municipio = municipio.Text;
             ren.estado = estado.Text;
             ren.telefono = tel.Text;
             db.SubmitChanges();
             MessageBox.Show("El registro se modifico correctamente");
         }
     }
     else if (tabClienteEx.IsSelected)
     {
         MessageBox.Show("Selecciono Externo");
         ClienteExt clex = (from ce in db.ClienteExt
                            where ce.curp_rfc == ident.Text
                            select ce).SingleOrDefault();
         if (clex == null)
         {
             //INSERTAR
             Table<ClienteExt> ce = db.GetTable<ClienteExt>();
             ClienteExt ex = new ClienteExt();
             ex.curp_rfc = ident.Text;
             ex.Nombre = nomAl.Text;
             ex.apPater = apPater.Text;
             ex.apMater = apMater.Text;
             ex.calle = calle.Text;
             ex.colonia = colonia.Text;
             ex.num = noExt.Text;
             ex.municipio = municipio.Text;
             ex.estado = estado.Text;
             ex.telefono = tel.Text;
             ce.InsertOnSubmit(ex);
             ce.Context.SubmitChanges();
             MessageBox.Show("El registro se agrego correctamente");
         }
         else
         {
             //MODIFICAR
             clex.curp_rfc = ident.Text;
             clex.Nombre = nomAl.Text;
             clex.apPater = apPater.Text;
             clex.apMater = apMater.Text;
             clex.calle = calle.Text;
             clex.colonia = colonia.Text;
             clex.num = noExt.Text;
             clex.municipio = municipio.Text;
             clex.estado = estado.Text;
             clex.telefono = tel.Text;
             db.SubmitChanges();
             MessageBox.Show("El registro se modifico correctamente");
         }
     }
     }
     else { MessageBox.Show("Faltan algunos datos..."); }
     limpiar_Click(sender, e);
 }