/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="gridName"></param>
        /// <param name="dm"></param>
        /// <param name="parentForm"></param>
        /// <param name="addressTextBox"></param>
        public GridRelatedAddressTaskPane(string gridName, IDisplayManager dm, IArchiveMasterForm parentForm, LinkLabel addressTextBox)
        {
            XceedUtility.SetUIStyle(this);

            m_parentForm = parentForm;
            m_dm = dm;
            m_addressTextBox = addressTextBox;

            LoadMenus(gridName);
            if (m_items1.Count != 0)
            {
                var archiveSeeForm = parentForm;
                if (archiveSeeForm != null)
                {
                    archiveSeeForm.MasterGrid.GridControl.CurrentRowChanged += new EventHandler(MasterGrid_CurrentRowChanged);

                    MasterGrid_CurrentRowChanged(archiveSeeForm.DisplayManager, System.EventArgs.Empty);
                }

                if (m_addressTextBox != null)
                {
                    m_addressTextBox.Text = null;
                }
            }
            else
            {
                if (m_addressTextBox != null)
                {
                    m_addressTextBox.Visible = false;
                }
            }
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                foreach (SmartItem item in this.Items)
                {
                    foreach (SmartItem subItem in item.Items)
                    {
                        subItem.Click -= new Xceed.SmartUI.SmartItemClickEventHandler(GridGotoFormTaskPane_Click);
                    }
                }
                this.Items.Clear();

                IArchiveMasterForm archiveSeeForm = m_parentForm as IArchiveMasterForm;
                if (archiveSeeForm != null)
                {
                    archiveSeeForm.MasterGrid.GridControl.CurrentRowChanged -= new EventHandler(MasterGrid_CurrentRowChanged);
                }
                m_parentForm = null;

                if (m_dm != null)
                {
                    m_dm.Dispose();
                    m_dm = null;
                }
            }
            base.Dispose(disposing);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="gridName"></param>
        /// <param name="dm"></param>
        /// <param name="parentForm"></param>
        public GridRelatedControl(string gridName, IDisplayManager dm, IArchiveMasterForm parentForm)
        {
            InitializeComponent();

            m_taskPane1 = new GridGotoFormTaskPane(gridName, dm, parentForm);
            m_taskPane1.Dock = DockStyle.Fill;
            this.panel1.Controls.Add(m_taskPane1);

            m_taskPane2 = new GridRelatedAddressTaskPane(gridName, dm, parentForm, linkLabelAddress);
            m_taskPane2.Dock = DockStyle.Fill;
            this.panel2.Controls.Add(m_taskPane2);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="gridName"></param>
        /// <param name="dm"></param>
        /// <param name="parentForm"></param>
        public GridRelatedControl(string gridName, IDisplayManager dm, IArchiveMasterForm parentForm)
        {
            InitializeComponent();

            m_taskPane1      = new GridGotoFormTaskPane(gridName, dm, parentForm);
            m_taskPane1.Dock = DockStyle.Fill;
            this.panel1.Controls.Add(m_taskPane1);

            m_taskPane2      = new GridRelatedAddressTaskPane(gridName, dm, parentForm, linkLabelAddress);
            m_taskPane2.Dock = DockStyle.Fill;
            this.panel2.Controls.Add(m_taskPane2);
        }
        internal static void ShowFormFromGrid(IArchiveMasterForm sourceForm, GridRelatedInfo info, bool asDetailDialog)
        {
            try
            {
                ISearchExpression se = GetSearchExpressionFromGrid(sourceForm, info, asDetailDialog);

                ShowFrom(info.Action.Name, se, asDetailDialog);
            }
            catch (Exception ex)
            {
                ExceptionProcess.ProcessWithNotify(ex);
            }
        }
示例#6
0
        void TaskPane_Click(object sender, Xceed.SmartUI.SmartItemClickEventArgs e)
        {
            Xceed.SmartUI.SmartItem item = sender as Xceed.SmartUI.SmartItem;
            TaskInfo info = item.Tag as TaskInfo;

            IArchiveMasterForm   seeForm  = ServiceProvider.GetService <IApplication>().ExecuteAction(info.Action.Name) as IArchiveMasterForm;
            ArchiveOperationForm operForm = seeForm as ArchiveOperationForm;

            if (seeForm == null)
            {
                MessageForm.ShowError("未能创建目标窗体!");
                return;
            }
            switch (info.TaskType)
            {
            case TaskType.Add:
                operForm.DoAdd();
                break;

            case TaskType.Edit:
                ISearchManager smSrc;
                if (m_sms.ContainsKey(info.Name))
                {
                    smSrc = m_sms[info.Name];
                }
                else
                {
                    smSrc = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(info.SearchManagerClassName, info.SearchManagerClassParams);
                }

                ISearchManager smDest = seeForm.DisplayManager.SearchManager;
                if (smSrc.GetType() == smDest.GetType())
                {
                    smDest.LoadData(SearchExpression.Parse(EntityHelper.ReplaceExpression(info.SearchExpression)), null);
                }
                else
                {
                    smSrc.EnablePage = false;
                    object dataSource = smSrc.GetData(SearchExpression.Parse(EntityHelper.ReplaceExpression(info.SearchExpression)), null);

                    IDisplayManager dm = seeForm.DisplayManager;
                    dm.SetDataBinding(dataSource, string.Empty);
                    dm.SearchManager.OnDataLoaded(new DataLoadedEventArgs(dataSource, 0));
                }
                break;

            default:
                throw new NotSupportedException("Invalide TaskType");
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="gridName"></param>
        /// <param name="dm"></param>
        /// <param name="parentForm"></param>
        public GridGotoFormTaskPane(string gridName, IDisplayManager dm, IArchiveMasterForm parentForm)
        {
            XceedUtility.SetUIStyle(this);

            LoadMenus(gridName);
            m_parentForm = parentForm;
            m_dm = dm;

            IArchiveMasterForm archiveSeeForm = parentForm;
            if (archiveSeeForm != null)
            {
                archiveSeeForm.MasterGrid.GridControl.CurrentRowChanged += new EventHandler(MasterGrid_CurrentRowChanged);

                MasterGrid_CurrentRowChanged(archiveSeeForm.DisplayManager, System.EventArgs.Empty);
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="gridName"></param>
        /// <param name="dm"></param>
        /// <param name="parentForm"></param>
        public GridGotoFormTaskPane(string gridName, IDisplayManager dm, IArchiveMasterForm parentForm)
        {
            XceedUtility.SetUIStyle(this);

            LoadMenus(gridName);
            m_parentForm = parentForm;
            m_dm         = dm;

            IArchiveMasterForm archiveSeeForm = parentForm;

            if (archiveSeeForm != null)
            {
                archiveSeeForm.MasterGrid.GridControl.CurrentRowChanged += new EventHandler(MasterGrid_CurrentRowChanged);

                MasterGrid_CurrentRowChanged(archiveSeeForm.DisplayManager, System.EventArgs.Empty);
            }
        }
示例#9
0
        public static bool DoView(IArchiveMasterForm masterForm)
        {
            if (masterForm.ArchiveDetailForm == null)
            {
                MessageForm.ShowError("您只能通过表格来查看数据!");
                return(false);
            }

            //if (this.DisplayManager.CurrentItem == null)
            //{
            //    MessageForm.ShowError("请选择要查看的记录!");
            //    return false;
            //}

            masterForm.ShowArchiveDetailForm();

            return(true);
        }
        void TaskPaneAlert_Click(object sender, Xceed.SmartUI.SmartItemClickEventArgs e)
        {
            Xceed.SmartUI.SmartItem item = sender as Xceed.SmartUI.SmartItem;
            AlertInfo info = item.Tag as AlertInfo;

            IArchiveMasterForm seeForm = ServiceProvider.GetService <IApplication>().ExecuteAction(info.Action.Name) as IArchiveMasterForm;

            if (seeForm == null)
            {
                MessageForm.ShowError("未能创建目标窗体!");
                return;
            }

            ISearchManager sm = seeForm.DisplayManager.SearchManager;

            sm.LoadData(SearchExpression.Parse(info.SearchExpression), null);

            FixIt(info);
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                foreach (SmartItem item in this.Items)
                {
                    foreach (SmartItem subItem in item.Items)
                    {
                        subItem.Click -= new Xceed.SmartUI.SmartItemClickEventHandler(GridGotoFormTaskPane_Click);
                    }
                }
                this.Items.Clear();

                var archiveSeeForm = m_parentForm;
                if (archiveSeeForm != null)
                {
                    archiveSeeForm.MasterGrid.GridControl.CurrentRowChanged -= new EventHandler(MasterGrid_CurrentRowChanged);
                }
                m_parentForm = null;

                if (m_dm != null)
                {
                    m_dm.Dispose();
                    m_dm = null;
                }
            }
            base.Dispose(disposing);
        }
        internal static ISearchExpression GetSearchExpressionFromGrid(IArchiveMasterForm sourceForm, GridRelatedInfo info, bool onlyFirstOne)
        {
            if (sourceForm == null)
            {
                throw new ArgumentException("未能找到父窗体!", "sourceForm");
            }

            if (info.RelatedType == GridRelatedType.ByRows)
            {
                if (sourceForm.MasterGrid == null)
                {
                    throw new ArgumentException("未能找到主表格!", "sourceForm");
                }

                List<object> selectedEntities = new List<object>();
                if (sourceForm.MasterGrid.GridControl.SelectedRows.Count == 0)
                {
                    Xceed.Grid.Row row = sourceForm.MasterGrid.CurrentRow;
                    Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow;
                    if (dataRow != null && dataRow.Visible
                        && (info.GridLevel == Feng.Grid.MyGrid.GetGridLevel(dataRow.ParentGrid) || string.IsNullOrEmpty(info.GridLevel)))
                    {
                        selectedEntities.Add(dataRow.Tag);
                    }
                }
                else
                {
                    foreach (Xceed.Grid.Row row in sourceForm.MasterGrid.GridControl.SelectedRows)
                    {
                        if (!row.Visible)
                        {
                            continue;
                        }

                        Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow;
                        if (dataRow == null)
                        {
                            continue;
                        }
                        if (info.GridLevel == Feng.Grid.MyGrid.GetGridLevel(dataRow.ParentGrid)
                            || string.IsNullOrEmpty(info.GridLevel))
                        {
                            selectedEntities.Add(dataRow.Tag);
                        }
                        else
                        {
                            foreach(Xceed.Grid.DetailGrid dg in dataRow.DetailGrids)
                            {
                                GetDetailGridRows(info, dg, selectedEntities);
                            }
                        }

                        if (onlyFirstOne && selectedEntities.Count > 0)
                        {
                            break;
                        }
                    }
                }

                if (selectedEntities.Count == 0)
                {
                    throw new InvalidOperationException("请选择表格行!");
                }

                Dictionary<string, string> exps = new Dictionary<string, string>();
                foreach (object entity in selectedEntities)
                {
                    //if (entity.GetType() != Feng.Utils.ReflectionHelper.GetTypeFromName(info.EntityType))
                    //    continue;

                    string exp = EntityHelper.ReplaceEntity(info.SearchExpression, entity);
                    exps[exp] = exp;
                }
                ISearchExpression se = null;
                foreach (string exp in exps.Keys)
                {
                    ISearchExpression subSearch = SearchExpression.Parse(exp);
                    if (se == null)
                    {
                        se = subSearch;
                    }
                    else
                    {
                        se = SearchExpression.Or(se, subSearch);
                    }
                }
                return se;

                //string[] fromColumns = info.FromColumnName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                //for (int i = 0; i < fromColumns.Length; ++i)
                //{
                //    fromColumns[i] = fromColumns[i].Replace(":", ".");
                //}
                //int count = fromColumns.Length;
                //string[] toColumns = info.ToColumnName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                //Debug.Assert(count == toColumns.Length, "FromColumnName必须和ToColumnName内容个数相同");

                //ArrayList[] selected = new ArrayList[count];

                //for (int i = 0; i < count; ++i)
                //{
                //    selected[i] = new ArrayList();
                //    string columnName = fromColumns[i];

                //    foreach (object entity in selectedEntities)
                //    {
                //        object o = EntityHelper.GetPropertyValue(entity, columnName);
                //        //if (o != null && !string.IsNullOrEmpty(o.ToString()))
                //        {
                //            selected[i].Add(o);
                //        }
                //    }
                //}
            }
            else
            {
                throw new NotSupportedException("Not Supported now!");
            }
        }
        internal static void ShowFormFromGrid(IArchiveMasterForm sourceForm, GridRelatedInfo info, bool asDetailDialog)
        {
            try
            {
                ISearchExpression se = GetSearchExpressionFromGrid(sourceForm, info, asDetailDialog);

                ShowFrom(info.Action.Name, se, asDetailDialog);
            }
            catch (Exception ex)
            {
                ExceptionProcess.ProcessWithNotify(ex);
            }
        }
        internal static ISearchExpression GetSearchExpressionFromGrid(IArchiveMasterForm sourceForm, GridRelatedAddressInfo info, bool onlyFirstOne)
        {
            if (sourceForm == null)
            {
                throw new ArgumentException("未能找到父窗体!", "sourceForm");
            }

            if (info.RelatedType == GridRelatedType.ByRows)
            {
                if (sourceForm.MasterGrid == null)
                {
                    throw new ArgumentException("未能找到主表格!", "sourceForm");
                }

                List <object> selectedEntities = new List <object>();
                if (sourceForm.MasterGrid.GridControl.SelectedRows.Count == 0)
                {
                    Xceed.Grid.Row     row     = sourceForm.MasterGrid.CurrentRow;
                    Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow;
                    if (dataRow != null && dataRow.Visible &&
                        (Feng.Grid.MyGrid.GetGridLevel(dataRow.ParentGrid) == info.GridLevel || string.IsNullOrEmpty(info.GridLevel)))
                    {
                        selectedEntities.Add(dataRow.Tag);
                    }
                }
                else
                {
                    foreach (Xceed.Grid.Row row in sourceForm.MasterGrid.GridControl.SelectedRows)
                    {
                        if (!row.Visible)
                        {
                            continue;
                        }

                        Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow;
                        if (dataRow == null)
                        {
                            continue;
                        }

                        if (Feng.Grid.MyGrid.GetGridLevel(dataRow.ParentGrid) == info.GridLevel ||
                            string.IsNullOrEmpty(info.GridLevel))
                        {
                            selectedEntities.Add(dataRow.Tag);
                        }
                        else
                        {
                            foreach (Xceed.Grid.DetailGrid dg in dataRow.DetailGrids)
                            {
                                GetDetailGridRows(info, dataRow.DetailGrids[0], selectedEntities);
                            }
                        }

                        if (onlyFirstOne && selectedEntities.Count > 0)
                        {
                            break;
                        }
                    }
                }

                if (selectedEntities.Count == 0)
                {
                    throw new InvalidOperationException("请选择表格行!");
                }


                Dictionary <string, string> exps = new Dictionary <string, string>();
                foreach (object entity in selectedEntities)
                {
                    //if (entity.GetType() != Feng.Utils.ReflectionHelper.GetTypeFromName(info.EntityType))
                    //    continue;

                    string exp = EntityHelper.ReplaceEntity(info.SearchExpression, entity);
                    exps[exp] = exp;
                }
                ISearchExpression se = null;
                foreach (string exp in exps.Keys)
                {
                    ISearchExpression subSearch = SearchExpression.Parse(exp);
                    if (se == null)
                    {
                        se = subSearch;
                    }
                    else
                    {
                        se = SearchExpression.Or(se, subSearch);
                    }
                }
                return(se);

                //string[] fromColumns = info.FromColumnName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                //for (int i = 0; i < fromColumns.Length; ++i)
                //{
                //    fromColumns[i] = fromColumns[i].Replace(":", ".");
                //}
                //int count = fromColumns.Length;
                //string[] toColumns = info.ToColumnName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                //Debug.Assert(count == toColumns.Length, "FromColumnName必须和ToColumnName内容个数相同");

                //ArrayList[] selected = new ArrayList[count];

                //for (int i = 0; i < count; ++i)
                //{
                //    selected[i] = new ArrayList();
                //    string columnName = fromColumns[i];

                //    foreach (object entity in selectedEntities)
                //    {
                //        object o = EntityHelper.GetPropertyValue(entity, columnName);
                //        //if (o != null && !string.IsNullOrEmpty(o.ToString()))
                //        {
                //            selected[i].Add(o);
                //        }
                //    }
                //}
            }
            else
            {
                throw new NotSupportedException("Not Supported now!");
            }
        }
        public static bool DoView(IArchiveMasterForm masterForm)
        {
            if (masterForm.ArchiveDetailForm == null)
            {
                MessageForm.ShowError("��ֻ��ͨ��������鿴���ݣ�");
                return false;
            }

            //if (this.DisplayManager.CurrentItem == null)
            //{
            //    MessageForm.ShowError("��ѡ��Ҫ�鿴�ļ�¼��");
            //    return false;
            //}

            masterForm.ShowArchiveDetailForm();

            return true;
        }