Example #1
0
        public static ArchiveSeeForm AssociateSeeForm(Control container, string windowName, bool asDetail)
        {
            WindowInfo windowInfo = ADInfoBll.Instance.GetWindowInfo(windowName);

            if (windowInfo == null)
            {
                return(null);
            }

            ArchiveSeeForm form = new GeneratedArchiveSeeForm(windowInfo);

            form.TopLevel        = false;
            form.FormBorderStyle = FormBorderStyle.None;
            form.Visible         = true;

            if (asDetail)
            {
                form.MenuStrip.Visible = false;
                Feng.Utils.ReflectionHelper.SetObjectValue(Feng.Utils.ReflectionHelper.GetObjectValue(form, "tsbView"), "Visible", false);
            }

            AddControl(container, form);

            return(form);
        }
Example #2
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);
        }
Example #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 static ArchiveSeeForm AssociateSeeForm(Control container, string windowName, bool asDetail)
        {
            WindowInfo windowInfo = ADInfoBll.Instance.GetWindowInfo(windowName);
            if (windowInfo == null)
                return null;

            ArchiveSeeForm form = new GeneratedArchiveSeeForm(windowInfo);
            form.TopLevel = false;
            form.FormBorderStyle = FormBorderStyle.None;
            form.Visible = true;

            if (asDetail)
            {
                form.MenuStrip.Visible = false;
                Feng.Utils.ReflectionHelper.SetObjectValue(Feng.Utils.ReflectionHelper.GetObjectValue(form, "tsbView"), "Visible", false);
            }

            AddControl(container, form);

            return form;
        }
        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;
        }
        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);
            });
        }
        /// <summary>
        /// CreateWindow
        /// </summary>
        /// <param name="windowInfo"></param>
        /// <returns></returns>
        public object CreateWindow(WindowInfo windowInfo)
        {
            MyForm returnForm = null;
            switch (windowInfo.WindowType)
            {
                case WindowType.Maintain:
                case WindowType.Transaction:
                    {
                        returnForm = new GeneratedArchiveOperationForm(windowInfo);
                    }
                    break;
                case WindowType.Query:
                    {
                        // decide gridType
                        IList<WindowTabInfo> tabInfos = ADInfoBll.Instance.GetWindowTabInfosByWindowId(windowInfo.Name);
                        IList<GridColumnInfo> gridColumns = ADInfoBll.Instance.GetGridColumnInfos(tabInfos[0].GridName);
                        foreach (GridColumnInfo info in gridColumns)
                        {
                            if (!string.IsNullOrEmpty(info.ParentPropertyName))
                            {
                                returnForm = new GeneratedArchiveSeeForm(windowInfo, DataGridType.DataUnboundGridLoadOnce);
                            }
                        }
                        returnForm = new GeneratedArchiveSeeForm(windowInfo);
                    }
                    break;
                case WindowType.QueryBound:
                    {
                        returnForm = new GeneratedArchiveSeeForm(windowInfo, DataGridType.DataBoundGridLoadOnDemand);
                    }
                    break;
                case WindowType.TransactionBound:
                    {
                        returnForm = new GeneratedArchiveOperationForm(windowInfo, ArchiveGridType.ArchiveBoundGrid);
                    }
                    break;
                case WindowType.Select:
                    {
                        returnForm = new GeneratedArchiveCheckForm(windowInfo);
                    }
                    break;
                case WindowType.DatabaseReport:
                    {
                        returnForm = new GeneratedArchiveDatabaseReportForm(windowInfo);
                    }
                    break;
                case WindowType.DataSetReport:
                    {
                        returnForm = new GeneratedArchiveDataSetReportForm(windowInfo);
                    }
                    break;
                case WindowType.SelectWindow:
                    {
                        using (ArchiveSelectForm selectForm = new ArchiveSelectForm(windowInfo.Name))
                        {
                            if (selectForm.ShowDialog() == DialogResult.OK)
                            {
                                returnForm = selectForm.SelectedForm;
                            }
                            else
                            {
                                returnForm = null;
                            }
                        }
                    }
                    break;
                case WindowType.DetailTransaction:
                    {
                        ArchiveDetailForm form = ArchiveFormFactory.GenerateArchiveDetailForm(ADInfoBll.Instance.GetWindowInfo(windowInfo.Name), null);
                        form.Load += new EventHandler(delegate(object sender, System.EventArgs e)
                        {
                            form.UpdateContent();
                            form.SetMenuState();
                        });
                        form.SetAsMdiChild();
                        //// 创建TaskPane
                        //GridRelatedControl gridRelatedControl = null;
                        //form.SetGridRelatedPanel(() =>
                        //    {
                        //        if (gridRelatedControl == null)
                        //        {
                        //            gridRelatedControl = new GridRelatedControl(form.GridName, form.DisplayManager, form);
                        //        }
                        //        return gridRelatedControl;
                        //    });

                        form.GenerateWindowMenu(ADInfoBll.Instance.GetWindowMenuInfo(windowInfo.Name));
                        form.Disposed += new EventHandler(delegate(object sender, System.EventArgs e)
                        {
                            form.DisposeWindowMenu();
                        });
                        returnForm = form;
                    }
                    break;
                case WindowType.DataControl:
                    {
                        returnForm = new GeneratedArchiveDataControlForm(windowInfo);
                    }
                    break;
                case WindowType.ExcelOperation:
                    {
                        returnForm = new GeneratedArchiveExcelForm(windowInfo);
                    }
                    break;
                default:
                    throw new ArgumentException("Invalid WindowType in WindowInfo");
            }

            if (WindowCreated != null)
            {
                WindowCreated(returnForm, System.EventArgs.Empty);
            }

            return returnForm;
        }