コード例 #1
0
        private DetalleOperacion MapearDetalleOperacion(IDataReader dr)
        {
            var detalleOperacion = new DetalleOperacion
            {
                OperacionId = GetDataValue <Int32>(dr, "OperacionId"),
                ProductoId  = GetDataValue <Int32>(dr, "ProductoId"),
                Monto       = GetDataValue <Int32>(dr, "Monto"),
                Cantidad    = GetDataValue <Int32>(dr, "Cantidad"),
                SubTotal    = GetDataValue <Int32>(dr, "SubTotal"),
                DVH         = GetDataValue <Int64>(dr, "DVH")
            };

            return(detalleOperacion);
        }
コード例 #2
0
        public void RegistrarDetalleOperacion(DetalleOperacion detalleActual)
        {
            const string sqlStatement = "INSERT INTO dbo.DetalleOperacion  ([OperacionId], [ProductoId], [Monto], [Cantidad], [SubTotal], [DVH])" +
                                        "VALUES(@OperacionId, @ProductoId, @Monto, @Cantidad, @SubTotal, @DVH); SELECT SCOPE_IDENTITY();";

            var db = DatabaseFactory.CreateDatabase(ConnectionName);

            using (var cmd = db.GetSqlStringCommand(sqlStatement))
            {
                db.AddInParameter(cmd, "@OperacionId", DbType.Int32, detalleActual.OperacionId);
                db.AddInParameter(cmd, "@ProductoId", DbType.Int32, detalleActual.ProductoId);
                db.AddInParameter(cmd, "@Monto", DbType.Int32, detalleActual.Monto);
                db.AddInParameter(cmd, "@Cantidad", DbType.Int32, detalleActual.Cantidad);
                db.AddInParameter(cmd, "@SubTotal", DbType.Int32, detalleActual.SubTotal);
                db.AddInParameter(cmd, "@DVH", DbType.Int64, 0);

                db.ExecuteScalar(cmd);
            }
        }
コード例 #3
0
        private List <DetalleOperacion> RegistrarDetalleOperacion(int operacionId)
        {
            var ln   = new NegocioOperaciones();
            var inte = new IntegridadDatos();


            if (Session["Carrito"] != null)
            {
                var detalleCompleto = new List <DetalleOperacion>();

                foreach (var item in Session["Carrito"] as List <Carrito> )
                {
                    var subtotal = (item.Precio * item.Cantidad);


                    var detalleActual = new DetalleOperacion
                    {
                        OperacionId = operacionId,
                        ProductoId  = item.ProductoId,
                        Monto       = item.Precio,
                        Cantidad    = item.Cantidad,
                        SubTotal    = subtotal,
                    };

                    detalleCompleto.Add(detalleActual);

                    ln.RegistrarDetalleOperacion(detalleActual);

                    detalleActual.DVH = inte.CalcularDVH(detalleActual.OperacionId.ToString() + detalleActual.ProductoId.ToString() + detalleActual.SubTotal.ToString() + detalleActual.Cantidad.ToString() + detalleActual.Monto.ToString());

                    // Actualiza el DVH
                    inte.ActualizarDVHDetalleOperacion(detalleActual.OperacionId, detalleActual.ProductoId, detalleActual.DVH);
                }

                inte.RecalcularDVV("DetalleOperacion");

                return(detalleCompleto);
            }

            return(null);
        }
コード例 #4
0
        public void RegistrarDetalleOperacion(DetalleOperacion detalleActual)
        {
            var datos = new OperacionesDAC();

            datos.RegistrarDetalleOperacion(detalleActual);
        }