示例#1
0
        private void DetallecomboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int ID, id;

            id = Convert.ToInt32(IDcomboBox.Text);
            ID = Convert.ToInt32(DetallecomboBox.Text);
            if (facturas.Detalle.Count() == 0)
            {
                facturas.Detalle = FacturaDetalleBLL.GetList(x => x.FacturaId == id);
            }
            foreach (var item in facturas.Detalle)
            {
                if (item.Id == ID)
                {
                    DescripcionProductotextBox.Text = item.Descripcion;
                    PreciotextBox.Text          = item.Precio.ToString();
                    ProductoIdcomboBox.Text     = item.ProductoId.ToString();
                    CantidadnumericUpDown.Value = item.Cantidad;
                }
            }
        }
示例#2
0
        private void IDcomboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            LimpiarProvider();
            int idfactura = Convert.ToInt32(IDcomboBox.Text);

            facturas = FacturacionBLL.Buscar(Convert.ToInt32(IDcomboBox.Text));
            CLienteIDcomboBox.Text          = facturas.ClienteID.ToString();
            DescripciponFacturatextBox.Text = facturas.Descripcion;
            DevueltatextBox.Text            = facturas.Devuelta.ToString();
            MontotextBox.Text           = facturas.Monto.ToString();
            Monto                       = facturas.Monto;
            FechadateTimePicker.Value   = facturas.Fecha;
            EfectivonumericUpDown.Value = facturas.EfectivoRecibido;
            facturas.Detalle            = FacturaDetalleBLL.GetList(x => x.FacturaId == idfactura);
            LlenarDetalleComboBox();
            DetallecomboBox.Enabled = true;
            EliminarDetalle.Enabled = true;
            foreach (var item in facturas.Detalle)
            {
                item.Importe = FacturacionBLL.Importedemas(item.Cantidad, item.Precio);
            }
            FacturadataGridView.DataSource = facturas.Detalle;
            Detalle = new List <FacturaDetalle>();
        }
示例#3
0
        private void BuscarFacturaButton_Click(object sender, EventArgs e)
        {
            int            ID      = int.Parse(IDNumericUpDown.Text);
            Facturas       Factura = new Facturas();
            FacturaDetalle Detalle = new FacturaDetalle();

            Factura = FacturaDetalleBLL.Buscar(ID);

            if (Factura != null)
            {
                MessageBox.Show("Factura Encontrada");
                IdPersonasNumericUpDown.Value  = Factura.IdPersona;
                IdProductoNumericUpDown.Value  = Detalle.IdProducto;
                FechadateTimePicker.Value      = Factura.Fecha;
                ObservacionTextBox.Text        = Factura.Observacion;
                MontoTextBox.Text              = (Factura.Monto).ToString();
                FacturaDataGridView.DataSource = FacturaDetalleBLL.GetList(X => X.IdFactura == (int)IDNumericUpDown.Value);
                IdProductoNumericUpDown.Value  = Detalle.IdProducto;
            }
            else
            {
                MessageBox.Show("Factura No encontada");
            }
        }
示例#4
0
        private void Agregarbutton_Click_1(object sender, EventArgs e)
        {
            LimpiarProvider();
            RepositoryBase <Producto> repositoryBase = new RepositoryBase <Producto>();

            if (SetError(6) || SetError(7))
            {
                MessageBox.Show("Debe de completar los campos marcados");
                return;
            }
            if (repositoryBase.Buscar(Convert.ToInt32(ProductoIdcomboBox.Text)).Cantidad - Convert.ToInt32(CantidadnumericUpDown.Value) < 0)
            {
                MessageBox.Show("Cantidad insuficiente del producto solicitado");
                MessageBox.Show("Disponibles " + repositoryBase.Buscar(Convert.ToInt32(ProductoIdcomboBox.Text)).Cantidad.ToString());
                return;
            }
            if (IDcomboBox.Text == string.Empty)
            {
                facturas.Detalle.Add(new FacturaDetalle(0, facturas.FacturaId, Convert.ToInt32(ProductoIdcomboBox.Text), Convert.ToInt32(CantidadnumericUpDown.Value), Convert.ToDecimal(PreciotextBox.Text), DescripcionProductotextBox.Text, Convert.ToDecimal(ImportetextBox.Text)));
            }
            else
            {
                int idfactura = Convert.ToInt32(IDcomboBox.Text);
                if (facturas.Detalle.Count == 0)
                {
                    facturas.Detalle = FacturaDetalleBLL.GetList(x => x.FacturaId == idfactura);
                }
                if (DetallecomboBox.Text == string.Empty)
                {
                    var Idproducto = Convert.ToInt32(ProductoIdcomboBox.Text);
                    if (facturas.Detalle.Exists(x => x.ProductoId == Idproducto))
                    {
                        foreach (var item in facturas.Detalle)
                        {
                            if (item.ProductoId == Idproducto)
                            {
                                item.Cantidad += Convert.ToInt32(CantidadnumericUpDown.Value);
                            }
                        }
                    }
                    else
                    {
                        facturas.Detalle.Add(new FacturaDetalle(0, Convert.ToInt32(IDcomboBox.Text), Convert.ToInt32(ProductoIdcomboBox.Text), Convert.ToInt32(CantidadnumericUpDown.Value), Convert.ToDecimal(PreciotextBox.Text), DescripcionProductotextBox.Text, Convert.ToDecimal(ImportetextBox.Text)));
                    }
                }
                else
                {
                    Monto -= FacturacionBLL.DescontarImporte(facturas.Detalle, Convert.ToInt32(DetallecomboBox.Text));

                    foreach (var item in facturas.Detalle)
                    {
                        item.Importe = FacturacionBLL.Importe(item.Cantidad, CantidadnumericUpDown.Value, item.Precio, Convert.ToInt32(ProductoIdcomboBox.Text), item.ProductoId);
                    }
                    facturas.Detalle = FacturacionBLL.Editar(facturas.Detalle, new FacturaDetalle(Convert.ToInt32(DetallecomboBox.Text), Convert.ToInt32(IDcomboBox.Text), Convert.ToInt32(ProductoIdcomboBox.Text), Convert.ToInt32(CantidadnumericUpDown.Value), Convert.ToDecimal(PreciotextBox.Text), DescripcionProductotextBox.Text, Convert.ToDecimal(ImportetextBox.Text)));
                }
            }
            Monto            += FacturacionBLL.CalcularMonto(Convert.ToDecimal(ImportetextBox.Text));
            MontotextBox.Text = Monto.ToString();
            if (paso)
            {
                AsignarDevuelta();
            }
            FacturadataGridView.DataSource = null;
            FacturadataGridView.DataSource = facturas.Detalle;
            LimpiarProducto();
            LlenarDetalleComboBox();
            EliminarDetalle.Enabled = true;
        }