Пример #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
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService svc = null;

            if (provider != null)
            {
                svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            }

            if (svc != null)
            {
                using (TableChooserForm form = new TableChooserForm())
                {
                    String strOld = String.Empty;
                    if (value != null)
                    {
                        strOld = value.ToString();
                    }
                    String strResult = form.ShowChooseOne(strOld);
                    if (form.DialogResult == DialogResult.OK)
                    {
                        value = strResult;
                    }
                }
            }


            return(value);
        }
Пример #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();
                }
            }
        }