public ActionResult SendToEmail(int id)
 {
     if (User.Identity.IsAuthenticated && (User.IsInRole("Admin") || (User.IsInRole("Administrator"))))
     {
         try
         {
             Statement statement = StatementManager.GetStatementById(id);
             if (User.Identity.IsAuthenticated &&
                 ((User.IsInRole("Administrator") && statement.KindergartenId == User.Identity.GetUserId()) ||
                  (User.IsInRole("Admin"))))
             {
                 Kindergarten Kindergarten        = KindergartenManager.GetKindergartenById(statement.KindergartenId);
                 SiteUser     siteUser            = SiteUserManager.GetSiteUserById(statement.SiteUserId);
                 StatementListItemViewModel model = new StatementListItemViewModel
                 {
                     Statement        = statement,
                     UserPrivileges   = StatementManager.GetUserPrivilegesByStatementId(id),
                     KindergartenName = Kindergarten.Name,
                     UserName         = String.Format("{0} {1} {2}", siteUser.Surname, siteUser.Name, siteUser.FathersName)
                 };
                 return(View(model));
             }
             ;
         }
         catch (Exception) { }
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
Example #2
0
 public ActionResult Apply(AddStatementViewModel model)
 {
     if (User.Identity.IsAuthenticated && (User.IsInRole("Admin") || User.IsInRole("User")))
     {
         if (ModelState.IsValid)
         {
             if (model.Captcha != Session["code"].ToString())
             {
                 ModelState.AddModelError("Captcha", "Неправильно введений код перевірки!");
             }
             if (model.Consent == false)
             {
                 ModelState.AddModelError("Consent", "Потрібне підтвердження!");
             }
             if (ModelState.IsValid)
             {
                 StatementManager.ApplyStatement(model, User.Identity.GetUserId());
                 return(RedirectToAction("Index", "Home"));
             }
             List <Kindergarten> Kindergartens = KindergartenManager.GetKindergartens().ToList();
             model.Kindergartens = new SelectList(Kindergartens, "Id", "Name");
             return(View(model));
         }
     }
     return(RedirectToAction("Index", "Home"));
 }
Example #3
0
        public ActionResult Apply(string id)
        {
            if (User.Identity.IsAuthenticated)
            {
                List <Privilege>      privileges    = StatementManager.GetAllPrivileges();
                List <Group>          groups        = StatementManager.GetAllGroups();
                List <Kindergarten>   Kindergartens = KindergartenManager.GetKindergartens().ToList();
                AddStatementViewModel model         = new AddStatementViewModel {
                };
                model.Privileges = new List <PrivilegesInnerViewModel> {
                };
                model.Groups     = new List <string> {
                };
                for (int i = 0; i < privileges.Count; i++)
                {
                    model.Privileges.Add(new PrivilegesInnerViewModel {
                        Key = privileges[i].Value, Value = false
                    });
                }
                for (int i = 0; i < groups.Count; i++)
                {
                    model.Groups.Add(groups[i].Value);
                }

                model.Kindergartens = new SelectList(Kindergartens, "Id", "Name");

                return(View(model));
            }
            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult SendToEmail(string kindergartenId, int id, string email)
        {
            Statement statement = StatementManager.GetStatementById(id);

            if (User.Identity.IsAuthenticated &&
                ((User.IsInRole("Administrator") && statement.KindergartenId == User.Identity.GetUserId()) ||
                 (User.IsInRole("Admin"))))
            {
                try
                {
                    Kindergarten Kindergarten        = KindergartenManager.GetKindergartenById(statement.KindergartenId);
                    SiteUser     siteUser            = SiteUserManager.GetSiteUserById(statement.SiteUserId);
                    StatementListItemViewModel model = new StatementListItemViewModel
                    {
                        Statement        = statement,
                        UserPrivileges   = StatementManager.GetUserPrivilegesByStatementId(id),
                        KindergartenName = Kindergarten.Name,
                        UserName         = siteUser.FullName
                    };

                    MailCustom.Mail(email, "Заява в електронну чергу #" + model.Statement.Id, GetAnswer(model));

                    return(RedirectToAction("Statements", "Kindergarten", new { kindergartenId }));
                }
                catch { return(RedirectToAction("Statements", "Kindergarten", new { kindergartenId })); }
            }
            ;
            return(RedirectToAction("Index", "Home"));
        }
Example #5
0
 public ActionResult MyStatements()
 {
     if (User.Identity.IsAuthenticated && (User.IsInRole("Admin") || User.IsInRole("User")))
     {
         return(View(StatementManager.GetFormatStatementListViewModel(User.Identity.GetUserId(), false, "none", true)));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult EditGroup(Group group)
 {
     if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
     {
         StatementManager.EditGroup(group);
         return(RedirectToAction("Groups", "Admin"));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult EditGroup(int id)
 {
     if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
     {
         Group group = StatementManager.GetGroupById(id);
         return(View(group));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult Groups()
 {
     if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
     {
         List <Group> groups = StatementManager.GetAllGroups();
         return(View(groups));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult EditPrivilege(Privilege privilege)
 {
     if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
     {
         StatementManager.EditPrivilege(privilege);
         return(RedirectToAction("Privileges", "Admin"));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult EditPrivilege(int id)
 {
     if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
     {
         Privilege privilege = StatementManager.GetPrivilegeById(id);
         return(View(privilege));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult Privileges()
 {
     if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
     {
         List <Privilege> privileges = StatementManager.GetAllPrivileges();
         return(View(privileges));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult NotConsideredStatements()
 {
     if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
     {
         ViewBag.Type = "NotConsidered";
         return(View("~/Views/Kindergarten/Statements.cshtml", StatementManager.GetFormatStatementListViewModel("none", false, "NotConsidered", true)));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult RemoveGroup(int id)
 {
     if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
     {
         return(View(new RemoveGroupViewModel {
             Id = id, Value = StatementManager.GetGroupById(id).Value
         }));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult NotConsideredStatements(string id)
 {
     if (User.Identity.IsAuthenticated && (User.IsInRole("Admin") || (User.IsInRole("Administrator") && User.Identity.GetUserId() == id)))
     {
         ViewBag.Id   = id;
         ViewBag.Type = "NotConsidered";
         return(View("~/Views/Kindergarten/Statements.cshtml", StatementManager.GetFormatStatementListViewModel(id, true, "NotConsidered")));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult Statements(string id)
 {
     if (User.Identity.IsAuthenticated && (User.IsInRole("Admin") || (User.IsInRole("Administrator") && User.Identity.GetUserId() == id)))
     {
         ViewBag.Id   = id;
         ViewBag.Type = "All";
         return(View(StatementManager.GetFormatStatementListViewModel(id, true)));
     }
     return(RedirectToAction("Index", "Home"));
 }
Example #16
0
 public StatementDataRefAppService(
     TaskItemManager taskItemManager, StatementManager statementManager, ProcedureManager procedureManager,
     IRepository <ProcedureStepTaskItem, Guid> repositoryPt,
     IRepository <ProcedureStep, Guid> repositoryProcedureStep)
 {
     _taskItemManager         = taskItemManager;
     _statementManager        = statementManager;
     _procedureManager        = procedureManager;
     _repositoryPt            = repositoryPt;
     _repositoryProcedureStep = repositoryProcedureStep;
 }
Example #17
0
        public ActionResult GenerateStatementEmail(int customerId)
        {
            CakesPosRepository cpr = new CakesPosRepository(_connectionString);
            int              id    = cpr.GenerateStatement(customerId);
            StatementsModel  s     = cpr.GetStatementsForPdf(id, customerId);
            StatementManager sm    = new StatementManager();

            sm.CreateStatementPDF(s, @"C:\inetpub\sites\CakesPos\StatementsPdf\" + s.Statement.Id + ".pdf");
            cpr.AddStatementFilePath(s.Statement.Id, @"C:\inetpub\sites\CakesPos\StatementsPdf\" + s.Statement.Id + ".pdf");
            sm.EmailStatement(@"C:\inetpub\sites\CakesPos\StatementsPdf\" + s.Statement.Id + ".pdf", s.Orders.FirstOrDefault().customer.Email, s.Statement.Date.ToShortDateString());
            return(null);
        }
 public ActionResult RemoveGroup(RemoveGroupViewModel model)
 {
     if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
     {
         if (StatementManager.GetGroupById(model.Id) != null)
         {
             StatementManager.RemoveGroup(model.Id);
         }
         return(RedirectToAction("Groups", "Admin"));
     }
     return(RedirectToAction("Index", "Home"));
 }
Example #19
0
        static void Main(string[] args)
        {
            //string srcStatementFile = @"D:\data\Dropbox\household\bank\Smile\Page77.htm";
            string destOfxFile = @"d:\\scratch\\x.ofx";

            var srcStatementStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"ConsoleExecutor.Artifacts.SmileStatementSource.htm");
            var ss = new StreamReader(srcStatementStream, Encoding.GetEncoding(readEncoding));
            string srcStatementFile = ss.ReadToEnd();

            var statementManager = new StatementManager(srcStatementFile, destOfxFile);
            statementManager.ProcessStatement();
        }
Example #20
0
        private JsonResult SwitchIsSelected(string statementId, bool isSelected)
        {
            int       intStatementId = Convert.ToInt32(statementId);
            Statement statement      = StatementManager.GetStatementById(intStatementId);

            if (User.Identity.IsAuthenticated && User.Identity.GetUserId() == statement.KindergartenId || User.IsInRole("Admin"))
            {
                try
                {
                    StatementManager.SwitchIsSelected(intStatementId, isSelected);
                    return(Json(true));
                }
                catch (Exception) { }
            }
            return(Json("Error"));
        }
Example #21
0
 public ActionResult RemoveStatement(StatementListItemViewModel model)
 {
     try
     {
         Statement statement = StatementManager.GetStatementById(model.Statement.Id);
         if (User.Identity.IsAuthenticated &&
             ((User.IsInRole("User") && statement.SiteUserId == User.Identity.GetUserId()) ||
              (User.IsInRole("Admin") && statement.SiteUserId == User.Identity.GetUserId())))
         {
             StatementManager.RemoveStatement(model.Statement.Id);
             return(RedirectToAction("MyStatements", "Home"));
         }
     }
     catch { }
     return(RedirectToAction("MyStatements", "Home"));
 }
Example #22
0
        public ActionResult GenerateStatementPrint(int customerId)
        {
            CakesPosRepository cpr = new CakesPosRepository(_connectionString);
            int              id    = cpr.GenerateStatement(customerId);
            StatementsModel  s     = cpr.GetStatementsForPdf(id, customerId);
            StatementManager sm    = new StatementManager();

            sm.CreateStatementPDF(s, @"C:\inetpub\sites\CakesPos\StatementsPdf\" + s.Statement.Id + ".pdf");
            cpr.AddStatementFilePath(s.Statement.Id, @"C:\inetpub\sites\CakesPos\StatementsPdf\" + s.Statement.Id + ".pdf");
            return(Json(id, JsonRequestBehavior.AllowGet));
            //sm.EmailStatement(@"C:\Users\Barry\Documents\Pdf-Statements\" + s.Statement.Id + ".pdf", s.Orders.FirstOrDefault().customer.Email, s.Statement.Date.ToShortDateString());
            //Statement s=cpr.GetStatementByCustomerId(customerId);
            //StatementManager sm = new StatementManager();
            //sm.CreateStatementPDF(s, @"C:\Users\Barry\Documents\Pdf-Statements\" + s.StatementNumber + ".pdf");
            //sm.EmailStatement(@"C:\Users\Barry\Documents\Pdf-Statements\" + s.StatementNumber + ".pdf", s.Orders.FirstOrDefault().customer.Email, s.StatementDate.ToShortDateString());
            //cpr.AddStatementsFilePath()Path.Combine(AppDomain.CurrentDomain.BaseDirectory,s.Statement.Id + ".pdf");
        }
 public TaskItemAssignmentAppService(
     IRepository <TaskItemAssignment, Guid> repositoryTaskItemAssignmentData,
     TaskItemManager taskItemManager,
     ProjectManager projectManager,
     NotificationManager notificationManager,
     SubProjectManager subProjectManager, IRepository <User, long> repositoryUser,
     TaskItemAssignmentManager taskItemAssignmentManager, RoleManager roleManager, StatementManager statementManager) : base(
         repositoryTaskItemAssignmentData)
 {
     _taskItemManager           = taskItemManager;
     _projectManager            = projectManager;
     _notificationManager       = notificationManager;
     _subProjectManager         = subProjectManager;
     _repositoryUser            = repositoryUser;
     _taskItemAssignmentManager = taskItemAssignmentManager;
     _roleManager      = roleManager;
     _statementManager = statementManager;
 }
Example #24
0
        private static void Main()
        {
            const string destOfxFile = @"x.ofx";
            const string sourceStatementFile = @"ShortSmileStatementSource.htm";
            const string resourceFolder = "ConsoleExecutor.Resources";
            const string backSlash = @"\";
            string tempFolder = Environment.GetEnvironmentVariable("TEMP");

            // test purposes only...
            CopyResourceToFile(tempFolder, resourceFolder, sourceStatementFile);

            // todo - delete whole class
            IHtmlParser x = new SmileHtmlStatementParser();

            var statementManager = new StatementManager(tempFolder + backSlash + sourceStatementFile, x);
            statementManager.ProcessStatement();

            Console.WriteLine(Resources.ProgramMainComplete, destOfxFile);
            Console.ReadLine();
        }
Example #25
0
        void saveButton_Click(object sender, EventArgs e)
        {
            TransactionType toSave = new TransactionType()
            {
                Id         = mLoadedType != null && mLoadedType.Id > 0 ? mLoadedType.Id : -1,
                Vendor     = vendorText.Text,
                Category   = categoryText.Text,
                Identifier = identifierText.Text,
                IdentifierCaseSensitive = caseSensitiveCheckbox.Checked,
                IdentifierMustStart     = startsWithCheckbox.Checked
            };

            TypeManager.Add(toSave);
            mLoadedType = toSave;

            //Scan all transactions and see where the new type can be applied
            List <Transaction> matches = FindMatches(toSave.Identifier, toSave.IdentifierMustStart, toSave.IdentifierCaseSensitive);

            foreach (Transaction transaction in matches)
            {
                transaction.TypeId = toSave.Id;
            }
            StatementManager.SaveAllToCache();

            mUpdateCallback?.Invoke();

            RefreshUi();

            string description = $"{toSave.Vendor}: {toSave.Identifier}";

            foreach (DataGridViewRow row in existingGrid.Rows)
            {
                if (row.Cells[1].Value != null && row.Cells[1].Value.Equals(description))
                {
                    row.Selected = true;
                    break;
                }
            }
        }
        public void LoadDirectory()
        {
            BackgroundWorker bw = new BackgroundWorker
            {
                WorkerReportsProgress = true
            };

            bw.DoWork += delegate(object o, DoWorkEventArgs args)
            {
                SetUiEnabled(false);

                BackgroundWorker worker = o as BackgroundWorker;
                worker?.ReportProgress(0, "Loading data");

                mLoadWarnings = StatementManager.Load(mDirectory);

                worker?.ReportProgress(0, "Unifying transactions");

                mUnifiedTransactions = BudgetAnalyzer.UnifyTransactions(StatementManager.AllStatements, StatementManager.AmazonStatements);
                mStartDate           = mUnifiedTransactions[0].Date;

                ShowSummary();

                SetUiEnabled(true);
            };

            bw.ProgressChanged += delegate(object o, ProgressChangedEventArgs args)
            {
                UpdateStatus((string)args.UserState);
            };

            bw.RunWorkerCompleted += delegate
            {
                UpdateStatus("Done");
            };

            bw.RunWorkerAsync();
        }
Example #27
0
        internal void Import(MyMoney myMoney, AttachmentManager myAttachments, StatementManager myStatements, string[] fileNames)
        {
            this.myMoney       = myMoney;
            this.myAttachments = myAttachments;
            this.myStatements  = myStatements;
            cancelSource       = new CancellationTokenSource();
            var token = cancelSource.Token;

            Task.Factory.StartNew(() => {
                busy = true;
                foreach (string file in fileNames)
                {
                    if (token.IsCancellationRequested)
                    {
                        break;
                    }
                    if (!ProcessFile(file))
                    {
                        break;
                    }
                }
                busy = false;
            }, token);
        }
Example #28
0
        public void Reconcile(MyMoney money, Account a, StatementManager statementManager)
        {
            this.initializing = true;
            this.myMoney      = money;
            this.account      = a;
            this.statements   = statementManager;

            DateTime oldestUnreconciledDate = DateTime.MaxValue;

            HashSet <DateTime> previous = new HashSet <DateTime>();

            foreach (Transaction t in this.myMoney.Transactions.GetAllTransactions())
            {
                if (t.Account == a)
                {
                    if (t.ReconciledDate.HasValue)
                    {
                        previous.Add(t.ReconciledDate.Value);
                    }
                    else
                    {
                        if (t.Date < oldestUnreconciledDate)
                        {
                            oldestUnreconciledDate = t.Date;
                        }
                    }
                }
            }

            if (previous.Count == 0)
            {
                // Make sure that we have at least one date in the dropdown
                // In order to include the oldest un-reconciled transaction we need to start at least 1 day before the
                // oldest un-reconciled date.
                oldestUnreconciledDate = oldestUnreconciledDate.AddDays(-1);
                previous.Add(oldestUnreconciledDate);
            }

            foreach (var stmt in statementManager.GetStatements(a))
            {
                previous.Add(stmt.Date);
            }

            previousReconciliations = new List <string>(from d in previous orderby d ascending select d.ToShortDateString());
            previousReconciliations.Add(""); // add one more so user has to move selection to select a previous statement.
            this.ComboBoxPreviousReconcileDates.ItemsSource = previousReconciliations;

            this.AccountInfo.Text = string.Format("{0} ({1})", a.Name, a.AccountId);


            DateTime estdate = a.LastBalance;

            if (estdate == DateTime.MinValue)
            {
                this.SelectedPreviousStatement = oldestUnreconciledDate;
            }
            else
            {
                string lastDate = estdate.ToShortDateString();
                if (!previousReconciliations.Contains(lastDate))
                {
                    previousReconciliations.Add(lastDate);
                }

                this.SelectedPreviousStatement = estdate;
            }
            this.ComboBoxPreviousReconcileDates.SelectedIndex = previousReconciliations.Count - 1;
            estdate = this.SelectedPreviousStatement.AddMonths(1);
            this.ComboBoxPreviousReconcileDates.SelectionChanged += new SelectionChangedEventHandler(ComboBoxPreviousReconcileDates_SelectionChanged);

            this.StatementDate = estdate;

            this.myMoney.Transactions.Changed += new EventHandler <ChangeEventArgs>(Transactions_Changed);

            this.interestCategory = (this.account.Type == AccountType.Brokerage) ?
                                    this.myMoney.Categories.InvestmentInterest : this.myMoney.Categories.InterestEarned;

            FindInterestTransaction(estdate);

            this.StatementDatePicker.KeyDown             += new KeyEventHandler(ChildKeyDown);
            this.StatementDatePicker.SelectedDateChanged += new EventHandler <SelectionChangedEventArgs>(OnStatementDateChanged);
            this.TextBoxStatementBalance.KeyDown         += new KeyEventHandler(ChildKeyDown);
            this.TextBoxInterestEarned.LostFocus         += new RoutedEventHandler(TextBoxInterestEarned_LostFocus);
            this.initializing = false;

            // setup initial values.
            UpdateBalances(estdate);

            this.Loaded += new RoutedEventHandler(OnLoad);
        }
Example #29
0
        private void ImportAccount(MyMoney newMoney, AccountImportState a, AttachmentManager newAttachments, StatementManager importStatements)
        {
            Account             acct         = a.Account;
            IList <Transaction> transactions = newMoney.Transactions.GetTransactionsFrom(acct);

            a.PercentComplete = 0;
            a.Loading         = true;
            List <Transaction> changed = new List <Transaction>();

            a.Changed = changed;
            this.myMoney.BeginUpdate(this);
            StringBuilder sb = new StringBuilder();

            List <Transaction> newTransactions = new List <Transaction>();

            for (int i = 0, n = transactions.Count; i < n; i++)
            {
                double percent = ((double)i * 100.0) / (double)n;
                a.PercentComplete = (int)percent;
                Transaction t = transactions[i];
                Transaction u = this.myMoney.Transactions.FindTransactionById(t.Id);

                try {
                    if (u == null)
                    {
                        newTransactions.Add(t);
                    }
                    else if (u.Merge(t))
                    {
                        a.Modified++;
                        changed.Add(u);
                        // make the amounts the same
                        u.Amount = t.Amount;
                        List <string> attachments = newAttachments.GetAttachments(t);
                        this.myAttachments.ImportAttachments(t, attachments);
                    }
                }
                catch (Exception ex)
                {
                    // todo: handle errors.
                    sb.Append(ex);
                }
            }

            // must be done last so we don't get confused over mismatching transaction ids.
            foreach (Transaction t in newTransactions)
            {
                try
                {
                    Account target = this.myMoney.Accounts.FindAccount(t.AccountName);
                    if (target == null)
                    {
                        throw new Exception("Cannot import transaction to missing account: " + t.AccountName);
                    }
                    else
                    {
                        Transaction u = this.myMoney.Transactions.NewTransaction(target);
                        u.Merge(t);
                        a.Modified++;
                        changed.Add(u);
                        this.myMoney.Transactions.Add(u);
                        // make the amounts the same
                        u.Amount = t.Amount;
                        List <string> attachments = newAttachments.GetAttachments(t);
                        this.myAttachments.ImportAttachments(t, attachments);
                    }
                }
                catch (Exception ex)
                {
                    // todo: handle errors.
                    sb.Append(ex);
                }
            }

            this.myStatements.ImportStatements(acct, importStatements);

            this.myMoney.EndUpdate();

            a.Loading = false;
            a.Done    = true;

            if (sb.Length > 0)
            {
                MessageBoxEx.Show(sb.ToString(), "Import Errors", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #30
0
        private void ImportMoneyFile(MyMoney newMoney, AttachmentManager newAttachments, StatementManager importStatements)
        {
            this.dispatcher.Invoke(new Action(() =>
            {
                // gather accounts to be merged (skipping closed accounts).
                foreach (var acct in newMoney.Accounts)
                {
                    if (!acct.IsClosed && !acct.IsCategoryFund)
                    {
                        list.Add(new AccountImportState()
                        {
                            Dispatcher = this.dispatcher,
                            Account    = acct,
                            Name       = acct.Name,
                        });
                    }
                }
            }));

            foreach (AccountImportState a in list)
            {
                ImportAccount(newMoney, a, newAttachments, importStatements);
            }

            ShowStatus("Done");
        }
Example #31
0
        private bool ProcessFile(string file)
        {
            ShowStatus(string.Format(loadingStatusPrompt, file));

            try
            {
                if (file.EndsWith(".db", StringComparison.OrdinalIgnoreCase) ||
                    file.EndsWith(".mmdb", StringComparison.OrdinalIgnoreCase))
                {
                    string userName  = null;
                    string password  = null;
                    string path      = Path.GetFullPath(file);
                    bool   cancelled = false;

                    dispatcher.Invoke(new Action(() =>
                    {
                        PasswordWindow w = new PasswordWindow();
                        Paragraph p      = (Paragraph)w.IntroMessagePrompt.Document.Blocks.FirstBlock;
                        Run run          = (Run)p.Inlines.FirstInline;
                        run.Text         = "Please enter password for the imported database";
                        if (w.ShowDialog() == true)
                        {
                            userName = w.UserName;
                            password = w.PasswordConfirmation;
                            path     = Path.GetFullPath(file);
                        }
                        else
                        {
                            ShowStatus("Import cancelled.");
                            cancelled = true;
                        }
                    }));

                    if (!cancelled)
                    {
                        SqliteDatabase database = new SqliteDatabase()
                        {
                            DatabasePath = path,
                            UserId       = userName,
                            Password     = password
                        };
                        database.Create();

                        // import the database, and any associated attachments or statements.
                        MyMoney           newMoney          = database.Load(this);
                        AttachmentManager importAttachments = new AttachmentManager(newMoney);
                        importAttachments.SetupAttachmentDirectory(path);
                        StatementManager importStatements = new StatementManager(newMoney);
                        importStatements.SetupStatementsDirectory(path);
                        importStatements.Load();
                        ImportMoneyFile(newMoney, importAttachments, importStatements);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    ShowStatus("Import only supports sqllite money files");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ShowStatus("Error: " + ex.Message);
                return(false);
            }
            return(true);
        }