protected void lsbArticulos_SelectedIndexChanged(object sender, EventArgs e) { nTasIGV = double.Parse(lblTasIGV.Value); int ArtCod = 0; int PrvCod = 0; int LotNro = 0; double LprPrecio = 0.0; double LprDscto = 0.0; double nPrecio = 0.0; ArtCod = int.Parse(lsbArticulos.SelectedValue); PrvCod = int.Parse(ddlLaboratorios.SelectedValue); txtLotVenci.Text = ""; txtLotNro.Text = ""; txtLotStock.Text = "0"; clsArticulos lstArticulos = new clsArticulos(); clsListaPrecios lstPrecios = new clsListaPrecios(); clsLotesArt lstLotesArt = new clsLotesArt(); Articulos oArticulo = new Articulos(); ListaPrecios oPrecio = new ListaPrecios(); LotesArt oLoteArt = new LotesArt(); txtLotNro.Enabled = false; txtLotVenci.Enabled = false; txtLotStock.Enabled = false; txtArtDescuento.Enabled = true; oPrecio = lstPrecios.GetArticuloPrecio(ArtCod); oLoteArt = lstLotesArt.GetLoteArt(ArtCod); //oLoteArt.ListaPrecios.Articulos oArticulo = lstArticulos.GetArticulo(ArtCod); if (oArticulo != null) { txtArtCod.Text = oArticulo.ArtCod.ToString(); txtArtUniMed.Text = oArticulo.Unidades.UniDescripcion; txtStockFact.Text = oArticulo.ArtStockFac.ToString(); txtStockFis.Text = oArticulo.ArtStock.ToString(); hideStockLote.Value = lstLotesArt.GetLoteArtStock(ArtCod).ToString(); if (oLoteArt != null) { txtLotNro.Text = oLoteArt.LotNro.ToString(); txtLotStock.Text = oLoteArt.LotStock.ToString(); if (oLoteArt.LotFecVenci != null) txtLotVenci.Text = ((DateTime)oLoteArt.LotFecVenci).ToString("yyyy-MM-dd"); } if (oArticulo.ArtStock <= 0) txtStockFis.ForeColor = System.Drawing.Color.Red; else txtStockFis.ForeColor = System.Drawing.Color.Gray; txtArtPreUnitario.Text = lstPrecios.GetCostoPromedio(ArtCod, nTasIGV).ToString(); //if (oPrecio == null) // txtArtPreUnitario.Text = "0.0"; //else //{ // nPrecio = (double)oPrecio.LprPrecio; // var nDcto = Math.Round((nPrecio * (double)oPrecio.LprDscto / 100), 2); // nPrecio -= nDcto; // var nFlete = Math.Round(nPrecio / 100, 2); // nPrecio += nFlete; // var nIgv = Math.Round(nPrecio * nTasIGV, 2); // nPrecio += nIgv; // if (oArticulo.Proveedores.PrvGanancia != 0) // nPrecio = Math.Round((nPrecio * (double)oArticulo.Proveedores.PrvGanancia), 2); // txtArtPreUnitario.Text = nPrecio.ToString(); //} if (BuscarArticulo(oArticulo.ArtCod, ref LotNro, ref LprPrecio, ref LprDscto)) { txtArtDescuento.Enabled = false; txtArtDescuento.Text = LprDscto.ToString(); } else { txtArtDescuento.Enabled = true; txtArtDescuento.Text = "0"; } txtArtCant.Text = "1"; } else txtArtCant.Text = "0"; txtImpTotal.Text = "0.0"; lstArticulos = null; oArticulo = null; lstPrecios = null; oPrecio = null; CalcularTotalArticulo(); lsbArticulos.Focus(); }
protected void lsbArticulos_SelectedIndexChanged(object sender, EventArgs e) { int ArtCod = 0; int LotNro = 0; double LprPrecio = 0.0; double LprDscto = 0.0; if (lsbArticulos.SelectedValue != "") ArtCod = int.Parse(lsbArticulos.SelectedValue); clsArticulos lstArticulos = new clsArticulos(); clsListaPrecios lstPrecios = new clsListaPrecios(); clsLotesArt lstLotesArt = new clsLotesArt(); Articulos oArticulo = new Articulos(); ListaPrecios oPrecio = new ListaPrecios(); oPrecio = lstPrecios.GetArticuloPrecio(ArtCod); oArticulo = lstArticulos.GetArticulo(ArtCod); if (oArticulo != null) { txtArtCod.Text = oArticulo.ArtCod.ToString(); txtArtUniMed.Text = oArticulo.Unidades.UniDescripcion; txtStockFact.Text = oArticulo.ArtStockFac.ToString(); txtStockFis.Text = oArticulo.ArtStock.ToString(); txtArtDescuento.Text = (oArticulo.Proveedores.PrvDscto).ToString(); ddlTipDcto.SelectedValue = "%"; txtLotVenci.Text = DateTime.Now.AddDays(30).ToString("yyyy-MM-dd"); ddlLaboratorios.SelectedValue = oArticulo.PrvCod.ToString(); hideStockLote.Value = lstLotesArt.GetLoteArtStock(ArtCod).ToString(); if (oArticulo.ArtStock <= 0) { txtStockFis.ForeColor = System.Drawing.Color.Red; } else { txtStockFis.ForeColor = System.Drawing.Color.Gray; } if (oPrecio == null) { txtArtPreUnitario.Text = "0.0"; } else { txtArtPreUnitario.Text = oPrecio.LprPrecio.ToString(); } if (BuscarArticulo(oArticulo.ArtCod, ref LotNro, ref LprPrecio, ref LprDscto)) { if (lblEstadoVenArticulo.Value == "NORMAL") txtArtPreUnitario.Enabled = false; else txtArtPreUnitario.Enabled = true; txtLotNro.Enabled = false; txtLotNro.Text = LotNro.ToString(); txtArtPreUnitario.Text = LprPrecio.ToString(); } else { txtArtPreUnitario.Enabled = true; txtLotNro.Enabled = true; LotNro = lstLotesArt.MaxLotNro(ArtCod); txtLotNro.Text = (LotNro + 1).ToString(); } if (lblEstadoVenArticulo.Value == "NORMAL") txtArtCant.Text = "1"; } else LimpiarCamposArticulos(); txtImpTotal.Text = "0.0"; lstArticulos = null; oArticulo = null; lstPrecios = null; oPrecio = null; lstLotesArt = null; CalcularTotalArticulo(); lsbArticulos.Focus(); }