private void txtNombrePromotor_TextChanged(object sender, TextChangedEventArgs e)
        {
            Promotore _promotor = new Promotore();
            _promotor.Nombre = txtNombrePromotor.Text;

            dgPromotor.ItemsSource = _promotorBL.ObtenerPromotoresPorNombre(_promotor);
        }
Example #2
0
        public int EliminarPromotores(Promotore pPromotore)
        {
            Promotore tmpPromotores = BuscarPromotores(pPromotore);

            BDComun.Contexto.Promotores.Remove(tmpPromotores);
            return BDComun.Contexto.SaveChanges();
        }
Example #3
0
        public int ModificarPromotores(Promotore pPromotore)
        {
            Promotore tmpPromotores = BuscarPromotores(pPromotore);
            tmpPromotores.Id = pPromotore.Id;
            tmpPromotores.Nombre = pPromotore.Nombre;
            tmpPromotores.Apellido = pPromotore.Apellido;
            tmpPromotores.Telefono = pPromotore.Telefono;
            tmpPromotores.Direccion = pPromotore.Direccion;

            return BDComun.Contexto.SaveChanges();
        }
 private void dgPromotor_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     PromotorE = dgPromotor.SelectedItem as Promotore;
     DialogResult = true;
 }
        private void btnBusPromotor_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                BuscarPromotor _bus = new BuscarPromotor();
                _bus.ShowDialog();

                _promotorB = _bus.PromotorE;
                txtPromotor.Text = _promotorB.Nombre;
            }
            catch
            {
            }
        }
Example #6
0
 public List<Promotore> ObtenerPromotoresPorNombre(Promotore pPromotore)
 {
     return BDComun.Contexto.Promotores.Where(c => c.Nombre.Contains(pPromotore.Nombre)).ToList();
 }
Example #7
0
 public Promotore BuscarPromotores(Promotore pPromotore)
 {
     return BDComun.Contexto.Promotores.SingleOrDefault(c => c.Id == pPromotore.Id);
 }
Example #8
0
        public int AgregarPromotores(Promotore pPromotore)
        {
            BDComun.Contexto.Promotores.Add(pPromotore);

            return BDComun.Contexto.SaveChanges();
        }
        private void btnConsultar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                BuscarPromotor _bus = new BuscarPromotor();
                _bus.ShowDialog();

                _promotorEntity = _bus.PromotorE;
                txtId.Text = _promotorEntity.Id.ToString();
                txtNombre.Text = _promotorEntity.Nombre;
                txtApellido.Text = _promotorEntity.Apellido;
                txtTelefono.Text = _promotorEntity.Telefono;
                txtDireccion.Text = _promotorEntity.Direccion;
                txtZona.Text = _zonaB.Nombre;

                txtNombre.IsEnabled = true;
                txtApellido.IsEnabled = true;
                txtTelefono.IsEnabled = true;
                txtDireccion.IsEnabled = true;
                txtZona.IsEnabled = false;
                btnNuevo.IsEnabled = false;
                btnGuardar.IsEnabled = false;
                btnModificar.IsEnabled = true;
                btnEliminar.IsEnabled = true;
                btnBuscar.IsEnabled = true;
                btnConsultar.IsEnabled = true;
                btnSalir.IsEnabled = true;
            }
            catch
            {
            }
        }
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtNombre.Text == string.Empty)
                {
                    MessageBox.Show("Llene el campo nombre");
                }
                if (txtApellido.Text == string.Empty)
                {
                    MessageBox.Show("Llene el campo apellido");
                }
                if (txtTelefono.Text == string.Empty)
                {
                    MessageBox.Show("Llene el campo teléfono");
                }
                if (txtDireccion.Text == string.Empty)
                {
                    MessageBox.Show("Llene el campo dirección");
                }
                if (txtZona.Text == string.Empty)
                {
                    MessageBox.Show("Llene el campo zona");
                }
                if (!(txtNombre.Text == string.Empty || txtApellido.Text == string.Empty || txtTelefono.Text == string.Empty || txtDireccion.Text == string.Empty || txtZona.Text == string.Empty))
                {
                    Promotore _promotor = new Promotore();
                    _promotor.Nombre = txtNombre.Text;
                    _promotor.Apellido = txtApellido.Text;
                    _promotor.Telefono = txtTelefono.Text;
                    _promotor.Direccion = txtDireccion.Text;
                    _promotor.Zona = _zonaB;

                    if (_promotorBL.AgregarPromotores(_promotor) > 0)
                    {
                        MessageBox.Show("El registro se agregó con éxito");
                        Actualizar();
                    }
                    else
                    {
                        MessageBox.Show("El registro no pudo ser agregado");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lo sentimos, algo ocurrió mal\n" + "Advertencia" + ex.Message);
            }
        }