using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Flight
{
    public partial class VariablesDlg : Form
    {
        public string Type { get; set; }
        public string Format { get; set; }
        private bool _Init = false;
        
        public VariablesDlg()
        {
            InitializeComponent();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_Init == false) return;
            Type = (comboBox1.SelectedIndex != 0) ? comboBox1.Text : "";
            if (Type == "DATETIME")
            {
                Format = "dd/MM/yyyy";
            }
            else Format = "";
            UpdateUI();
        }

        private void UpdateUI()
        {
            textBox1.Enabled = (Type != "");
            textBox1.Text = Format;
        }

        private void VariablesDlg_Load(object sender, EventArgs e)
        {
            int idx = 0;
            if (Type != "")
                for (int i= 0 ; i< comboBox1.Items.Count; i++)
                    if (comboBox1.Items[i].ToString()==Type)
                        idx = i;
            comboBox1.SelectedIndex = idx;
            _Init = true;
            UpdateUI();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Format = (Type != "") ? textBox1.Text : "";
        }
    }
}
