Пример #1
0
        public ItemTypeEditor(ItemType itemType)
        {
            try
            {
                InitializeComponent();

                this.ItemType = itemType;

                this.txtName.DataBindings.Add(new Binding("Text", ItemType, "Name"));
            }
            catch (Exception ex)
            {
                ex.ShowMessageBox();
            }
        }
        public void InitializeData()
        {
            Role vendedor = new Role { Name = "Vendedor" };
            vendedor.Actions.Add(new RoleAction { Action = SystemAction.Sales });
            RoleService.Save(vendedor);

            User testuser = new User
            {
                Username = "******",
                Name = "test",
                LastName = "test",
                Password = "******".GetMD5Hash()
            };

            UserService.Save(testuser);

            UserService.Update(testuser, new List<Role> { vendedor });

            Measurement units = new Measurement { Name = "Unidad/es", Abbreviation = "Un." };
            MeasurementService.Save(units);

            ItemType cigarrillos = new ItemType { Name = "Cigarrillos" };
            ItemTypeService.Save(cigarrillos);

            Item item1 = new Item
            {
                Name = "Marlboro Box 10",
                InternalCode = "321",
                ExternalCode = "321",
                ItemTypeID = cigarrillos.ID,
                BaseMeasurementID = units.ID,
                MovesStock = true,
                MinimumStock = 10
            };
            item1.CurrentPrice = new Price
            {
                Date = DateTime.Now,
                Value = 2.5
            };

            Item item2 = new Item
            {
                Name = "Marlboro Box 20",
                InternalCode = "987",
                ExternalCode = "987",
                ItemTypeID = cigarrillos.ID,
                BaseMeasurementID = units.ID,
                MovesStock = true,
                MinimumStock = 10
            };
            item2.CurrentPrice = new Price
            {
                Date = DateTime.Now,
                Value = 5
            };
            Item item3 = new Item
            {
                Name = "Marlboro Comun 20",
                InternalCode = "654",
                ExternalCode = "654",
                ItemTypeID = cigarrillos.ID,
                BaseMeasurementID = units.ID,
                MovesStock = true,
                MinimumStock = 10
            };
            item3.CurrentPrice = new Price
            {
                Date = DateTime.Now,
                Value = 4.5
            };

            ItemService.Save(item1);
            ItemService.Save(item2);
            ItemService.Save(item3);
        }
Пример #3
0
        private void ImportItemTypes()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                // Import ItemTypes
                ItemTypes.Clear();
                foreach (var i in itemTypeRecordBindingSource.Cast<ItemTypeRecord>())
                {
                    try
                    {
                        if (i.Import)
                        {
                            ItemType itemType = new ItemType
                            {
                                ID = Guid.NewGuid(),
                                Name = i.Name
                            };

                            ItemTypeService.Save(itemType);

                            i.ImportStatus = ImportStatus.Importado;

                            ItemTypes.Add(itemType);

                            i.Import = false;
                        }
                        else
                            ItemTypes.Add(ItemTypeService.GetByName(i.Name));
                    }
                    catch (Exception ex)
                    {
                        i.ImportStatus = ImportStatus.Error;
                        i.Message = ex.Message;
                    }
                }

                scope.Complete();
            }
        }