예제 #1
0
        void repoTableNameChooser_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            String strTableName = this.TableName;

            TreeConfigNode obj = (TreeConfigNode)DataConfigTreeCtrl.GetDataRecordByNode(DataConfigTreeCtrl.FocusedNode);

            if (obj == null || (TreeConfigData)obj.InnerData == null)
            {
                return;
            }

            TreeConfigData configData = (TreeConfigData)obj.InnerData;

            strTableName = configData.TableName;

            String           strOldTableName = strTableName;
            TableChooserForm chooser         = new TableChooserForm();
            String           strResult       = chooser.ShowChooseOne(strOldTableName);

            if (chooser.DialogResult == DialogResult.OK)
            {
                configData.TableName = strResult;
            }

            DataConfigTreeCtrl.RefreshDataSource();
            DataConfigTreeCtrl.RefreshNode(DataConfigTreeCtrl.FocusedNode);
        }
예제 #2
0
        void TreeList.IVirtualTreeListData.VirtualTreeSetCellValue(VirtualTreeSetCellValueInfo info)
        {
            if (Manager == null)
            {
                return;
            }

            TreeConfigNode config = null;

            if (Manager.ConfigList.TryGetValue(ObjectName, out config) == false)
            {
                return;
            }

            String strField = String.Empty;

            if (config.InnerData.ColumnFieldNames.TryGetValue(info.Column.Caption, out strField) == false)
            {
                return;
            }

            if (String.IsNullOrWhiteSpace(strField))
            {
                return;
            }

            if (strField.Contains(":"))
            {
                info.Cancel = true;
                return;
            }

            ABCBusinessEntities.ABCDynamicInvoker.SetValue(InnerData, strField, info.NewCellData);
        }
예제 #3
0
        void Menu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (e.Item.Tag != null && e.Item.Tag.ToString() == "New")
            {
                TableChooserForm form         = new TableChooserForm();
                String           strTableName = form.ShowChooseOne();
                if (form.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
                if (DataStructureProvider.IsExistedTable(strTableName) == false)
                {
                    return;
                }

                TreeConfigData configData = new TreeConfigData();
                configData.Name             = "objNew" + this.Manager.ConfigList.Count;
                configData.DefaultLoad      = true;
                configData.TableName        = strTableName;
                configData.ColumnFieldNames = new Dictionary <string, string>();

                TreeConfigNode obj = (TreeConfigNode)DataConfigTreeCtrl.GetDataRecordByNode(DataConfigTreeCtrl.FocusedNode);
                if (obj == null)
                {
                    new TreeConfigNode(Manager.RootConfig, configData);
                }
                else
                {
                    configData.ParentTableName = obj.InnerData.TableName;
                    configData.ParentField     = DataStructureProvider.GetPrimaryKeyColumn(obj.InnerData.TableName);
                    configData.ChildField      = DataStructureProvider.GetForeignKeyOfTableName(configData.TableName, obj.InnerData.TableName);
                    new TreeConfigNode(obj, configData);
                }

                UpdateDataConfigs();
                RefreshDataConfigTree();
            }

            if (e.Item.Tag != null && e.Item.Tag.ToString() == "Delete")
            {
                TreeConfigNode obj = (TreeConfigNode)DataConfigTreeCtrl.GetDataRecordByNode(DataConfigTreeCtrl.FocusedNode);
                if (obj == null || (TreeConfigData)obj.InnerData == null)
                {
                    return;
                }

                DialogResult result = ABCHelper.ABCMessageBox.Show("Do you want to delete selected Object ? ", "Delete Object", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    obj.ParentNode.ChildrenNodes.Remove(obj.InnerData.Name);
                    obj.ParentNode = null;

                    UpdateDataConfigs();
                    RefreshDataConfigTree();
                }
            }
        }
예제 #4
0
        private void RefreshConfigList(TreeConfigNode currentNode)
        {
            if (currentNode.InnerData != null && ConfigList.ContainsKey(currentNode.InnerData.Name) == false)
            {
                ConfigList.Add(currentNode.InnerData.Name, currentNode);
            }

            foreach (TreeConfigNode child in currentNode.ChildrenNodes.Values)
            {
                RefreshConfigList(child);
            }
        }
