public LoginForm()
        {
            InitializeComponent();

            //need to subscribe to event here because Designer file is generated by compiler
            textBoxPassword.KeyPress += new System.Windows.Forms.KeyPressEventHandler(textBox_TextChanged);
            textBoxUsername.KeyPress += new System.Windows.Forms.KeyPressEventHandler(textBox_TextChanged);
            textBoxPassword.TextChanged += textBox_ResizeToContent;
            textBoxUsername.TextChanged += textBox_ResizeToContent;

            string serverName = "46.22.134.194";
            string port = "5432";
            string userName = "******";
            string password = "******";
            string databaseName = "WellsForZoe_fyp";
            string connString = String.Format("Server={0};Port={1}; User Id={2};Password={3};Database={4};Ssl=True;SslMode=Prefer;Timeout=5;CommandTimeout=5;Pooling=False;",
                    serverName, port, userName, password, databaseName);
            databaseLoader = new DatabaseLoader(connString, NetworkChecker.LastStatus);

            textBoxUsername.Select();
        }
        private void Edit_Click(object sender, EventArgs e)
        {
            editErrorLbl.Text = string.Empty;
            var button = sender as Button;
            if (button.Text == "Edit")
            {
                latEditBackup = editLngBox.Text;
                lngEditBackup = editLatBox.Text;
                //open edit window or better allow editing in same open space
                //let browse new image
                editLngBox.Enabled = true;
                editLatBox.Enabled = true;
                editImageBtn.Visible = true;
                button.Text = "Save";
                closeBtn.Text = "Cancel";
            }
            else if (button.Text == "Save")
            {
                if (string.IsNullOrWhiteSpace(editLngBox.Text)) editErrorLbl.Text = "Latitude cannot be empty";
                else if (string.IsNullOrWhiteSpace(editLatBox.Text)) editErrorLbl.Text = "Longitude cannot be empty";
                else
                {
                    editLngBox.Enabled = false;
                    editLatBox.Enabled = false;
                    editImageBtn.Visible = false;
                    try
                    {
                        var testPoint = StringToCoordinateConverter.ConvertToCoordinate(editLngBox.Text, editLatBox.Text);
                    }
                    catch (ArgumentException)
                    {
                        editErrorLbl.Text = "Lat/Long not in L DD MM.MMM";
                        editLngBox.Enabled = true;
                        editLatBox.Enabled = true;
                        editImageBtn.Visible = true;
                        return;
                    }

                    //send all to database
                    var db = new DatabaseLoader(connectionString, NetworkChecker.LastStatus);
                    well.UpdateCoordinates(editLatBox.Text, editLngBox.Text);
                    try
                    {
                        db.UpdateWellData(well);
                    }
                    catch (NpgsqlException ex)
                    {
                        editErrorLbl.Text = ex.Message;
                        RestoreFromBackup();
                    }
                    updateMarkerPositionAction(well);
                    button.Text = "Edit";
                    closeBtn.Text = "Close";
                }
            }
            else
            {
                throw new NotSupportedException("Button can only be Edit or Save");
            }
        }
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            var warning = MessageBox.Show(
                this,
                "Are you sure you want to delete well?\n This action cannot be undone.",
                "Deleting Well",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Exclamation,
                MessageBoxDefaultButton.Button2);

            if (warning == DialogResult.Yes)
            {
                var db = new DatabaseLoader(connectionString, NetworkChecker.LastStatus);
                try
                {
                    db.DeleteWell(well);
                    deleteMarkerAction(well);
                    this.Close();
                }
                catch (NpgsqlException ex)
                {
                    editErrorLbl.Text = ex.Message;
                }
            }
        }