Esempio n. 1
0
        protected internal override void ButtonClick(string tag)
        {
            switch (tag)
            {
            case TagResources.ContactList:
                UpdateMainView(gridView1);
                ClearSortingAndGrouping();
                break;

            case TagResources.ContactAlphabetical:
                UpdateMainView(gridView1);
                ClearSortingAndGrouping();
                colName.Group();
                break;

            case TagResources.ContactByState:
                UpdateMainView(gridView1);
                ClearSortingAndGrouping();
                colState.Group();
                colCity.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
                break;

            case TagResources.ContactCard:
                UpdateMainView(layoutView1);
                break;

            case TagResources.FlipLayout:
                layoutControl1.Root.FlipLayout();
                break;

            case TagResources.ContactDelete:
                if (CurrentContact == null)
                {
                    return;
                }
                int index = gridView1.FocusedRowHandle;
                gridControl1.MainView.BeginDataUpdate();
                try {
                    DataHelper.Contacts.Remove(CurrentContact);
                } finally {
                    gridControl1.MainView.EndDataUpdate();
                }
                if (index > gridView1.DataRowCount - 1)
                {
                    index--;
                }
                gridView1.FocusedRowHandle = index;
                ShowInfo(gridView1);
                break;

            case TagResources.ContactNew:
                Contact contact = new Contact();
                if (EditContact(contact) == DialogResult.OK)
                {
                    gridControl1.MainView.BeginDataUpdate();
                    try {
                        DataHelper.Contacts.Add(contact);
                    } finally {
                        gridControl1.MainView.EndDataUpdate();
                    }
                    ColumnView view = gridControl1.MainView as ColumnView;
                    if (view != null)
                    {
                        GridHelper.GridViewFocusObject(view, contact);
                        ShowInfo(view);
                    }
                }
                break;

            case TagResources.ContactEdit:
                EditContact(CurrentContact);
                break;
            }
            UpdateCurrentContact();
        }