/// <summary>
        ///
        /// </summary>
        /// <param name="tabInfo"></param>
        /// <param name="dmParent"></param>
        /// <returns></returns>
        public virtual ISearchManager GenerateSearchManager(WindowTabInfo tabInfo, IDisplayManager dmParent)
        {
            if (string.IsNullOrEmpty(tabInfo.SearchManagerClassName))
            {
                throw new ArgumentException("WindowTabInfo of " + tabInfo.Identity + " 's SearchManagerClassName must not be null!");
            }

            ISearchManager sm = null;

            if (dmParent != null)
            {
                if (string.IsNullOrEmpty(tabInfo.SearchManagerClassParams))
                {
                    sm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(GenerateSearchManagerType(tabInfo), dmParent) as ISearchManager;
                }
                else
                {
                    string[] s    = Feng.Utils.StringHelper.Split(tabInfo.SearchManagerClassParams, ',');
                    object[] args = new object[s.Length + 1];
                    args[0] = dmParent;
                    for (int i = 0; i < s.Length; ++i)
                    {
                        args[i + 1] = s[i];
                    }
                    sm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(GenerateSearchManagerType(tabInfo), args) as ISearchManager;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(tabInfo.SearchManagerClassParams))
                {
                    sm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(GenerateSearchManagerType(tabInfo)) as ISearchManager;
                }
                else
                {
                    string[] s = Feng.Utils.StringHelper.Split(tabInfo.SearchManagerClassParams, ',');
                    sm = Feng.Utils.ReflectionHelper.CreateInstanceFromType(GenerateSearchManagerType(tabInfo), s) as ISearchManager;
                }
            }


            sm.Name = tabInfo.Identity;

            if (sm is IRepositoryConsumer)
            {
                (sm as IRepositoryConsumer).RepositoryCfgName = tabInfo.RepositoryConfigName;
            }

            sm.AdditionalSearchExpression = (string)ParamCreatorHelper.TryGetParam(tabInfo.WhereClause);
            sm.AdditionalSearchOrder      = (string)ParamCreatorHelper.TryGetParam(tabInfo.OrderByClause);

            return(sm);
        }
Пример #2
0
        private static void ReloadNvFromDataControl(EventProcessInfo eventProcessInfo, IDisplayManager dm, IDataControl dc, string changedDataControlName)
        {
            string[] columns = eventProcessInfo.ExecuteParam.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in columns)
            {
                IDataControl idc = dm.DataControls[s];
                if (idc == null)
                {
                    throw new ArgumentException("there is no IDataControl with name " + s + " in eventProcess's SelectedDataValueChanged!");
                }

                //object saveValue = idc.SelectedDataValue;
                GridColumnInfo iInfo = idc.Tag as GridColumnInfo;

                switch (iInfo.CellEditorManager)
                {
                case "Combo":
                case "MultiCombo":
                case "FreeCombo":
                {
                    // NameValueMapping
                    NameValueMapping nv = NameValueMappingCollection.Instance[iInfo.CellEditorManagerParam];

                    // will throw 集合已改变Exception
                    List <string> ls = new List <string>();
                    foreach (KeyValuePair <string, object> kvp in nv.Params)
                    {
                        ls.Add(kvp.Key.Substring(1));
                    }
                    if (!ls.Contains(changedDataControlName))
                    {
                        continue;
                    }

                    object savedValue = idc.SelectedDataValue;
                    idc.SelectedDataValue = null;
                    foreach (string key in ls)
                    {
                        object o = GetDataControlValue(key, dm).Item2;

                        nv.Params["@" + key] = o == null ? System.DBNull.Value : o;
                    }
                    NameValueMappingCollection.Instance.Reload(dm.Name, iInfo.CellEditorManagerParam);
                    nv.ResetParams();

                    idc.SelectedDataValue = savedValue;
                }
                break;

                case "ObjectPicker":
                {
                    object savedValue = idc.SelectedDataValue;
                    idc.SelectedDataValue = null;

                    Feng.Windows.Forms.MyObjectPicker op = (idc as Feng.Windows.Forms.IWindowControl).Control as Feng.Windows.Forms.MyObjectPicker;
                    string exp = (string)ParamCreatorHelper.TryGetParam(iInfo.CellEditorManagerParamFilter);
                    exp = EntityHelper.ReplaceEntity(exp, new EntityHelper.GetReplaceValue(delegate(string paramName)
                        {
                            return(GetDataControlValue(paramName, dm).Item2);
                        }));
                    op.DropDownControl.DisplayManager.SearchManager.LoadData(SearchExpression.Parse(exp), null);

                    idc.SelectedDataValue = savedValue;
                }
                break;

                default:
                    throw new ArgumentException("EventProcess's SelectedDataValueChanged CellEditorManagerType is not support!");
                }

                //idc.SelectedDataValue = saveValue;
            }
        }
