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); } } }