public static bool addPensionAndDeath(PensionAndDeath pd)
        {
            DBConnector dbcon = new DBConnector();

            //try
            //{
            if (dbcon.openConnection())
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "INSERT INTO pension_death (retired, dead, died_date, informed_date, note, employee_idemployee) VALUES (" + pd.retired + ", " + pd.dead + ", '" + pd.died_date.ToString("yyyy-MM-dd") + "', '" + pd.informed_date.ToString("yyyy-MM-dd") + "', N'" + pd.note + "', " + Employee.employee_id + ")";
                cmd.Connection = dbcon.connection;
                cmd.Prepare();
                cmd.ExecuteNonQuery();

                dbcon.closeConnection();
                return true;
            }
            else
            {
                dbcon.closeConnection();
                return false;
            }

            /*}
            catch (MySqlException e)
            {
                int errorcode = e.Number;
                dbcon.closeConnection();
                return false;
            }*/
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool pd_present = true;
            if (PensionAndDeathHandler.getPensionAndDeath() == null)
            {
                pd_present = false;
            }

            PensionAndDeath pd = null;

            if (!pd_present)
            {
                pd = new PensionAndDeath();
            }
            else
            {
                pd = PensionAndDeathHandler.getPensionAndDeath();
            }

            pd.note = pension_notes.Text;

            pd.died_date = pension_died_date.Value.Date;
            pd.informed_date = pension_informed_date.Value.Date;

            if (pension_retired.Checked) { pd.retired = true; }
            else { pd.retired = false; }

            if (pension_dead.Checked) { pd.dead = true; }
            else { pd.dead = false; }

            bool state;

            if (!pd_present)
            {
                state = PensionAndDeathHandler.addPensionAndDeath(pd);
            }
            else
            {
                state = PensionAndDeathHandler.updatePensionAndDeath(pd);
            }

            if (state)
            {
                MessageBox.Show("Employee Pension and Death details updated succesfully...!");

            }
            else
            {
                MessageBox.Show("Updating Pension and Death details failed...!");
            }
        }
        public static PensionAndDeath getPensionAndDeath()
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "SELECT * FROM pension_death WHERE employee_idemployee=" + Employee.employee_id;
                cmd.Connection = dbcon.connection;

                MySqlDataReader reader = cmd.ExecuteReader();

                Console.Write(Employee.employee_id + "\n");

                PensionAndDeath pd = null;

                if (reader.Read())
                {
                    pd = new PensionAndDeath();

                    pd.note = reader["note"].ToString();

                    pd.died_date = Convert.ToDateTime(reader["died_date"]);
                    pd.informed_date = Convert.ToDateTime(reader["informed_date"]);

                    if (reader["retired"].ToString() == "True") { pd.retired = true; }
                    else { pd.retired = false; }

                    if (reader["dead"].ToString() == "True") { pd.dead = true; }
                    else { pd.dead = false; }

                }

                reader.Close();

                dbcon.closeConnection();

                return pd;
            }
            else
            {

                return null;
            }

            //}
            //catch (MySqlException e)
            //{
            //int errorcode = e.Number;
            //return null;
            //}
        }
        public static bool updatePensionAndDeath(PensionAndDeath pd)
        {
            DBConnector dbcon = new DBConnector();

            //try
            //{
            if (dbcon.openConnection())
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "UPDATE pension_death SET retired=" + pd.retired + ", dead=" + pd.dead + ", died_date='" + pd.died_date.ToString("yyyy-MM-dd") + "', informed_date='" + pd.informed_date.ToString("yyyy-MM-dd") + "', note=N'" + pd.note + "' WHERE employee_idemployee=" + Employee.employee_id;
                cmd.Connection = dbcon.connection;
                cmd.Prepare();
                cmd.ExecuteNonQuery();

                dbcon.closeConnection();

                return true;
            }
            else
            {
                dbcon.closeConnection();
                return false;
            }

            /*}
            catch (MySqlException e)
            {
                int errorcode = e.Number;
                dbcon.closeConnection();
                return false;
            }*/
        }