예제 #1
0
        public RoleEditor(Role role)
        {
            try
            {
                InitializeComponent();

                this.Role = role;

                this.txtName.DataBindings.Add(new Binding("Text", Role, "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);
        }