Beispiel #1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                this.DisposeWindowMenu();
                if (m_detailForm != null)
                {
                    m_detailForm.DisposeWindowMenu();
                }

                if (m_detailForm != null)
                {
                    m_detailForm.VisibleChanged -= new EventHandler(m_detailForm_VisibleChanged);

                    IArchiveDetailFormWithDetailGrids dfdg = m_detailForm as IArchiveDetailFormWithDetailGrids;
                    if (dfdg != null)
                    {
                        foreach (IBoundGrid grid in dfdg.DetailGrids)
                        {
                            if (grid.DisplayManager != null)
                            {
                            }
                        }
                    }
                    m_detailForm = null;
                }
            }
            base.Dispose(disposing);
        }
Beispiel #2
0
        internal static void OnButtonClick(WindowMenuInfo windowMenuInfo, System.Windows.Forms.Form parentForm)
        {
            IArchiveDetailFormWithDetailGrids addg = parentForm as IArchiveDetailFormWithDetailGrids;

            if (addg != null)
            {
                foreach (IBoundGrid i in addg.DetailGrids)
                {
                    MyGrid.CancelEditCurrentDataRow(i);
                }
            }
            IGridContainer agf = parentForm as IGridContainer;

            if (agf != null)
            {
                MyGrid.CancelEditCurrentDataRow(agf.MasterGrid);
            }

            IControlManagerContainer cmc = parentForm as IControlManagerContainer;

            if (cmc != null)
            {
                InternalExecuteWindowMenu(cmc.ControlManager, windowMenuInfo, parentForm);
            }
            else
            {
                IDisplayManagerContainer dmc = parentForm as IDisplayManagerContainer;
                if (dmc != null)
                {
                    InternalExecuteWindowMenu(dmc.DisplayManager, windowMenuInfo, parentForm);
                    //InternalExecuteWindowMenu((parentForm as ArchiveDetailForm).ParentArchiveForm, windowMenuInfo);
                }
            }
        }
