コード例 #1
0
        private void btnBOMDeletePart_Click(object sender, EventArgs e)
        {
            if (cBoxBOMParts.SelectedIndex == -1)
            {
                return;
            }

            EplanArticleReferenceViewModel articleReference = this.cBoxBOMParts.SelectedItem as EplanArticleReferenceViewModel;

            if (articleReference == null)
            {
                return;
            }

            Function targetFunction = ((EplanFunctionViewModel)this.cBoxBOMFunctions.SelectedItem).Function;

            if (targetFunction == null)
            {
                return;
            }

            targetFunction.RemoveArticleReference(articleReference.ArticleReference);

            int functionIndex = cBoxBOMFunctions.SelectedIndex;

            cBoxBOMFunctions.SelectedIndex = -1;
            cBoxBOMFunctions.SelectedIndex = functionIndex;

            // Refresh Part Reference List
            RefreshPartReferenceList(this.cBoxBOMFunctions);

            // Refresh Drawing
            ApiExtHelpers.RefreshDrawing();
        }
コード例 #2
0
        private void btnBOMReplacePart_Click(object sender, EventArgs e)
        {
            // 01. Get Current Selected Part Reference
            if (cBoxBOMParts.SelectedIndex == -1)
            {
                return;
            }

            EplanArticleReferenceViewModel articleReference = this.cBoxBOMParts.SelectedItem as EplanArticleReferenceViewModel;

            if (articleReference == null)
            {
                return;
            }

            // 02. Get Current Function to replce against
            Function targetFunction = ((EplanFunctionViewModel)this.cBoxBOMFunctions.SelectedItem).Function;

            if (targetFunction == null)
            {
                return;
            }

            // 03. Get New Part
            string selectedPartNumber  = string.Empty;
            string selectedPartVariant = string.Empty;

            new EplApplication().ShowPartSelectionDialog(ref selectedPartNumber, ref selectedPartVariant);

            if (this._logger.IsDebugEnabled)
            {
                this._logger.DebugFormat("btnBOMReplacePart_Click(), selectedPartNumber=[{0}], selectedPartVariant=[{1}]", selectedPartNumber, selectedPartVariant);
            }

            if (string.IsNullOrEmpty(selectedPartNumber))
            {
                return;
            }

            // 04. Info from Current Part Reference
            int articleReferenceIndex = articleReference.ArticleReference.ReferencePos;

            if (this._logger.IsDebugEnabled)
            {
                this._logger.DebugFormat("btnBOMReplacePart_Click(), articleReference.PartNr=[{0}], articleReference.Index=[{1}]",
                                         articleReference.ArticleReference.PartNr, articleReferenceIndex);
            }

            // 05. Replace the Part Number with New One
            articleReference.ArticleReference.PartNr = selectedPartNumber;
            articleReference.ArticleReference.StoreToObject();

            // 06. Refresh Part Reference List
            RefreshPartReferenceList(this.cBoxBOMFunctions);

            // 07. Refresh Drawing
            ApiExtHelpers.RefreshDrawing();
        }
コード例 #3
0
        private void cBoxBOMParts_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.txtBOMPartNumber.Text   = string.Empty;
            this.txtBOMPartQuantity.Text = string.Empty;

            if (cBoxBOMParts.SelectedIndex == -1)
            {
                return;
            }

            EplanArticleReferenceViewModel articleReference = this.cBoxBOMParts.SelectedItem as EplanArticleReferenceViewModel;

            if (articleReference == null)
            {
                return;
            }

            this.txtBOMPartNumber.Text   = articleReference.PartNumber;
            this.txtBOMPartQuantity.Text = articleReference.Quantity?.ToString() ?? string.Empty;
        }