コード例 #1
0
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            bool bandera = verificar();

            if (!bandera)
            {
                String nombre       = txtNombre.Text;
                int    departamento = Convert.ToInt32(cmbDpto.SelectedValue);
                int    municipio    = Convert.ToInt32(cmbMun.SelectedValue);

                _ComunidadLN comunidad = new _ComunidadLN(nombre, true, departamento, municipio);
                Boolean      correcto  = comunidad.Ingresar_C();

                if (mod == false)
                {
                    if (correcto)
                    {
                        comunidad.InsertarComunidad();
                        txtNombre.Text = "";
                        cmbDpto.Text   = "";
                        if (MessageBox.Show("¿Desea agregar otra comunidad?", "Confirmación", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            txtNombre.Focus();
                        }
                        else
                        {
                            comun.fillDataGrid();
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show(comunidad._obtenerError());
                    }
                }
                else
                {
                    if (correcto)
                    {
                        comunidad.ModificarComunidad(idComn);
                        comun.fillDataGrid();
                        mod = false;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show(comunidad._obtenerError());
                    }
                }
            }
        }
コード例 #2
0
        private void btnCancelar_Click(object sender, RoutedEventArgs e)
        {
            _Comunidad   sele      = dataGridComn.SelectedItem as _Comunidad;
            _ComunidadLN comunidad = new _ComunidadLN();
            Boolean      correcto  = comunidad.Ingresar_C();

            if (correcto)
            {
                if (MessageBox.Show("¿Desea eliminar esta comunidad?", "Confirmación", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    comunidad.eliminarComunidad(sele.idComunidad);
                    fillDataGrid();
                }
                else
                {
                    fillDataGrid();
                }
            }
            else
            {
                MessageBox.Show(comunidad._obtenerError());
            }
        }