﻿using System;
using System.Windows.Forms;
using QuickBooks_POS_Email_List.Properties;

namespace QuickBooks_POS_Email_List
{
    public partial class DatabasePickForm : Form
    {
        public String Database { get; private set; }
        public DatabasePickForm()
        {
            InitializeComponent();
        }

        private void OpenDatabaseButton_Click(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog {Filter = Resources.DatabaseFilter};
            if (dialog.ShowDialog() != DialogResult.OK) return;
            Settings.Default.Database = dialog.FileName;
            Settings.Default.Save();
            Database = dialog.FileName;
            DialogResult = DialogResult.OK;
            Close();
        }

        private void NewDatabaseButton_Click(object sender, EventArgs e)
        {
            var dialog = new SaveFileDialog {Filter = Resources.DatabaseFilter};
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Settings.Default.Database = dialog.FileName;
                Settings.Default.Save();
                Database = dialog.FileName;
                DialogResult = DialogResult.OK;
                Close();
            }
        }
    }
}
