Esempio n. 1
0
        private void RemoverDetalleButton_Click(object sender, RoutedEventArgs e)
        {
            if (SDetalleDataGrid.SelectedIndex < 0)
            {
                MessageBox.Show("Debe de seleccionar una fila a remover");
                return;
            }
            else
            {
                if (SDetalleDataGrid.Items.Count > 1 && SDetalleDataGrid.SelectedIndex < SDetalleDataGrid.Items.Count - 1)
                {
                    var id   = salidas.SDetalle[SDetalleDataGrid.SelectedIndex].ProductoId;
                    var cant = salidas.SDetalle[SDetalleDataGrid.SelectedIndex].Cantidad;

                    SalidasBLL.ReponerProducto(Convert.ToInt32(id), Convert.ToInt32(cant));

                    salidas.SDetalle.RemoveAt(SDetalleDataGrid.SelectedIndex);

                    Actualizar();
                }
                else
                {
                    MessageBox.Show("No puedes quitar mas filas");
                }
            }
        }
Esempio n. 2
0
        private void AgregarButton_Click(object sender, RoutedEventArgs e)
        {
            if (!ValidarDetalle())
            {
                return;
            }

            if (!SalidasBLL.QuitarProducto(Convert.ToInt32(ProductoIdTextBox.Text), Convert.ToInt32(CantidadTextBox.Text)))
            {
                MessageBox.Show("El producto esta agotado o Digitó mas cantidad de la que existe");
                return;
            }

            salidas.SDetalle.Add(new SalidasDetalle(
                                     Convert.ToInt32(SalidaIdTextBox.Text),
                                     Convert.ToInt32(ProductoIdTextBox.Text),
                                     NombreProductoTextBox.Text,
                                     Convert.ToInt32(CantidadTextBox.Text),
                                     Convert.ToDecimal(PrecioTextBox.Text)));

            decimal Monto;
            decimal total;

            Monto = Convert.ToDecimal(PrecioTextBox.Text) * Convert.ToDecimal(CantidadTextBox.Text);
            total = Monto + Convert.ToDecimal(TotalTextBox.Text);

            TotalTextBox.Text = Convert.ToString(total);


            Actualizar();
            ProductoIdTextBox.Clear();
            CantidadTextBox.Clear();
        }
Esempio n. 3
0
        private void GuardarButton_Click(object sender, RoutedEventArgs e)
        {
            bool paso = false;

            if (!Validar())
            {
                return;
            }

            if (SalidaIdTextBox.Text == "0")
            {
                paso = SalidasBLL.Guardar(salidas);
            }
            else
            {
                if (!ExisteBase())
                {
                    MessageBox.Show("La Salida que digitó no Existe en la Base de Datos");
                    return;
                }
                paso = SalidasBLL.Modificar(salidas);
            }

            if (paso)
            {
                MessageBox.Show("La Salida Se ha Guardado Exitosamente");
                Limpiar();
            }
            else
            {
                MessageBox.Show("Ocurrio un Error al Guardar La Salida");
            }
        }
Esempio n. 4
0
        private void ConsultarButton_Click(object sender, RoutedEventArgs e)
        {
            var Listado = new List <Salidas>();

            if (CriterioTextBox.Text.Trim().Length > 0 || FiltroComboBox.SelectedIndex == 0 || FiltroComboBox.SelectedIndex == 3)
            {
                switch (FiltroComboBox.SelectedIndex)
                {
                case 0:    //Todo
                    Listado = SalidasBLL.GetList(s => true);
                    break;

                case 1:    //SalidaId
                    try
                    {
                        int id = Convert.ToInt32(CriterioTextBox.Text);
                        Listado = SalidasBLL.GetList(c => c.SalidaId == id);
                    }
                    catch (FormatException)
                    {
                        MessageBox.Show("El Id que digitó no es valido");
                    }
                    break;

                case 2:    //UsuarioId
                    try
                    {
                        int id = Convert.ToInt32(CriterioTextBox.Text);
                        Listado = SalidasBLL.GetList(c => c.UsuarioId == id);
                    }
                    catch (FormatException)
                    {
                        MessageBox.Show("El Id que digitó no es valido");
                    }
                    break;

                case 3:    //Fecha
                    try
                    {
                        if (DesdeDatePicker.SelectedDate != null && HastaDatePicker.SelectedDate != null)
                        {
                            Listado = SalidasBLL.GetList(c => c.Fecha.Date >= DesdeDatePicker.SelectedDate.Value && c.Fecha.Date <= HastaDatePicker.SelectedDate.Value).ToList();
                        }
                        else
                        {
                            MessageBox.Show("Falta una o ambas Fechas");
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("La fecha que ingreso no es valida");
                    }
                    break;
                }
                ConsultaDataGrid.ItemsSource = null;
                ConsultaDataGrid.ItemsSource = Listado;
            }
        }
Esempio n. 5
0
 private void EliminarButton_Click(object sender, RoutedEventArgs e)
 {
     if (SalidasBLL.Eliminar(Convert.ToInt32(SalidaIdTextBox.Text)))
     {
         MessageBox.Show("La Salida Se ha Eliminado Exitosamente");
         Limpiar();
     }
     else
     {
         MessageBox.Show("La Salida que digitó no existe");
     }
 }
Esempio n. 6
0
        private void BuscarButton_Click(object sender, RoutedEventArgs e)
        {
            Salidas s = SalidasBLL.Buscar(Convert.ToInt32(SalidaIdTextBox.Text));

            if (s != null)
            {
                salidas = s;
                Actualizar();
            }
            else
            {
                MessageBox.Show("La Salida que digitó no existe o no se pudo localizar");
            }
        }
Esempio n. 7
0
        private bool ExisteBase()
        {
            Salidas s = SalidasBLL.Buscar((int)Convert.ToInt32(SalidaIdTextBox.Text));

            return(s != null);
        }