Beispiel #1
0
        public Modelo.Ventas.DetallePedido GetById(int Id)
        {
            SqlConnection connection = null;
            SqlCommand    cmd        = null;
            SqlDataReader reader     = null;

            Modelo.Ventas.DetallePedido d = null;

            try
            {
                connection = GetConnection();
                connection.Open();
                cmd = connection.CreateCommand();

                cmd.CommandText = "SELECT * FROM [Ventas].[DetallesPedido] WHERE IdDetalle = @Id";

                cmd.Parameters.AddWithValue("@Id", Id);

                reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    d = new Modelo.Ventas.DetallePedido();
                    d.IdDetallePedido = Id;
                    d.Base            = new Modelo.Produccion.Material()
                    {
                        IdMaterial = (int)reader["Base"]
                    };
                    d.Design = new Modelo.Produccion.Design()
                    {
                        IdDesign = (int)reader["Design"]
                    };
                    d.Cantidad = (int)reader["Cantidad"];
                    d.Precio   = (double)(decimal)reader["Precio"];
                }

                return(d);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                    connection.Dispose();
                }
            }
        }
Beispiel #2
0
        private Modelo.Ventas.Pedido GenerarPedido()
        {
            Modelo.Ventas.Pedido p = new Modelo.Ventas.Pedido()
            {
                Cliente       = ctrlCliente.GetById((int)cmbIdCliente.EditValue),
                Vendedor      = Session.UsuarioEnCurso,
                DetallePedido = new List <Modelo.Ventas.DetallePedido>(),
                FechaPedido   = DateTime.Today
            };

            foreach (DataRow row in DetallePedido.Rows)
            {
                Modelo.Ventas.DetallePedido d = new Modelo.Ventas.DetallePedido();
                d.Base     = ctrlBases.GetById((int)row["Material"]);
                d.Design   = ctrlDesigns.GetById((int)row["Design"]);
                d.Cantidad = (double)(int)row["Cantidad"];
                d.Precio   = (double)row["Precio"];

                p.DetallePedido.Add(d);
            }

            return(p);
        }