Example #1
0
        // Update tool Selection
        private void ToolDataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            if (ToolDataGrid.SelectedIndex != -1)
            {
                // Get toolData from ToolDataGrid
                ToolModel selectedTool = (ToolModel)ToolDataGrid.SelectedItems[0];

                // Get toolID from toolData
                toolID = selectedTool.ToolID;

                // Load ToolData from SQLite DB
                var toolData = SqliteDataAcces.LoadToolDataByID(toolID);

                // Fill tool information
                functionTextBlock.Text = toolData.Function;
                typeTextBlock.Text     = toolData.Type;
                holderTextBlock.Text   = toolData.Holder;
                machineTextBlock.Text  = toolData.Machine;
                diameterTextBlock.Text = toolData.Diameter.ToString("F");
                lengthTextBlock.Text   = toolData.Length.ToString("F");
                storageTextBlock.Text  = toolData.Storage;
                locationTextBlock.Text = toolData.Location;

                holderVendorTextBlock.Text = toolData.HolderVendor;
                holderArtTextBlock.Text    = toolData.HolderArt;

                extensionVendorTextBlock.Text = toolData.ExtensionVendor;
                extensionArtTextBlock.Text    = toolData.ExtensionArt;

                toolVendorTextBlock.Text = toolData.ToolVendor;
                toolArtTextBlock.Text    = toolData.ToolArt;
            }
        }
        private void FillForm()
        {
            //Get data from selected tool
            selectedTool = SqliteDataAcces.LoadToolDataByID(Convert.ToInt32(toolID));

            //Fill in readonly data
            ToolTextBlock.Text       = $"Edit Tool - {toolID}";
            TypeTextBlock.Text       = selectedTool.Type;
            FunctionTextBlock.Text   = selectedTool.Function;
            HolderTextBlock.Text     = selectedTool.Holder;
            MachineTextBlock.Text    = selectedTool.Machine;
            DiameterTextBlock.Text   = selectedTool.Diameter.ToString("F");
            LengthTextBlock.Text     = selectedTool.Length.ToString("F");
            StorageTextBox.Text      = selectedTool.Storage;
            LocationTextBox.Text     = selectedTool.Location;
            DescriptionTextBox.Text  = selectedTool.Description;
            HolderArtTextBox.Text    = selectedTool.HolderArt;
            ExtensionArtTextBox.Text = selectedTool.ExtensionArt;
            ToolArtTextBox.Text      = selectedTool.ToolArt;

            if (selectedTool.HolderVendor != "-" && selectedTool.HolderVendor != "")
            {
                HolderVendorComboBox.Text         = selectedTool.HolderVendor;
                HolderVendorComboBox.SelectedItem = selectedTool.HolderVendor;
            }
            if (selectedTool.ExtensionVendor != "-" && selectedTool.ExtensionVendor != "")
            {
                ExtensionVendorComboBox.Text         = selectedTool.ExtensionVendor;
                ExtensionVendorComboBox.SelectedItem = selectedTool.ExtensionVendor;
            }
            if (selectedTool.ToolVendor != "-" && selectedTool.ToolVendor != "")
            {
                ToolVendorComboBox.Text         = selectedTool.ToolVendor;
                ToolVendorComboBox.SelectedItem = selectedTool.ToolVendor;
            }
        }