private void buttonEdit1_EditValueChanged(object sender, EventArgs e) { if (sender == null) { return; } ButtonEdit buttonEdit = (ButtonEdit)sender; if (buttonEdit.EditValue == null) { return; } if (this.CODIGOBODEGALookUpEdit.EditValue == null) { return; } if (this.comprobante.CODIGOBODEGA == null) { XtraMessageBox.Show("Seleccione una bodega."); return; } IEnumerable <ARTICULO> listadoArticulo; DETALLECOMPROBANTE detalleComprobante; listadoArticulo = articuloServicio.getArticuloGeneral(codigoEmpresa, buttonEdit.EditValue.ToString(), CredencialUsuario.getInstancia().getEstablecimientoSeleccionado().CODIGOESTABLECIMIENTO); if (listadoArticulo != null) { if (listadoArticulo.Count() == 1) { int numlinea = 0; foreach (ARTICULO articulo in listadoArticulo) { numlinea++; detalleComprobante = existeArticulo(articulo, this.textEditCantidad.Value); if (detalleComprobante == null) { detalleComprobante = new DETALLECOMPROBANTE(); detalleComprobante.ARTICULO = articulo; detalleComprobante.CODIGOARTICULO = articulo.CODIGOARTICULO; /*revisar stock del articulo*/ BODEGASTOCK bodegaStock = facturaServicio.getStockBodega(articulo.CODIGOARTICULO, (long)this.CODIGOBODEGALookUpEdit.EditValue); if (bodegaStock.STOCKACTUAL == 0) { XtraMessageBox.Show("No existe stock para articulo: " + articulo.DESCRIPCION); return; } detalleComprobante.CANTIDAD = this.textEditCantidad.Value; detalleComprobante.NUMEROLINEA = numlinea; detalleComprobante.DESCRIPCIONARTICULO = articulo.DESCRIPCION; detalleComprobante.DESCUENTO = 0; if (articulo.PRECIOVARIABLE == "S") { PrecioVariableForm precioForm = new PrecioVariableForm(); precioForm.Articulo = articulo; precioForm.ShowDialog(); if (precioForm.DialogResult == DialogResult.OK) { articulo.PRECIOVENTA = precioForm.Articulo.PRECIOVENTA; } } decimal precioArticulo = 0; precioArticulo = getPrecio((long)this.CODIGOLISTADEPRECIOLookUpEdit.EditValue, articulo.CODIGOARTICULO, this.socionegocioSeleccionado.CODIGOSOCIONEGOCIO); if (precioArticulo > 0) { articulo.PRECIOVENTA = precioArticulo; } detalleComprobante.PVP = (articulo.IMPUESTO.DESGLOSADO == "N" ? articulo.PRECIOVENTA / (articulo.IMPUESTO.PORCENTAJE / 100) : articulo.PRECIOVENTA); detalleComprobante.BASEIMPONIBLE = Math.Round(detalleComprobante.CANTIDAD * detalleComprobante.PVP, 2); detalleComprobante.VALORIMPUESTO = Math.Round((decimal)detalleComprobante.BASEIMPONIBLE * (articulo.IMPUESTO.PORCENTAJE / 100), 2); detalleComprobante.TOTAL = Math.Round((decimal)detalleComprobante.BASEIMPONIBLE + (decimal)detalleComprobante.VALORIMPUESTO, 2); detalleComprobante.PORCENTAJEIMPUESTO = articulo.IMPUESTO.PORCENTAJE / 100; detalleComprobante.CODIGOIMPUESTO = articulo.CODIGOIMPUESTO; detalleComprobante.IMPUESTO = articulo.IMPUESTO; detalleComprobante.NUMEROLINEA = numlinea; detalleComprobante.ESTADO = (int)EnumEstado.ACTIVO; detalleComprobante.CODIGOBODEGA = (long)this.CODIGOBODEGALookUpEdit.EditValue; detalleComprobanteList.Add(detalleComprobante); bindingListDetalleComprobante = new BindingList <DETALLECOMPROBANTE>(detalleComprobanteList); this.DETALLECOMPROBANTEGridControl.DataSource = bindingListDetalleComprobante; } } } else { FormBuscarProducto formproducto = new FormBuscarProducto(listadoArticulo); formproducto.ShowDialog(); if (formproducto.DialogResult == DialogResult.OK) { ARTICULO articulo = formproducto.getProductoSeleccionado(); detalleComprobante = existeArticulo(formproducto.getProductoSeleccionado(), this.textEditCantidad.Value); if (detalleComprobante == null) { detalleComprobante = new DETALLECOMPROBANTE(); detalleComprobante.ARTICULO = articulo; detalleComprobante.CODIGOARTICULO = articulo.CODIGOARTICULO; BODEGASTOCK bodegaStock = facturaServicio.getStockBodega(articulo.CODIGOARTICULO, (long)this.CODIGOBODEGALookUpEdit.EditValue); if (bodegaStock.STOCKACTUAL == 0) { XtraMessageBox.Show("No existe stock para articulo: " + articulo.DESCRIPCION); return; } detalleComprobante.CANTIDAD = this.textEditCantidad.Value; detalleComprobante.DESCUENTO = 0; if (articulo.PRECIOVARIABLE == "S") { PrecioVariableForm precioForm = new PrecioVariableForm(); precioForm.Articulo = articulo; precioForm.ShowDialog(); if (precioForm.DialogResult == DialogResult.OK) { articulo.PRECIOVENTA = precioForm.Articulo.PRECIOVENTA; } } decimal precioArticulo = 0; precioArticulo = getPrecio((long)this.CODIGOLISTADEPRECIOLookUpEdit.EditValue, articulo.CODIGOARTICULO, this.socionegocioSeleccionado.CODIGOSOCIONEGOCIO); if (precioArticulo > 0) { articulo.PRECIOVENTA = precioArticulo; } detalleComprobante.PVP = (articulo.IMPUESTO.DESGLOSADO == "N" ? articulo.PRECIOVENTA / (articulo.IMPUESTO.PORCENTAJE / 100) : articulo.PRECIOVENTA); detalleComprobante.BASEIMPONIBLE = Math.Round(detalleComprobante.CANTIDAD * detalleComprobante.PVP, 2); detalleComprobante.VALORIMPUESTO = Math.Round((decimal)detalleComprobante.BASEIMPONIBLE * (articulo.IMPUESTO.PORCENTAJE / 100), 2); detalleComprobante.TOTAL = Math.Round((decimal)detalleComprobante.BASEIMPONIBLE + (decimal)detalleComprobante.VALORIMPUESTO, 2); detalleComprobante.DESCRIPCIONARTICULO = articulo.DESCRIPCION; detalleComprobante.PORCENTAJEIMPUESTO = articulo.IMPUESTO.PORCENTAJE / 100; detalleComprobante.CODIGOIMPUESTO = articulo.CODIGOIMPUESTO; detalleComprobante.IMPUESTO = articulo.IMPUESTO; detalleComprobante.CODIGOBODEGA = (long)this.CODIGOBODEGALookUpEdit.EditValue; detalleComprobanteList.Add(detalleComprobante); bindingListDetalleComprobante = new BindingList <DETALLECOMPROBANTE>(detalleComprobanteList); this.DETALLECOMPROBANTEGridControl.DataSource = bindingListDetalleComprobante; } } } } else { MessageBox.Show("No existe producto para: " + buttonEdit1.EditValue.ToString()); } calcularImpuestos(); buttonEdit.EditValue = null; buttonEdit.Focus(); }