Beispiel #3
0
        //private static void AddManualDetailForm(System.Windows.Forms.Form form, IArchiveDetailFormAuto detailFormAuto)
        //{
        //    form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
        //    form.TopLevel = false;

        //    detailFormAuto.ReplaceFlowLayoutPanel(form);
        //}

        public static ArchiveDetailForm GenerateArchiveDetailForm(WindowInfo windowInfo, IWindowControlManager cmParent, IBaseDao daoParent, IDisplayManager dmParent, IArchiveDetailForm originalDetailForm = null)
        {
            ArchiveDetailForm     detailForm = originalDetailForm as ArchiveDetailForm;
            IList <WindowTabInfo> tabInfos   = ADInfoBll.Instance.GetWindowTabInfosByWindowId(windowInfo.Name);

            IList <WindowTabInfo> detailFormTabInfos  = new List <WindowTabInfo>();
            IList <WindowTabInfo> detailFormTabInfos2 = new List <WindowTabInfo>();

            foreach (WindowTabInfo subTabInfo in tabInfos[0].ChildTabs)
            {
                if (subTabInfo.IsInDetailForm)
                {
                    detailFormTabInfos.Add(subTabInfo);
                }
                else
                {
                    detailFormTabInfos2.Add(subTabInfo);
                }
            }

            //if (detailStyleForm == null && windowInfo.DetailForm != null)
            //{
            //    FormInfo formInfo = ADInfoBll.Instance.GetFormInfo(windowInfo.DetailForm.Name);
            //    if (formInfo == null)
            //    {
            //        throw new ArgumentException("There is no FormInfo with Name of " + windowInfo.DetailForm.Name);
            //    }
            //    detailStyleForm = CreateForm(formInfo);
            //}
            //if (detailStyleForm != null)
            //{
            //    ret = detailStyleForm as ArchiveDetailForm;
            //}

            // 当第二层的任何一个ControlManager为空时,DetailForm作为不可编辑的。
            bool isControlManagerEnable = cmParent != null;

            if (isControlManagerEnable)
            {
                for (int i = 0; i < detailFormTabInfos.Count; ++i)
                {
                    if (string.IsNullOrEmpty(detailFormTabInfos[i].ControlManagerClassName))
                    {
                        dmParent = cmParent.DisplayManager;
                        isControlManagerEnable = false;
                        break;
                    }
                }
            }

            if (detailForm == null)
            {
                if (detailFormTabInfos.Count == 0)
                {
                    if (isControlManagerEnable)
                    {
                        detailForm = new ArchiveDetailFormAuto(cmParent, tabInfos[0].GridName);
                    }
                    else
                    {
                        detailForm = new ArchiveDetailFormAuto(dmParent, tabInfos[0].GridName);
                    }
                }
                else if (detailFormTabInfos.Count == 1)
                {
                    if (isControlManagerEnable)
                    {
                        detailForm = new ArchiveDetailFormAutoWithDetailGrid(cmParent, tabInfos[0].GridName);
                    }
                    else
                    {
                        detailForm = new ArchiveDetailFormAutoWithDetailGrid(dmParent, tabInfos[0].GridName);
                    }
                }
                else
                {
                    string[] texts = new string[detailFormTabInfos.Count];
                    for (int i = 0; i < detailFormTabInfos.Count; ++i)
                    {
                        texts[i] = detailFormTabInfos[i].Text;
                    }

                    if (isControlManagerEnable)
                    {
                        detailForm = new ArchiveDetailFormAutoWithMultiDetailGrid(cmParent, tabInfos[0].GridName, detailFormTabInfos.Count, texts);
                    }
                    else
                    {
                        detailForm = new ArchiveDetailFormAutoWithMultiDetailGrid(dmParent, tabInfos[0].GridName, detailFormTabInfos.Count, texts);
                    }
                }

                //IArchiveDetailFormAuto detailFormAuto = ret as IArchiveDetailFormAuto;
                //if (detailStyleForm != null && detailFormAuto != null)
                //{
                //    AddManualDetailForm(detailStyleForm, detailFormAuto);
                //}
            }
            else
            {
                // Dao 在cmParent处已经设置了
                if (isControlManagerEnable)
                {
                    detailForm.SetControlMananger(cmParent, tabInfos[0].GridName);
                }
                else
                {
                    detailForm.SetDisplayManager(dmParent, tabInfos[0].GridName);
                }
            }

            detailForm.Name = windowInfo.Name;
            detailForm.Text = windowInfo.Text;

            // 只有2层可编辑。主层(控件)-第二层(grid)。再下去就是第二层grid的DetailGrid,不可编辑。
            IArchiveDetailFormWithDetailGrids detailFormWithGrids = detailForm as IArchiveDetailFormWithDetailGrids;

            if (detailFormWithGrids != null)
            {
                for (int i = 0; i < detailFormTabInfos.Count; ++i)
                {
                    if (i >= detailFormWithGrids.DetailGrids.Count)
                    {
                        break;
                    }
                    // 主是ControlManager,并不一定子也是ControlManager。
                    // 主可以在grid编辑,不能通过DetailForm编辑。此时DetailForm是另外显示的东西。
                    if (isControlManagerEnable)
                    {
                        var daoRelational = daoParent as IRelationalDao;
                        if (daoRelational == null)
                        {
                            throw new ArgumentException("IArchiveDetailFormWithDetailGrids must has IRelationalDao.");
                        }

                        ISearchManager        subSm = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(detailFormTabInfos[i], cmParent.DisplayManager);
                        IWindowControlManager subCm = ServiceProvider.GetService <IManagerFactory>().GenerateControlManager(detailFormTabInfos[i], subSm) as IWindowControlManager;
                        subCm.Name = detailFormTabInfos[i].Name;
                        ((IArchiveGrid)detailFormWithGrids.DetailGrids[i]).SetControlManager(subCm, detailFormTabInfos[i].GridName);

                        ManagerFactory.GenerateBusinessLayer(daoParent as IRelationalDao, detailFormTabInfos[i]);

                        IBaseDao subDao = daoRelational.GetRelationalDao(i);
                        if (subDao is IMemoriedRelationalDao)
                        {
                            IMemoryDao subMemoryDao = ((IMemoriedRelationalDao)daoRelational.GetRelationalDao(i)).DetailMemoryDao;
                            subCm.Dao = subMemoryDao;

                            //subMemoryDao.AddSubDao(new MasterDetailMemoryDao<>(cmParent));
                            ((IMemoriedRelationalDao)daoRelational.GetRelationalDao(i)).AddRelationToMemoryDao(cmParent.DisplayManager);
                        }
                        else
                        {
                            subCm.Dao = subDao;
                        }
                    }
                    else
                    {
                        ISearchManager  subSm = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(detailFormTabInfos[i], dmParent);
                        IDisplayManager subDm = ServiceProvider.GetService <IManagerFactory>().GenerateDisplayManager(detailFormTabInfos[i], subSm);
                        subDm.Name = detailFormTabInfos[i].Name;

                        detailFormWithGrids.DetailGrids[i].SetDisplayManager(subDm, detailFormTabInfos[i].GridName);
                    }
                    GenerateDetailGrids(detailFormWithGrids.DetailGrids[i], detailFormTabInfos[i]);
                }
            }

            if (isControlManagerEnable)
            {
                // Generate Other Daos
                for (int i = 0; i < detailFormTabInfos2.Count; ++i)
                {
                    if (!string.IsNullOrEmpty(detailFormTabInfos2[i].BusinessLayerClassName))
                    {
                        ManagerFactory.GenerateBusinessLayer(daoParent as IRelationalDao, detailFormTabInfos2[i]);
                    }
                }
            }

            // if Master Tab's IsInDetailForm=false, Invisible it
            if (!tabInfos[0].IsInDetailForm)
            {
                if (detailForm is IArchiveDetailFormAuto)
                {
                    (detailForm as IArchiveDetailFormAuto).RemoveControls();
                }
            }

            return(detailForm);
        }