Example #1
0
        private void ToolStripMenuItemOpenClick(object sender, EventArgs e)
        {
            ComponentCollection selected = new ComponentCollection();

            foreach (BaseEntityObject o in _directivesViewer.SelectedItems)
            {
                if (o is ComponentDirective)
                {
                    selected.CompareAndAdd(((ComponentDirective)o).ParentComponent);
                }
                if (o is Component)
                {
                    selected.CompareAndAdd((Component)o);
                }
            }

            foreach (Component t in selected)
            {
                var             refE      = new ReferenceEventArgs();
                DisplayerParams dp        = null;
                string          regNumber = "";
                if (t is BaseComponent)
                {
                    if (((BaseComponent)t).BaseComponentType.ItemId == 4)
                    {
                        regNumber = t.ToString();
                    }
                    else
                    {
                        dp = ScreenAndFormManager.GetBaseComponentScreen((BaseComponent)t);
                    }
                }
                else
                {
                    dp = ScreenAndFormManager.GetComponentScreen(t);
                }
                refE.SetParameters(dp);
                InvokeDisplayerRequested(refE);
            }
        }
        private void HeaderControlSaveButtonDisplayerRequested(object sender, Interfaces.ReferenceEventArgs e)
        {
            try
            {
                string message;
                if (!ValidateData(out message))
                {
                    message += "\nAbort operation";
                    MessageBox.Show(message, new GlobalTermsProvider()["SystemName"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    e.Cancel = true;
                    return;
                }

                AddNewDetail();
                var dp = ScreenAndFormManager.GetComponentScreen(_addedComponent);
                e.SetParameters(dp);
                e.TypeOfReflection = ReflectionTypes.DisplayInNewWithCloseCurrent;
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while saving data", ex);
                e.Cancel = true;
            }
        }