public MeasurementEditor(Measurement measurement)
        {
            try
            {
                InitializeComponent();

                this.Measurement = measurement;

                this.txtName.DataBindings.Add(new Binding("Text", Measurement, "Name"));
                this.txtAbbreviation.DataBindings.Add(new Binding("Text", Measurement, "Abbreviation"));
            }
            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);
        }
Esempio n. 3
0
        private void ImportMeasurements()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                //Import Measurements
                Measurements.Clear();
                foreach (var m in measurementRecordBindingSource.Cast<MeasurementRecord>())
                {
                    try
                    {
                        if (m.Import)
                        {
                            Measurement measurement = new Measurement
                            {
                                ID = Guid.NewGuid(),
                                Name = m.Name,
                                Abbreviation = m.Symbol
                            };

                            MeasurementService.Save(measurement);

                            m.ImportStatus = ImportStatus.Importado;

                            Measurements.Add(measurement);

                            m.Import = false;
                        }
                        else
                            Measurements.Add(MeasurementService.GetByName(m.Name));

                    }
                    catch (Exception ex)
                    {
                        m.ImportStatus = ImportStatus.Error;
                        m.Message = ex.Message;
                    }
                }

                scope.Complete();
            }
        }