private async void SaveCompany(Company fromCompany)
        {
            int    setupType = 1; /*Copy Setup */
            int    importFrom = -1;
            string path = string.Empty;
            bool   set0InAccount, set0InCustAcc, set0InVendAcc;
            bool   includeVatInPrices, concatC5ItemNames;
            int    importDim;

#if !SILVERLIGHT
            setupType  = lstSetupType.SelectedIndex;
            importFrom = cmbImportFrom.SelectedIndex;
            if (importFrom == (int)ImportFrom.BC_NAVOnline)
            {
                path = txtImportFromFile.Text;
            }
            else
            {
                path = txtImportFromDirectory.Text;
            }
            set0InAccount      = chkSet0InAct.IsChecked.Value;
            set0InCustAcc      = chkSet0InCustAcc.IsChecked.Value;
            set0InVendAcc      = chkSet0InVendAcc.IsChecked.Value;
            concatC5ItemNames  = chkConcatC5ItemNames.IsChecked.Value;
            includeVatInPrices = chkInvoiceVatPriceCheck.IsChecked.Value;
            importDim          = cmbImportDimension.SelectedIndex;
            switch ((ImportFrom)importFrom)
            {
            case ImportFrom.c5_Danmark:
            case ImportFrom.c5_Iceland: editrow._ConvertedFrom = (int)ConvertFromType.C5; break;

            case ImportFrom.economic_Danmark:
            case ImportFrom.economic_English:
            case ImportFrom.economic_Norge:
            case ImportFrom.economic_Germany:
            case ImportFrom.economic_Sweden: editrow._ConvertedFrom = (int)ConvertFromType.Eco; break;

            case ImportFrom.BC_NAVOnline:
            case ImportFrom.NAV: editrow._ConvertedFrom = (int)ConvertFromType.Nav; break;

            case ImportFrom.Ax30_eCTRL: editrow._ConvertedFrom = (int)ConvertFromType.eCtrl; break;

            case ImportFrom.dk_Iceland: editrow._ConvertedFrom = (int)ConvertFromType.dk_Iceland; break;
            }
#endif
            if (setupType == 1)
            {
                if (dateFrm.DateTime.Date < new DateTime(2000, 1, 1))
                {
                    UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("YearStartError"), dateFrm.DateTime.Date), Uniconta.ClientTools.Localization.lookup("Warning"));
                    return;
                }
            }
            else
            {
                if (importFrom == -1)
                {
                    UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("CannotBeBlank"), Uniconta.ClientTools.Localization.lookup("ImportFrom")),
                                            Uniconta.ClientTools.Localization.lookup("Warning"));
                    return;
                }
                if (string.IsNullOrEmpty(path))
                {
                    UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("CannotBeBlank"), Uniconta.ClientTools.Localization.lookup("SelectDirectory")),
                                            Uniconta.ClientTools.Localization.lookup("Warning"));
                    return;
                }
            }
            try
            {
                if (setupType == 1)
                {
                    if (fromCompany != null)
                    {
                        editrow.CopyFunctions(fromCompany);
                        busyIndicator.BusyContent = string.Format(Uniconta.ClientTools.Localization.lookup("CopyingCompany"), fromCompany._Name, editrow._Name);
                    }
                    busyIndicator.IsBusy = true;
                    if (chkDimensions.IsChecked == true && fromCompany != null)
                    {
                        var dim = await session.GetCompany(fromCompany.CompanyId);

                        if (dim != null)
                        {
                            editrow.NumberOfDimensions = dim.NumberOfDimensions;
                            editrow._Dim1 = dim._Dim1;
                            editrow._Dim2 = dim._Dim2;
                            editrow._Dim3 = dim._Dim3;
                            editrow._Dim4 = dim._Dim4;
                            editrow._Dim5 = dim._Dim5;
                        }
                    }
                }
                else
                {
                    busyIndicator.IsBusy = true;
                }
                ErrorCodes err;
                if (editrow._Name == null)
                {
                    editrow._Name = "import";
                }
                if (usermaster != null)
                {
                    err = await session.CreateCompany(editrow, usermaster);
                }
                else
                {
                    err = await session.CreateCompany(editrow);
                }
                if (err == ErrorCodes.Succes)
                {
                    Company[] companies = await BasePage.session.GetCompanies();

                    UnicontaClient.Controls.CWDefaultCompany.loadedCompanies = companies;

                    if (Utility.GetDefaultCompany() == null)
                    {
                        globalEvents.OnRefresh(NameOfControl);
                    }
                    if (setupType == 1)/* Import- Financial year not required*/
                    {
                        await SaveFinancialYear(editrow, dateFrm.DateTime.Date, dateTo.DateTime.Date);

                        if (fromCompany != null)
                        {
                            await CopyBaseData();
                        }
                    }
                    await SaveCompanyLogos();

                    if (setupType != 1)
                    {
#if !SILVERLIGHT
                        var      pastYears      = string.IsNullOrWhiteSpace(invoiceDateCounter.Text) ? 0 : -(int)NumberConvert.ToInt(invoiceDateCounter.Text);
                        DateTime invoiceFrmDate = DateTime.Today.AddYears(pastYears);
                        var      listOfNavDim   = new List <string>();
                        var      dim            = string.IsNullOrWhiteSpace(txtNavDim1.Text) ? string.Empty : txtNavDim1.Text;
                        listOfNavDim.Add(dim);
                        dim = string.IsNullOrWhiteSpace(txtNavDim2.Text) ? string.Empty : txtNavDim2.Text;
                        listOfNavDim.Add(dim);
                        dim = string.IsNullOrWhiteSpace(txtNavDim3.Text) ? string.Empty : txtNavDim3.Text;
                        listOfNavDim.Add(dim);
                        dim = string.IsNullOrWhiteSpace(txtNavDim4.Text) ? string.Empty : txtNavDim4.Text;
                        listOfNavDim.Add(dim);
                        dim = string.IsNullOrWhiteSpace(txtNavDim5.Text) ? string.Empty : txtNavDim5.Text;
                        listOfNavDim.Add(dim);

                        var arrayOfNavDim = listOfNavDim.ToArray();

                        object[] compParams = new object[18];
                        compParams[0]  = path;
                        compParams[1]  = editrow;
                        compParams[2]  = (ImportFrom)importFrom;
                        compParams[3]  = set0InAccount;
                        compParams[4]  = importDim;
                        compParams[5]  = arrayOfNavDim;
                        compParams[6]  = cmbInvoiceOrContactMail.SelectedIndex == 0;
                        compParams[7]  = txtNavErrorAccount.Text;
                        compParams[8]  = includeVatInPrices;
                        compParams[9]  = chkLedgerTransactions.IsChecked.Value;
                        compParams[10] = chkDebtorTransactions.IsChecked.Value;
                        compParams[11] = chkCreditorTransactions.IsChecked.Value;
                        compParams[12] = txtAccountForPrimo.Text;
                        compParams[13] = chkImportInvoice.IsChecked.Value;
                        compParams[14] = set0InCustAcc;
                        compParams[15] = set0InVendAcc;
                        compParams[16] = concatC5ItemNames;
                        compParams[17] = invoiceFrmDate;

                        string header = string.Format(Uniconta.ClientTools.Localization.lookup("ImportOBJ"), Uniconta.ClientTools.Localization.lookup("Company"));
                        AddDockItem(TabControls.ImportFromOtherCompanySetup, compParams, header);
#endif
                    }

                    if (usermaster != null && usermaster.Uid != session.Uid)
                    {
                        busyIndicator.IsBusy = false;
                        return;
                    }

                    if (setupType == 1)
                    {
                        globalEvents.OnRefresh(TabControls.CreateCompany, editrow.RowId);
                        CloseDockItem();
                    }
                }
                else
                {
                    busyIndicator.IsBusy = false;
                    UtilDisplay.ShowErrorCode(err);
                }
            }
            catch (Exception ex)
            {
                BasePage.session.ReportException(ex, "Create Company. Setup Page", 0);
                UnicontaMessageBox.Show(ex);
            }
            if (setupType == 1)
            {
                busyIndicator.IsBusy = false;
            }
        }