Пример #1
0
        //Boton consultar
        private void btnConsultar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                BuscarADESCO _bus = new BuscarADESCO();
                _bus.ShowDialog();

                _adescoEntity = _bus.AdescoE;
                txtId.Text = _adescoEntity.Id.ToString();
                txtNombre.Text = _adescoEntity.Nombre;
                txtTipo.Text = _adescoEntity.TipoADESCO;

                txtNombre.IsEnabled = true;
                txtTipo.IsEnabled = true;
                btnNuevo.IsEnabled = false;
                btnGuardar.IsEnabled = false;
                btnModificar.IsEnabled = true;
                btnEliminar.IsEnabled = true;
                btnConsultar.IsEnabled = true;
                btnSalir.IsEnabled = true;
            }
            catch
            {
            }
        }
Пример #2
0
        //Boton Modificar datos
        private void btnModificar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtNombre.Text == string.Empty)
                {
                    MessageBox.Show("Llene el campo nombre");
                }
                if (txtTipo.Text == string.Empty)
                {
                    MessageBox.Show("Llene el campo tipo");
                }
                if (!(txtNombre.Text == string.Empty || txtTipo.Text == string.Empty))
                {
                    AccesoADatos.ADESCO _adesco = new AccesoADatos.ADESCO();
                    _adescoEntity.Id = Convert.ToInt64(txtId.Text);
                    _adescoEntity.Nombre = txtNombre.Text;
                    _adescoEntity.TipoADESCO = txtTipo.Text;

                    if (_adescoBL.ModificarADESCOS(_adescoEntity) > 0)
                    {
                        MessageBox.Show("El registro se modificó correctamente");
                    }
                    //else
                    //{
                    //    MessageBox.Show("El registro no se pudo modificar");
                    //}

                    Actualizar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No seleccione los últimos datos de la lista(están vacios) o pueda que se guarden pero no es recomendable\n" + "Advertencia" + ex.Message);
            }
        }
Пример #3
0
        //Boton Guardar datos
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtNombre.Text == string.Empty)
                {
                    MessageBox.Show("Llene el campo nombre");
                }
                if (txtTipo.Text == string.Empty)
                {
                    MessageBox.Show("Llene el campo tipo");
                }
                if (!(txtNombre.Text == string.Empty || txtTipo.Text == string.Empty))
                {
                    AccesoADatos.ADESCO _adesco = new AccesoADatos.ADESCO();
                    _adesco.Nombre = txtNombre.Text;
                    _adesco.TipoADESCO = txtTipo.Text;

                    if (_adescoBL.AgregarADESCOS(_adesco) > 0)
                    {
                        MessageBox.Show("El registro se agregó correctamente");
                    }
                    else
                    {
                        MessageBox.Show("El registro no se pudo guardar");
                    }

                    Actualizar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se pudo agregar el registro" + "Advertencia" + ex.Message);
            }
        }