Пример #3
0
        private static void ReloadNvFromGridCell(EventProcessInfo eventProcessInfo, IDisplayManager dm, Xceed.Grid.Cell cell, string changedDataControlName)
        {
            string[] columns = eventProcessInfo.ExecuteParam.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in columns)
            {
                Xceed.Grid.Cell iCell = cell.ParentRow.Cells[s];
                if (iCell == null)
                {
                    continue;
                    //throw new ArgumentException("there is no column with name " + s + "!");
                }
                GridColumnInfo iInfo = iCell.ParentColumn.Tag as GridColumnInfo;

                switch (iInfo.CellEditorManager)
                {
                case "Combo":
                case "MultiCombo":
                case "FreeCombo":
                {
                    NameValueMapping nv = NameValueMappingCollection.Instance[iInfo.CellEditorManagerParam];
                    List <string>    ls = new List <string>();
                    foreach (KeyValuePair <string, object> kvp in nv.Params)
                    {
                        ls.Add(kvp.Key.Substring(1));
                    }
                    if (!ls.Contains(changedDataControlName))
                    {
                        continue;
                    }

                    iCell.Value = null;
                    foreach (string key in ls)
                    {
                        object o = GetDataCellValue(key, iCell).Item2;
                        nv.Params["@" + key] = o == null ? System.DBNull.Value : o;
                    }
                    NameValueMappingCollection.Instance.Reload(dm.Name, iInfo.CellEditorManagerParam);

                    // when in grid, we can't use comboBox's DataTableChanged because combobox only created when in edit
                    System.Data.DataView dv = NameValueMappingCollection.Instance.GetDataSource(dm.Name, iInfo.CellEditorManagerParam, iInfo.CellEditorManagerParamFilter);
                    if (dv.Count == 1)
                    {
                        object toValue = dv[0][NameValueMappingCollection.Instance[iInfo.CellEditorManagerParam].ValueMember];
                        if (!Feng.Utils.ReflectionHelper.ObjectEquals(iCell.Value, toValue))
                        {
                            dm.OnSelectedDataValueChanged(new SelectedDataValueChangedEventArgs(s, iCell));
                        }
                        iCell.Value = toValue;
                    }

                    iCell.ReadOnly = (dv.Count == 0);

                    nv.ResetParams();
                }
                break;

                case "ObjectPicker":
                {
                    // Todo: if (!ls.Contains(changedDataControlName))

                    iCell.Value = null;
                    Feng.Windows.Forms.MyObjectPicker op = (iCell.CellEditorManager as Feng.Grid.Editors.MyObjectPickerEditor).TemplateControl;
                    string exp = (string)ParamCreatorHelper.TryGetParam(iInfo.CellEditorManagerParamFilter);
                    exp = EntityHelper.ReplaceEntity(exp, new EntityHelper.GetReplaceValue(delegate(string paramName)
                        {
                            return(GetDataCellValue(paramName, iCell).Item2);
                        }));
                    op.DropDownControl.DisplayManager.SearchManager.LoadData(SearchExpression.Parse(exp), null);
                }
                break;
                }
            }
        }
Пример #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="column"></param>
 /// <param name="info"></param>
 public static void CreateCellEditorManager(Xceed.Grid.Column column, GridColumnInfo info, IDisplayManager dm)
 {
     try
     {
         Xceed.Grid.Editors.CellEditorManager editor = ControlFactory.CreateCellEditorManager(dm.Name,
                                                                                              info.CellEditorManager, info.CellEditorManagerParam, GridColumnInfoHelper.CreateType(info), (string)ParamCreatorHelper.TryGetParam(info.CellEditorManagerParamFilter),
                                                                                              info.CellViewerManagerParam);
         if (editor != null)
         {
             column.CellEditorManager = editor;
         }
     }
     catch (Exception ex)
     {
         throw new ArgumentException("GridColumnInfo of " + info.Name + " is Invalid when CreateCellEditorManager!", ex);
     }
 }