public List <BEProducto> ListarProductoCliente(int pIdCliente) { DatabaseHelper oDatabaseHelper = new DatabaseHelper(); List <BEProducto> vLista = new List <BEProducto>(); BEProducto oBEProducto = null; IDataReader oIDataReader = null; try { oDatabaseHelper.ClearParameter(); oDatabaseHelper.AddParameter("@intIdCliente", pIdCliente); oIDataReader = oDatabaseHelper.ExecuteReader("DGP_Listar_ProductoClienteVenta", CommandType.StoredProcedure); while (oIDataReader.Read()) { oBEProducto = new BEProducto(); oBEProducto.IdProducto = int.Parse(oIDataReader["Id_Producto"].ToString()); oBEProducto.Nombre = oIDataReader["Producto"].ToString(); vLista.Add(oBEProducto); } return(vLista); } catch (Exception ex) { throw ex; } finally { if (!oIDataReader.IsClosed) { oIDataReader.Close(); } oIDataReader.Dispose(); oDatabaseHelper.Dispose(); } }
public bool GuardarActualizar(BEProducto producto, int accion) { try { bool bExito = false; using (var cmd = new SqlCommand("sp_producto_actualizar", _cn, _trx)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", producto.Id).SqlDbType = SqlDbType.VarChar; cmd.Parameters.AddWithValue("@Descripcion", producto.Descripcion).SqlDbType = SqlDbType.VarChar; cmd.Parameters.AddWithValue("@Igv", producto.Igv).SqlDbType = SqlDbType.Decimal; cmd.Parameters.AddWithValue("@Precio", producto.Precio).SqlDbType = SqlDbType.Decimal; cmd.Parameters.AddWithValue("@Activo", producto.Activo).SqlDbType = SqlDbType.Bit; cmd.Parameters.AddWithValue("@Accion", accion).SqlDbType = SqlDbType.Int; var n = cmd.ExecuteNonQuery(); if (n > 0) { bExito = true; } } return(bExito); } catch (Exception ex) { throw ex; } }
public static bool Eliminar(BEProducto producto) { bool bExito = false; using (var cn = new SqlConnection(cnx)) { try { cn.Open(); using (var trx = cn.BeginTransaction()) { try { bExito = new DLProducto(cn, trx).Eliminar(producto); trx.Commit(); } catch (Exception ex) { trx.Rollback(); throw ex; } } } catch (Exception ex) { throw ex; } } return(bExito); }
public void AplicarPreciosGrupo(BEProducto producto, decimal precioBase, decimal Margen, int FormaAplicar) { foreach (DataGridViewRow item in this.dgrvVentas.Rows) { if (producto.IdProducto == (int)item.Cells["IdProducto"].Value) { decimal margen = (string.IsNullOrEmpty(item.Cells["Margen"].Value.ToString())) ? Margen : decimal.Parse(item.Cells["Margen"].Value.ToString()); decimal PrecioCompra = (string.IsNullOrEmpty(item.Cells["PrecioCompra"].Value.ToString())) ? precioBase : decimal.Parse(item.Cells["PrecioCompra"].Value.ToString()); PrecioCompra *= 1.0000m; decimal PrecioVentaActual = (string.IsNullOrEmpty(item.Cells["Precio"].Value.ToString())) ? precioBase : decimal.Parse(item.Cells["Precio"].Value.ToString()); if (FormaAplicar == 2) //clientes precio variable { PrecioCompra = (PrecioCompra <= 0) ? 0 : decimal.Round(PrecioCompra, 1, MidpointRounding.AwayFromZero); bool tieneMargenVariable = false; bool.TryParse(item.Cells["TienePrecioVariable"].Value.ToString(), out tieneMargenVariable); if (PrecioCompra != 0 && (PrecioVentaActual != PrecioCompra + margen) && (item.Cells["NuevoPrecio"].Value == null || string.IsNullOrEmpty(item.Cells["NuevoPrecio"].Value.ToString()))) { item.Cells["NuevoPrecio"].Value = (tieneMargenVariable) ? (PrecioCompra + margen).ToString() : string.Empty; item.Cells["Precio"].Style.ForeColor = (PrecioVentaActual < PrecioCompra + margen) ? Color.Red :Color.Black; item.Cells["NuevoPrecio"].Style.ForeColor = (PrecioVentaActual < PrecioCompra + margen) ? Color.Red : Color.Black; } } else { item.Cells["NuevoPrecio"].Value = precioBase + margen; } } } }
public static BaseResponse Eliminar(int Id) { try { var respuesta = new BaseResponse(); var producto = new BEProducto() { Id = Id }; var bExito = BLProducto.Eliminar(producto); if (bExito) { respuesta.Exito = true; respuesta.Data = "Producto eliminado correctamente"; } else { respuesta.Exito = true; respuesta.Data = string.Format("Error al eliminar el producto {0} ", Id); } return(respuesta); } catch (Exception ex) { return(new BaseResponse(false, ex.Message)); } }
public async Task <IActionResult> AgregarNuevaFoto( IFormFile Files, PictureViewModels PictureViewModels) { string NombreImagenInicial = string.Empty; if (Files != null) { if (Files.FileName.Contains(".jpg") || Files.FileName.Contains(".JPEG") || Files.FileName.Contains(".gif") || Files.FileName.Contains(".png") || Files.FileName.Contains(".tif")) { NombreImagenInicial = Files.FileName.Replace(" ", ""); /////// var Insert_Fotos = new PictureViewModels(); if (PictureViewModels != null) { var GetValue = new BEImagen(); var GetValuep = new BEProducto(); GetValue.descripcion = PictureViewModels.descripcionImagen; GetValue.posicionPortada = PictureViewModels.posicionPortada; GetValuep.Descripcion = PictureViewModels.DescripcionProducto; GetValuep.fechaexpiracion = PictureViewModels.fechaexpiracion; GetValuep.fechaproduccion = PictureViewModels.fechaproduccion; GetValuep.Nombre = PictureViewModels.NombreProducto; GetValuep.Precio = PictureViewModels.Precio; GetValuep.Stock = PictureViewModels.Stock; NombreImagenInicial = PictureViewModels.NombreImagen.Replace(" ", "") + Guid.NewGuid().ToString() + NombreImagenInicial; GetValue.Nombre = NombreImagenInicial; Insert_Fotos = _IFotos.Insert_BEFoto(GetValue, GetValuep); PictureViewModels.idfoto = Insert_Fotos.idfoto; PictureViewModels.idproducto = Insert_Fotos.idproducto; PictureViewModels.CantidadDeregistros = Insert_Fotos.CantidadDeregistros; PictureViewModels.NombreImagen = NombreImagenInicial; } // solo guarda si se completo el insert de las entidades var PathToSave = Path.Combine(_IEnviroment.WebRootPath, "images"); if (Files.Length > 0) { if (Insert_Fotos.CantidadDeregistros > 0) { //grabamos la imange en la APP using (var SaveFile = new FileStream(Path.Combine(PathToSave, NombreImagenInicial), FileMode.Create)) { await Files.CopyToAsync(SaveFile); } //Enviamos A La API La imagen SendToApi(Files, NombreImagenInicial, PictureViewModels); } } } } ///////////////// //var file = Request.; return(RedirectToAction("ProductosLista", "Producto")); }
public List <BEProducto> Listar(BEProducto pBEProducto) { try { return(new DAProducto().Listar(pBEProducto)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> AgregarNuevaFoto( IFormFile Files, PictureViewModels PictureViewModels) { string NombreImagenInicial = string.Empty; string NombreImagen = string.Empty; if (Files.Name.Length >= 5) { if (Files.Name.Contains(".jpg") || Files.Name.Contains(".JPEG") || Files.Name.Contains(".gif") || Files.Name.Contains(".png") || Files.Name.Contains(".tif")) { NombreImagenInicial = Files.Name.Replace(" ", ""); /////// var Insert_Fotos = new PictureViewModels(); if (PictureViewModels != null) { var GetValue = new BEFotos(); var GetValuep = new BEProducto(); GetValue.descripcion = PictureViewModels.descripcionImagen; GetValue.Nombre = PictureViewModels.NombreImagen; GetValue.posicionPortada = PictureViewModels.posicionPortada; GetValuep.Descripcion = PictureViewModels.DescripcionProducto; GetValuep.fechaexpiracion = PictureViewModels.fechaexpiracion; GetValuep.fechaproduccion = PictureViewModels.fechaproduccion; GetValuep.Nombre = PictureViewModels.NombreProducto; GetValuep.Precio = PictureViewModels.Precio; GetValuep.Stock = PictureViewModels.Stock; var Gui = new Guid(); NombreImagen = PictureViewModels.NombreImagen.Replace(" ", "") + Gui.ToString(); Insert_Fotos = _IFotos.Insert_BEFoto(GetValue, GetValuep); } // solo guarda si se completo el insert de las entidades var PathToSave = Path.Combine(_IEnviroment.WebRootPath, "Imagen"); if (Files.Length > 0) { if (Insert_Fotos.CantidadDeregistros > 0) { using (var SaveFile = new FileStream(Path.Combine(PathToSave, NombreImagen + NombreImagenInicial), FileMode.Create)) { await Files.CopyToAsync(SaveFile); } } } } } ///////////////// //var file = Request.; return(View()); }
public static BaseResponse GuardarActualizar(BEProducto producto, int accion) { try { bool bExito = false; var respuesta = new BaseResponse(); switch (accion) { case 0: bExito = BLProducto.GuardarActualizar(producto, 0); break; case 1: bExito = BLProducto.GuardarActualizar(producto, 1); break; } if (accion.Equals(0)) { if (bExito) { respuesta.Exito = true; respuesta.Data = "Producto guardado correctamente"; } else { respuesta.Exito = false; respuesta.Data = "No se pudo guardar el prodcuto"; } } else if (accion.Equals(1)) { if (bExito) { respuesta.Exito = true; respuesta.Data = "Producto actualizado correctamente"; } else { respuesta.Exito = false; respuesta.Data = "No se pudo actualizar el prodcuto"; } } return(respuesta); } catch (Exception ex) { return(new BaseResponse(false, ex.Message)); } }
private void CargarProducto() { BEProducto producto = (BEProducto)this.cbProducto.SelectedItem; if (producto == null) { return; } this.nudPrecioBase.Value = producto.PrecioCompra; //this.nubMargenMinimo }
public BEProducto ShowDetalleProducto(string conexion, string key) { BEProducto BEProducto = new BEProducto(); try { var Parameter = new SqlParameter[3]; Parameter[0] = new SqlParameter("@key", SqlDbType.VarChar) { Value = key }; Parameter[1] = new SqlParameter("@Error", SqlDbType.Bit) { Direction = ParameterDirection.Output }; Parameter[2] = new SqlParameter("@Respuesta", SqlDbType.NVarChar, 200) { Direction = ParameterDirection.Output }; using (var read = SqlHelper.ExecuteReader(conexion, CommandType.StoredProcedure, "dbo.GetDetalleProducto", Parameter)) { while (read.Read() && read.HasRows && !read.IsDBNull(read.GetOrdinal("codigo"))) { BEProducto.idproducto = read.GetInt64(read.GetOrdinal("idproducto")); BEProducto.idcategoria = read.GetInt64(read.GetOrdinal("idcategoria")); BEProducto.Descripcion = read.GetString(read.GetOrdinal("Descripcion")); BEProducto.codigo = read.GetString(read.GetOrdinal("codigo")); BEProducto.Stock = read.GetInt32(read.GetOrdinal("Stock")); BEProducto.Precio = read.GetDecimal(read.GetOrdinal("Precio")); BEProducto.fechaproduccion = read.GetDateTime(read.GetOrdinal("fechaproduccion")); BEProducto.fechaexpiracion = read.GetDateTime(read.GetOrdinal("fechaexpiracion")); BEProducto.Error = read.GetBoolean(read.GetOrdinal("Error")); BEProducto.Respuesta = read.GetString(read.GetOrdinal("Respuesta")); } } } catch (Exception ex) { throw ex; } return(BEProducto); }
public static BEProducto Obtener(int id) { BEProducto oRegistro = null; using (var cn = new SqlConnection(cnx)) { try { cn.Open(); oRegistro = new DLProducto(cn, null).Obtener(id); } catch (Exception ex) { throw ex; } } return(oRegistro); }
private void btnAplicar_Click(object sender, EventArgs e) { try { BEProducto producto = (BEProducto)this.cbProducto.SelectedItem; if (producto == null) { return; } this.frmMantenimientoVentas.AplicarPreciosGrupo(producto, this.nudPrecioBase.Value, this.nubMargenMinimo.Value, (int)this.cbFormaAplicar.SelectedValue); this.Close(); } catch (Exception ex) { this.MostrarMensaje(ex.Message, MessageBoxIcon.Error); } }
public void AplicarPreciosGrupo(BEProducto producto, decimal precioBase, decimal Margen, int FormaAplicar) { foreach (DataGridViewRow item in this.dgrvVentas.Rows) { if (producto.IdProducto == (int)item.Cells["IdProducto"].Value) { decimal margen = (string.IsNullOrEmpty(item.Cells["Margen"].Value.ToString())) ? Margen : decimal.Parse(item.Cells["Margen"].Value.ToString()); if (FormaAplicar == 2) //clientes precio variable { bool tieneMargenVariable = false; bool.TryParse(item.Cells["TienePrecioVariable"].Value.ToString(), out tieneMargenVariable); item.Cells["NuevoPrecio"].Value = (tieneMargenVariable) ? (precioBase + margen).ToString() : string.Empty; } else { item.Cells["NuevoPrecio"].Value = precioBase + margen; } } } }
public bool Eliminar(BEProducto producto) { try { bool bExito = false; using (var cmd = new SqlCommand("sp_producto_eliminar", _cn, _trx)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", producto.Id).SqlDbType = SqlDbType.Int; var n = cmd.ExecuteNonQuery(); if (n > 0) { bExito = true; } } return(bExito); } catch (Exception ex) { throw ex; } }
public List <BEProducto> Listar(BEProducto pBEProducto) { DatabaseHelper oDatabaseHelper = new DatabaseHelper(); List <BEProducto> vLista = new List <BEProducto>(); IDataReader oIDataReader = null; BEProducto oBEProducto = null; try { oDatabaseHelper.ClearParameter(); oDatabaseHelper.AddParameter("@intIdProducto", (pBEProducto.IdProducto <= 0) ? (object)DBNull.Value : pBEProducto.IdProducto); oDatabaseHelper.AddParameter("@varNombre", string.IsNullOrEmpty(pBEProducto.Nombre) ? (object)DBNull.Value : pBEProducto.Nombre); oIDataReader = oDatabaseHelper.ExecuteReader("DGP_Listar_Producto", CommandType.StoredProcedure); while (oIDataReader.Read()) { oBEProducto = new BEProducto(); oBEProducto.IdProducto = int.Parse(oIDataReader["Id_Producto"].ToString()); //.GetInt32(0); oBEProducto.Nombre = (string)oIDataReader["Nombre"]; //.GetString(1); oBEProducto.Tara = decimal.Parse(oIDataReader["tara"].ToString()); //oIDataReader.GetDecimal(2); oBEProducto.PrecioVenta = decimal.Parse(oIDataReader["PrecioVenta"].ToString()); oBEProducto.PrecioCompra = decimal.Parse(oIDataReader["PrecioCompra"].ToString()); oBEProducto.Margen = decimal.Parse(oIDataReader["Margen"].ToString()); vLista.Add(oBEProducto); } return(vLista); } catch (Exception ex) { throw ex; } finally { if (!oIDataReader.IsClosed) { oIDataReader.Close(); } oIDataReader.Dispose(); oDatabaseHelper.Dispose(); } }
public BEProducto Obtener(int id) { try { BEProducto oRegistro = null; using (var cmd = new SqlCommand("sp_producto_obtener", _cn))// Disposing { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", id).SqlDbType = SqlDbType.Int; using (var reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (reader.HasRows) { while (reader.Read()) { oRegistro = new BEProducto(); oRegistro.Id = reader.GetInt32(reader.GetOrdinal("Id")); oRegistro.Descripcion = reader.IsDBNull(reader.GetOrdinal("Descripcion")) ? string.Empty : reader.GetString(reader.GetOrdinal("Descripcion")).Trim(); oRegistro.Igv = reader.GetDecimal(reader.GetOrdinal("Igv")); oRegistro.Precio = reader.GetDecimal(reader.GetOrdinal("Precio")); oRegistro.Activo = reader.GetBoolean(reader.GetOrdinal("Activo")); } } } } return(oRegistro); } catch (Exception ex) { throw ex; } }
public List <BEProducto> Listar(bool?activo) { try { var oLista = new List <BEProducto>(); using (var cmd = new SqlCommand("sp_producto_listar", _cn))// Disposing { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@activo", activo ?? (object)DBNull.Value).SqlDbType = SqlDbType.Bit; using (var reader = cmd.ExecuteReader(CommandBehavior.SingleResult)) { if (reader.HasRows) { while (reader.Read()) { var oRegistro = new BEProducto(); oRegistro.Id = reader.GetInt32(reader.GetOrdinal("Id")); oRegistro.Descripcion = reader.IsDBNull(reader.GetOrdinal("Descripcion")) ? string.Empty : reader.GetString(reader.GetOrdinal("Descripcion")).Trim(); oRegistro.Igv = reader.GetDecimal(reader.GetOrdinal("Igv")); oRegistro.Precio = reader.GetDecimal(reader.GetOrdinal("Precio")); oRegistro.Activo = reader.GetBoolean(reader.GetOrdinal("Activo")); oLista.Add(oRegistro); } } } } return(oLista); } catch (Exception ex) { throw ex; } }
public List <BEListaDePrecioDetalle> ListDesdeStockCompras(BaseFiltro filtro) // string prm_CodigoPersonaEmpre, string prm_CodigoPuntoVenta, string prm_codDeposito, string prm_CodigoArguMoneda, bool prm_ParaCompras, bool prm_ParaVentas, string prm_CodigoLista, string prm_UsuarioLogin) { List <BEListaDePrecioDetalle> lstListaDePrecioDetalle = new List <BEListaDePrecioDetalle>(); List <DTOProductoResponse> lstProducto = new List <DTOProductoResponse>(); List <BEProducto> lstProductoDep = new List <BEProducto>(); List <BEProductoPrecio> lstProductoPrecio = new List <BEProductoPrecio>(); BETipoDeCambio tipoDeCambio = new BETipoDeCambio(); try { ProductoLogic oProductoLogic = new ProductoLogic(); ProductoPrecioData oProductoPrecioData = new ProductoPrecioData(); TipoDeCambioLogic oTiposdeCambioLogic = new TipoDeCambioLogic(); lstProducto = oProductoLogic.List(new BaseFiltroProducto { codEmpresaRUC = filtro.codEmpresaRUC, codDeposito = string.Empty, codProductoRefer = string.Empty, desNombre = string.Empty, desComercial = string.Empty, codMarca = null, codRegTipo = string.Empty, indDestinoCompra = true, indDestinaVenta = true, codRegCentroProducc = string.Empty, codRegCategoria = string.Empty, codRegUnidadMedida = string.Empty, indEstado = true, desPalabraClave = string.Empty, indTodos = true }); tipoDeCambio = oTiposdeCambioLogic.Find(new BaseFiltroTipoCambio { codEmpresa = filtro.codEmpresa, fecInicioDate = DateTime.Now, codRegMoneda = ConfigCROM.AppConfig(filtro.codEmpresa, ConfigTool.DEFAULT_MonedaInt) }); foreach (DTOProductoResponse xProducto in lstProducto) { if (xProducto.EsListaPrecio) { BEProducto productoNew = new BEProducto(); productoNew = oProductoLogic.Find(new BaseFiltroAlmacen { codEmpresa = filtro.codEmpresa, codProducto = xProducto.codProducto }); productoNew.itemProductoPrecio.CodigoProductoNombre = productoNew.Descripcion; lstProductoPrecio.Add(productoNew.itemProductoPrecio); } } filtro.codProducto = null; foreach (BEProductoPrecio itemproductoPrecio in lstProductoPrecio) { BEListaDePrecioDetalle xlstListaDePrecioDetalle = new BEListaDePrecioDetalle { CodigoArguMoneda = filtro.codRegMoneda, codProducto = itemproductoPrecio.codProducto, CodigoProducto = itemproductoPrecio.CodigoProducto, Estado = itemproductoPrecio.Estado, segFechaEdita = DateTime.Now, segUsuarioEdita = filtro.segUsuarioEdita, CodigoProductoNombre = itemproductoPrecio.CodigoProductoNombre, CodigoLista = filtro.codListaPrecio, segUsuarioCrea = filtro.segUsuarioEdita, segFechaCrea = DateTime.Now, CodigoPersonaEmpre = filtro.codEmpresaRUC, CodigoPuntoVenta = filtro.codPuntoVenta, }; if (itemproductoPrecio.CodigoArguMoneda == filtro.codRegMoneda) { xlstListaDePrecioDetalle.PrecioUnitario = itemproductoPrecio.ValorVenta; } else { if (filtro.codRegMoneda == ConfigCROM.AppConfig(filtro.codEmpresa, ConfigTool.DEFAULT_MonedaNac)) { if (itemproductoPrecio.CodigoArguMoneda == filtro.codRegMoneda) { xlstListaDePrecioDetalle.PrecioUnitario = itemproductoPrecio.ValorVenta; } else { xlstListaDePrecioDetalle.PrecioUnitario = Helper.DecimalRound(itemproductoPrecio.ValorVenta * tipoDeCambio.CambioVentasPRL, 2); } } if (filtro.codRegMoneda == ConfigCROM.AppConfig(filtro.codEmpresa, ConfigTool.DEFAULT_MonedaInt)) { if (itemproductoPrecio.CodigoArguMoneda == filtro.codRegMoneda) { xlstListaDePrecioDetalle.PrecioUnitario = itemproductoPrecio.ValorVenta; } else { xlstListaDePrecioDetalle.PrecioUnitario = Helper.DecimalRound(itemproductoPrecio.ValorVenta / tipoDeCambio.CambioVentasPRL, 2); } } } lstListaDePrecioDetalle.Add(xlstListaDePrecioDetalle); } } catch (Exception ex) { throw ex; } return(lstListaDePrecioDetalle); }
public Queue <MPProducto> GetLisRutaProducto(int idFoto, string Conexion, string RutaFotos) { Queue <MPProducto> lstBEfotoProducto = new Queue <MPProducto>(); try { var Parameter = new SqlParameter[4]; Parameter[0] = new SqlParameter("@CallAPP", SqlDbType.VarChar) { Value = "APP_Publicidad" }; Parameter[1] = new SqlParameter("@idfoto", SqlDbType.Int) { Value = idFoto }; Parameter[2] = new SqlParameter("@Error", SqlDbType.Bit) { Direction = ParameterDirection.Output }; Parameter[3] = new SqlParameter("@Respuesta", SqlDbType.NVarChar, 200) { Direction = ParameterDirection.Output }; using (var read = SqlHelper.ExecuteReader(Conexion, CommandType.StoredProcedure, "dbo.ListarRankingImagenes", Parameter)) { while (read.Read() && read.HasRows && !read.IsDBNull(read.GetOrdinal("hashCode"))) { //MPProducto BEfotoProducto = new MPProducto(); MPProducto MPObjeto = new MPProducto(); BEFotos BEFoto = new BEFotos(); BEProducto Producto = new BEProducto(); BEFoto.hashCode = read.GetString(read.GetOrdinal("hashCode")); BEFoto.idfoto = read.GetInt64(read.GetOrdinal("idfoto")); BEFoto.Nombre = read.GetString(read.GetOrdinal("Nombre")); Producto.codigo = read.GetString(read.GetOrdinal("codigo")); Producto.Descripcion = read.GetString(read.GetOrdinal("Descripcion")); Producto.idproducto = read.GetInt64(read.GetOrdinal("idproducto")); Producto.Precio = read.GetDecimal(read.GetOrdinal("Precio")); Producto.idfoto = read.GetInt64(read.GetOrdinal("idfoto")); Producto.Nombre = read.GetString(read.GetOrdinal("NombreProducto")); BEFoto.rutafoto = RutaFotos; MPObjeto.BEFoto = BEFoto; MPObjeto.Producto = Producto; //BEfotoProducto.Error = false; //BEfotoProducto.Respuesta = "OK"; lstBEfotoProducto.Enqueue(MPObjeto); } //else //{ // //read.NextResult(); // error = read.GetBoolean(read.GetOrdinal("Error")); // respuesta = read.GetString(read.GetOrdinal("Respuesta")); //} } } catch (Exception ex) { throw ex; } return(lstBEfotoProducto); }
public PictureViewModels Insert_BEFoto(BEFotos BEImagen, BEProducto BEProducto) { PictureViewModels Cantidadregistros = new PictureViewModels(); int cantidadregistro = 0; using (var conexion = new SqlConnection()) { API_Video_Imagen.Data.Repository.Conecta Conecta = new API_Video_Imagen.Data.Repository.Conecta(); string Conexion = Conecta.GetConexion().ConnectionString; try { var Parameter = new SqlParameter[13]; Parameter[0] = new SqlParameter("@Nombre", SqlDbType.VarChar, 300) { Value = BEImagen.Nombre }; Parameter[1] = new SqlParameter("@rutafoto", SqlDbType.VarChar, 300) { Value = "" }; Parameter[2] = new SqlParameter("@posicionPortada", SqlDbType.Int) { Value = BEImagen.posicionPortada }; Parameter[3] = new SqlParameter("@descripcion", SqlDbType.VarChar, 500) { Value = BEImagen.descripcion }; Parameter[4] = new SqlParameter("@NombreProducto", SqlDbType.VarChar, 500) { Value = BEProducto.Nombre }; Parameter[5] = new SqlParameter("@DescripcionProducto", SqlDbType.VarChar, 600) { Value = BEProducto.Descripcion }; Parameter[6] = new SqlParameter("@Precio", SqlDbType.Decimal) { Value = BEProducto.Precio }; Parameter[7] = new SqlParameter("@Stock", SqlDbType.Int) { Value = BEProducto.Stock }; Parameter[8] = new SqlParameter("@fechaproduccion", SqlDbType.DateTime) { Value = BEProducto.fechaproduccion }; Parameter[9] = new SqlParameter("@fechaexpiracion", SqlDbType.DateTime) { Value = BEProducto.fechaexpiracion }; Parameter[10] = new SqlParameter("@Error", SqlDbType.Bit) { Direction = ParameterDirection.Output }; Parameter[11] = new SqlParameter("@Respuesta", SqlDbType.NVarChar, 200) { Direction = ParameterDirection.Output }; Parameter[12] = new SqlParameter("@CantidadRegistrado ", SqlDbType.Int) { Direction = ParameterDirection.Output }; using (var read = PI_Video_Imagen.Data.SqlHelper.ExecuteReader(Conexion, CommandType.StoredProcedure, "dbo.Insert_Foto", Parameter)) { while (read.Read()) { Cantidadregistros.idfoto = Int64.Parse(read.GetInt64(read.GetOrdinal("IdFoto")).ToString()); Cantidadregistros.CantidadDeregistros = Int32.Parse(read.GetInt32(read.GetOrdinal("CantidadRegistrado")).ToString()); Cantidadregistros.idproducto = Int64.Parse(read.GetInt64(read.GetOrdinal("IdFoto")).ToString()); } } } catch (Exception ex) { throw ex; } } return(Cantidadregistros); }
public void EncontrarPrecios(BEProducto prm_itemProducto, BaseFiltro filtro, ref decimal prm_PRECIO_VENTAS, ref decimal prm_PRECIO_COMPRA, ref string prm_CODIMONEDA) // string prm_CodigoEmpresa, string prm_CodigoPuntoVenta, string prm_DestinoComp) { decimal intPRECIO_VENTAS = 0; decimal intPRECIO_COMPRA = 0; string intprm_CODIMONEDA = ConfigCROM.AppConfig(ConfigTool.DEFAULT_MonedaNac); filtro.codProducto = prm_itemProducto.codProducto; filtro.codRegMoneda = string.Empty; filtro.indEstado = true; if (prm_itemProducto.EsListaPrecio) { ListaDePrecioLogic oListaDePrecioLogic = new ListaDePrecioLogic(); List <BEListaDePrecioDetalle> listaListaDePrecioDetalle = new List <BEListaDePrecioDetalle>(); if (filtro.codRegDestinoDocum == ConstantesGC.OPERACION_DESTINO_VENTAS) { filtro.codListaPrecio = ConfigCROM.AppConfig(ConfigTool.DEFAULT_ListaPrecioVenta); listaListaDePrecioDetalle = oListaDePrecioLogic.ListDetalle(filtro); if (listaListaDePrecioDetalle.Count == 0) { intPRECIO_VENTAS = 0; } else { intPRECIO_VENTAS = listaListaDePrecioDetalle[0].PrecioUnitario; intprm_CODIMONEDA = listaListaDePrecioDetalle[0].CodigoArguMoneda; } } else if (filtro.codRegDestinoDocum == ConstantesGC.OPERACION_DESTINO_COMPRAS) { filtro.codListaPrecio = ConfigCROM.AppConfig(ConfigTool.DEFAULT_ListaPrecioCompra); listaListaDePrecioDetalle = oListaDePrecioLogic.ListDetalle(filtro); if (listaListaDePrecioDetalle.Count == 0) { intPRECIO_COMPRA = 0; } else { intPRECIO_COMPRA = listaListaDePrecioDetalle[0].PrecioUnitario; intprm_CODIMONEDA = listaListaDePrecioDetalle[0].CodigoArguMoneda; } } else if (filtro.codRegDestinoDocum == ConstantesGC.OPERACION_DESTINO_INTERNO) { filtro.codListaPrecio = ConfigCROM.AppConfig(ConfigTool.DEFAULT_ListaPrecioCompra); listaListaDePrecioDetalle = oListaDePrecioLogic.ListDetalle(filtro); if (listaListaDePrecioDetalle.Count == 0) { intPRECIO_COMPRA = 0; } else { intPRECIO_COMPRA = listaListaDePrecioDetalle[0].PrecioUnitario; intprm_CODIMONEDA = listaListaDePrecioDetalle[0].CodigoArguMoneda; } } } else { if (filtro.codRegDestinoDocum == ConstantesGC.OPERACION_DESTINO_VENTAS) { intPRECIO_VENTAS = prm_itemProducto.itemProductoPrecio.ValorVenta; } else if (filtro.codRegDestinoDocum == ConstantesGC.OPERACION_DESTINO_COMPRAS) { intPRECIO_COMPRA = prm_itemProducto.itemProductoPrecio.ValorCosto; } else if (filtro.codRegDestinoDocum == ConstantesGC.OPERACION_DESTINO_INTERNO) { intPRECIO_COMPRA = prm_itemProducto.itemProductoPrecio.ValorCosto; } intprm_CODIMONEDA = prm_itemProducto.itemProductoPrecio.CodigoArguMoneda; } prm_CODIMONEDA = intprm_CODIMONEDA; prm_PRECIO_COMPRA = intPRECIO_COMPRA; prm_PRECIO_VENTAS = intPRECIO_VENTAS; }
private BEComprobanteEmision GenerarTicketDeVenta(int pcodEmpresa, MovimientoAux pitem, int pcodPersonaEmpleado, string pcodEmpresaRUC, string pUserActual, string pcodPlanilla, ref BEDocumento pTicketRef, ref int pcodDocumentoSerie) { DocumentoLogic oDocumentoLogic = new DocumentoLogic(); PersonasLogic oPersonasLogic = new PersonasLogic(); ImpuestoLogic oTiposDeImpuestoLogic = new ImpuestoLogic(); TarifaLogic oTarifaLogic = new TarifaLogic(); TipoDeCambioLogic oTiposdeCambioLogic = new TipoDeCambioLogic(); BEImpuesto miImpuestoVTA = new BEImpuesto(); BEDocumento miTicket = new BEDocumento(); BEPersona miPersona = new BEPersona(); TarifaAux miTarifa = new TarifaAux(); BETipoDeCambio miTiposDeCambio = new BETipoDeCambio(); miTicket = oDocumentoLogic.Find(ConfigurationManager.AppSettings["DEFAULT_Doc_Ticket"].ToString(), pcodEmpresaRUC, pcodEmpresa, pUserActual); pTicketRef = miTicket; miPersona = oPersonasLogic.Find(pcodEmpresa, pitem.codPersonaCliente, pUserActual); miImpuestoVTA = oTiposDeImpuestoLogic.Find(pcodEmpresa, ConfigurationManager.AppSettings["DEFAULT_Impuesto_Ventas"].ToString(), pUserActual); miTarifa = oTarifaLogic.Find(pitem.codTarifa); miTiposDeCambio = oTiposdeCambioLogic.Find(new BaseFiltroTipoCambio { codEmpresa = pcodEmpresa, fecInicioDate = DateTime.Now, codRegMoneda = ConfigurationManager.AppSettings["DEFAULT_MonedaInt"].ToString() }); string p_NroComprobante = HelpDocumentos.Tipos.TCK.ToString() + NumerodeComprobante(oDocumentoLogic, pcodEmpresa, pitem.codPersonaEmpresa, miTicket.CodigoComprobante, pitem.codPuntoDeVenta, pcodPlanilla, pitem.segUsuarioCrea, ref pcodDocumentoSerie); BEComprobanteEmision miDocumentoTicket = new BEComprobanteEmision { CodigoArguEstadoDocu = miTicket.CodigoArguEstEMIDefault, CodigoArguMoneda = ConfigurationManager.AppSettings["DEFAULT_MonedaNac"].ToString(), CodigoArguTipoDeOperacion = ConfigurationManager.AppSettings["DEFAULT_Movim_Venta"].ToString(), CodigoArguTipoDomicil = ((int)TipoDomicilio.FISCAL_PRINCIPAL).ToString(), // ConfigCROM.AppConfig(ConfigTool.DEFAULT_Atributo_DomicFiscal), CodigoArguUbigeo = ConfigCROM.AppConfig(pcodEmpresa, ConfigTool.DEFAULT_Ubigeo), //. ConfigurationManager.AppSettings["DEFAULT_Ubigeo"].ToString(), CodigoComprobante = ConfigurationManager.AppSettings["DEFAULT_Doc_Ticket"].ToString(), CodigoArguDestinoComp = WebConstants.DEFAULT_DOCUM_DESTINADO_CLIENTES, CodigoComprobanteFact = miTicket.CodigoComprobante, codEmpleado = pcodPersonaEmpleado, CodigoPersonaEmpre = pitem.codPersonaEmpresa, CodigoPersonaEntidad = pitem.codPersonaCliente, codEmpleadoVendedor = pcodPersonaEmpleado, CodigoPuntoVenta = pitem.codPuntoDeVenta, codCondicionVenta = Convert.ToInt32(ConfigCROM.AppConfig(pcodEmpresa, ConfigTool.DEFAULT_CondicionVenta)), //.ConfigurationManager.AppSettings["DEFAULT_CondicionVenta"].ToString(), DocEsFacturable = miTicket.EsComprobanteFiscal, EntidadDireccion = "No exige el tipo de DOC", EntidadDireccionUbigeo = "LIMA", EntidadNumeroRUC = "9999", EntidadRazonSocial = miPersona.RazonSocial, Estado = true, FechaDeEmision = DateTime.Now, FechaDeEntrega = DateTime.Now, FechaDeCancelacion = DateTime.Now, FechaDeProceso = DateTime.Now, FechaDeVencimiento = DateTime.Now, Nota01 = "Ticket gen. automático", NumeroComprobante = p_NroComprobante, // NumerodeComprobante(oComprobantesLogic, miTicket.CodigoComprobante, item.codPersonaEmpresa, item.codPuntoDeVenta, item.segUsuarioCrea), Observaciones = pitem.gloObservacion, SegUsuarioCrea = pitem.segUsuarioCrea, SegUsuarioEdita = pitem.segUsuarioCrea, ValorIGV = miImpuestoVTA.Porcentaje, ValorTipoCambioCMP = miTiposDeCambio.CodigoArguMoneda == null ? 2 : miTiposDeCambio.CambioCompraPRL, ValorTipoCambioVTA = miTiposDeCambio.CodigoArguMoneda == null ? 2 : miTiposDeCambio.CambioVentasPRL, }; ProductoLogic oProductoLogic = new ProductoLogic(); BEProducto miProducto = new BEProducto(); miProducto = oProductoLogic.Find(new BaseFiltroAlmacen { codEmpresaRUC = pitem.codPersonaEmpresa, codPuntoVenta = pitem.codPuntoDeVenta, codProducto = miTarifa.codProducto }); miDocumentoTicket.listaComprobanteEmisionDetalle.Add(new BEComprobanteEmisionDetalle { Cantidad = 1, CantiDecimales = 4, CodigoArguEstadoDocu = miTicket.CodigoArguEstEMIDefault, CodigoArguDestinoComp = WebConstants.DEFAULT_DOCUM_DESTINADO_CLIENTES, CodigoArguTipoProducto = ConfigurationManager.AppSettings["DEFAULT_ProducTerminado"].ToString(), CodigoArguUnidadMed = ConfigurationManager.AppSettings["DEFAULT_UnidadMedida"].ToString(), CodigoComprobante = miTicket.CodigoComprobante, NumeroComprobante = miDocumentoTicket.NumeroComprobante, CodigoItemDetalle = "001", //codEmpresa = item.codPersonaEmpresa, codEmpleadoVendedor = pcodPersonaEmpleado, CodigoProducto = miTarifa.codiProducto, codProducto = miTarifa.codProducto, Descripcion = miProducto.Descripcion, Estado = true, CodigoPuntoVenta = pitem.codPuntoDeVenta, EsVerificarStock = false, FechaDeEmision = miDocumentoTicket.FechaDeEmision, IncluyeIGV = miImpuestoVTA.DiscriminaIGV, PesoTotal = 0, SegUsuarioCrea = pitem.segUsuarioCrea, SegUsuarioEdita = pitem.segUsuarioCrea, UnitPrecioBruto = pitem.monMontoPagado.Value, }); CalcularDatosDelPrecioDeVenta(miImpuestoVTA, pitem, miDocumentoTicket.listaComprobanteEmisionDetalle[0]); CalcularTotalDocumento(ref miDocumentoTicket, miImpuestoVTA); return(miDocumentoTicket); }
public List <BEListaDePrecioDetalle> ListDesdeStock(BaseFiltro filtro) //, string prm_CodigoPersonaEmpre, string prm_CodigoPuntoVenta, string prm_codDeposito, string prm_CodigoArguMoneda, bool prm_EsParaVentas, string prm_CodigoLista, string prm_UsuarioLogin) { List <BEListaDePrecioDetalle> lstListaDePrecioDetalle = new List <BEListaDePrecioDetalle>(); List <BEProducto> lstProducto = new List <BEProducto>(); List <BEProducto> lstProductoDep = new List <BEProducto>(); List <BEProductoPrecio> lstProductoPrecio = new List <BEProductoPrecio>(); BETipoDeCambio itemTiposDeCambio = new BETipoDeCambio(); try { ProductoLogic productoLogic = new ProductoLogic(); ProductoPrecioData oProductoPrecioData = new ProductoPrecioData(); TipoDeCambioLogic oTiposdeCambioLogic = new TipoDeCambioLogic(); lstProducto = productoLogic.List(new BaseFiltroAlmacen { codPerEmpresa = filtro.codPerEmpresa, codDeposito = string.Empty, codProductoRefer = string.Empty, codProducto = null, desNombre = string.Empty, desComercial = string.Empty, codRegMarca = string.Empty, codRegTipo = string.Empty, indDestinoCompra = true, indDestinaVenta = true, codRegCentroProducc = string.Empty, codRegCategoria = string.Empty, codRegUnidadMedida = string.Empty, indEstado = true, desPalabraClave = string.Empty, indTodos = true }); itemTiposDeCambio = oTiposdeCambioLogic.Find(new BaseFiltro { fecInicioDate = DateTime.Now, codRegMoneda = ConfigCROM.AppConfig(ConfigTool.DEFAULT_MonedaInt) }); foreach (BEProducto xProducto in lstProducto) { if (xProducto.EsListaPrecio) { BEProducto productoNew = new BEProducto(); filtro.codProducto = xProducto.codProducto; BaseFiltroAlmacen filtroAlmacen = new BaseFiltroAlmacen { codProductoRefer = filtro.codProductoRefer, codProducto = filtro.codProducto.Value }; productoNew = productoLogic.Find(filtroAlmacen); productoNew.itemProductoPrecio.codProducto = xProducto.codProducto; productoNew.itemProductoPrecio.CodigoProductoNombre = productoNew.Descripcion; lstProductoPrecio.Add(productoNew.itemProductoPrecio); } } filtro.codProducto = null; foreach (BEProductoPrecio itemproductoPrecio in lstProductoPrecio) { BEListaDePrecioDetalle itemlistaDePrecioDetalle = new BEListaDePrecioDetalle { CodigoArguMoneda = filtro.codRegMoneda, codProducto = itemproductoPrecio.codProducto, CodigoProducto = itemproductoPrecio.CodigoProducto, Estado = itemproductoPrecio.Estado, segFechaEdita = DateTime.Now, segUsuarioEdita = filtro.segUsuarioEdita, CodigoProductoNombre = itemproductoPrecio.CodigoProductoNombre, CodigoLista = filtro.codListaPrecio, segUsuarioCrea = filtro.segUsuarioEdita, segFechaCrea = DateTime.Now, CodigoPersonaEmpre = filtro.codPerEmpresa, CodigoPuntoVenta = filtro.codPuntoVenta, }; decimal PRECIO_A_TOMAR = 0; if (filtro.indParaVenta.Value) { PRECIO_A_TOMAR = itemproductoPrecio.ValorVenta; } else { PRECIO_A_TOMAR = itemproductoPrecio.ValorCosto; } if (itemproductoPrecio.CodigoArguMoneda == filtro.codRegMoneda) { itemlistaDePrecioDetalle.PrecioUnitario = PRECIO_A_TOMAR; } else { if (filtro.codRegMoneda == ConfigCROM.AppConfig(ConfigTool.DEFAULT_MonedaNac)) { if (itemproductoPrecio.CodigoArguMoneda == filtro.codRegMoneda) { itemlistaDePrecioDetalle.PrecioUnitario = PRECIO_A_TOMAR; } else { itemlistaDePrecioDetalle.PrecioUnitario = Helper.DecimalRound(PRECIO_A_TOMAR * itemTiposDeCambio.CambioVentasPRL, 2); } } if (filtro.codRegMoneda == ConfigCROM.AppConfig(ConfigTool.DEFAULT_MonedaInt)) { if (itemproductoPrecio.CodigoArguMoneda == filtro.codRegMoneda) { itemlistaDePrecioDetalle.PrecioUnitario = PRECIO_A_TOMAR; } else { itemlistaDePrecioDetalle.PrecioUnitario = Helper.DecimalRound(PRECIO_A_TOMAR / itemTiposDeCambio.CambioVentasPRL, 2); } } } lstListaDePrecioDetalle.Add(itemlistaDePrecioDetalle); } } catch (Exception ex) { throw ex; } return(lstListaDePrecioDetalle); }
public BEDocumRegSerie() { objDocumRegDetalle = new BEComprobanteEmisionDetalle(); objProductoSeriado = new BEProductoSeriado(); objProducto = new BEProducto(); }