Example #1
0
        private void buttonAgregar_Click(object sender, EventArgs e)
        {
            List <MantenimientoDetalle> Detalle = new List <MantenimientoDetalle>();

            if (DetalleDataGridView.DataSource != null)
            {
                Detalle = (List <MantenimientoDetalle>)DetalleDataGridView.DataSource;
            }

            foreach (var item in ArticulosBLL.GetList(x => x.Inventario < CantidadNumericUpDown.Value))
            {
                MessageBox.Show("No Dispone de esa cantidad", "Verificacion",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (string.IsNullOrEmpty(ImporteTextBox.Text))
            {
                MessageBox.Show("EL Importe Se Encuentra vacio, Introduzca la cantidad",
                                "Verificacion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Detalle.Add(
                    new MantenimientoDetalle(id: 0,
                                             mantenimientoId: (int)Convert.ToInt32(MantenimientoIdNumericUpDown.Value),
                                             tallerId: (int)TallerComboBox.SelectedValue,
                                             articuloId: (int)ArticulosComboBox.SelectedValue,
                                             articulo: (string)ArticulosBLL.RetornarDescripcion(ArticulosComboBox.Text),
                                             cantidad: (int)Convert.ToInt32(CantidadNumericUpDown.Value),
                                             precio: (int)Convert.ToInt32(PrecioTextBox.Text),
                                             importe: (int)Convert.ToInt32(ImporteTextBox.Text)

                                             ));

                //Cargar el detalle al Grid
                DetalleDataGridView.DataSource = null;
                DetalleDataGridView.DataSource = Detalle;

                //Oculta las Columnas No deceada
                QuitarColumnas();
            }

            decimal subtotal = 0;

            foreach (var item in Detalle)
            {
                subtotal += item.Importe;
            }

            SubtotalTextBox.Text = subtotal.ToString();

            itbis = MantenimientoBLL.CalcularItbis(Convert.ToDecimal(SubtotalTextBox.Text));

            ITBISTextBox.Text = itbis.ToString();

            Total = MantenimientoBLL.CalcularTotal(Convert.ToDecimal(SubtotalTextBox.Text), Convert.ToDecimal(ITBISTextBox.Text));

            TotalTextBox.Text = Total.ToString();
        }