public static bool addContactDetails(ContactDetails cd)
        {
            DBConnector dbcon = new DBConnector();

            try
            {
                if (dbcon.openConnection())
                {
                    MySqlCommand cmd = new MySqlCommand();
                    cmd.CommandText = "INSERT INTO contact_details (perm_home_no, perm_address, perm_city, perm_province, perm_district, perm_uc, perm_grama, perm_polling_division, perm_teleophone, perm_mobile, perm_fax, perm_email, cur_home_no, cur_address, cur_city, cur_province, cur_uc, cur_grama, cur_polling_division, cur_teleophone, cur_mobile, cur_fax, cur_email, employee_idemployee) VALUES (N'" + cd.perm_home_no + "', N'" + cd.perm_address + "', N'" + cd.perm_city + "', N'" + cd.perm_province + "', N'" + cd.perm_district + "', N'" + cd.perm_uc + "', N'" + cd.perm_grama + "', N'" + cd.perm_polling_division + "', N'" + cd.perm_teleophone + "', N'" + cd.perm_mobile + "', N'" + cd.perm_fax + "', N'" + cd.perm_email + "', N'" + cd.cur_home_no + "', N'" + cd.cur_address + "', N'" + cd.cur_city + "', N'" + cd.cur_province + "', N'" + cd.cur_uc + "', N'" + cd.cur_grama + "', N'" + cd.cur_polling_division + "', N'" + cd.cur_teleophone + "', N'" + cd.cur_mobile + "', N'" + cd.cur_fax + "', N'" + cd.cur_email + "', " + 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;
            }
        }
        public void updateContactDetails()
        {
            ContactDetails cd = new ContactDetails();
            cd.cd_id = this.cd_id;
            cd.cur_address = this.cur_address.Text;
            cd.cur_city = this.cur_city.Text;
            cd.cur_district = this.cur_district.Text;
            cd.cur_email = this.cur_email.Text;
            cd.cur_fax = this.cur_fax.Text;
            cd.cur_grama = this.cur_grama.Text;
            cd.cur_home_no = this.cur_home_no.Text;
            cd.cur_mobile = this.cur_mobile.Text;
            cd.cur_polling_division = this.cur_polling_division.Text;
            cd.cur_province = this.cur_province.Text;
            cd.cur_teleophone = this.cur_teleophone.Text;
            cd.cur_uc = this.cur_uc.Text;
            cd.perm_address = this.perm_address.Text;
            cd.perm_city = this.perm_city.Text;
            cd.perm_district = this.perm_district.Text;
            cd.perm_email = this.perm_email.Text;
            cd.perm_fax = this.perm_fax.Text;
            cd.perm_grama = this.perm_grama.Text;
            cd.perm_home_no = this.perm_home_no.Text;
            cd.perm_mobile = this.perm_mobile.Text;
            cd.perm_polling_division = this.perm_polling_division.Text;
            cd.perm_province = this.perm_province.Text;
            cd.perm_teleophone = this.perm_teleophone.Text;
            cd.perm_uc = this.perm_uc.Text;

            bool state = ContactDetailsHandler.updateContactDetails(cd);

            Console.Write(state + "\n");
        }
        private void btnSave2_Click(object sender, EventArgs e)
        {
            ContactDetails cd = new ContactDetails();
            cd.cur_address = cur_address.Text;
            cd.cur_city = cur_city.Text;
            cd.cur_district = cur_district.Text;
            cd.cur_email = cur_email.Text;
            cd.cur_fax = cur_fax.Text;
            cd.cur_grama = cur_grama.Text;
            cd.cur_home_no = cur_home_no.Text;
            cd.cur_mobile = cur_mobile.Text;
            cd.cur_polling_division = cur_polling_division.Text;
            cd.cur_province = cur_province.Text;
            cd.cur_teleophone = cur_teleophone.Text;
            cd.cur_uc = cur_uc.Text;
            cd.perm_address = perm_address.Text;
            cd.perm_city = perm_city.Text;
            cd.perm_district = perm_district.Text;
            cd.perm_email = perm_email.Text;
            cd.perm_fax = perm_fax.Text;
            cd.perm_grama = perm_grama.Text;
            cd.perm_home_no = perm_home_no.Text;
            cd.perm_mobile = perm_mobile.Text;
            cd.perm_polling_division = perm_polling_division.Text;
            cd.perm_province = perm_province.Text;
            cd.perm_teleophone = perm_teleophone.Text;
            cd.perm_uc = perm_uc.Text;

            bool status = ContactDetailsHandler.addContactDetails(cd);

            if (status)
            {
                MessageBox.Show("Contact details added successfully...!");
                //btnSave3.Enabled = true;
                //btnClear1.Enabled = true;
                //btnSave4.Enabled = true;
                //btnSave5.Enabled = true;
            }
            else
            {
                MessageBox.Show("Failed to add contact details...!");
            }
        }
        public static ContactDetails getContactDetails()
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

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

                MySqlDataReader reader = cmd.ExecuteReader();

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

                ContactDetails cd = null;

                if (reader.Read())
                {
                    cd = new ContactDetails();

                    cd.cd_id = int.Parse(reader["idcontact_details"].ToString());
                    cd.cur_address=reader["cur_address"].ToString();
                    cd.cur_city = reader["cur_city"].ToString();
                    cd.cur_district = reader["cur_district"].ToString();
                    cd.cur_email = reader["cur_email"].ToString();
                    cd.cur_fax = reader["cur_fax"].ToString();
                    cd.cur_grama = reader["cur_grama"].ToString();
                    cd.cur_home_no = reader["cur_home_no"].ToString();
                    cd.cur_mobile = reader["cur_mobile"].ToString();
                    cd.cur_polling_division = reader["cur_polling_division"].ToString();
                    cd.cur_province = reader["cur_province"].ToString();
                    cd.cur_teleophone = reader["cur_teleophone"].ToString();
                    cd.cur_uc = reader["cur_uc"].ToString();
                    cd.perm_address = reader["perm_address"].ToString();
                    cd.perm_city = reader["perm_city"].ToString();
                    cd.perm_district = reader["perm_district"].ToString();
                    cd.perm_email = reader["perm_email"].ToString();
                    cd.perm_fax = reader["perm_fax"].ToString();
                    cd.perm_grama = reader["perm_grama"].ToString();
                    cd.perm_home_no = reader["perm_home_no"].ToString();
                    cd.perm_mobile = reader["perm_mobile"].ToString();
                    cd.perm_polling_division = reader["perm_polling_division"].ToString();
                    cd.perm_province = reader["perm_province"].ToString();
                    cd.perm_teleophone = reader["perm_teleophone"].ToString();
                    cd.perm_uc = reader["perm_uc"].ToString();

                }

                reader.Close();

                dbcon.closeConnection();

                return cd;
            }
            else
            {

                return null;
            }

            //}
            //catch (MySqlException e)
            //{
            //int errorcode = e.Number;
            //return null;
            //}
        }
        public static bool updateContactDetails(ContactDetails cd)
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "UPDATE contact_details SET perm_home_no=N'" + cd.perm_home_no + "', perm_address=N'" + cd.perm_address + "', perm_city=N'" + cd.perm_city + "', perm_province=N'" + cd.perm_province + "', perm_district=N'" + cd.perm_district + "', perm_uc=N'" + cd.perm_uc + "', perm_grama=N'" + cd.perm_grama + "', perm_polling_division=N'" + cd.perm_polling_division + "', perm_teleophone=N'" + cd.perm_teleophone + "', perm_mobile=N'" + cd.perm_mobile + "', perm_fax=N'" + cd.perm_fax + "', perm_email=N'" + cd.perm_email + "', cur_home_no=N'" + cd.cur_home_no + "', cur_address=N'" + cd.cur_address + "', cur_city=N'" + cd.cur_city + "', cur_province=N'" + cd.cur_province + "', cur_district=N'" + cd.cur_district + "', cur_uc=N'" + cd.cur_uc + "', cur_grama=N'" + cd.cur_grama + "', cur_polling_division=N'" + cd.cur_polling_division + "', cur_teleophone=N'" + cd.cur_teleophone + "', cur_mobile=N'" + cd.cur_mobile + "', cur_fax=N'" + cd.cur_fax + "', cur_email=N'" + cd.cur_email + "' WHERE employee_idemployee=" + Employee.employee_id + " AND idcontact_details="+cd.cd_id;
                cmd.Connection = dbcon.connection;
                cmd.Prepare();
                cmd.ExecuteNonQuery();

                dbcon.closeConnection();

                return true;
            }
            else
            {

                return false;
            }

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