private async void localMenu_OnItemClicked(string ActionType)
        {
            var selectedItem = dgAccessGrid.SelectedItem as CompanyUserAccessClient;

            switch (ActionType)
            {
            case "Accept":
                if (selectedItem == null)
                {
                    return;
                }
                ErrorCodes res = await companyAPI.GiveCompanyAccess(selectedItem._Uid, 0);

                if (res != ErrorCodes.Succes)
                {
                    UtilDisplay.ShowErrorCode(res);
                }
                else
                {
                    CWUserTasks userTask = new CWUserTasks(companyAPI, selectedItem);
                    userTask.Closing += delegate
                    {
                        if (userTask.DialogResult == true)
                        {
                            InitQuery();
                        }
                    };
                    userTask.Show();
                }
                break;

            case "Deny":
                if (selectedItem == null)
                {
                    return;
                }
                ErrorCodes resdeny = await companyAPI.DenyCompanyAccess(selectedItem._Uid);

                if (resdeny != ErrorCodes.Succes)
                {
                    UtilDisplay.ShowErrorCode(resdeny);
                }
                break;

            case "RefreshGrid":
                InitQuery();
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }
示例#2
0
        private void localMenu_OnItemClicked(string ActionType)
        {
            var selectedItem = dgCompanyUsersGrid.SelectedItem as CompanyUserAccessClient;

            switch (ActionType)
            {
            case "AddRow":
                var  curComp = UtilDisplay.GetDefaultCompany();
                long rights  = curComp.Rights;
                if (AccessLevel.Get(rights, CompanyTasks.AsOwner) == CompanyPermissions.Full)
                {
                    CWSearchUser searchUserDialog = new CWSearchUser(companyAPI);
                    searchUserDialog.Closing += delegate
                    {
                        if (searchUserDialog.DialogResult == true)
                        {
                            if (searchUserDialog.lstSetupType.SelectedIndex != 0)
                            {
                                InitQuery();
                            }
                            else
                            {
                                object[] parm = new object[3];
                                parm[0] = api;
                                parm[1] = true;
                                parm[2] = dockCtrl.Activpanel;
                                AddDockItem(TabControls.UsersPage2, parm, Uniconta.ClientTools.Localization.lookup("User"), "Add_16x16.png");
                            }
                        }
                    };
                    searchUserDialog.Show();
                }
                else
                {
                    UnicontaMessageBox.Show(string.Format("{0} {1}", Uniconta.ClientTools.Localization.lookup("NoRightsToInsert"), Uniconta.ClientTools.Localization.lookup("User")), Uniconta.ClientTools.Localization.lookup("Warning"));
                }
                break;

            case "EditRow":
                if (selectedItem != null)
                {
                    var parms = new object[2] {
                        selectedItem, true
                    };
                    AddDockItem(TabControls.EditCompanyUser, parms, string.Format("{0}:{1}", Uniconta.ClientTools.Localization.lookup("Edit"), selectedItem.UserName));
                }
                break;

            case "DeleteRow":
                if (selectedItem != null)
                {
                    RemoveAccess(selectedItem);
                }
                break;

            case "ChangeOwnership":
                if (selectedItem == null)
                {
                    return;
                }
                var msg = string.Format(Uniconta.ClientTools.Localization.lookup("OwnershipConfirmation"),
                                        companyAPI.CompanyEntity._Name, selectedItem._Name);
                CWConfirmationBox confirmationDialog = new CWConfirmationBox(msg, null, false);
                confirmationDialog.Closing += async delegate
                {
                    if (confirmationDialog.ConfirmationResult == CWConfirmationBox.ConfirmationResultEnum.Yes)
                    {
                        var errcode = await companyAPI.TransferOwnershipOfCompany(selectedItem._Uid);

                        if (errcode != ErrorCodes.Succes)
                        {
                            UtilDisplay.ShowErrorCode(errcode);
                        }
                        else
                        {
                            CloseDockItem();
                            UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("OwnershipChanged"), Uniconta.ClientTools.Localization.lookup("Warning"));
                        }
                    }
                };
                confirmationDialog.Show();
                break;

            case "SetPermissions":
                if (selectedItem == null)
                {
                    return;
                }
                selectedRowIndex = dgCompanyUsersGrid.tableView.FocusedRowHandle;
                CWUserTasks userTask = new CWUserTasks(companyAPI, selectedItem);
                userTask.Closing += delegate
                {
                    if (userTask.DialogResult == true)
                    {
                        InitQuery();
                    }
                };
                userTask.Show();
                break;

            case "FixedProfiles":
                if (selectedItem == null)
                {
                    return;
                }
                selectedRowIndex = dgCompanyUsersGrid.tableView.FocusedRowHandle;
                CWFixedProfiles profile = new CWFixedProfiles(companyAPI, selectedItem);
                profile.Closing += delegate
                {
                    if (profile.DialogResult == true)
                    {
                        selectedItem._Rights = profile.userAccess._Rights;
                        selectedItem.NotifyPropertyChanged("FixedProfile");
                    }
                };
                profile.Show();
                break;

            case "UserOf":
                if (selectedItem != null)
                {
                    object[] ob = new object[2];
                    ob[0] = selectedItem;
                    ob[1] = selectedItem.Userid;
                    AddDockItem(TabControls.CompaniesPage, ob,
                                string.Format("{0} {1}", Uniconta.ClientTools.Localization.lookup("Companies"),
                                              Uniconta.ClientTools.Localization.lookup("Access")));
                }
                break;

            case "OwnerOf":
                if (selectedItem != null)
                {
                    AddDockItem(TabControls.CompaniesPage, selectedItem,
                                string.Format("{0} {1}", Uniconta.ClientTools.Localization.lookup("Companies"),
                                              Uniconta.ClientTools.Localization.lookup("Owner")));
                }
                break;

            case "RefreshGrid":
                selectedRowIndex = 0;
                InitQuery();
                break;

            case "UserOperations":
                if (selectedItem != null)
                {
                    AddDockItem(TabControls.UserOperationsLog, selectedItem, string.Format("{0} : {1}", Uniconta.ClientTools.Localization.lookup("UserOperations"), selectedItem._Name));
                }
                break;

            case "UserLoginHistory":
                if (selectedItem != null)
                {
                    AddDockItem(TabControls.AllUsersLoginHistoryPage, selectedItem, string.Format("{0} : {1}", Uniconta.ClientTools.Localization.lookup("UserLoginHistory"), selectedItem._Name));
                }
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }