public static bool addWorkingExperience(WorkingExperience we)
        {
            DBConnector dbcon = new DBConnector();

            try
            {
                if (dbcon.openConnection())
                {
                    MySqlCommand cmd = new MySqlCommand();
                    cmd.CommandText = "INSERT INTO working_experience (institute, address, telephone, email, department, contact, date_from, date_to, date_perma, resign_reason, responsibility, occupation_relevant, award, employee_idemployee) VALUES (N'" + we.institute + "', N'" + we.address + "', N'" + we.telephone + "', N'" + we.email + "', N'" + we.department + "', N'" + we.contact + "', '" + we.getDate_from().ToString("yyyy-MM-dd") + "', '" + we.getDate_to().ToString("yyyy-MM-dd") + "', '" + we.getDate_perma().ToString("yyyy-MM-dd") + "', N'" + we.resign_reason + "', N'" + we.responsibility + "', " + we.occupation_relevant + ", N'" + we.award + "', " + 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 updateWorkingExperience()
        {
            WorkingExperience we = new WorkingExperience();

            we.we_id = this.we_id;
            we.address = this.we_address.Text;
            we.award = this.we_award.Text;
            we.contact = this.we_contact.Text;
            we.department = this.we_department.Text;
            we.email = this.we_department.Text;
            we.institute = this.we_institute.Text;

            if (this.we_occupation_relevant.Checked) { we.occupation_relevant = true; }
            else { we.occupation_relevant = false; }

            we.resign_reason = this.we_resign_reason.Text;
            we.responsibility = this.we_responsibility.Text;
            we.telephone = this.we_telephone.Text;
            we.setDate_from(this.we_date_from_date.Value.Date);
            we.setDate_to(this.we_date_to_date.Value.Date);
            we.setDate_perma(this.we_date_perma_date.Value.Date);

            bool state = WorkingExperienceHandler.updateWorkingExperience(we);

            Console.Write(state + "\n");
        }
        private void btnSave2_Click(object sender, EventArgs e)
        {
            WorkingExperience we = new WorkingExperience();

            we.address = we_address.Text;
            we.award = we_award.Text;
            we.contact = we_contact.Text;
            we.department = we_department.Text;
            we.email = we_department.Text;
            we.institute = we_institute.Text;

            if (we_occupation_relevant.Checked) { we.occupation_relevant = true; }
            else { we.occupation_relevant = false; }

            we.resign_reason = we_resign_reason.Text;
            we.responsibility = we_responsibility.Text;
            we.telephone = we_telephone.Text;
            we.setDate_from(we_date_from_date.Value.Date);
            we.setDate_to(we_date_to_date.Value.Date);
            we.setDate_perma(we_date_perma_date.Value.Date);

            bool status = WorkingExperienceHandler.addWorkingExperience(we);

            if (status)
            {
                MessageBox.Show("Working experience details added successfully...!");
                //btnSave4.Enabled = true;
                //btnSave5.Enabled = true;
            }
            else { MessageBox.Show("Failed to add working experience details...!"); }
        }
        public static WorkingExperience getWorkingExperience()
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

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

                MySqlDataReader reader = cmd.ExecuteReader();

                WorkingExperience we = null;

                if (reader.Read())
                {
                    we = new WorkingExperience();

                    we.we_id = int.Parse(reader["idworking_experience"].ToString());
                    we.address = reader["address"].ToString();
                    we.award = reader["award"].ToString();
                    we.contact = reader["contact"].ToString();
                    we.department = reader["department"].ToString();
                    we.email = reader["email"].ToString();
                    we.institute = reader["institute"].ToString();
                    we.resign_reason = reader["resign_reason"].ToString();
                    we.responsibility = reader["responsibility"].ToString();
                    we.telephone = reader["telephone"].ToString();

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

                    we.setDate_from(Convert.ToDateTime(reader["date_from"]));
                    we.setDate_to(Convert.ToDateTime(reader["date_to"]));
                    we.setDate_perma(Convert.ToDateTime(reader["date_perma"]));

                }

                reader.Close();

                dbcon.closeConnection();

                return we;
            }
            else
            {

                return null;
            }

            //}
            //catch (MySqlException e)
            //{
            //int errorcode = e.Number;
            //return null;
            //}
        }
        public static bool updateWorkingExperience(WorkingExperience we)
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "UPDATE working_experience SET institute=N'" + we.institute + "', address=N'" + we.address + "', telephone=N'" + we.telephone + "', email=" + we.email + ", department=" + we.department + ", contact=N'" + we.contact + "', date_from='" + we.getDate_from().ToString("yyyy-MM-dd") + "', date_to=N'" + we.getDate_to().ToString("yyyy-MM-dd") + "', date_perma='" + we.getDate_perma().ToString("yyyy-MM-dd") + "', resign_reason=N'" + we.resign_reason + "', responsibility=N'" + we.responsibility + "', occupation_relevant=" + we.occupation_relevant + ", award=N'" + we.award + "' WHERE employee_idemployee=" + Employee.employee_id + " AND idworking_experience=" + we.we_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;
            //}
        }