internal void SetDetails(EmployeeDetails employeeDetails)
 {
     employeeNameTxtbox.Text = employeeDetails.employeeName;
     employeeDobDatepicker.SelectedDate = employeeDetails.employeeDob;
     employeeAddressTxtbox.Text = employeeDetails.employeeAddress;
     employeePhoneNumberTxtbox.Text = employeeDetails.employeePhoneNumber;
     employeeEmailTxtbox.Text = employeeDetails.employeeEmail;
     employeeJoinDatePicker.SelectedDate = employeeDetails.employeeJoinDate;
     employeeDepartmentTxtbox.Text = employeeDetails.employeeDepartment;
     employeeSalaryTxtbox.Text = employeeDetails.employeeSalary.ToString();
     employeeManagerIdTxtbox.Text = employeeDetails.employeeManagerId;
     employeeIdTxtbox.Text = employeeDetails.employeeId;
 }
        public EmployeeDetails getDetails()
        {
            EmployeeDetails employeeData = new EmployeeDetails();

            employeeData.employeeName = employeeNameTxtbox.Text;
            employeeData.employeeDob = employeeDobDatepicker.SelectedDate.Value;
            employeeData.employeeAddress = employeeAddressTxtbox.Text;
            employeeData.employeePhoneNumber = employeePhoneNumberTxtbox.Text;
            employeeData.employeeEmail = employeeEmailTxtbox.Text;
            employeeData.employeeJoinDate = employeeJoinDatePicker.SelectedDate.Value;
            employeeData.employeeDepartment = employeeDepartmentTxtbox.Text;
            employeeData.employeeSalary = Convert.ToDouble(employeeSalaryTxtbox.Text);
            employeeData.employeeManagerId = employeeManagerIdTxtbox.Text;
            return employeeData;
        }
        private static int DoRegisterNewEmployeeInDb(EmployeeDetails employeeDetails)
        {
            int returnVal = 0;
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = null;

            msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=Mmm_mb;persist security info=False");
            try
            {
                //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();

                //define the connection used by the command object
                msqlCommand.Connection = msqlConnection;

                //open the connection
                if (msqlConnection.State != System.Data.ConnectionState.Open)
                    msqlConnection.Open();

                msqlCommand.CommandText = "INSERT INTO employees(employee_id,employee_name,employee_dob,employee_address,employee_phone_no,employee_email,employee_join_date,department,salary,employee_manager_id) "
                                                   + "VALUES(@employee_id,@employee_name,@employee_dob,@employee_address,@employee_phone_no,@employee_email,@employee_join_date,@department,@salary,@employee_manager_id)";

                msqlCommand.Parameters.AddWithValue("@employee_id", employeeDetails.employeeId);
                msqlCommand.Parameters.AddWithValue("@employee_name", employeeDetails.employeeName);
                msqlCommand.Parameters.AddWithValue("@employee_dob", employeeDetails.employeeDob);
                msqlCommand.Parameters.AddWithValue("@employee_address", employeeDetails.employeeAddress);
                msqlCommand.Parameters.AddWithValue("@employee_phone_no", employeeDetails.employeePhoneNumber);
                msqlCommand.Parameters.AddWithValue("@employee_email", employeeDetails.employeeEmail);
                msqlCommand.Parameters.AddWithValue("@employee_join_date", employeeDetails.employeeJoinDate);
                msqlCommand.Parameters.AddWithValue("@department", employeeDetails.employeeDepartment);
                msqlCommand.Parameters.AddWithValue("@salary", employeeDetails.employeeSalary);
                msqlCommand.Parameters.AddWithValue("@employee_manager_id", employeeDetails.employeeManagerId);
                msqlCommand.ExecuteNonQuery();
                returnVal = 1;
            }
            catch (Exception er)
            {
                returnVal = 0;
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
            return returnVal;
        }
 public static int DoRegisterNewEmployee(EmployeeDetails employeeDetails)
 {
     return DoRegisterNewEmployeeInDb(employeeDetails);
 }
        private static List<EmployeeDetails> QueryAllEmployeeList()
        {
            List<EmployeeDetails> employeeList = new List<EmployeeDetails>();
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = null;

            msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=Mmm_mb;persist security info=False");
            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlConnection.Open();

                msqlCommand.CommandText = "Select * From employees;";
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

                while (msqlReader.Read())
                {
                    EmployeeDetails employee = new EmployeeDetails();

                    employee.employeeId = msqlReader.GetString("employee_id");
                    employee.employeeName = msqlReader.GetString("employee_name");
                    employee.employeeDob = msqlReader.GetDateTime("employee_dob");
                    employee.employeeAddress = msqlReader.GetString("employee_address");
                    employee.employeeJoinDate = msqlReader.GetDateTime("employee_join_date");
                    employee.employeePhoneNumber = msqlReader.GetString("employee_phone_no");
                    employee.employeeEmail = msqlReader.GetString("employee_email");
                    employee.employeeDepartment = msqlReader.GetString("department");
                    employee.employeeSalary = msqlReader.GetDouble("salary");
                    employee.employeeManagerId = msqlReader.GetString("employee_manager_id");

                    employeeList.Add(employee);
                }

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }

            return employeeList;
        }