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

namespace marketconnectionNET
{
    public partial class Dashboard : Form
    {
        List<cities> city = new List<cities>();
        public Dashboard()
        {
            InitializeComponent();

            UpdateBinding();

        }

        private void UpdateBinding()
        {
            locationbox.DataSource = city;
            locationbox.DisplayMember = "FullInfo";
        }

        private void search_Click(object sender, EventArgs e)
        {
            dataaccess db = new dataaccess();

            city = db.GetLocations(LocationName.Text);

            UpdateBinding();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void insertRecordButton_Click(object sender, EventArgs e)
        {
            dataaccess db = new dataaccess();

            db.InsertPerson(firstnameInsText.Text, lastnameInsText.Text, dateTimePicker.Value.Date.ToString("yyyyMMdd"), streetnameInsText.Text, streetnumberInsText.Text);

            firstnameInsText.Text = "";
            lastnameInsText.Text = "";
            dateTimePicker.Text = "";
            streetnameInsText.Text = "";
            streetnumberInsText.Text = "";
        }

        private void dateTimePicker_ValueChanged(object sender, EventArgs e)
        {

        }
    }
  
}
