protected void btnNuevoPrecio_Click(object sender, EventArgs e) { AgregarVariableSession("operacionPrecio", 1); int linProCodigo = (int)LeerVariableSesion("proCodigo"); clsListaPrecios oListaPrecioLst = new clsListaPrecios(); clsLotesArt oLotesArtLst = new clsLotesArt(); int linLprCod = oListaPrecioLst.MaxListaPrecioCod(); int linLotCod = oLotesArtLst.MaxLotesCod(); int linNroLot = oLotesArtLst.MaxLotNro(linProCodigo) + 1; txtLote.Text = linNroLot.ToString(); txtCodigoPrecio.Text = linLprCod.ToString(); lblCodigoLote.Text = linLotCod.ToString(); //GUARDAR DATOS NUEVO PRODUCTO INGRESADOS GuardarDatosProducto_Sesion(); pnlEditProductos.Visible = false; pnlBusqueda.Visible = false; pnlProductos.Visible = false; pnlListaPrecios.Visible = false ; pnlDetallePrecio.Visible = true ; lblMensajes.Visible = false; txtPrecio.Text = "0"; txtDescuento.Text = "0"; txtStockLote.Text = "0"; txtFecVenceLote.Text = DateTime.Today.ToString(); ; chkEstadoPrecio.Checked = true; }
private void EventoGuardarPrecio() { int linOperacion = (int)LeerVariableSesion("operacionPrecio"); if (linOperacion == 1) //NUEVO { int linProCodigo = (int)LeerVariableSesion("proCodigo"); clsListaPrecios oListaPrecioLst = new clsListaPrecios(); clsLotesArt oLotesArtLst = new clsLotesArt(); ListaPrecios oListaPrecio = new ListaPrecios(); LotesArt oLotesArt = new LotesArt(); int linLprCod = oListaPrecioLst.MaxListaPrecioCod() + 1; int linLotCod = oLotesArtLst.MaxLotesCod() + 1; int linNroLot = oLotesArtLst.MaxLotNro(linProCodigo) + 1; oListaPrecio.LprPrecio = Convert.ToDecimal( txtPrecio.Text); oListaPrecio.LprDscto = Convert.ToDecimal( txtDescuento.Text); oListaPrecio.LprCod = linLprCod; oListaPrecio.LprFecRegis = DateTime.Today; oListaPrecio.LprEstado = true; oListaPrecio.ArtCod = linProCodigo; oLotesArt.LotStock = Convert.ToDecimal(txtStockLote.Text); oLotesArt.LotFecVenci = DateTime.Parse( txtFecVenceLote.Text); oLotesArt.LprCod = linLprCod; oLotesArt.LotCod = linLotCod; oLotesArt.LotNro = Convert.ToInt32(txtLote.Text); oLotesArt.LotFecModi = DateTime.Today; oLotesArt.LotFecRegis = DateTime.Today; oLotesArt.LotEstado = true; try { oListaPrecioLst.Add(oListaPrecio); oListaPrecioLst.SaveChanges(); oLotesArtLst.Add(oLotesArt); oLotesArtLst.SaveChanges(); RestaurarDatosProducto_sesion(); lblMensajes.Visible = true; lblMensajes.Text = "El registro se Grabo Satisfactoriamente."; this.MessageBox("El registro se Grabo Satisfactoriamente."); pnlBusqueda.Visible = false; //pnlTipoProductos.Visible = false; pnlProductos.Visible = false; pnlEditProductos.Visible = true; pnlListaPrecios.Visible = true; pnlDetallePrecio.Visible = false; } catch (Exception ex) { lblMensajes.Text = "Error:" + ex.Message; this.MessageBox("Error:" + ex.Message); } } else // MODIFICAR { int linPrecioCodigo = (int)LeerVariableSesion("precioCodigo"); ListaPrecios oListaPrecio = new ListaPrecios(); clsListaPrecios oListaPrecioLst = new clsListaPrecios (); oListaPrecio = oListaPrecioLst.GetPrecio(linPrecioCodigo); LotesArt oLotesArt = new LotesArt(); clsLotesArt oLotesArtLst = new clsLotesArt(); oLotesArt = oLotesArtLst.GetLotesPrecio(oListaPrecio.LprCod); oListaPrecio.LprPrecio = Convert.ToDecimal( txtPrecio.Text); oListaPrecio.LprDscto = Convert.ToDecimal( txtDescuento.Text); oLotesArt.LotStock = Convert.ToDecimal(txtStockLote.Text); oLotesArt.LotFecVenci = DateTime.Parse( txtFecVenceLote.Text); try { oListaPrecioLst.Update(oListaPrecio); oListaPrecioLst.SaveChanges(); oLotesArtLst.Update(oLotesArt); oLotesArtLst.SaveChanges(); lblMensajes.Visible = true; lblMensajes.Text = "El registro se Grabo Satisfactoriamente."; this.MessageBox("El registro se Grabo Satisfactoriamente."); pnlBusqueda.Visible = false; //pnlTipoProductos.Visible = false; pnlProductos.Visible = false; pnlEditProductos.Visible = true; pnlListaPrecios.Visible = true; pnlDetallePrecio.Visible = false; RestaurarDatosProducto_sesion(); } catch (Exception ex) { lblMensajes.Text = "Error:" + ex.Message; this.MessageBox("Error:" + ex.Message); } } }
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(); }