Ejemplo n.º 1
0
        private void Init()
        {
            InitializeComponent();
            layoutStDate.Label  = Uniconta.ClientTools.Localization.lookup("FromDate");
            layoutEndDate.Label = Uniconta.ClientTools.Localization.lookup("ToDate");
            layoutControl       = layoutItems;
            editrow             = CreateNew() as CompanyClient;
            var defaultCompany = UtilDisplay.GetDefaultCompany();

            if (defaultCompany != null)
            {
                editrow.Country         = defaultCompany._CountryId;
                layoutItems.DataContext = editrow;
                int year = BasePage.GetSystemDefaultDate().Year;
                dateFrm.DateTime         = new DateTime(year, 1, 1);
                dateTo.DateTime          = new DateTime(year, 12, 31);
                frmRibbon.OnItemClicked += frmRibbon_OnItemClicked;
                SetOwnCompany();
                CompanySetupPage.SetCountry(cmbCountry, cmbStandardCompany, editrow, true);
                browseTopLogo.FileSelected += BrowseTopLogo_FileSelected;
#if !SILVERLIGHT
                lblImportInvoice.Label = string.Format(Uniconta.ClientTools.Localization.lookup("ImportOBJ"), Uniconta.ClientTools.Localization.lookup("Invoice"));
                BindSetupType();
                grpImportSetup.Header               = string.Format(Uniconta.ClientTools.Localization.lookup("ImportOBJ"), Uniconta.ClientTools.Localization.lookup("Company"));
                cmbImportFrom.ItemsSource           = Enum.GetNames(typeof(ImportFrom));
                cmbImportFrom.SelectedIndexChanged += cmbImportFrom_SelectionChanged;
                cmbImportDimension.ItemsSource      = new List <string>()
                {
                    "Ingen", "Kun Afdeling", "Afdeling, Bærer", "Afdeling, Bærer, Formål"
                };
                cmbImportDimension.SelectedIndex = 3;

                lblDim1.Label           = string.Concat(string.Format(Uniconta.ClientTools.Localization.lookup("ImportOBJ"), Uniconta.ClientTools.Localization.lookup("Dimension")), " 1");
                lblDim2.Label           = string.Concat(string.Format(Uniconta.ClientTools.Localization.lookup("ImportOBJ"), Uniconta.ClientTools.Localization.lookup("Dimension")), " 2");
                lblDim3.Label           = string.Concat(string.Format(Uniconta.ClientTools.Localization.lookup("ImportOBJ"), Uniconta.ClientTools.Localization.lookup("Dimension")), " 3");
                lblDim4.Label           = string.Concat(string.Format(Uniconta.ClientTools.Localization.lookup("ImportOBJ"), Uniconta.ClientTools.Localization.lookup("Dimension")), " 4");
                lblDim5.Label           = string.Concat(string.Format(Uniconta.ClientTools.Localization.lookup("ImportOBJ"), Uniconta.ClientTools.Localization.lookup("Dimension")), " 5");
                txtNavDim1.Text         = Uniconta.ClientTools.Localization.lookup("Optional");
                txtNavDim2.Text         = Uniconta.ClientTools.Localization.lookup("Optional");
                txtNavDim3.Text         = Uniconta.ClientTools.Localization.lookup("Optional");
                txtNavDim4.Text         = Uniconta.ClientTools.Localization.lookup("Optional");
                txtNavDim5.Text         = Uniconta.ClientTools.Localization.lookup("Optional");
                txtNavErrorAccount.Text = Uniconta.ClientTools.Localization.lookup("Required");
                txtAccountForPrimo.Text = Uniconta.ClientTools.Localization.lookup("Required");

                var navEmailType = new List <string>()
                {
                    Uniconta.ClientTools.Localization.lookup("InvoiceEmail"),
                    Uniconta.ClientTools.Localization.lookup("ContactEmail")
                };
                cmbInvoiceOrContactMail.ItemsSource = navEmailType;
#endif
            }
            else
            {
                UtilDisplay.ShowErrorCode(ErrorCodes.NoRights);
            }
        }
Ejemplo n.º 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;
            }
        }