예제 #1
0
        public void Write(Assemblage assemblage)
        {
            var select = assemblage.ListOfNomenc.GroupBy(i => i.Nomenclature).Select(g => new LineItem()
            {
                Nomenclature = g.Key,
                Quantity     = g.Sum(i => i.Quantity),
                Sum          = g.Sum(i => i.Sum)
            });

            foreach (var item in select)
            {
                var recordNomenclature = new RemainNomenclature
                {
                    Nomenclature = item.Nomenclature,
                    RecordType   = RecordType.Expose,
                    Quantity     = item.Quantity,
                };
                var recordCostPrice = new RemainCostPrice
                {
                    Nomenclature = item.Nomenclature,
                    RecordType   = RecordType.Expose,
                    Amount       = item.Quantity,
                };

                recordNomenclature.Warehouse = assemblage.Warehouse;
                _remainNomenclature.Create(recordNomenclature);
                _remainCostPrice.Create(recordCostPrice);
            }
            _repository.Create(assemblage);
            _remainNomenclature.RecalcBalances();
            _remainCostPrice.RecalcBalances();
        }
예제 #2
0
파일: ICM.cs 프로젝트: Blecki/InnerWorkings
        public void Connect(Assemblage.IN8 CPU, params byte[] ports)
        {
            if (ports.Length != 2) throw new InvalidOperationException("ICM-CD2 display must be connected to 2 ports");
            this.CPU = CPU;
            dataPort = ports[0];
            controlPort = ports[1];

            CPU.AttachHardware(this, ports);
        }
        public void TestAssemblageDbFindById_WithAssemblageId_ShouldFindTheAssemblageInDbById()
        {
            var repository = new Repository <Assemblage>(_db);
            var assemblage = new Assemblage();

            repository.Create(assemblage);
            var assemblageFindById = repository.GetById(assemblage.Id);

            Assert.Equal(assemblage.Id, assemblageFindById.Id);
        }
예제 #4
0
        public VisualHardwareGrid(Assemblage.IN8 CPU)
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            this.IsMouseVisible = true;

            this.CPU = CPU;

            graphics.PreferredBackBufferHeight = 600;
            graphics.PreferredBackBufferWidth = 800;
        }
        public void TestAssemblageDbAdd_WithNewAssemblage_ShouldAddTheAssemblageToDb()
        {
            var repository         = new Repository <Assemblage>(_db);
            var assemblage         = new Assemblage();
            var assemblageFindById = repository.GetById(assemblage.Id);

            Assert.Null(assemblageFindById);
            repository.Create(assemblage);
            assemblageFindById = repository.GetById(assemblage.Id);
            Assert.NotNull(assemblageFindById);
        }
예제 #6
0
        static Assemblage GetData()
        {
            var whole = new Whole();
            var part  = new Part {
                Whole = whole
            };

            whole.Parts.Add(part);
            var assemblage = new Assemblage();

            assemblage.Parts.Add(part);
            return(assemblage);
        }
        public void TestAssemblageDbDelete_WithAssemblage_ShouldDeleteTheAssemblageFromDb()
        {
            var repository = new Repository <Assemblage>(_db);
            var assemblage = new Assemblage();

            repository.Create(assemblage);
            var assemblageFindById = repository.GetById(assemblage.Id);

            Assert.NotNull(assemblageFindById);
            repository.Delete(assemblage.Id);
            assemblageFindById = repository.GetById(assemblage.Id);
            Assert.Null(assemblageFindById);
        }
        public void TestAssemblageDbUbdate_WithNewAssemblage_ShouldUpdateTheAssemblageToDb()
        {
            var repository = new Repository <Assemblage>(_db);
            var assemblage = new Assemblage();

            repository.Create(assemblage);
            var assemblageFindById = repository.GetById(assemblage.Id);

            Assert.Null(assemblageFindById.Warehouse);
            var warehouse = new Warehouse("warehouse name");

            assemblage.Warehouse = warehouse;
            repository.Update(assemblage);
            Assert.Equal("warehouse name", assemblageFindById.Warehouse.Description);
        }
예제 #9
0
        public void Test_Assemblage_WithEmptyData_ShouldContainData()
        {
            DateTime date       = DateTime.Now;
            var      assemblage = new Assemblage(date);

            assemblage.Warehouse = SelectWarehouse("Main");
            assemblage.ListOfNomenc.Add(CreateLineItem(SelectNomenclature("AMD"), 100, 100));

            Assert.NotEqual(Guid.Empty, assemblage.Id);
            Assert.Equal(date, assemblage.Date);
            Assert.Equal("Main", assemblage.Warehouse.Description);
            Assert.Collection(assemblage.ListOfNomenc, item => item.Nomenclature.Description.Equals("AMD"));
            Assert.Collection(assemblage.ListOfNomenc, item => item.Price.Equals(100));
            Assert.Collection(assemblage.ListOfNomenc, item => item.Quantity.Equals(100));
            Assert.Collection(assemblage.ListOfNomenc, item => item.Sum.Equals(100 * 100));
        }
예제 #10
0
        public VisualHardwareHost(System.Type hostedHardwareType, Assemblage.IN8 CPU, params byte[] ports)
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            this.CPU = CPU;
            this.ports = ports;

            screenDevice = Activator.CreateInstance(hostedHardwareType) as IVisualHardware;
            if (screenDevice == null) throw new InvalidProgramException("Cannot host devices that are not visual hardware.");

            screenDevice.Connect(CPU, ports);
            var size = screenDevice.PreferredWindowSize;

            graphics.PreferredBackBufferHeight = (int)size.X;
            graphics.PreferredBackBufferWidth = (int)size.Y;
        }
예제 #11
0
 public void Connect(Assemblage.IN8 CPU, params byte[] ports)
 {
     if (ports.Length != 1) throw new InvalidOperationException("7-segment display takes exactly one port");
     CPU.AttachHardware(this, ports);
 }