public static int Eliminar(int pIdProducto) { string consulta = @"DELETE FROM Producto WHERE Id = @Id;"; SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@Id", pIdProducto); return(ComunDB.EjecutarComando(comando)); }
public static int Guardar(Marca pMarca) { string consulta = @"INSERT INTO Marca (Nombre, Comentario) values (@Nombre, @Comentario)"; SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@Nombre", pMarca.Nombre); comando.Parameters.AddWithValue("@Comentario", pMarca.Comentario); return(ComunDB.EjecutarComando(comando)); }
public static int Modificar(Marca pMarca) { string consulta = @"UPDATE Marca SET Nombre = @Nombre, Comentario = @Comentario WHERE Id = @Id;"; SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@Nombre", pMarca.Nombre); comando.Parameters.AddWithValue("@Comentario", pMarca.Comentario); comando.Parameters.AddWithValue("@Id", pMarca.Id); return(ComunDB.EjecutarComando(comando)); }
public static int Guardar(Ingreso pIngreso) { string consulta = @"INSERT INTO Ingreso (IdUsuario, IdMarca, FechaIngreso, NumeroCCF, Sumas) VALUES (@IdUsuario, @IdMarca, @FechaIngreso, @NumeroCCF, @Sumas)"; SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@IdUsuario", pIngreso.IdUsuario); comando.Parameters.AddWithValue("@IdMarca", pIngreso.IdMarca); comando.Parameters.AddWithValue("@FechaIngreso", pIngreso.FechaIngreso); comando.Parameters.AddWithValue("@NumeroCCF", pIngreso.NumeroCCF); comando.Parameters.AddWithValue("@Sumas", (pIngreso.Sumas > 0)?pIngreso.Sumas:SqlDouble.Null); return(ComunDB.EjecutarComando(comando)); }
public static int Guardar(DetalleIngreso pDetalleIngreso) { string consulta = string.Concat("INSERT INTO DetalleIngreso (IdIngreso, IdProducto, Cantidad, PrecioUnitario) ", "VALUES (@IdIngreso, @IdProducto, @Cantidad, @PrecioUnitario)"); SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@IdIngreso", pDetalleIngreso.IdIngreso); comando.Parameters.AddWithValue("@IdProducto", pDetalleIngreso.IdProducto); comando.Parameters.AddWithValue("@Cantidad", pDetalleIngreso.Cantidad); comando.Parameters.AddWithValue("@PrecioUnitario", (decimal)pDetalleIngreso.PrecioUnitario); return(ComunDB.EjecutarComando(comando)); }
public static int Modificar(DetalleIngreso pDetalleIngreso) { string consulta = @"UPDATE DetalleIngreso SET IdIngreso = @IdIngreso, IdProducto = @IdProducto, Cantidad = @Cantidad, PrecioUnitario = @PrecioUnitario WHERE Id = @Id"; SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@IdIngreso", pDetalleIngreso.IdIngreso); comando.Parameters.AddWithValue("@IdProducto", pDetalleIngreso.IdProducto); comando.Parameters.AddWithValue("@Cantidad", pDetalleIngreso.Cantidad); comando.Parameters.AddWithValue("@PrecioUnitario", (decimal)pDetalleIngreso.PrecioUnitario); comando.Parameters.AddWithValue("@Id", pDetalleIngreso.Id); return(ComunDB.EjecutarComando(comando)); }
public static int Guardar(DetallePedido pDetallePedido) { string consulta = @"INSERT INTO DetallePedido (IdPedido, IdProducto, Cantidad, PrecioUnitario, Estado) values (@IdPedido, @IdProducto, @Cantidad, @PrecioUnitario, @Estado)"; SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@IdPedido", pDetallePedido.IdPedido); comando.Parameters.AddWithValue("@IdProducto", pDetallePedido.IdProducto); comando.Parameters.AddWithValue("@Cantidad", (int)pDetallePedido.Cantidad); comando.Parameters.AddWithValue("@PrecioUnitario", (decimal)pDetallePedido.PrecioUnitario); comando.Parameters.AddWithValue("@Estado", pDetallePedido.Estado); return(ComunDB.EjecutarComando(comando)); }
public static int Guardar(Producto pProducto) { string consulta = @"INSERT INTO Producto (IdMarca, Nombre, Descripcion, PrecioCompra, PrecioVenta, Stock) values (@IdMarca, @Nombre, @Descripcion, @PrecioCompra, @PrecioVenta, @Stock)"; SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@IdMarca", pProducto.IdMarca); comando.Parameters.AddWithValue("@Nombre", pProducto.Nombre); comando.Parameters.AddWithValue("@Descripcion", pProducto.Descripcion); comando.Parameters.AddWithValue("@PrecioCompra", pProducto.PrecioCompra); comando.Parameters.AddWithValue("@PrecioVenta", pProducto.PrecioVenta); comando.Parameters.AddWithValue("@Stock", pProducto.Stock); return(ComunDB.EjecutarComando(comando)); }
public static int Guardar(Usuario pUsuario) { string consulta = @"INSERT INTO Usuario (Nombres, Apellidos, NombreUsuario, Clave, StatusAdministrador, Imagen) values (@Nombres, @Apellidos, @NombreUsuario, @Clave, @StatusAdministrador, @Imagen)"; SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@Nombres", pUsuario.Nombres); comando.Parameters.AddWithValue("@Apellidos", pUsuario.Apellidos); comando.Parameters.AddWithValue("@NombreUsuario", pUsuario.NombreUsuario); comando.Parameters.AddWithValue("@Clave", pUsuario.Clave); comando.Parameters.AddWithValue("@StatusAdministrador", pUsuario.StatusAdmin); comando.Parameters.AddWithValue("@Imagen", (pUsuario.Imagen == null)?SqlBinary.Null:pUsuario.Imagen); return(ComunDB.EjecutarComando(comando)); }
public static int Modificar(Ingreso pIngreso) { string consulta = string.Concat("UPDATE Ingreso SET IdUsuario = @IdUsuario, IdMarca = @IdMarca, FechaIngreso = @FechaIngreso, ", "NumeroCCF = @NumeroCCF, Sumas = @Sumas WHERE Id = @Id"); SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@IdUsuario", pIngreso.IdUsuario); comando.Parameters.AddWithValue("@IdMarca", pIngreso.IdMarca); comando.Parameters.AddWithValue("@FechaIngreso", pIngreso.FechaIngreso); comando.Parameters.AddWithValue("@NumeroCCF", pIngreso.NumeroCCF); comando.Parameters.AddWithValue("@Sumas", (pIngreso.Sumas > 0)?pIngreso.Sumas:SqlDouble.Null); comando.Parameters.AddWithValue("@Id", pIngreso.Id); return(ComunDB.EjecutarComando(comando)); }
public static int Modificar(Producto pProducto) { string consulta = @"UPDATE Producto SET IdMarca = @IdMarca, Nombre = @Nombre, Descripcion = @Descripcion, PrecioCompra = @PrecioCompra, PrecioVenta = @PrecioVenta, Stock = @Stock WHERE Id = @Id;"; SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@Id", pProducto.Id); comando.Parameters.AddWithValue("@IdMarca", pProducto.IdMarca); comando.Parameters.AddWithValue("@Nombre", pProducto.Nombre); comando.Parameters.AddWithValue("@Descripcion", pProducto.Descripcion); comando.Parameters.AddWithValue("@PrecioCompra", pProducto.PrecioCompra); comando.Parameters.AddWithValue("@PrecioVenta", pProducto.PrecioVenta); comando.Parameters.AddWithValue("@Stock", pProducto.Stock); return(ComunDB.EjecutarComando(comando)); }
public static int Modificar(Usuario pUsuario) { string consulta = string.Concat("UPDATE Usuario SET Nombres = @Nombres, Apellidos = @Apellidos, NombreUsuario = @NombreUsuario, ", "Clave = @Clave, StatusAdministrador = @StatusAdministrador, Imagen = @Imagen WHERE Id = @Id"); SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@Id", pUsuario.Id); comando.Parameters.AddWithValue("@Nombres", pUsuario.Nombres); comando.Parameters.AddWithValue("@Apellidos", pUsuario.Apellidos); comando.Parameters.AddWithValue("@NombreUsuario", pUsuario.NombreUsuario); comando.Parameters.AddWithValue("@Clave", pUsuario.Clave); comando.Parameters.AddWithValue("@StatusAdministrador", pUsuario.StatusAdmin); comando.Parameters.AddWithValue("@Imagen", (pUsuario.Imagen == null) ? SqlBinary.Null : pUsuario.Imagen); return(ComunDB.EjecutarComando(comando)); }
public static int Guardar(Pedido pPedido) { string consulta = string.Concat("INSERT INTO Pedido (IdCliente, NumeroPedido, IdUsuario, FechaCreacion, FechaEntrega, DireccionEntrega, Estado, NumeroCCF) ", "values (@IdCliente, @NumeroPedido, @IdUsuario, @FechaCreacion, @FechaEntrega, @DireccionEntrega, @Estado, @NumeroCCF)"); SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@IdCliente", pPedido.IdCliente); comando.Parameters.AddWithValue("@IdUsuario", pPedido.IdUsuario); comando.Parameters.AddWithValue("@NumeroPedido", pPedido.NumeroPedido); comando.Parameters.AddWithValue("@NumeroCCF", pPedido.NumeroCCF); comando.Parameters.AddWithValue("@FechaCreacion", pPedido.FechaCreacion); comando.Parameters.AddWithValue("@FechaEntrega", pPedido.FechaEntrega); comando.Parameters.AddWithValue("@DireccionEntrega", pPedido.DireccionEntrega); comando.Parameters.AddWithValue("@Estado", pPedido.Estado); return(ComunDB.EjecutarComando(comando)); }
public static int Guardar(Cliente pCliente) { string consulta = @"INSERT INTO Cliente (PrimerNombre, SegundoNombre, PrimerApellido, SegundoApellido, Dui, Direccion, Telefono, Correo) values (@PrimerNombre, @SegundoNombre, @PrimerApellido, @SegundoApellido, @Dui, @Direccion, @Telefono, @Correo)"; SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@PrimerNombre", pCliente.PrimerNombre); comando.Parameters.AddWithValue("@SegundoNombre", pCliente.SegundoNombre); comando.Parameters.AddWithValue("@PrimerApellido", pCliente.PrimerApellido); comando.Parameters.AddWithValue("@SegundoApellido", pCliente.SegundoApellido); comando.Parameters.AddWithValue("@Dui", pCliente.DUI); comando.Parameters.AddWithValue("@Direccion", pCliente.Direccion); comando.Parameters.AddWithValue("@Telefono", pCliente.Telefono); comando.Parameters.AddWithValue("@Correo", pCliente.Correo); return(ComunDB.EjecutarComando(comando)); }
public static int Modificar(Cliente pCliente) { string consulta = @"UPDATE Cliente SET PrimerNombre = @PrimerNombre, SegundoNombre = @SegundoNombre, PrimerApellido = @PrimerApellido, SegundoApellido = @SegundoApellido, Dui = @Dui, Direccion = @Direccion, Telefono = @Telefono, Correo = @Correo WHERE Id = @Id;"; SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@PrimerNombre", pCliente.PrimerNombre); comando.Parameters.AddWithValue("@SegundoNombre", pCliente.SegundoNombre); comando.Parameters.AddWithValue("@PrimerApellido", pCliente.PrimerApellido); comando.Parameters.AddWithValue("@SegundoApellido", pCliente.SegundoApellido); comando.Parameters.AddWithValue("@Dui", pCliente.DUI); comando.Parameters.AddWithValue("@Direccion", pCliente.Direccion); comando.Parameters.AddWithValue("@Telefono", pCliente.Telefono); comando.Parameters.AddWithValue("@Correo", pCliente.Correo); comando.Parameters.AddWithValue("@Id", pCliente.Id); return(ComunDB.EjecutarComando(comando)); }
public static int Eliminar(int pDetallePedido, int?idPedido = null) { string consulta = @"DELETE FROM DetallePedido WHERE Id = @Id;"; if (idPedido != null) { consulta = @"DELETE FROM DetallePedido WHERE IdPedido = @IdPedido;"; } SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; if (idPedido == null) { comando.Parameters.AddWithValue("@Id", pDetallePedido); } else { comando.Parameters.AddWithValue("@IdPedido", idPedido); } return(ComunDB.EjecutarComando(comando)); }
public static int Eliminar(int pIdDetalleIngreso, int?pIdIngreso = null) { string consulta = @"DELETE FROM DetalleIngreso WHERE Id = @Id"; if (pIdIngreso != null) { consulta = @"DELETE FROM DetalleIngreso WHERE IdIngreso = @IdIngreso"; } SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; if (pIdIngreso == null) { comando.Parameters.AddWithValue("@Id", pIdDetalleIngreso); } else { comando.Parameters.AddWithValue("@IdIngreso", pIdIngreso); } return(ComunDB.EjecutarComando(comando)); }
public static int Modificar(Pedido pPedido) { string consulta = string.Concat("UPDATE Pedido SET IdCliente = @IdCliente, IdUsuario = @IdUsuario, ", "NumeroPedido = @NumeroPedido, NumeroCCF = @NumeroCCF, FechaCreacion = @FechaCreacion, FechaEntrega = @FechaEntrega, ", "DireccionEntrega = @DireccionEntrega, Estado = @Estado, Sumas = @Sumas, Iva = @Iva, Total = @Total WHERE Id = @Id;"); SqlCommand comando = ComunDB.ObtenerComando(); comando.CommandText = consulta; comando.Parameters.AddWithValue("@Id", pPedido.Id); comando.Parameters.AddWithValue("@IdCliente", pPedido.IdCliente); comando.Parameters.AddWithValue("@IdUsuario", pPedido.IdUsuario); comando.Parameters.AddWithValue("@NumeroPedido", pPedido.NumeroPedido); comando.Parameters.AddWithValue("@NumeroCCF", pPedido.NumeroCCF); comando.Parameters.AddWithValue("@FechaCreacion", pPedido.FechaCreacion); comando.Parameters.AddWithValue("@FechaEntrega", pPedido.FechaEntrega); comando.Parameters.AddWithValue("@DireccionEntrega", pPedido.DireccionEntrega); comando.Parameters.AddWithValue("@Estado", pPedido.Estado); comando.Parameters.AddWithValue("@Sumas", (pPedido.Sumas > 0)?pPedido.Sumas:SqlDouble.Null); comando.Parameters.AddWithValue("@Iva", (pPedido.Iva > 0)?pPedido.Iva:SqlDouble.Null); comando.Parameters.AddWithValue("@Total", (pPedido.Total > 0)?pPedido.Total:SqlDouble.Null); return(ComunDB.EjecutarComando(comando)); }