/// <summary>
        /// Search customer by id 
        /// and checking the correctness of the input 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            int parsedValue;

            if (!int.TryParse(textBoxId.Text, out parsedValue)) // check if id number not contain a characters
            {
                MessageBox.Show("Id number have to be digits only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxId.Text = "";

            }

            if (textBoxId.Text == "")
            {
                MessageBox.Show("Enter Customer id");
            }
            else
            {
                CurrentCustomer = obj.getCusomerById(Convert.ToInt32(textBoxId.Text));

                if (CurrentCustomer != null)
                {
                    buttonSearch.Enabled = false;
                    panelClasses.Visible = true;
                    customerClasses = CurrentCustomer.getListGymClass();
                }
                else
                {
                    MessageBox.Show("No user with this id number");
                    textBoxId.Text = "";
                }
            }

        }
 public FormViewRegisterdClasses(Customer Curr)
 {
     InitializeComponent();
     this.Current = Curr;
     
     
 }
Exemplo n.º 3
0
 public static Customer CreatCustomer(String nameFirst, String nameLast, String homeAddress, String phoneNumber, String emailAddress,
     long idNumber, int permissionLevel, String DateJoined, String MDClernsExpiration,TrainingProgram traningProgram , int Class_Miss)
 {
     Customer newCustomer = new Customer(nameFirst, nameLast, homeAddress, phoneNumber, emailAddress, idNumber, permissionLevel, DateJoined, MDClernsExpiration , Class_Miss);
     newCustomer.addTraningProgram(traningProgram);
     return newCustomer;
 }
 //string reason;
 public FormRequestTrPrgmChg()
 {
     
     InitializeComponent();
     curr = (Customer)User.Instance.getCurrent();
     listTrainingPrograms = curr.getListTrainingPrograms();
     list = dbConnector.Instance.getTrainers();
     
 }
        public FormCustomerRegisterToClass()
        {
            Curr = (Customer)User.Instance.getCurrent();
            //Curr = (Customer)dbConnector.Instance.getRandomPersonByPermission(PermissiomLevels.CUSTOMER);
            this.allgymClasses = dbConnector.Instance.getClasses();

            InitializeComponent();




        }
Exemplo n.º 6
0
 public String editCustomer(String nameFirst, String nameLast, String homeAddress, String phoneNumber, String emailAddress,
  String medicalClearanceExpiration, Customer UpdateCustomer)
 {
     
     UpdateCustomer.setNameFirst(nameFirst);
     UpdateCustomer.setNameLast(nameLast);
     UpdateCustomer.setEmailAddress(emailAddress);
     UpdateCustomer.setHomeAddress(homeAddress);
     UpdateCustomer.setphoneNumber(phoneNumber);
     UpdateCustomer.setmedicalClearanceExpiration(medicalClearanceExpiration);
     String result = dbConnector.Instance.EditCustomer(UpdateCustomer);
     return result;
 }
Exemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            int parsedValue;

            if (!int.TryParse(textBoxID.Text, out parsedValue)) // check if id number not contain a characters
            {
                MessageBox.Show("Id number have to be digits only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxID.Text = "";


            }

            if (textBoxID.Text == "")
            {
                MessageBox.Show("Enter Customer id");
            }
            else
            {
                CurrentCustomer = obj.getCusomerById(Convert.ToInt32(textBoxID.Text));

                if (CurrentCustomer != null)
                {
                    if (CurrentCustomer.getListGymClass().Count() != 0)
                    {
                        button1.Enabled = false;
                        foreach (GymClass ClassName in CurrentCustomer.getListGymClass())
                        { // empEdit classes name to combobox
                            comboBox1.Items.Add(ClassName.getClassName());
                        }
                        panel1.Visible = true;

                    }
                    else
                    {
                        MessageBox.Show("This user have no classes");
                    }
                }
                else
                {
                    MessageBox.Show("No user with this id number");
                    textBoxID.Text = "";
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// add new customer to gymclass
 /// </summary>
 /// <param name="customer">customer object that we need to add to the gymclas</param>
 public void AddNewPersonToClass(Customer customer)
 {
     this.classListed++;
     this.listCustomerListed.Add(customer);
     dbConnector.Instance.updateCostumerGymClass(this, customer);
 }
Exemplo n.º 9
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {

            if (!validateID()) { return; }

            customerObject = dbcObject.getCusomerById(Convert.ToInt32(textBoxID.Text));

            if (customerObject == null)
            {
                MessageBox.Show("No user with this id number");
                textBoxID.Text = "";
                return;
            }

            if (this.requetsType == "Add")
            {
                // Creat New Training Program with First Free workoutID
                long workoutID = customerObject.getListTrainingPrograms().Count;
                selectedTrp = new TrainingProgram(workoutID, new List<Exercise>());
                // Add The New (Empty) Traning Program To Customer
                customerObject.addTraningProgram(selectedTrp);
            }

            else
            { // Request type is Edit
                buttonSearch.Enabled = false;
                // Get Customers Existing Traning Programs
                listTrainingPrograms = customerObject.getListTrainingPrograms();
                foreach (TrainingProgram trp in listTrainingPrograms)
                {
                    comboBoxTraningPrograms.Items.Add(trp.getWorkoutID());
                }
            }
            // Show Panels
            panelEditExercise.Visible = true;
            panelMainDisplay.Visible = true;
        }
Exemplo n.º 10
0
        public List<Customer> getListedCustomerByClassID(int classId) { 
        
            List<Customer> customerList = new List<Customer>();
            string query = "Select * FROM cilent INNER JOIN client_activity ON cilent.idCilent = client_activity.client_id WHERE client_activity.activity_id ='" + classId + "';";
            MySqlCommand cmd = new MySqlCommand(query, this.connection);
            MySqlDataReader dataReader = cmd.ExecuteReader();
            while (dataReader.Read())
            {
                String first_name = (String)dataReader["F_Name"];
                String last_name = (String)dataReader["L_Name"];
                String address = (String)dataReader["Address"];
                String phone_number = (String)dataReader["phone_number"];
                String email = (String)dataReader["eMail"];
                int personId = (int)dataReader["person_id"];
                int permmsion = (int)dataReader["Premission"];
                String DataJoind = (String)dataReader["DateJoind"];
                String Md_LastDate = (String)dataReader["Md_LastDate"];
                int class_miss = (int)dataReader["class_miss"];
                //Console.Write(first_name);
                Customer temp = new Customer(first_name, last_name, address, phone_number, email, personId, permmsion, DataJoind, Md_LastDate, class_miss);
                temp.setDBid((int)dataReader["idCilent"]);
                customerList.Add(temp);
                
            }
            dataReader.Close();
            return customerList;

        }
Exemplo n.º 11
0
        /* Add Methods */
        public String addCustomer(Customer add, String password)
        { // TODO: change to bool     

            string checkIfExsites = "Select * FROM users WHERE person_id = '" + add.getIdNumber() + "' ;";
            MySqlCommand cmdCheck = new MySqlCommand(checkIfExsites, this.connection);
            MySqlDataReader dataReader = cmdCheck.ExecuteReader();
            int count = 0;

            while (dataReader.Read())
            {
                count++;
            }
            dataReader.Close();

            if (count > 0)
            { 
                return "ID allready in use";
            }

            string query = "INSERT INTO cilent (F_Name, L_Name, ClientIDNum, phone_number, Address, DateJoind, Md_LastDate, eMail, program, person_id, password, Premission) VALUES('" + add.getNameFirst() + "', '" + add.getNameLast() + "' , '" + add.getIdNumber() + "', '" + add.getPhoneNumber() + "','" + add.getHomeAddress() + "','" + add.getDateJoined() + "','" + add.getMedicalClearanceExpiration() + "','" + add.getEmailAddress() + "', '1','" + add.getIdNumber() + "', md5('" + password + "'), 0);";
            MySqlCommand cmd = new MySqlCommand(query, this.connection);
            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (MySqlException ex)
            {
                if (ex.Message.Contains("Duplicate"))
                {
                    if (ex.Message.Contains("PhoneNumber"))
                    {
                        return "Phone Number";
                    }
                    else if (ex.Message.Contains("eMail"))
                    {
                        return "Email";
                    }


                }
                else
                    System.Windows.Forms.MessageBox.Show("Unknow error");
            }
            long customerDbId = cmd.LastInsertedId;

            string query2 = "INSERT INTO users (person_id, password, type) VALUES('" + add.getIdNumber() + "', md5('" + password + "'), 'customer');";
            MySqlCommand cmd2 = new MySqlCommand(query2, this.connection);
            cmd2.ExecuteNonQuery();


            string query3 = "INSERT INTO client_program (program_id, client_id) VALUES('1', '" + customerDbId + "');";
            MySqlCommand cmd3 = new MySqlCommand(query3, this.connection);
            cmd3.ExecuteNonQuery();
            return "OK";
        }
Exemplo n.º 12
0
        /// <summary>
        /// get all the customer from the data base
        /// </summary>
        /// <returns>return a list of customers</returns>
        public List<Customer> getAllCustomer() {

            List<Customer> customerList = new List<Customer>();
            string query = "Select * FROM cilent;";
            MySqlCommand cmd = new MySqlCommand(query, this.connection);
            MySqlDataReader dataReader = cmd.ExecuteReader();
            while (dataReader.Read())
            {
                String first_name = (String)dataReader["F_Name"];
                String last_name = (String)dataReader["L_Name"];
                String address = (String)dataReader["Address"];
                String phone_number = (String)dataReader["phone_number"];
                String email = (String)dataReader["eMail"];
                int personId = (int)dataReader["person_id"];
                int permmsion = (int)dataReader["Premission"];
                String DataJoind = (String)dataReader["DateJoind"];
                String Md_LastDate = (String)dataReader["Md_LastDate"];
                int class_miss = (int)dataReader["class_miss"];                
                Customer temp = new Customer(first_name, last_name, address, phone_number, email, personId, permmsion, DataJoind, Md_LastDate, class_miss);
                temp.setDBid((int)dataReader["idCilent"]);
                customerList.Add(temp);
            }
            dataReader.Close();
            return customerList;
        
        }
Exemplo n.º 13
0
        /// <summary>
        /// add training progrem to a customer
        /// </summary>
        /// <param name="edit"></param>
        /// <param name="tp"></param>
        public void AddCustomerTrainingProgrem(Customer edit, TrainingProgram tp) {

            Dictionary<String, int> excersisses = this.getExcerssiesBackwords();

            String tpList = "";

            foreach(Exercise ex in tp.getExerciseList()) {
                tpList = tpList + excersisses[ex.getExerciseName()] + "_" + ex.getExerciseRepeats() + "_" + ex.getExerciseSets() + ",";
            }

            tpList = tpList.Substring(0, tpList.Length - 1);

            string query = "INSERT INTO training_program (exersie_list) VALUES('" + tpList + "');";
            MySqlCommand cmd = new MySqlCommand(query, this.connection);            
            cmd.ExecuteNonQuery();            
            long tpLastId = cmd.LastInsertedId;

            string query2 = "INSERT INTO client_program (program_id, client_id) VALUES ('"+ tpLastId +"', '" + edit.getDBid() + "');";
            MySqlCommand cmd2 = new MySqlCommand(query2, this.connection);
            cmd2.ExecuteNonQuery();            
        }
 /// <summary>
 /// delete customer from the system(only manager)
 /// </summary>
 /// <param name="DeleteCustomer">customer object that he want to delete</param>
 public void deleteCustomer(Customer DeleteCustomer)
 {
     dbConnector.Instance.deleteCustomer(DeleteCustomer);
 }
Exemplo n.º 15
0
        /// <summary>
        /// look for a customer in the data base by its id number
        /// </summary>
        /// <param name="id"></param>
        /// <returns>returns a customer instance by a given id</returns>
        public Customer getCusomerById(int id)
        {
            Customer temp = null;
            string queryPerson = "Select * FROM cilent WHERE person_id='" + id + "';";
            MySqlCommand cmdPerson = new MySqlCommand(queryPerson, this.connection);
            MySqlDataReader personReader = cmdPerson.ExecuteReader();

            while (personReader.Read())
            {
                String first_name = (String)personReader["F_Name"];
                String last_name = (String)personReader["L_Name"];
                String address = (String)personReader["Address"];
                String phone_number = (String)personReader["phone_number"];
                String email = (String)personReader["eMail"];
                int personId = (int)personReader["person_id"];
                int permmsion = (int)personReader["Premission"];
                String DataJoind = (String)personReader["DateJoind"];
                String Md_LastDate = (String)personReader["Md_LastDate"];
                int class_miss = (int)personReader["class_miss"];                
                temp = new Customer(first_name, last_name, address, phone_number, email, personId, permmsion, DataJoind, Md_LastDate, class_miss);
                temp.setDBid((int)personReader["idCilent"]);                
            }
            personReader.Close();
            if (temp != null) {
                ((Customer)temp).setListGymClass(getCustomerGymClassByDbId(temp.getDBid())); //sets the customr gymclasses
                ((Customer)temp).setListTrainingProgram(getCustomerTPByDbId(temp.getDBid())); // sets the customer training progrem
            }            
            return temp;
        }
Exemplo n.º 16
0
        private void buttonAddFind_Click(object sender, EventArgs e) 
        {
            // Validate ID Input
            if (!validateID()) { return; }

            if (this.requetsType == "Add")
            {// Current Form Request is Add
                if (validateData())
                {// Detiles are OK

                    String result = current.getCutomerManagement().addCustomer(textBoxNameFirst.Text, textBoxNameLast.Text, textBoxAddress.Text, textBoxPhoneNumber.Text, textBoxEmail.Text,
                     Convert.ToInt64(textBoxID.Text), PermissiomLevels.CUSTOMER, DateTime.Now.ToString("dd/mm/yyyy"), dateTimePickerMDClerExp.Value.ToString("dd/MM/yyyy"), textBoxPassword.Text);
                    switch (result)
                    {// Varify Addition
                        case "ID":
                            labelID.ForeColor = Color.Red;
                            MessageBox.Show("This ID Number is listed for another customer!");
                            return;
                        case "Phone Number":
                            labelPhone.ForeColor = Color.Red;
                            MessageBox.Show("This Phone Number is listed for another customer!");
                            return;
                        case "Email":
                            labelEmail.ForeColor = Color.Red;
                            MessageBox.Show("This Email is listed for another customer!");
                            return;
                        case "Customer Allready existes":
                            MessageBox.Show("Customer Allready existes!");
                            resetLabelColors();
                            refresher();
                            return;
                        case "OK":
                            MessageBox.Show("Customer Added Successfully!");
                            refresher();
                            return;
                    } // Switch
                } // if (validateData())
                return;
            } // if (this.requetsType == "Add")

            // Current Form Request is Edit (Button Text is Find)
            customerObject = dbConnector.Instance.getCusomerById(Convert.ToInt32(textBoxID.Text));
            // in this place we need to read data from MYSQL database and fill in our text boxes
            if (customerObject == null)
            { // Customer Not Found
                MessageBox.Show("There is no Customer with this id");
                return;
            }
            // Fill Data
            textBoxNameFirst.Text = customerObject.getNameFirst();
            textBoxNameLast.Text = customerObject.getNameLast();
            textBoxPhoneNumber.Text = customerObject.getPhoneNumber();
            dateTimePickerMDClerExp.Value = Convert.ToDateTime(customerObject.getMedicalClearanceExpiration());
            textBoxEmail.Text = customerObject.getEmailAddress();
            textBoxAddress.Text = customerObject.getHomeAddress();
            buttonSave.Enabled = true;
            panelData.Visible = true;
        }
Exemplo n.º 17
0
         public void updateCostumerGymClass(GymClass gymclass, Customer customer) {
             string query = "INSERT INTO client_activity (client_id, activity_id) VALUES('"+customer.getDBid()+"', '"+gymclass.getDBid()+"');";
             MySqlCommand cmd = new MySqlCommand(query, this.connection);
             cmd.ExecuteNonQuery();

             string query2 = "UPDATE activity SET listed=listed + 1 WHERE id='" + gymclass.getDBid() + "';";
             MySqlCommand cmd2 = new MySqlCommand(query2, this.connection);
             cmd2.ExecuteNonQuery();
         }
Exemplo n.º 18
0
         public void deleteCustomer(Customer customer) {
             string query = "DELETE FROM cilent WHERE idCilent='" + customer.getDBid() + "';";
             MySqlCommand cmd = new MySqlCommand(query, this.connection);

             cmd.ExecuteNonQuery();

             string query2 = "DELETE FROM users WHERE person_id = '" + customer.getIdNumber() + "' AND type = 'customer';";
             MySqlCommand cmd2 = new MySqlCommand(query2, this.connection);
             cmd2.ExecuteNonQuery();

             System.Windows.Forms.MessageBox.Show(customer.getNameFirst()+" "+customer.getNameLast()+" Was Deleted");
         }
Exemplo n.º 19
0
        public String EditCustomer(Customer add) {
            string query = "UPDATE cilent SET F_Name='" + add.getNameFirst() + "', L_Name='" + add.getNameLast() + "', Md_LastDate = '"+add.getMedicalClearanceExpiration() +"' ,phone_number='" + add.getPhoneNumber() + "', person_id='" + add.getIdNumber() + "', address='" + add.getHomeAddress() + "', email='" + add.getEmailAddress() + "' WHERE idCilent='" + add.getDBid() + "';";
            MySqlCommand cmd = new MySqlCommand(query, this.connection);

            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (MySqlException ex)
            {
                if (ex.Message.Contains("Duplicate"))
                {
                    if (ex.Message.Contains("ClientIDNum"))
                    {
                        return "ID";
                    }
                    else if (ex.Message.Contains("PhoneNumber"))
                    {
                        return "Phone Number";
                    }
                    else if (ex.Message.Contains("eMail"))
                    {
                        return "Email";
                    }


                }
                else
                    System.Windows.Forms.MessageBox.Show("Unknow error");
            }

            return "O.K";
        }
Exemplo n.º 20
0
 /// <summary>
 /// delete customer from the clas
 /// </summary>
 /// <param name="customer">customer object that want to be deleted</param>
 public void DeleteCustomerFromClass(Customer customer)
 {
     this.classListed--;
     this.listCustomerListed.Remove(customer);
     MessageBox.Show("You just delete your self from " + this.getClassName());
     dbConnector.Instance.deleteCostumerGymClass(this, customer);
 }
Exemplo n.º 21
0
         public void deleteCostumerGymClass(GymClass gymclass, Customer customer)
         {
             string query = "DELETE FROM client_activity WHERE client_id = '" + customer.getDBid() + "' AND activity_id = '" + gymclass.getDBid() + "';";
             MySqlCommand cmd = new MySqlCommand(query, this.connection);
             cmd.ExecuteNonQuery();

             string query2 = "UPDATE activity SET listed=listed - 1 WHERE id='" + gymclass.getDBid() + "';";
             MySqlCommand cmd2 = new MySqlCommand(query2, this.connection);
             cmd2.ExecuteNonQuery();
         }
Exemplo n.º 22
0
        /// <summary>
        /// get an id and a password from the login form, search for it in the user table and if it exisets returns the right person object
        /// </summary>
        /// <param name="id"></param>
        /// <param name="password"></param>
        /// <returns>null if the user was not found , else return the person object from the database</returns>
        public Person getPersonByCredentials(long id, String password)
        {
            Person person = null;
            String type = null;
            string query = "Select * FROM users WHERE person_id='" + id + "' AND  password=md5('" + password + "');";
            MySqlCommand cmd = new MySqlCommand(query, this.connection);
            MySqlDataReader dataReader = cmd.ExecuteReader();

            while (dataReader.Read())
            {
                type = (String)dataReader["type"]; //get the user type from the users table
            }
            dataReader.Close();
            if (type != null)
            {
                //Create query for the right person type (customer, manager, reception, instructor, trainer)
                switch (type)
                {
                    case "manager":
                        {
                            string queryPerson = "Select * FROM administration WHERE person_id='" + id + "' AND  password=md5('" + password + "');";
                            MySqlCommand cmdPerson = new MySqlCommand(queryPerson, this.connection);
                            MySqlDataReader personReader = cmdPerson.ExecuteReader();

                            while (personReader.Read())
                            {
                                String first_name = (String)personReader["F_Name"];
                                String last_name = (String)personReader["L_Name"];
                                String address = (String)personReader["address"];
                                String phone_number = (String)personReader["phone_number"];
                                String email = (String)personReader["email"];
                                int personId = (int)personReader["person_id"];
                                int permmsion = (int)personReader["Premission"];
                                float sallery = (float)personReader["Sal_Hour"];                               
                                person = new Manager(first_name, last_name, address, phone_number, email, personId, permmsion, sallery); //create a new manager
                                person.setDBid((int)personReader["idAdministration"]); //set the uniqe id from the mysql table
                            }
                            personReader.Close();
                            break;
                        }
                    case "customer":
                        {
                            string queryPerson = "Select * FROM cilent WHERE person_id='" + id + "' AND  password=md5('" + password + "');";
                            MySqlCommand cmdPerson = new MySqlCommand(queryPerson, this.connection);
                            MySqlDataReader personReader = cmdPerson.ExecuteReader();

                            while (personReader.Read())
                            {
                                String first_name = (String)personReader["F_Name"];
                                String last_name = (String)personReader["L_Name"];
                                String address = (String)personReader["Address"];
                                String phone_number = (String)personReader["phone_number"];
                                String email = (String)personReader["eMail"];
                                int personId = (int)personReader["person_id"];
                                int permmsion = (int)personReader["Premission"];
                                String DataJoind = (String)personReader["DateJoind"];
                                String Md_LastDate = (String)personReader["Md_LastDate"];
                                int class_miss = (int)personReader["class_miss"];
                                //Console.Write(first_name);
                                person = new Customer(first_name, last_name, address, phone_number, email, personId, permmsion, DataJoind, Md_LastDate, class_miss); //create a new customer instance
                                person.setDBid((int)personReader["idCilent"]); //set the uniqe id from the mysql table                               
                            }
                            personReader.Close();
                            ((Customer)person).setListGymClass(getCustomerGymClassByDbId(person.getDBid()));
                            ((Customer)person).setListTrainingProgram(getCustomerTPByDbId(person.getDBid()));
                            break;
                        }
                    case "instructor":
                        {
                            string queryPerson = "Select * FROM instructor WHERE person_id='" + id + "' AND  password=md5('" + password + "');";
                            MySqlCommand cmdPerson = new MySqlCommand(queryPerson, this.connection);
                            MySqlDataReader personReader = cmdPerson.ExecuteReader();

                            while (personReader.Read())
                            {
                                String first_name = (String)personReader["F_Name"];
                                String last_name = (String)personReader["L_Name"];
                                String address = (String)personReader["address"];
                                String phone_number = (String)personReader["phone_number"];
                                String email = (String)personReader["email"];
                                int personId = (int)personReader["person_id"];
                                int permmsion = (int)personReader["Premission"];
                                float sallery = (float)personReader["Sal_Hour"];
                                person = new Instructor(first_name, last_name, address, phone_number, email, personId, permmsion, sallery); //crate a new instructor instance
                                person.setDBid((int)personReader["idInstructor"]); //set the uniqe id from the mysql table
                            }
                            personReader.Close();
                            break;
                        }
                    case "reception":
                        {
                            string queryPerson = "Select * FROM reception WHERE person_id='" + id + "' AND  password=md5('" + password + "');";
                            MySqlCommand cmdPerson = new MySqlCommand(queryPerson, this.connection);
                            MySqlDataReader personReader = cmdPerson.ExecuteReader();

                            while (personReader.Read())
                            {
                                String first_name = (String)personReader["F_Name"];
                                String last_name = (String)personReader["L_Name"];
                                String address = (String)personReader["address"];
                                String phone_number = (String)personReader["phone_number"];
                                String email = (String)personReader["email"];
                                int personId = (int)personReader["person_id"];
                                int permmsion = (int)personReader["Premission"];
                                float sallery = (float)personReader["Sal_Hour"];
                                person = new Receptionist(first_name, last_name, address, phone_number, email, personId, permmsion, sallery); //create a new reception instance
                                person.setDBid((int)personReader["idReception"]); //set the uniqe id from the mysql table
                            }
                            personReader.Close();
                            break;
                        }
                    case "trainer":
                        {
                            string queryPerson = "Select * FROM trainers WHERE person_id='" + id + "' AND  password=md5('" + password + "');";
                            MySqlCommand cmdPerson = new MySqlCommand(queryPerson, this.connection);
                            MySqlDataReader personReader = cmdPerson.ExecuteReader();

                            while (personReader.Read())
                            {
                                String first_name = (String)personReader["F_Name"];
                                String last_name = (String)personReader["L_Name"];
                                String address = (String)personReader["address"];
                                String phone_number = (String)personReader["phone_number"];
                                String email = (String)personReader["email"];
                                int personId = (int)personReader["person_id"];
                                int permmsion = (int)personReader["Premission"];
                                float sallery = (float)personReader["Sal_Hour"];
                                String certificate = (String)personReader["certificate"];                                
                                person = new Trainer(first_name, last_name, address, phone_number, email, personId, permmsion, sallery, certificate); //create a new trainer instance
                                person.setDBid((int)personReader["idtrainer"]); //set the uniqe id from the mysql table
                            }
                            personReader.Close();
                            break;
                        }
                }
            }

            return person;
        }