예제 #5
0
        void DataConfigTreeCtrl_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e)
        {
            TreeConfigNode obj = (TreeConfigNode)DataConfigTreeCtrl.GetDataRecordByNode(e.Node);

            if (obj == null || (TreeConfigData)obj.InnerData == null)
            {
                DataConfigDetailVGridCtrl.SelectedObject = null;
                return;
            }

            DataConfigDetailVGridCtrl.SelectedObject = (TreeConfigData)obj.InnerData;
        }
예제 #6
0
        void TreeList.IVirtualTreeListData.VirtualTreeGetCellValue(VirtualTreeGetCellValueInfo info)
        {
            if (Manager == null)
            {
                return;
            }

            TreeConfigNode config = null;

            if (Manager.ConfigList.TryGetValue(ObjectName, out config) == false)
            {
                return;
            }

            String strField = String.Empty;

            if (config.InnerData.ColumnFieldNames.TryGetValue(info.Column.Caption, out strField) == false)
            {
                return;
            }

            if (String.IsNullOrWhiteSpace(strField))
            {
                return;
            }

            String strFirstField = strField.Split(':')[0];

            if (DataStructureProvider.IsForeignKey(InnerData.AATableName, strFirstField))
            {
                Guid iID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(InnerData, strFirstField));
                if (iID != Guid.Empty)
                {
                    info.CellData = DataCachingProvider.GetCachingObjectAccrossTable(InnerData.AATableName, iID, strField);
                }
            }
            else
            {
                info.CellData = ABCBusinessEntities.ABCDynamicInvoker.GetValue(InnerData, strFirstField);
                String strEnum = DataConfigProvider.TableConfigList[InnerData.AATableName].FieldConfigList[strFirstField].AssignedEnum;
                if (info.CellData != null && String.IsNullOrWhiteSpace(info.CellData.ToString()) == false && EnumProvider.EnumList.ContainsKey(strEnum))
                {
                    info.CellData = EnumProvider.EnumList[strEnum].Items[info.CellData.ToString()].CaptionVN;
                }
            }
        }
예제 #7
0
        void repoFieldNameChooser_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            String strTableName = this.TableName;

            TreeConfigNode obj = (TreeConfigNode)DataConfigTreeCtrl.GetDataRecordByNode(DataConfigTreeCtrl.FocusedNode);

            if (obj == null || (TreeConfigData)obj.InnerData == null)
            {
                return;
            }

            TreeConfigData configData = (TreeConfigData)obj.InnerData;

            strTableName = configData.TableName;

            if (String.IsNullOrWhiteSpace(strTableName) == false)
            {
                String strOldFieldName = String.Empty;
                if (configData.ColumnFieldNames.ContainsKey(this.DataConfigTreeCtrl.FocusedColumn.Caption))
                {
                    strOldFieldName = configData.ColumnFieldNames[this.DataConfigTreeCtrl.FocusedColumn.Caption];
                }

                FieldChooserEx chooser = new FieldChooserEx(strTableName, strOldFieldName);
                if (chooser.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    if (configData.ColumnFieldNames.ContainsKey(this.DataConfigTreeCtrl.FocusedColumn.Caption))
                    {
                        configData.ColumnFieldNames[this.DataConfigTreeCtrl.FocusedColumn.Caption] = chooser.Result;
                    }
                    else
                    {
                        configData.ColumnFieldNames.Add(this.DataConfigTreeCtrl.FocusedColumn.Caption, chooser.Result);
                    }
                }


                DataConfigTreeCtrl.RefreshNode(DataConfigTreeCtrl.FocusedNode);
                DataConfigTreeCtrl.RefreshDataSource();
                UpdateDataConfigs();
                DisplayTreeListCtrl.RefreshDataSource();
            }
        }
