using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SanSystem
{
    /// <summary>
    /// 
    /// </summary>
    public partial class frmProjektList : Form
    {
        /// <summary>
        /// 
        /// </summary>
        public frmProjektList()
        {
            InitializeComponent();
        }

        private void frmProjektList_Load(object sender, EventArgs e)
        {
            
            foreach(DirectoryInfo projekte in (new DirectoryInfo("./projekte").GetDirectories()))
            {
                lb_projekte.Items.Add(projekte.Name);
            }
        }

        private void btn_ok_Click(object sender, EventArgs e)
        {
            string projekt = (string)lb_projekte.SelectedItem;
            if (projekt == null) return;

            if(Database.Datenbank.Instance.projekt != projekt)
            {
                Database.Datenbank.Instance.SaveProjekt();
                Global.Instance.ProjektNummer = projekt;
                Database.Datenbank.Instance.LoadProjekt(projekt, Global.Instance.Projektpfad);
            }
            this.Close();
        }
    }
}
