Ejemplo n.º 1
0
        /// <summary>
        /// Loads and Excel spreadsheet with the items list
        /// </summary>
        public void LoadItemList()
        {
            OpenExcel();
            int rowCount    = 25;
            int colCount    = 25;
            int roomnumber  = -1;
            var currentRoom = new RoomVM(null, 0);

            for (int row = 0; row < rowCount; row++)
            {
                // Import job information
                if (WorkSheet.Cells[row, 1] == "Job")
                {
                    ViewModel.Job.SetProperty(WorkSheet.Cells[row, 2], WorkSheet.Cells[row, 3]);
                }

                if (WorkSheet.Cells[row, 1] == "Room")
                {
                    roomnumber++;
                    ViewModel.AddRoom(WorkSheet.Cells[row, 3]);
                    currentRoom = ViewModel.Rooms[roomnumber];
                }

                if (WorkSheet.Cells[row, 1] == "Strip")
                {
                    var strip = new Strip
                    {
                        RoomNumber = roomnumber,
                        Color      = WorkSheet.Cells[row, COLOR_COL],
                        Length     = WorkSheet.Cells[row, LENGTH_COL]
                    };
                    currentRoom.StripViewModel.AddStrip(strip);
                }
            }

            CloseExcel();
        }
Ejemplo n.º 2
0
 public void AddRoomToJob()
 {
     room = job.AddRoom();
 }
Ejemplo n.º 3
0
 public void Execute(object parameter)
 {
     ViewModel.AddRoom();
 }
Ejemplo n.º 4
0
        public JobVM Load()
        {
            DataSet = new DataSet(DataSetName);
            DataSet.ReadXml("Tyler Holstead.xml");
            JobData       = DataSet.Tables[JobDataName];
            RoomData      = DataSet.Tables[RoomDataName];
            StripData     = DataSet.Tables[StripDataName];
            PanelData     = DataSet.Tables[PanelDataName];
            ShelfData     = DataSet.Tables[ShelfDataName];
            AccessoryData = DataSet.Tables[AccessoryDataName];

            var newJob = new JobVM();

            //===================================
            // Import Job Information
            //===================================
            var job = new Job();

            foreach (DataColumn propertyName in JobData.Columns)
            {
                var propertyValue = JobData.Rows[0][propertyName].ToString();
                job.SetProperty(propertyName.ColumnName, propertyValue);
            }
            newJob.Job = job;

            //===================================
            // Import Room Information
            //===================================
            if (RoomData != null)
            {
                for (int row = 0; row < RoomData.Rows.Count; row++)
                {
                    newJob.AddRoom();
                    RoomVM roomvm = newJob.Rooms[row];
                    foreach (string propertyName in roomvm.Room.Properties)
                    {
                        if (RoomData.Columns[propertyName] != null)
                        {
                            roomvm.Room.SetProperty(propertyName, RoomData.Rows[row][propertyName].ToString());
                        }
                    }
                }
            }

            //===================================
            // Import Strip Information
            //===================================
            if (PanelData != null)
            {
                for (int row = 0; row < StripData.Rows.Count; row++)
                {
                    var strip = new Strip();
                    foreach (string propertyName in strip.Properties)
                    {
                        strip.SetProperty(propertyName, StripData.Rows[row][propertyName].ToString());
                    }

                    foreach (RoomVM roomvm in newJob.Rooms)
                    {
                        if (roomvm.Room.RoomNumber == strip.RoomNumber)
                        {
                            roomvm.StripViewModel.AddStrip(strip);
                        }
                    }
                }
            }


            //===================================
            // Import Panel Information
            //===================================
            if (PanelData != null)
            {
                for (int row = 0; row < PanelData.Rows.Count; row++)
                {
                    var panel = new Panel();
                    foreach (string propertyName in panel.Properties)
                    {
                        panel.SetProperty(propertyName, PanelData.Rows[row][propertyName].ToString());
                    }

                    foreach (RoomVM roomvm in newJob.Rooms)
                    {
                        if (roomvm.Room.RoomNumber == panel.RoomNumber)
                        {
                            roomvm.PanelViewModel.Add(panel);
                        }
                    }
                }
            }

            //===================================
            // Import Shelf Information
            //===================================
            if (ShelfData != null)
            {
                for (int row = 0; row < ShelfData.Rows.Count; row++)
                {
                    var shelf = new Shelf();
                    foreach (string propertyName in shelf.Properties)
                    {
                        if (ShelfData.Columns[propertyName] != null)
                        {
                            shelf.SetProperty(propertyName, ShelfData.Rows[row][propertyName].ToString());
                        }
                    }

                    foreach (RoomVM roomvm in newJob.Rooms)
                    {
                        if (roomvm.Room.RoomNumber == shelf.RoomNumber)
                        {
                            roomvm.ShelfViewModel.Add(shelf);
                        }
                    }
                }
            }

            //===================================
            // Import Accessory Information
            //===================================
            if (AccessoryData != null)
            {
                for (int row = 0; row < AccessoryData.Rows.Count; row++)
                {
                    var accessory = new Accessory();
                    foreach (string propertyName in accessory.Properties)
                    {
                        if (AccessoryData.Columns[propertyName] != null)
                        {
                            accessory.SetProperty(propertyName, AccessoryData.Rows[row][propertyName].ToString());
                        }
                    }

                    foreach (RoomVM roomvm in newJob.Rooms)
                    {
                        if (roomvm.Room.RoomNumber == accessory.RoomNumber)
                        {
                            roomvm.AccessoryViewModel.Add(accessory);
                        }
                    }
                }
            }

            return(newJob);
        }