예제 #8
0
        public void RefreshCachingNodes(TreeConfigNode configNode)
        {
            try
            {
                if (configNode.InnerData != null && configNode.ParentNode != null)
                {
                    Dictionary <Guid, ABCTreeListNode> innerList = null;
                    if (this.DataList.TryGetValue(configNode.InnerData.Name, out innerList) == false)
                    {
                        innerList = new Dictionary <Guid, ABCTreeListNode>();
                        this.DataList.Add(configNode.InnerData.Name, innerList);
                    }

                    DataView view = DataCachingProvider.TryToGetDataView(configNode.InnerData.TableName, false);
                    BusinessObjectController Controller = BusinessControllerFactory.GetBusinessController(configNode.InnerData.TableName);
                    String strPK = DataStructureProvider.GetPrimaryKeyColumn(configNode.InnerData.TableName);
                    foreach (DataRow dr in view.Table.Rows)
                    {
                        BusinessObject obj = Controller.GetObjectFromDataRow(dr);
                        if (obj != null)
                        {
                            Guid iID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(obj, strPK));
                            if (innerList.ContainsKey(iID) == false)
                            {
                                ABCTreeListNode node = new ABCTreeListNode(null, configNode.InnerData.Name, obj);
                                node.Manager = this;
                                node.CachingNode();
                            }
                            else
                            {
                                innerList[iID].InnerData = obj;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #9
0
        public TreeConfigNode(TreeConfigNode parent, TreeConfigData _data)
        {
            this.ParentNode = parent;

            this.InnerData = _data;
            if (parent != null && parent.InnerData != null)
            {
                this.InnerData.Level = parent.InnerData.Level + 1;
            }

            if (this.ParentNode != null)
            {
                if (this.ParentNode.ChildrenNodes.ContainsKey(InnerData.Name) == false)
                {
                    this.ParentNode.ChildrenNodes.Add(InnerData.Name, this);
                }
                else
                {
                    this.ParentNode.ChildrenNodes[InnerData.Name] = this;
                }
            }
        }
예제 #10
0
        public TreeConfigNode BackupManager(TreeConfigNode rootConfig)
        {
            TreeConfigNode newNode = new TreeConfigNode();

            if (rootConfig.InnerData != null)
            {
                newNode.InnerData = (TreeConfigData)rootConfig.InnerData.Clone();
            }

            foreach (TreeConfigNode child in rootConfig.ChildrenNodes.Values)
            {
                TreeConfigNode newChild = BackupManager(child);
                newChild.ParentNode = newNode;
                if (newNode.InnerData != null)
                {
                    newChild.InnerData.Level = newNode.InnerData.Level + 1;
                }
                if (newNode.ChildrenNodes.ContainsKey(newChild.InnerData.Name) == false)
                {
                    newNode.ChildrenNodes.Add(newChild.InnerData.Name, newChild);
                }
                else
                {
                    newNode.ChildrenNodes[newChild.InnerData.Name] = newChild;
                }

                if (Manager.ConfigList.ContainsKey(newChild.InnerData.Name) == false)
                {
                    Manager.ConfigList.Add(newChild.InnerData.Name, newChild);
                }
                else
                {
                    Manager.ConfigList[newChild.InnerData.Name] = newChild;
                }
            }

            return(newNode);
        }
예제 #11
0
        public void ExpandData(Boolean includeChildren, Boolean defaultOnly)
        {
            if (Manager == null || this.InnerData == null)
            {
                return;
            }

            TreeConfigNode config = null;

            if (Manager.ConfigList.TryGetValue(ObjectName, out config) == false)
            {
                return;
            }

            #region Current Childrens
            if (config.ParentNode == null || config.ParentNode.InnerData == null)
            {
                if (DataStructureProvider.IsTableColumn(config.InnerData.TableName, config.InnerData.ParentField) &&
                    DataStructureProvider.IsTableColumn(config.InnerData.TableName, config.InnerData.ChildField))
                {
                    String strPK          = DataStructureProvider.GetPrimaryKeyColumn(config.InnerData.TableName);
                    object objParentValue = ABCBusinessEntities.ABCDynamicInvoker.GetValue(this.InnerData, config.InnerData.ParentField);
                    foreach (ABCTreeListNode childNode in Manager.DataList[config.InnerData.Name].Values)
                    {
                        object objChildValue = ABCBusinessEntities.ABCDynamicInvoker.GetValue(childNode.InnerData, config.InnerData.ChildField);
                        if (objChildValue != null && (int)objChildValue == (int)objParentValue)
                        {
                            Guid iChildID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(childNode.InnerData, strPK));
                            if (this.ChildrenNodes.ContainsKey(iChildID) == false)
                            {
                                childNode.ParentNode = this;
                                this.ChildrenNodes.Add(iChildID, childNode);
                                childNode.ExpandData(includeChildren, defaultOnly);
                            }
                        }
                    }
                }
            }
            #endregion

            #region Other Config Childrens
            foreach (TreeConfigNode childConfig in config.ChildrenNodes.Values)
            {
                if (defaultOnly && childConfig.InnerData != null && childConfig.InnerData.DefaultLoad == false)
                {
                    continue;
                }

                String strPK = DataStructureProvider.GetPrimaryKeyColumn(childConfig.InnerData.TableName);

                object objParentValue = ABCBusinessEntities.ABCDynamicInvoker.GetValue(this.InnerData, childConfig.InnerData.ParentField);

                foreach (ABCTreeListNode childNode in Manager.DataList[childConfig.InnerData.Name].Values)
                {
                    object objChildValue = ABCBusinessEntities.ABCDynamicInvoker.GetValue(childNode.InnerData, childConfig.InnerData.ChildField);
                    if (objChildValue != null && (int)objChildValue == (int)objParentValue)
                    {
                        Guid iChildID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(childNode.InnerData, strPK));
                        if (this.ChildrenNodes.ContainsKey(iChildID) == false)
                        {
                            childNode.ParentNode = this;
                            this.ChildrenNodes.Add(iChildID, childNode);
                            if (includeChildren)
                            {
                                childNode.ExpandData(true, defaultOnly);
                            }
                        }
                    }
                }

                #region old

                //#region Generate Query
                //ABCHelper.ConditionBuilder strBuilder=new ABCHelper.ConditionBuilder();
                //strBuilder.Append( String.Format( @"SELECT * FROM {0}" , childConfig.InnerData.TableName ) );
                //if ( objParentValue is String||objParentValue  is DateTime)
                //    strBuilder.AddCondition( String.Format( @" {0} = '{1}' " , childConfig.InnerData.ChildField , objParentValue.ToString() ) );
                //else
                //    strBuilder.AddCondition( String.Format( @" {0} = {1} " , childConfig.InnerData.ChildField , objParentValue ) );


                //String strFilterCondintion=DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetMsSqlWhere( DevExpress.Data.Filtering.CriteriaOperator.Parse( childConfig.InnerData.FilterCondition ) );
                //strBuilder.AddCondition( strFilterCondintion );

                //if ( DataStructureProvider.IsExistABCStatus( childConfig.InnerData.TableName ) )
                //    strBuilder.AddCondition( Generation.QueryGenerator.GenerateCondition( childConfig.InnerData.TableName , ABCCommon.ABCConstString.ColumnType.ABCStatus ) );

                //strBuilder.AddCondition( Security.DataAuthentication.GetAuthenticationString( childConfig.InnerData.TableName ) );

                //#endregion

                //BusinessObjectController Controller=BusinessControllerFactory.GetBusinessController( childConfig.InnerData.TableName );

                //DataSet ds=DataQueryProvider.RunQuery( strBuilder.ToString() );
                //if ( ds!=null&&ds.Tables.Count>0 )
                //{
                //    foreach ( DataRow dr in ds.Tables[0].Rows )
                //    {
                //        BusinessObject objChild=Controller.GetObjectFromDataRow( dr );
                //        if ( objChild!=null )
                //        {
                //            ABCTreeListNode childNode=new ABCTreeListNode( this , childConfig.InnerData.Name , objChild );
                //            if ( includeChildren )
                //                childNode.Expand( true , defaultOnly );
                //        }
                //    }
                //}
                #endregion
            }
            #endregion
        }
예제 #12
0
 public ABCTreelistManager(ABCTreeList treelist)
 {
     RootConfig = new TreeConfigNode(null, null);
     TreeList   = treelist;
 }
예제 #13
0
        public TreeColumnConfigForm(BindingList <ABCTreeListColumn.ColumnConfig> list, TreeConfigNode rootConfig)
        {
            InitializeComponent();

            ColumnList         = new BindingList <ABCTreeListColumn.ColumnConfig>();
            Manager            = new ABCTreelistManager(DisplayTreeListCtrl);
            Manager.RootConfig = BackupManager(rootConfig);


            this.Load        += new EventHandler(Form_Load);
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;

            InitPopupMenu();

            if (list != null)
            {
                foreach (ABCTreeListColumn.ColumnConfig config in list)
                {
                    ColumnList.Add(config.Clone() as ABCTreeListColumn.ColumnConfig);
                }
            }
        }