Ejemplo n.º 1
0
        public GeneratedArchiveDatabaseReportForm(WindowInfo windowInfo)
        {
            this.Name = windowInfo.Name;
            this.Text = windowInfo.Text;

            IList <WindowTabInfo> tabInfos = ADInfoBll.Instance.GetWindowTabInfosByWindowId(windowInfo.Name);

            if (tabInfos == null)
            {
                throw new ArgumentException("there is no windowTab with windowId of " + windowInfo.Name);
            }
            if (tabInfos.Count == 0)
            {
                throw new ArgumentException("There should be at least one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }
            if (tabInfos.Count > 1)
            {
                throw new ArgumentException("There should be at most one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }

            ISearchManager smMaster = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(tabInfos[0], null);

            IDisplayManager dmMaster = ServiceProvider.GetService <IManagerFactory>().GenerateDisplayManager(tabInfos[0], smMaster);

            smMaster.DataLoading += new EventHandler <DataLoadingEventArgs>(smMaster_DataLoading);
            ReportInfo reportInfo = ADInfoBll.Instance.GetReportInfo(windowInfo.Name);

            CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = ReportHelper.CreateReportDocument(reportInfo.ReportDocument);

            this.ReportViewer.CrystalHelper.ReportSource = reportDocument;

            // Now only support Sql
            System.Data.SqlClient.SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder();
            builder.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[SecurityHelper.DataConnectionStringName].ConnectionString;

            this.ReportViewer.CrystalHelper.ServerName         = builder.DataSource;
            this.ReportViewer.CrystalHelper.DatabaseName       = builder.InitialCatalog;
            this.ReportViewer.CrystalHelper.UserId             = builder.UserID;
            this.ReportViewer.CrystalHelper.Password           = builder.Password;
            this.ReportViewer.CrystalHelper.IntegratedSecurity = builder.IntegratedSecurity;

            GeneratedArchiveSeeForm.InitializeWindowProcess(windowInfo, this);

            ArchiveSearchForm searchForm = null;

            this.SetSearchPanel(() =>
            {
                if (searchForm == null)
                {
                    searchForm = new ArchiveSearchForm(this, smMaster, tabInfos[0]);
                }
                return(searchForm);
            });
        }
        public GeneratedArchiveCheckForm(WindowInfo windowInfo)
            : base()
        {
            this.Name = windowInfo.Name;
            this.Text = windowInfo.Text;

            IList <WindowTabInfo> tabInfos = ADInfoBll.Instance.GetWindowTabInfosByWindowId(windowInfo.Name);

            if (tabInfos == null)
            {
                throw new ArgumentException("there is no windowTab with windowId of " + windowInfo.Name);
            }
            if (tabInfos.Count == 0)
            {
                throw new ArgumentException("There should be at least one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }
            if (tabInfos.Count > 1)
            {
                throw new ArgumentException("There should be at most one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }

            ISearchManager  smMaster = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(tabInfos[0], null);
            IDisplayManager dmMaster;

            if (!string.IsNullOrEmpty(tabInfos[0].DisplayManagerClassName))
            {
                dmMaster = ServiceProvider.GetService <IManagerFactory>().GenerateDisplayManager(tabInfos[0], smMaster);
            }
            else
            {
                dmMaster = (ServiceProvider.GetService <IManagerFactory>().GenerateControlManager(tabInfos[0], smMaster)).DisplayManager;
            }

            (base.MasterGrid as IBoundGrid).SetDisplayManager(dmMaster, tabInfos[0].GridName);

            ArchiveSearchForm searchForm = null;

            this.SetSearchPanel(() =>
            {
                if (searchForm == null)
                {
                    searchForm = new ArchiveSearchForm(this, smMaster, tabInfos[0]);
                }
                return(searchForm);
            });

            // in CheckWindow, no page
            smMaster.EnablePage = false;

            GeneratedArchiveSeeForm.InitializeWindowProcess(windowInfo, this);
        }
        private void Initialize(WindowInfo windowInfo)
        {
            this.Name = windowInfo.Name;
            this.Text = windowInfo.Text;

            IList <WindowTabInfo> tabInfos = ADInfoBll.Instance.GetWindowTabInfosByWindowId(windowInfo.Name);

            if (tabInfos == null)
            {
                throw new ArgumentException("there is no windowTab with windowId of " + windowInfo.Name);
            }
            if (tabInfos.Count == 0)
            {
                throw new ArgumentException("There should be at least one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }
            if (tabInfos.Count > 1)
            {
                throw new ArgumentException("There should be at most one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }

            ISearchManager smMaster = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(tabInfos[0], null);

            IDisplayManager dmMaster = ServiceProvider.GetService <IManagerFactory>().GenerateDisplayManager(tabInfos[0], smMaster);

            (base.MasterGrid as IBoundGrid).SetDisplayManager(dmMaster, tabInfos[0].GridName);

            if (base.MasterGrid is IBoundGridWithDetailGridLoadOnDemand)
            {
                ArchiveFormFactory.GenerateDetailGrids((IBoundGridWithDetailGridLoadOnDemand)base.MasterGrid, tabInfos[0]);
            }

            // Load Additional Menus
            IList <WindowMenuInfo> windowMenuInfos = ADInfoBll.Instance.GetWindowMenuInfo(windowInfo.Name);
            IList <WindowMenuInfo> masterWindowMenuInfos;
            IList <WindowMenuInfo> detailWindowMenuInfos;

            GeneratedArchiveSeeForm.SplitWindowMenu(windowMenuInfos, out masterWindowMenuInfos, out detailWindowMenuInfos);
            if (masterWindowMenuInfos.Count > 0)
            {
                this.GenerateWindowMenu(masterWindowMenuInfos);
            }

            if (windowInfo.GenerateDetailForm)
            {
                // 自定义窗体
                if (windowInfo.DetailForm != null)
                {
                    m_detailForm = ArchiveFormFactory.CreateForm(ADInfoBll.Instance.GetFormInfo(windowInfo.DetailForm.Name)) as IArchiveDetailForm;
                    if (windowInfo.DetailWindow == null)
                    {
                        ArchiveFormFactory.GenerateArchiveDetailForm(windowInfo, null, null, dmMaster, m_detailForm);
                    }
                }
                // 跟主DisplayManager无关的DetailForm
                else if (windowInfo.DetailWindow != null)
                {
                    WindowInfo detailWindowInfo = ADInfoBll.Instance.GetWindowInfo(windowInfo.DetailWindow.Name);
                    m_detailForm = ServiceProvider.GetService <IWindowFactory>().CreateWindow(detailWindowInfo) as IArchiveDetailForm;
                    var searchWindow = m_detailForm.GetCustomProperty(MyChildForm.SearchPanelName) as ArchiveSearchForm;
                    if (searchWindow != null)
                    {
                        searchWindow.EnableProgressForm = false;
                    }
                }
                else
                {
                    // 当DetailFormId有值的时候,不一定是DetailForm,而只是其中的一部分
                    // 和主表一致的明细窗体
                    m_detailForm = ArchiveFormFactory.GenerateArchiveDetailForm(windowInfo, dmMaster);
                }
                if (m_detailForm != null)
                {
                    //m_detailWindow.ParentArchiveForm = this;
                    //m_detailWindow = m_detailWindow;

                    // Generate DetailForm's Menu
                    if (detailWindowMenuInfos.Count > 0)
                    {
                        m_detailForm.GenerateWindowMenu(detailWindowMenuInfos);
                        m_detailForm.VisibleChanged += new EventHandler(m_detailForm_VisibleChanged);
                    }
                }
            }

            ArchiveSearchForm searchForm = null;

            this.SetSearchPanel(() =>
            {
                if (searchForm == null)
                {
                    searchForm = new ArchiveSearchForm(this, smMaster, tabInfos[0]);
                }
                return(searchForm);
            });

            m_attachmentForm = CreateAttachmentWindow(this, windowInfo);

            GeneratedArchiveSeeForm.InitializeWindowProcess(windowInfo, this);

            m_windowInfo = windowInfo;
        }
Ejemplo n.º 4
0
        private void Initialize(WindowInfo windowInfo)
        {
            this.Name = windowInfo.Name;
            this.Text = windowInfo.Text;

            IList <WindowTabInfo> tabInfos = ADInfoBll.Instance.GetWindowTabInfosByWindowId(windowInfo.Name);

            if (tabInfos == null)
            {
                throw new ArgumentException("there is no windowTab with windowId of " + windowInfo.Name);
            }
            if (tabInfos.Count == 0)
            {
                throw new ArgumentException("There should be at least one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }
            if (tabInfos.Count > 1)
            {
                throw new ArgumentException("There should be at most one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }

            ISearchManager        smMaster = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(tabInfos[0], null);
            IWindowControlManager cmMaster = ServiceProvider.GetService <IManagerFactory>().GenerateControlManager(tabInfos[0], smMaster) as IWindowControlManager;

            IBaseDao daoParent = ServiceProvider.GetService <IManagerFactory>().GenerateBusinessLayer(tabInfos[0]);

            cmMaster.Dao = daoParent;

            ((IArchiveGrid)base.MasterGrid).SetControlManager(cmMaster, tabInfos[0].GridName);

            // daoParent's subDao is inserted in detailForm
            if (base.MasterGrid is IBoundGridWithDetailGridLoadOnDemand)
            {
                ArchiveFormFactory.GenerateDetailGrids(base.MasterGrid as IBoundGridWithDetailGridLoadOnDemand, tabInfos[0]);
            }

            // Load Additional Menus
            IList <WindowMenuInfo> windowMenuInfos = ADInfoBll.Instance.GetWindowMenuInfo(windowInfo.Name);
            IList <WindowMenuInfo> masterWindowMenuInfos;
            IList <WindowMenuInfo> detailWindowMenuInfos;

            GeneratedArchiveSeeForm.SplitWindowMenu(windowMenuInfos, out masterWindowMenuInfos, out detailWindowMenuInfos);
            if (masterWindowMenuInfos.Count > 0)
            {
                this.GenerateWindowMenu(masterWindowMenuInfos);
            }

            if (windowInfo.GenerateDetailForm)
            {
                if (windowInfo.DetailForm != null)
                {
                    m_detailForm = ArchiveFormFactory.CreateForm(ADInfoBll.Instance.GetFormInfo(windowInfo.DetailForm.Name)) as IArchiveDetailForm;
                    if (windowInfo.DetailWindow == null)
                    {
                        ArchiveFormFactory.GenerateArchiveDetailForm(windowInfo, cmMaster, daoParent, null, m_detailForm);
                    }
                }
                // 和主窗体不关联
                else if (windowInfo.DetailWindow != null)
                {
                    WindowInfo detailWindowInfo = ADInfoBll.Instance.GetWindowInfo(windowInfo.DetailWindow.Name);
                    m_detailForm = ServiceProvider.GetService <IWindowFactory>().CreateWindow(detailWindowInfo) as IArchiveDetailForm;
                    var searchWindow = m_detailForm.GetCustomProperty(MyChildForm.SearchPanelName) as ArchiveSearchForm;
                    if (searchWindow != null)
                    {
                        searchWindow.EnableProgressForm = false;
                    }
                }
                else
                {
                    m_detailForm = ArchiveFormFactory.GenerateArchiveDetailForm(windowInfo, cmMaster, daoParent as IRelationalDao);
                }

                if (m_detailForm != null)
                {
                    //m_detailWindow.ParentArchiveForm = this;
                    // Generate DetailForm's Menu
                    if (detailWindowMenuInfos.Count > 0)
                    {
                        m_detailForm.GenerateWindowMenu(detailWindowMenuInfos);

                        m_detailForm.VisibleChanged += new EventHandler(m_detailForm_VisibleChanged);
                    }
                }
            }

            ArchiveSearchForm searchForm = null;

            this.SetSearchPanel(() =>
            {
                if (searchForm == null)
                {
                    searchForm = new ArchiveSearchForm(this, smMaster, tabInfos[0]);
                    if (cmMaster != null)
                    {
                        cmMaster.StateControls.Add(searchForm);
                    }
                }
                return(searchForm);
            });

            m_attachmentForm = GeneratedArchiveSeeForm.CreateAttachmentWindow(this, windowInfo);

            GeneratedArchiveSeeForm.InitializeWindowProcess(windowInfo, this);

            m_windowInfo = windowInfo;
        }
        public GeneratedArchiveDataSetReportForm(WindowInfo windowInfo)
            : base()
        {
            this.Name = windowInfo.Name;
            this.Text = windowInfo.Text;

            IList <WindowTabInfo> tabInfos = ADInfoBll.Instance.GetWindowTabInfosByWindowId(windowInfo.Name);

            if (tabInfos == null)
            {
                throw new ArgumentException("there is no windowTab with windowId of " + windowInfo.Name);
            }
            if (tabInfos.Count == 0)
            {
                throw new ArgumentException("There should be at least one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }
            if (tabInfos.Count > 1)
            {
                throw new ArgumentException("There should be at most one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }

            ISearchManager smMaster = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(tabInfos[0], null);

            this.SearchManager = smMaster;

            //IDisplayManager dmMaster = ArchiveFormFactory.GenerateDisplayManager(windowInfo, tabInfos[0], smMaster);

            this.SearchManager.DataLoading += new EventHandler <DataLoadingEventArgs>(smMaster_DataLoading);

            m_reportInfo = ADInfoBll.Instance.GetReportInfo(windowInfo.Name);

            CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = ReportHelper.CreateReportDocument(m_reportInfo.ReportDocument);

            this.ReportViewer.CrystalHelper.ReportSource = reportDocument;
            this.ReportViewer.TemplateDataSet            = ReportHelper.CreateDataset(m_reportInfo.DatasetName);

            m_reportDataInfos = ADInfoBll.Instance.GetReportDataInfo(m_reportInfo.Name);
            foreach (ReportDataInfo reportDataInfo in m_reportDataInfos)
            {
                if (string.IsNullOrEmpty(reportDataInfo.SearchManagerClassName))
                {
                    throw new ArgumentException("ReportDataInfo of " + reportDataInfo.Name + " 's SearchManagerClassName must not be null!");
                }

                ISearchManager sm = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(reportDataInfo.SearchManagerClassName, reportDataInfo.SearchManagerClassParams);

                m_sms.Add(sm);
            }

            this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(GeneratedArchiveDataSetReportForm_FormClosed);

            GeneratedArchiveSeeForm.InitializeWindowProcess(windowInfo, this);

            ArchiveSearchForm searchForm = null;

            this.SetSearchPanel(() =>
            {
                if (searchForm == null)
                {
                    searchForm = new ArchiveSearchForm(this, smMaster, tabInfos[0]);
                }
                return(searchForm);
            });
        }