void Dialog_DialogOk(object sender, EventArgs e)
        {
            MemberChoiceDialog dlg = sender as MemberChoiceDialog;

            if (dlg != null && dlg.UserData != null && dlg.UserData is MemberChoiceType)
            {
                CoordinateItem item = dlg.Tag as CoordinateItem;
                if (item != null)
                {
                    List <MemberChoiceSettings> selectedInfo = dlg.ChoiceControl.SelectedInfo;
                    if (selectedInfo != null && selectedInfo.Count == 1)
                    {
                        MemberWrap member = new MemberWrap();
                        member.Caption             = dlg.ChoiceControl.SelectedInfo[0].Caption;
                        member.UniqueName          = dlg.ChoiceControl.SelectedInfo[0].UniqueName;
                        member.HierarchyUniqueName = dlg.ChoiceControl.HierarchyUniqueName;
                        if (((MemberChoiceType)dlg.UserData) == MemberChoiceType.Source)
                        {
                            item.SourceMember = member;
                        }
                        if (((MemberChoiceType)dlg.UserData) == MemberChoiceType.Destination)
                        {
                            item.DestMember = member;
                        }
                    }
                }
                return;
            }

            MeasureChoiceDialog measure_dlg = sender as MeasureChoiceDialog;

            if (measure_dlg != null && measure_dlg.UserData != null && measure_dlg.UserData is MemberChoiceType)
            {
                CoordinateItem item = measure_dlg.Tag as CoordinateItem;
                if (item != null)
                {
                    if (measure_dlg.ChoiceControl.SelectedInfo != null)
                    {
                        MemberWrap member = new MemberWrap();
                        member.Caption             = measure_dlg.ChoiceControl.SelectedInfo.Caption;
                        member.UniqueName          = measure_dlg.ChoiceControl.SelectedInfo.UniqueName;
                        member.HierarchyUniqueName = "[Measures]";
                        if (((MemberChoiceType)measure_dlg.UserData) == MemberChoiceType.Source)
                        {
                            item.SourceMember = member;
                        }
                        if (((MemberChoiceType)measure_dlg.UserData) == MemberChoiceType.Destination)
                        {
                            item.DestMember = member;
                        }
                    }
                }
            }
        }
        bool BeginEdit(CoordinateItem item)
        {
            if (item != null)
            {
                // Если элемент только для чтения, то при отключенном режиме администрирования редактировать его не даем
                if (!IsAdminMode && item.CoordinateState == CoordinateStateTypes.Readonly)
                    return false;

                if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[0])
                {
                    return true;
                }
                if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[3] ||
                    (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[4]))
                {
                    IChoiceDialog dlg = null;

                    if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[3])
                    {
                        if (m_SourceDialogs.ContainsKey(item))
                        {
                            dlg = m_SourceDialogs[item];
                        }
                    }

                    if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[4])
                    {
                        if (m_DestDialogs.ContainsKey(item))
                        {
                            dlg = m_DestDialogs[item];
                        }
                    }

                    if (dlg == null)
                    {
                        if (item.DimensionUniqueName == "[Measures]")
                        {
                            // Выбор меры
                            MeasureChoiceDialog dialog = new MeasureChoiceDialog();
                            dialog.ChoiceControl.CubeName = CubeName;
                            dialog.ChoiceControl.Connection = ConnectionID;
                            dialog.ChoiceControl.LogManager = LogManager;
                            GetIDataLoaderArgs args = new GetIDataLoaderArgs();
                            Raise_GetOlapDataLoader(args);
                            if (args.Handled)
                                dialog.ChoiceControl.OlapDataLoader = args.Loader;
                            dialog.Tag = item;
                            dialog.DialogOk += new EventHandler(Dialog_DialogOk);
                            dialog.DialogCancel += new EventHandler(dlg_DialogCancel);
                            dialog.Show();
                            if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[3])
                            {
                                dialog.UserData = MemberChoiceType.Source;
                            }
                            if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[4])
                            {
                                dialog.UserData = MemberChoiceType.Destination;
                            }
                            dlg = dialog;
                        }
                        else
                        {
                            // Выбор элемента измерения
                            MemberChoiceDialog dialog = new MemberChoiceDialog();
                            dialog.ChoiceControl.CubeName = CubeName;
                            dialog.ChoiceControl.Connection = ConnectionID;
                            dialog.ChoiceControl.HierarchyUniqueName = item.HierarchyUniqueName;
                            dialog.ChoiceControl.LogManager = LogManager;

                            GetIDataLoaderArgs args = new GetIDataLoaderArgs();
                            Raise_GetOlapDataLoader(args);
                            if (args.Handled)
                                dialog.ChoiceControl.OlapDataLoader = args.Loader;

                            dialog.Tag = item;
                            dialog.DialogOk += new EventHandler(Dialog_DialogOk);
                            dialog.DialogCancel += new EventHandler(dlg_DialogCancel);
                            dialog.Show();
                            if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[3])
                            {
                                dialog.UserData = MemberChoiceType.Source;
                            }
                            if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[4])
                            {
                                dialog.UserData = MemberChoiceType.Destination;
                            }
                            dlg = dialog;
                        }
                        if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[3])
                        {
                            m_SourceDialogs[item] = dlg;
                        }
                        if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[4])
                        {
                            m_DestDialogs[item] = dlg;
                        }

                    }

                    if (dlg != null)
                    {
                        dlg.Show();
                        return true;
                    }
                }
            }
            return false;
        }
        bool BeginEdit(CoordinateItem item)
        {
            if (item != null)
            {
                // Если элемент только для чтения, то при отключенном режиме администрирования редактировать его не даем
                if (!IsAdminMode && item.CoordinateState == CoordinateStateTypes.Readonly)
                {
                    return(false);
                }

                if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[0])
                {
                    return(true);
                }
                if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[3] ||
                    (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[4]))
                {
                    IChoiceDialog dlg = null;

                    if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[3])
                    {
                        if (m_SourceDialogs.ContainsKey(item))
                        {
                            dlg = m_SourceDialogs[item];
                        }
                    }

                    if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[4])
                    {
                        if (m_DestDialogs.ContainsKey(item))
                        {
                            dlg = m_DestDialogs[item];
                        }
                    }

                    if (dlg == null)
                    {
                        if (item.DimensionUniqueName == "[Measures]")
                        {
                            // Выбор меры
                            MeasureChoiceDialog dialog = new MeasureChoiceDialog();
                            dialog.ChoiceControl.CubeName   = CubeName;
                            dialog.ChoiceControl.Connection = ConnectionID;
                            dialog.ChoiceControl.LogManager = LogManager;
                            GetIDataLoaderArgs args = new GetIDataLoaderArgs();
                            Raise_GetOlapDataLoader(args);
                            if (args.Handled)
                            {
                                dialog.ChoiceControl.OlapDataLoader = args.Loader;
                            }
                            dialog.Tag           = item;
                            dialog.DialogOk     += new EventHandler(Dialog_DialogOk);
                            dialog.DialogCancel += new EventHandler(dlg_DialogCancel);
                            dialog.Show();
                            if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[3])
                            {
                                dialog.UserData = MemberChoiceType.Source;
                            }
                            if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[4])
                            {
                                dialog.UserData = MemberChoiceType.Destination;
                            }
                            dlg = dialog;
                        }
                        else
                        {
                            // Выбор элемента измерения
                            MemberChoiceDialog dialog = new MemberChoiceDialog();
                            dialog.ChoiceControl.CubeName            = CubeName;
                            dialog.ChoiceControl.Connection          = ConnectionID;
                            dialog.ChoiceControl.HierarchyUniqueName = item.HierarchyUniqueName;
                            dialog.ChoiceControl.LogManager          = LogManager;

                            GetIDataLoaderArgs args = new GetIDataLoaderArgs();
                            Raise_GetOlapDataLoader(args);
                            if (args.Handled)
                            {
                                dialog.ChoiceControl.OlapDataLoader = args.Loader;
                            }

                            dialog.Tag           = item;
                            dialog.DialogOk     += new EventHandler(Dialog_DialogOk);
                            dialog.DialogCancel += new EventHandler(dlg_DialogCancel);
                            dialog.Show();
                            if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[3])
                            {
                                dialog.UserData = MemberChoiceType.Source;
                            }
                            if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[4])
                            {
                                dialog.UserData = MemberChoiceType.Destination;
                            }
                            dlg = dialog;
                        }
                        if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[3])
                        {
                            m_SourceDialogs[item] = dlg;
                        }
                        if (coordinatesGrid.CurrentColumn == coordinatesGrid.Columns[4])
                        {
                            m_DestDialogs[item] = dlg;
                        }
                    }

                    if (dlg != null)
                    {
                        dlg.Show();
                        return(true);
                    }
                }
            }
            return(false);
        }
        bool BeginMemberEdit(TupleItem item)
        {
            if (item != null)
            {
                IChoiceDialog dlg = null;
                if (!String.IsNullOrEmpty(item.HierarchyUniqueName) && m_ChoiceDialogs.ContainsKey(item.HierarchyUniqueName))
                {
                    dlg = m_ChoiceDialogs[item.HierarchyUniqueName];
                }
                
                if (dlg == null)
                {
                    if (item.HierarchyUniqueName == "[Measures]")
                    {
                        // Выбор меры
                        MeasureChoiceDialog dialog = new MeasureChoiceDialog();
                        dialog.ChoiceControl.CubeName = CubeName;
                        dialog.ChoiceControl.Connection = ConnectionID;
                        dialog.ChoiceControl.LogManager = LogManager;
                        GetIDataLoaderArgs args = new GetIDataLoaderArgs();
                        Raise_GetOlapDataLoader(args);
                        if (args.Handled)
                            dialog.ChoiceControl.OlapDataLoader = args.Loader;
                        dialog.Tag = item;
                        dialog.DialogOk += new EventHandler(Dialog_DialogOk);
                        dialog.DialogCancel += new EventHandler(Dialog_DialogCancel);
                        dialog.Show();
                        dlg = dialog;
                    }
                    else
                    {
                        // Выбор элемента измерения
                        MemberChoiceDialog dialog = new MemberChoiceDialog();
                        dialog.ChoiceControl.CubeName = CubeName;
                        dialog.ChoiceControl.Connection = ConnectionID;
                        dialog.ChoiceControl.HierarchyUniqueName = item.HierarchyUniqueName;
                        dialog.ChoiceControl.LogManager = LogManager;

                        GetIDataLoaderArgs args = new GetIDataLoaderArgs();
                        Raise_GetOlapDataLoader(args);
                        if (args.Handled)
                            dialog.ChoiceControl.OlapDataLoader = args.Loader;

                        dialog.Tag = item;
                        dialog.DialogOk += new EventHandler(Dialog_DialogOk);
                        dialog.DialogCancel += new EventHandler(Dialog_DialogCancel);
                        dialog.Show();
                        dlg = dialog;
                    }
                    if(!String.IsNullOrEmpty(item.HierarchyUniqueName))
                        m_ChoiceDialogs[item.HierarchyUniqueName] = dlg;
                }

                if (dlg != null)
                {
                    dlg.Show();
                    return true;
                }
            }
            return false;
        }